diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/examples/index.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/examples/index.js new file mode 100644 index 000000000000..1d971a98d70e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/examples/index.js @@ -0,0 +1,32 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Field = require( '@stdlib/plot/vega/field/ctor' ); +var PieTransform = require( './../lib' ); + +var field = new Field({ + 'field': 'amount' +}); + +var transform = new PieTransform({ + 'field': field +}); + +console.log( transform.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/as/get.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/as/get.js new file mode 100644 index 000000000000..0954cb7b980b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/as/get.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var copy = require( '@stdlib/array/base/copy-indexed' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the output field names for the computed start and end angle values. +* +* @private +* @returns {ArrayLikeObject} field names +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/as/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/as/properties.js new file mode 100644 index 000000000000..3f2304dc2f08 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/as/properties.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'as' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/as/set.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/as/set.js new file mode 100644 index 000000000000..ecb96109c5e7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/as/set.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:pie-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the output field names for the computed start and end angle values. +* +* @private +* @param {StringArray} value - input value +* @throws {TypeError} must be an array of strings +* @returns {void} +*/ +function set( value ) { + if ( !isStringArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be an array of strings. Value: `%s`.', prop.name, value ) ); + } + if ( !hasEqualValues( value, this[ prop.private ] ) ) { + debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) ); + this[ prop.private ] = copy( value ); + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/change_event.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/change_event.js new file mode 100644 index 000000000000..e444f9c667b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/change_event.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns a new change event object. +* +* @private +* @param {string} property - property name +* @returns {Object} event object +*/ +function event( property ) { // eslint-disable-line stdlib/no-redeclare + return { + 'type': 'update', + 'source': 'transform', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/defaults.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/defaults.js new file mode 100644 index 000000000000..284e73ce6b9f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/defaults.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var TWO_PI = require( '@stdlib/constants/float64/two-pi' ); + + +// MAIN // + +/** +* Returns defaults. +* +* @private +* @returns {Object} default options +* +* @example +* var o = defaults(); +* // returns {...} +*/ +function defaults() { + return { + // Output field names for the computed start and end angle values: + 'as': [ 'startAngle', 'endAngle' ], + + // End angle of the pie in radians: + 'endAngle': TWO_PI, + + // Boolean indicating whether to sort arcs according to field values: + 'sort': false, + + // Starting angle of the pie in radians: + 'startAngle': 0.0 + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/end-angle/get.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/end-angle/get.js new file mode 100644 index 000000000000..fc5a5e90fdd8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/end-angle/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the end angle of the pie in radians. +* +* @private +* @returns {NonNegativeNumber} end angle +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/end-angle/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/end-angle/properties.js new file mode 100644 index 000000000000..6cfbc9174fb6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/end-angle/properties.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'endAngle' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/end-angle/set.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/end-angle/set.js new file mode 100644 index 000000000000..34a694fe8636 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/end-angle/set.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:pie-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the end angle of the pie in radians. +* +* @private +* @param {NonNegativeNumber} value - input value +* @throws {TypeError} must be a nonnegative number +* @returns {void} +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative number. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/field/get.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/field/get.js new file mode 100644 index 000000000000..fe34b7dd00ef --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/field/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the data field determining pie slice size. +* +* @private +* @returns {(Field|void)} data field +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/field/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/field/properties.js new file mode 100644 index 000000000000..639ddb612903 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/field/properties.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'field' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/field/set.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/field/set.js new file mode 100644 index 000000000000..396505daaad7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/field/set.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isField = require( '@stdlib/plot/vega/base/assert/is-field' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:pie-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the data field determining pie slice size. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value, in which case all pie slices have an equal size. +* +* @private +* @param {(Field|void)} value - input value +* @throws {TypeError} must be a field instance +* @returns {void} +*/ +function set( value ) { + if ( !isField( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a field instance. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + this._removeChangeListener( this[ prop.private ] ); + debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + this._addChangeListener( this[ prop.private ] ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/index.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/index.js new file mode 100644 index 000000000000..85fc5a962e8f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/index.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Pie transform constructor. +* +* @module @stdlib/plot/vega/transform/pie/ctor +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* var PieTransform = require( '@stdlib/plot/vega/transform/pie/ctor' ); +* +* var field = new Field({ +* 'field': 'amount' +* }); +* // returns +* +* var transform = new PieTransform({ +* 'field': field +* }); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/main.js new file mode 100644 index 000000000000..8f1c97d0a36c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/main.js @@ -0,0 +1,383 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/no-empty-lines-between-requires */ + +'use strict'; + +// MODULES // + +var EventEmitter = require( 'events' ).EventEmitter; +var logger = require( 'debug' ); +var isObject = require( '@stdlib/assert/is-object' ); +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); // eslint-disable-line id-length +var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var inherit = require( '@stdlib/utils/inherit' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var instance2json = require( '@stdlib/plot/vega/base/to-json' ); +var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' ); +var format = require( '@stdlib/string/format' ); +var properties = require( './properties.json' ); +var defaults = require( './defaults.js' ); + +// Note: keep the following in alphabetical order according to the `require` path... +var getAs = require( './as/get.js' ); +var setAs = require( './as/set.js' ); + +var getEndAngle = require( './end-angle/get.js' ); +var setEndAngle = require( './end-angle/set.js' ); + +var getField = require( './field/get.js' ); +var setField = require( './field/set.js' ); + +var getProperties = require( './properties/get.js' ); + +var getSort = require( './sort/get.js' ); +var setSort = require( './sort/set.js' ); + +var getStartAngle = require( './start-angle/get.js' ); +var setStartAngle = require( './start-angle/set.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:pie-transform:main' ); + + +// MAIN // + +/** +* Pie transform constructor. +* +* @constructor +* @param {Options} options - constructor options +* @param {ArrayLikeObject} [options.as=['startAngle','endAngle']] - output field names for the computed start and end angle values +* @param {NonNegativeNumber} [options.endAngle=2*PI] - end angle of the pie in radians +* @param {Field} [options.field] - data field determining pie slice size (if not provided, all pie slices have an equal size) +* @param {boolean} [options.sort=false] - boolean indicating whether to sort arcs according to field values +* @param {NonNegativeNumber} [options.startAngle=0] - starting angle of the pie in radians +* @throws {TypeError} options argument must be an object +* @throws {Error} must provide valid options +* @returns {PieTransform} pie transform instance +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var field = new Field({ +* 'field': 'amount' +* }); +* // returns +* +* var transform = new PieTransform({ +* 'field': field +* }); +* // returns +*/ +function PieTransform( options ) { + var self; + var opts; + var keys; + var v; + var k; + var i; + if ( !( this instanceof PieTransform ) ) { + return new PieTransform( options ); + } + self = this; + EventEmitter.call( this ); + + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + + // Resolve the default configuration: + opts = defaults(); + + // Set internal properties according to the default configuration... + keys = objectKeys( opts ); + for ( i = 0; i < keys.length; i++ ) { + k = keys[ i ]; + this[ '_'+k ] = opts[ k ]; + } + + // Define an internal change event listener: + this._onChange = onChange; + + // Add change listeners to default event emitters: + if ( this._field && typeof this._field.on === 'function' ) { + this._addChangeListener( this._field ); + } + + // Validate provided options by attempting to assign option values to corresponding fields... + for ( i = 0; i < properties.length; i++ ) { + k = properties[ i ]; + if ( !hasProp( options, k ) ) { + continue; + } + v = options[ k ]; + try { + this[ k ] = v; + } catch ( err ) { + debug( 'Encountered an error. Error: %s', err.message ); + + // FIXME: retain thrown error type + throw new Error( transformErrorMessage( err.message ) ); + } + } + return this; + + /** + * Callback invoked upon a change event. + * + * @private + * @param {Object} event - event object + */ + function onChange( event ) { + debug( 'Received a change event: %s', JSON.stringify( event ) ); + self.emit( 'change', event ); + } +} + +/* +* Inherit from the `EventEmitter` prototype. +*/ +inherit( PieTransform, EventEmitter ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof PieTransform +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( PieTransform, 'name', 'PieTransform' ); + +/** +* Adds an internal listener to a change event on a child instance. +* +* @private +* @name _addChangeListener +* @memberof PieTransform.prototype +* @type {Function} +* @param {Object} emitter - event emitter +* @returns {PieTransform} pie transform instance +*/ +setNonEnumerableReadOnly( PieTransform.prototype, '_addChangeListener', function addChangeListener( emitter ) { + if ( emitter && typeof emitter.on === 'function' ) { + emitter.on( 'change', this._onChange ); + } + return this; +}); + +/** +* Adds internal listeners to change events on child instances. +* +* @private +* @name _addChangeListeners +* @memberof PieTransform.prototype +* @type {Function} +* @param {ArrayLikeObject} emitters - list of event emitters +* @returns {PieTransform} pie transform instance +*/ +setNonEnumerableReadOnly( PieTransform.prototype, '_addChangeListeners', function addChangeListeners( emitters ) { + var i; + for ( i = 0; i < emitters.length; i++ ) { + this._addChangeListener( emitters[ i ] ); + } + return this; +}); + +/** +* Removes an internal listener to a change event on a child instance. +* +* @private +* @name _removeChangeListener +* @memberof PieTransform.prototype +* @type {Function} +* @param {Object} emitter - event emitter +* @returns {PieTransform} pie transform instance +*/ +setNonEnumerableReadOnly( PieTransform.prototype, '_removeChangeListener', function removeChangeListener( emitter ) { + if ( emitter && typeof emitter.removeListener === 'function' ) { + emitter.removeListener( 'change', this._onChange ); + } + return this; +}); + +/** +* Removes internal listeners to change events on child instances. +* +* @private +* @name _removeChangeListeners +* @memberof PieTransform.prototype +* @type {Function} +* @param {ArrayLikeObject} emitters - list of event emitters +* @returns {PieTransform} pie transform instance +*/ +setNonEnumerableReadOnly( PieTransform.prototype, '_removeChangeListeners', function removeChangeListeners( emitters ) { + var i; + for ( i = 0; i < emitters.length; i++ ) { + this._removeChangeListener( emitters[ i ] ); + } + return this; +}); + +/** +* Output field names for the computed start and end angle values. +* +* @name as +* @memberof PieTransform.prototype +* @type {ArrayLikeObject} +* @default ['startAngle','endAngle'] +* +* @example +* var transform = new PieTransform({ +* 'as': [ 'foo', 'bar' ] +* }); +* +* var v = transform.as; +* // returns [ 'foo', 'bar' ] +*/ +setReadWriteAccessor( PieTransform.prototype, 'as', getAs, setAs ); + +/** +* End angle of the pie in radians. +* +* @name endAngle +* @memberof PieTransform.prototype +* @type {NonNegativeNumber} +* @default 2*PI +* +* @example +* var transform = new PieTransform({ +* 'endAngle': 3.141592653589793 +* }); +* +* var v = transform.endAngle; +* // returns 3.141592653589793 +*/ +setReadWriteAccessor( PieTransform.prototype, 'endAngle', getEndAngle, setEndAngle ); + +/** +* Data field determining pie slice size. +* +* ## Notes +* +* - If not set, all pie slices have an equal size. +* +* @name field +* @memberof PieTransform.prototype +* @type {(Field|void)} +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var field = new Field({ +* 'field': 'amount' +* }); +* +* var transform = new PieTransform({ +* 'field': field +* }); +* +* var v = transform.field; +* // returns +*/ +setReadWriteAccessor( PieTransform.prototype, 'field', getField, setField ); + +/** +* Pie transform properties. +* +* @name properties +* @memberof PieTransform.prototype +* @type {Array} +* +* @example +* var transform = new PieTransform({}); +* +* var v = transform.properties; +* // returns [...] +*/ +setNonEnumerableReadOnlyAccessor( PieTransform.prototype, 'properties', getProperties ); + +/** +* Boolean indicating whether to sort arcs according to field values. +* +* @name sort +* @memberof PieTransform.prototype +* @type {boolean} +* @default false +* +* @example +* var transform = new PieTransform({ +* 'sort': true +* }); +* +* var v = transform.sort; +* // returns true +*/ +setReadWriteAccessor( PieTransform.prototype, 'sort', getSort, setSort ); + +/** +* Starting angle of the pie in radians. +* +* @name startAngle +* @memberof PieTransform.prototype +* @type {NonNegativeNumber} +* @default 0 +* +* @example +* var transform = new PieTransform({ +* 'startAngle': 1.5707963267948966 +* }); +* +* var v = transform.startAngle; +* // returns 1.5707963267948966 +*/ +setReadWriteAccessor( PieTransform.prototype, 'startAngle', getStartAngle, setStartAngle ); + +/** +* Serializes an instance to a JSON object. +* +* ## Notes +* +* - This method is implicitly invoked by `JSON.stringify`. +* +* @name toJSON +* @memberof PieTransform.prototype +* @type {Function} +* @returns {Object} JSON object +* +* @example +* var transform = new PieTransform({}); +* +* var v = transform.toJSON(); +* // returns {...} +*/ +setNonEnumerableReadOnly( PieTransform.prototype, 'toJSON', function toJSON() { + return instance2json( this, properties ); +}); + + +// EXPORTS // + +module.exports = PieTransform; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/properties.json b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/properties.json new file mode 100644 index 000000000000..223aa8ec7bcc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/properties.json @@ -0,0 +1,7 @@ +[ + "as", + "endAngle", + "field", + "sort", + "startAngle" +] diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/properties/get.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/properties/get.js new file mode 100644 index 000000000000..f3cbb28454ea --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/properties/get.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var properties = require( './../properties.json' ); + + +// MAIN // + +/** +* Returns the list of enumerable properties. +* +* @private +* @returns {Array} properties +*/ +function get() { + return properties.slice(); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/sort/get.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/sort/get.js new file mode 100644 index 000000000000..6ba462ba947a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/sort/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns a boolean indicating whether to sort arcs according to field values. +* +* @private +* @returns {boolean} boolean indicating whether to sort arcs +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/sort/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/sort/properties.js new file mode 100644 index 000000000000..9a3846787a90 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/sort/properties.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'sort' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/sort/set.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/sort/set.js new file mode 100644 index 000000000000..9dab1e323e57 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/sort/set.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:pie-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets a boolean indicating whether to sort arcs according to field values. +* +* @private +* @param {boolean} value - input value +* @throws {TypeError} must be a boolean +* @returns {void} +*/ +function set( value ) { + if ( !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/start-angle/get.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/start-angle/get.js new file mode 100644 index 000000000000..ece3d9c3f167 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/start-angle/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the starting angle of the pie in radians. +* +* @private +* @returns {NonNegativeNumber} starting angle +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/start-angle/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/start-angle/properties.js new file mode 100644 index 000000000000..7509ef0cbba7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/start-angle/properties.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'startAngle' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/start-angle/set.js b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/start-angle/set.js new file mode 100644 index 000000000000..ad02ac451c6d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/lib/start-angle/set.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:pie-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the starting angle of the pie in radians. +* +* @private +* @param {NonNegativeNumber} value - input value +* @throws {TypeError} must be a nonnegative number +* @returns {void} +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative number. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/package.json b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/package.json new file mode 100644 index 000000000000..f4cb6721d0f3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/pie/ctor/package.json @@ -0,0 +1,61 @@ +{ + "name": "@stdlib/plot/vega/transform/pie/ctor", + "version": "0.0.0", + "description": "Pie transform constructor.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "vega", + "transform", + "pie", + "constructor", + "ctor" + ], + "__stdlib__": {} +}