From 4724b09d6dd99ab25addf33e179507acc8a187b5 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Thu, 19 Mar 2026 18:03:01 +0530 Subject: [PATCH] feat: add plot/vega/scale/quantize --- .../vega/scale/quantize/examples/index.js | 27 ++ .../vega/scale/quantize/lib/change_event.js | 41 +++ .../plot/vega/scale/quantize/lib/defaults.js | 46 ++++ .../plot/vega/scale/quantize/lib/index.js | 42 +++ .../plot/vega/scale/quantize/lib/main.js | 254 ++++++++++++++++++ .../plot/vega/scale/quantize/lib/nice/get.js | 43 +++ .../scale/quantize/lib/nice/properties.js | 33 +++ .../plot/vega/scale/quantize/lib/nice/set.js | 62 +++++ .../vega/scale/quantize/lib/properties.json | 16 ++ .../vega/scale/quantize/lib/properties/get.js | 41 +++ .../plot/vega/scale/quantize/lib/type/get.js | 41 +++ .../plot/vega/scale/quantize/lib/type/set.js | 46 ++++ .../plot/vega/scale/quantize/lib/type/type.js | 23 ++ .../plot/vega/scale/quantize/lib/zero/get.js | 43 +++ .../scale/quantize/lib/zero/properties.js | 33 +++ .../plot/vega/scale/quantize/lib/zero/set.js | 61 +++++ .../plot/vega/scale/quantize/package.json | 63 +++++ 17 files changed, 915 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/change_event.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/defaults.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/get.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/properties.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/set.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/properties.json create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/properties/get.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/get.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/set.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/type.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/get.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/properties.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/set.js create mode 100644 lib/node_modules/@stdlib/plot/vega/scale/quantize/package.json diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/examples/index.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/examples/index.js new file mode 100644 index 000000000000..0467812ac252 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/examples/index.js @@ -0,0 +1,27 @@ +/** +* @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 QuantizeScale = require( './../lib' ); + +var scale = new QuantizeScale({ + 'name': 'color' +}); + +console.log( scale.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/change_event.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/change_event.js new file mode 100644 index 000000000000..730718cd6454 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/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': 'scale', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/defaults.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/defaults.js new file mode 100644 index 000000000000..407ea48cf885 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/defaults.js @@ -0,0 +1,46 @@ +/** +* @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 defaults. +* +* @private +* @returns {Object} default options +* +* @example +* var o = defaults(); +* // returns {...} +*/ +function defaults() { + return { + // Boolean indicating whether to extend a scale domain so that the domain starts and ends on round values: + 'nice': false, + + // Boolean flag indicating if the scale domain should include zero: + 'zero': false + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/index.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/index.js new file mode 100644 index 000000000000..db91678a136f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/index.js @@ -0,0 +1,42 @@ +/** +* @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'; + +/** +* Quantize scale constructor. +* +* @module @stdlib/plot/vega/scale/quantize +* +* @example +* var QuantizeScale = require( '@stdlib/plot/vega/scale/quantize' ); +* +* var scale = new QuantizeScale({ +* 'name': 'color' +* }); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/main.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/main.js new file mode 100644 index 000000000000..d649ad43ece4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/main.js @@ -0,0 +1,254 @@ +/** +* @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 logger = require( 'debug' ); +var isObject = require( '@stdlib/assert/is-object' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); +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 inherit = require( '@stdlib/utils/inherit' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var DiscretizingScale = require( '@stdlib/plot/vega/scale/discretizing' ); +var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' ); +var instance2json = require( '@stdlib/plot/vega/base/to-json' ); +var format = require( '@stdlib/string/format' ); +var properties = require( './properties.json' ); +var defaults = require( './defaults.js' ); +var TYPE = require( './type/type.js' ); + +// Note: keep the following in alphabetical order according to the `require` path... +var getNice = require( './nice/get.js' ); +var setNice = require( './nice/set.js' ); + +var getProperties = require( './properties/get.js' ); + +var getType = require( './type/get.js' ); +var setType = require( './type/set.js' ); + +var getZero = require( './zero/get.js' ); +var setZero = require( './zero/set.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:quantize-scale:main' ); + + +// MAIN // + +/** +* Quantize scale constructor. +* +* @constructor +* @param {Options} options - constructor options +* @param {string} options.name - scale name +* @param {(Collection|Object|Signal)} [options.domain] - domain of associated data values +* @param {number} [options.domainMax] - maximum value in the scale domain (overrides the `domain` option) +* @param {number} [options.domainMin] - minimum value in the scale domain (overrides the `domain` option) +* @param {number} [options.domainMid] - single mid-point value inserted into a two-element domain +* @param {Collection} [options.domainRaw] - array of raw domain values which overrides the `domain` property +* @param {(string|Object)} [options.interpolate] - scale range interpolation method +* @param {(boolean|number)} [options.nice=false] - scale domain "nicing" +* @param {(Collection|Object|Signal|string)} [options.range] - scale range +* @param {boolean} [options.reverse=false] - boolean indicating whether to reverse the order of the scale range +* @param {boolean} [options.round=false] - boolean indicating whether to round numeric output values to integers +* @param {boolean} [options.zero=false] - boolean indicating whether the scale domain should include zero +* @throws {TypeError} options argument must be an object +* @throws {Error} must provide valid options +* @returns {QuantizeScale} scale instance +* +* @example +* var scale = new QuantizeScale({ +* 'name': 'color' +* }); +* // returns +*/ +function QuantizeScale( options ) { + var opts; + var keys; + var v; + var k; + var i; + if ( !( this instanceof QuantizeScale ) ) { + return new QuantizeScale( options ); + } + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + if ( hasProp( options, 'type' ) && options.type !== TYPE ) { + throw new TypeError( format( 'invalid argument. `%s` option must be equal to "%s". Option: `%s`.', 'type', TYPE, options.type ) ); + } + // Check for required properties... + if ( !hasProp( options, 'name' ) ) { + throw new TypeError( 'invalid argument. Options argument must specify the scale name.' ); + } + DiscretizingScale.call( this, { + 'name': options.name + }); + this._type = TYPE; + + // 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 ]; + } + // 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; +} + +/* +* Inherit from a parent prototype. +*/ +inherit( QuantizeScale, DiscretizingScale ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof QuantizeScale +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( QuantizeScale, 'name', 'QuantizeScale' ); + +/** +* Scale domain "nicing". +* +* @name nice +* @memberof QuantizeScale.prototype +* @type {(boolean|number)} +* @default false +* +* @example +* var scale = new QuantizeScale({ +* 'name': 'color', +* 'nice': true +* }); +* +* var v = scale.nice; +* // returns true +*/ +setReadWriteAccessor( QuantizeScale.prototype, 'nice', getNice, setNice ); + +/** +* Scale properties. +* +* @name properties +* @memberof QuantizeScale.prototype +* @type {Array} +* +* @example +* var scale = new QuantizeScale({ +* 'name': 'color' +* }); +* +* var v = scale.properties; +* // returns [...] +*/ +setNonEnumerableReadOnlyAccessor( QuantizeScale.prototype, 'properties', getProperties ); + +/** +* Scale type. +* +* @name type +* @memberof QuantizeScale.prototype +* @type {string} +* @default 'quantize' +* +* @example +* var scale = new QuantizeScale({ +* 'name': 'color' +* }); +* +* var v = scale.type; +* // returns 'quantize' +*/ +setReadWriteAccessor( QuantizeScale.prototype, 'type', getType, setType ); + +/** +* Boolean indicating whether the scale domain should include zero. +* +* @name zero +* @memberof QuantizeScale.prototype +* @type {boolean} +* @default false +* +* @example +* var scale = new QuantizeScale({ +* 'name': 'color', +* 'zero': true +* }); +* +* var v = scale.zero; +* // returns true +*/ +setReadWriteAccessor( QuantizeScale.prototype, 'zero', getZero, setZero ); + +/** +* Serializes an instance to a JSON object. +* +* ## Notes +* +* - This method is implicitly invoked by `JSON.stringify`. +* +* @name toJSON +* @memberof QuantizeScale.prototype +* @type {Function} +* @returns {Object} JSON object +* +* @example +* var scale = new QuantizeScale({ +* 'name': 'color' +* }); +* +* var v = scale.toJSON(); +* // returns {...} +*/ +setNonEnumerableReadOnly( QuantizeScale.prototype, 'toJSON', function toJSON() { + return instance2json( this, properties ); +}); + + +// EXPORTS // + +module.exports = QuantizeScale; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/get.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/get.js new file mode 100644 index 000000000000..9545ed2d54bc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/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 scale domain "nicing". +* +* @private +* @returns {(number|boolean)} output value +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/properties.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/properties.js new file mode 100644 index 000000000000..61afcfc54f0d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/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( 'nice' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/set.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/set.js new file mode 100644 index 000000000000..f1ee8cab581c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/nice/set.js @@ -0,0 +1,62 @@ +/** +* @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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +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:quantize-scale:set:'+prop.name ); + + +// MAIN // + +/** +* Sets scale domain "nicing". +* +* @private +* @param {(number|boolean)} value - input value +* @throws {TypeError} must be either a number or a boolean +* @returns {void} +*/ +function set( value ) { + if ( !isNumber( value ) && !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be either a number or 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/scale/quantize/lib/properties.json b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/properties.json new file mode 100644 index 000000000000..1f41946780a1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/properties.json @@ -0,0 +1,16 @@ +[ + "domain", + "domainMax", + "domainMin", + "domainMid", + "domainRaw", + "interpolate", + "name", + "range", + "reverse", + "round", + "type", + + "nice", + "zero" +] diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/properties/get.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/properties/get.js new file mode 100644 index 000000000000..f3cbb28454ea --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/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/scale/quantize/lib/type/get.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/get.js new file mode 100644 index 000000000000..b0e023118efa --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/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 TYPE = require( './type.js' ); + + +// MAIN // + +/** +* Returns the scale type. +* +* @private +* @returns {string} scale type +*/ +function get() { + return TYPE; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/set.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/set.js new file mode 100644 index 000000000000..d14f0839d329 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/set.js @@ -0,0 +1,46 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var TYPE = require( './type.js' ); + + +// MAIN // + +/** +* Sets the scale type. +* +* @private +* @param {string} value - input value +* @throws {TypeError} must be a valid scale +* @returns {void} +*/ +function set( value ) { + if ( value !== TYPE ) { + throw new TypeError( format( 'invalid assignment. `%s` must be equal to "%s". Value: `%s`.', 'type', TYPE, value ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/type.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/type.js new file mode 100644 index 000000000000..21ac3de957ae --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/type/type.js @@ -0,0 +1,23 @@ +/** +* @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'; + +// EXPORTS // + +module.exports = 'quantize'; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/get.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/get.js new file mode 100644 index 000000000000..317e988ff555 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/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 the scale domain should include zero. +* +* @private +* @returns {boolean} boolean flag +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/properties.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/properties.js new file mode 100644 index 000000000000..0dbaa85cc71a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/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( 'zero' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/set.js b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/set.js new file mode 100644 index 000000000000..f0ab14e2d1fc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/lib/zero/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:quantize-scale:set:'+prop.name ); + + +// MAIN // + +/** +* Sets a boolean flag indicating whether the scale domain should include zero. +* +* @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/scale/quantize/package.json b/lib/node_modules/@stdlib/plot/vega/scale/quantize/package.json new file mode 100644 index 000000000000..bfe6a2f951d3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/scale/quantize/package.json @@ -0,0 +1,63 @@ +{ + "name": "@stdlib/plot/vega/scale/quantize", + "version": "0.0.0", + "description": "Quantize scale 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", + "scale", + "discretizing", + "categorical", + "quantize", + "constructor", + "ctor" + ], + "__stdlib__": {} +}