From 1b3412fbbb3f5f94a360e8469c753011bddfd8fb Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Sat, 15 Aug 2026 22:34:42 +0530 Subject: [PATCH 1/4] feat: add plot/charts/scatter/ctor --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../charts/scatter/ctor/examples/index.js | 36 + .../charts/scatter/ctor/lib/change_event.js | 41 + .../charts/scatter/ctor/lib/colors/get.js | 44 + .../scatter/ctor/lib/colors/properties.js | 33 + .../charts/scatter/ctor/lib/colors/set.js | 75 ++ .../plot/charts/scatter/ctor/lib/defaults.js | 60 ++ .../plot/charts/scatter/ctor/lib/index.js | 42 + .../charts/scatter/ctor/lib/legend/get.js | 43 + .../scatter/ctor/lib/legend/properties.js | 33 + .../charts/scatter/ctor/lib/legend/set.js | 64 ++ .../plot/charts/scatter/ctor/lib/main.js | 828 ++++++++++++++++++ .../charts/scatter/ctor/lib/properties.json | 7 + .../scatter/ctor/lib/symbols-opacity/get.js | 44 + .../ctor/lib/symbols-opacity/properties.js | 33 + .../scatter/ctor/lib/symbols-opacity/set.js | 75 ++ .../scatter/ctor/lib/symbols-size/get.js | 44 + .../ctor/lib/symbols-size/properties.js | 33 + .../scatter/ctor/lib/symbols-size/set.js | 75 ++ .../charts/scatter/ctor/lib/symbols/get.js | 44 + .../scatter/ctor/lib/symbols/properties.js | 33 + .../charts/scatter/ctor/lib/symbols/set.js | 76 ++ .../plot/charts/scatter/ctor/package.json | 67 ++ 22 files changed, 1830 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/change_event.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/get.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/properties.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/get.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/properties.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/set.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/get.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/properties.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/set.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/get.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/properties.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/set.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/get.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/properties.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/set.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/package.json diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js new file mode 100644 index 000000000000..a0fac93debf7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js @@ -0,0 +1,36 @@ +/** +* @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 uniform = require( '@stdlib/random/uniform' ); +var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +var ScatterChart = require( './../lib' ); + +var a = new Float64Vector( [ 10.0, 20.0, 30.0, 40.0, 50.0 ] ); +var b = new Float64Vector( [ 20.0, 30.0, 40.0, 50.0, 60.0 ] ); + +var y = uniform( [ 100, 5 ], a, b ); + +var chart = new ScatterChart( y, { + 'symbols': [ 'o', 'square' ], + 'symbolsOpacity': [ 1.0, 0.4 ], + 'symbolsSize': [ 100, 50 ], + 'legend': true +}); +console.log( chart.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/change_event.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/change_event.js new file mode 100644 index 000000000000..269fa636e9cb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/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': 'visualization', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/get.js new file mode 100644 index 000000000000..838d44f30169 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/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' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the symbol colors. +* +* @private +* @returns {Array} colors +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/properties.js new file mode 100644 index 000000000000..2790499a9a07 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/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( 'colors' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js new file mode 100644 index 000000000000..55779a34a460 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js @@ -0,0 +1,75 @@ +/** +* @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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'scatter-chart:set:'+prop.name ); + + +// MAIN // + +/** +* Sets symbol colors. +* +* @private +* @param {(Array|string)} value - input value +* @throws {TypeError} must be a string or an array of strings +* @returns {void} +*/ +function set( value ) { + var isStr = isString( value ); + if ( !isStr && !isStringArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string or an array of strings. Value: `%s`.', prop.name, value ) ); + } + if ( isStr ) { + value = [ value ]; + } + if ( !hasEqualValues( value, this[ prop.private ] ) ) { + debug( 'Current value: [%s]. New value: [%s].', join( this[ prop.private ], ', ' ), join( value, ', ' ) ); + + // Perform a defensive copy as we will be caching the specified symbol colors: + value = copy( value ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Update the color range: + this.colorScale.range = value; + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js new file mode 100644 index 000000000000..01c64a8d50fc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js @@ -0,0 +1,60 @@ +/** +* @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 category10 = require( '@stdlib/plot/color-schemes/category10' ); + + +// MAIN // + +/** +* Returns defaults. +* +* @private +* @returns {Object} defaults +* +* @example +* var obj = defaults(); +* // returns {...} +*/ +function defaults() { + return { + // Symbol colors: + 'colors': category10(), + + // Boolean indicating whether to display a legend: + 'legend': false, + + // Symbol(s): + 'symbols': [ 'circle' ], + + // Symbol opacity: + 'symbolsOpacity': [ 1.0 ], + + // Symbol size(s) (in pixels squared): + 'symbolsSize': [ 100 ] + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/index.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/index.js new file mode 100644 index 000000000000..3279081d7735 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/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'; + +/** +* Scatter chart constructor. +* +* @module @stdlib/plot/charts/scatter/ctor +* +* @example +* var ScatterChart = require( '@stdlib/plot/charts/scatter/ctor' ); +* +* var chart = new ScatterChart(); +* // returns +* +* // TODO: update example +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/get.js new file mode 100644 index 000000000000..a54c76188171 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/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 display a chart legend. +* +* @private +* @returns {boolean} boolean flag +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/properties.js new file mode 100644 index 000000000000..2d94c431aafa --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/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( 'legend' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/set.js new file mode 100644 index 000000000000..af672e0c5b75 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/set.js @@ -0,0 +1,64 @@ +/** +* @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 prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'scatter-chart:set:'+prop.name ); + + +// MAIN // + +/** +* Sets a boolean flag indicating whether a layout should be re-calculated on every view update. +* +* @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; + if ( value ) { + this.config.legends = [ this._chartLegend ]; + return; + } + this.config.legends = []; + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js new file mode 100644 index 000000000000..4c6a5d88fdde --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js @@ -0,0 +1,828 @@ +/** +* @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 max-lines, no-restricted-syntax, no-invalid-this, stdlib/no-empty-lines-between-requires */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' ); +var isCollection = require( '@stdlib/assert/is-collection' ); +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 setReadOnlyAccessor = require( '@stdlib/utils/define-read-only-accessor' ); +var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var inherit = require( '@stdlib/utils/inherit' ); +var objectAssignIn = require( '@stdlib/object/assign-in' ); +var slice = require( '@stdlib/array/base/slice' ); +var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' ); +var symbols2shapes = require( '@stdlib/plot/base/symbols2shapes' ); +var QuantitativeChart = require( '@stdlib/plot/charts/base/quantitative' ); +var DataSource = require( '@stdlib/plot/vega/mark/data-source' ); +var Value = require( '@stdlib/plot/vega/value/ctor' ); +var OrdinalScale = require( '@stdlib/plot/vega/scale/ordinal' ); +var SymbolEncodingSet = require( '@stdlib/plot/vega/mark/symbol/encoding-set' ); +var SymbolEncoding = require( '@stdlib/plot/vega/mark/symbol/encoding' ); +var SymbolMark = require( '@stdlib/plot/vega/mark/symbol/ctor' ); +var Legend = require( '@stdlib/plot/vega/legend/ctor' ); +var spec2svg = require( '@stdlib/plot/vega/base/spec2svg' ); +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 getColors = require( './colors/get.js' ); +var setColors = require( './colors/set.js' ); + +var getLegend = require( './legend/get.js' ); +var setLegend = require( './legend/set.js' ); +var getSymbolsOpacity = require( './symbols-opacity/get.js' ); +var setSymbolsOpacity = require( './symbols-opacity/set.js' ); +var getSymbolsSize = require( './symbols-size/get.js' ); +var setSymbolsSize = require( './symbols-size/set.js' ); +var getSymbols = require( './symbols/get.js' ); +var setSymbols = require( './symbols/set.js' ); + + +// VARIABLES // + +var debug = logger( 'scatter-chart:main' ); + +var SCALE_TO_INDEX = { + 'x': 0, + 'y': 1, + 'color': 2, + 'opacity': 3, + 'shape': 4, + 'size': 5 +}; +var SCALE_TO_DEFAULT_NAME = { + 'color': 'colorScale', + 'opacity': 'symbolsOpacityScale', + 'shape': 'symbolsScale', + 'size': 'symbolsSizeScale' +}; +var SCALE_TO_ENCODING = { + 'color': 'fill', + 'opacity': 'fillOpacity', + 'shape': 'shape', + 'size': 'size' +}; +var INTERNAL_ORDINAL_SCALES = [ + 'color', + 'opacity', + 'shape', + 'size' +]; +var UPDATE_ORDINAL_SCALES = [ + 'color', + 'opacity', + 'shape', + 'size' +]; + + +// FUNCTIONS // + +/** +* Extract a property value from each element of an object array. +* +* @private +* @param {Array} arr - input array +* @param {string} prop - property name +* @returns {Array} output array +*/ +function pluck( arr, prop ) { // TODO: use `array/base/pluck` once implemented (ref: https://github.com/stdlib-js/stdlib/pull/5376) + var out; + var i; + + out = []; + for ( i = 0; i < arr.length; i++ ) { + out.push( arr[ i ][ prop ] ); + } + return out; +} + +/** +* Returns the scale data associated with the provided scale identifier. +* +* @private +* @param {Array} data - scale data +* @param {string} id - identifier +* @returns {*} scale data +*/ +function getScale( data, id ) { + return data[ SCALE_TO_INDEX[ id ] ]; +} + +/** +* Returns the default name for a specified scale identifier. +* +* @private +* @param {string} id - identifier +* @returns {string} default name +*/ +function scale2default( id ) { + return SCALE_TO_DEFAULT_NAME[ id ]; +} + +/** +* Returns the encoding name for a specified scale identifier. +* +* @private +* @param {string} id - identifier +* @returns {string} encoding name +*/ +function scale2encoding( id ) { + return SCALE_TO_ENCODING[ id ]; +} + +/** +* Returns a field value reference. +* +* @private +* @param {string} scale - scale name +* @param {string} field - field name +* @returns {Value} value reference +*/ +function fieldValue( scale, field ) { + return new Value({ + 'scale': scale, + 'field': field + }); +} + +/** +* Returns an ordinal value reference. +* +* @private +* @param {string} scale - scale name +* @param {*} value - value +* @returns {Value} value reference +*/ +function ordinalValue( scale, value ) { + return new Value({ + 'scale': scale, + 'value': value + }); +} + +/** +* Returns a symbol mark encoding for a specified dataset. +* +* @private +* @param {string} name - dataset name +* @param {Array} scales - scale names +* @returns {SymbolEncoding} symbol mark encoding +*/ +function encoding( name, scales ) { + return new SymbolEncoding({ + 'update': new SymbolEncodingSet({ + 'fill': ordinalValue( getScale( scales, 'color' ), name ), + 'fillOpacity': ordinalValue( getScale( scales, 'opacity' ), name ), + 'shape': ordinalValue( getScale( scales, 'shape' ), name ), + 'size': ordinalValue( getScale( scales, 'size' ), name ), + 'x': fieldValue( getScale( scales, 'x' ), 'x' ), + 'y': fieldValue( getScale( scales, 'y' ), 'y' ) + }) + }); +} + +/** +* Returns a symbol mark for a specified dataset. +* +* @private +* @param {string} name - dataset name +* @param {Array} scales - scale names +* @returns {SymbolMark} symbol mark +*/ +function symbolMark( name, scales ) { + return new SymbolMark({ + 'from': new DataSource({ + 'data': name + }), + 'encode': encoding( name, scales ) + }); +} + +/** +* Updates a symbol mark. +* +* @private +* @param {SymbolMark} mark - symbol mark +* @param {string} name - dataset name +* @param {Array} scales - scale names +* @returns {SymbolMark} symbol mark +*/ +function updateSymbolMark( mark, name, scales ) { + var encoding; + var id; + var v; + var i; + + mark.from.data = name; + + encoding = mark.encode.update; + encoding.x.scale = getScale( scales, 'x' ); + encoding.y.scale = getScale( scales, 'y' ); + + for ( i = 0; i < UPDATE_ORDINAL_SCALES.length; i++ ) { + id = UPDATE_ORDINAL_SCALES[ i ]; + v = encoding[ scale2encoding( id ) ]; + v.scale = getScale( scales, id ); + v.value = name; + } + return mark; +} + + +// MAIN // + +/** +* Scatter chart constructor. +* +* @constructor +* @param {(ndarrayLike|Collection)} [x] - x-values +* @param {(ndarrayLike|Collection)} [y] - y-values +* @param {Options} [options] - constructor options +* @param {string} [options.background] - background color +* @param {Object} [options.channels={'x':'x','y':'y'}] - object mapping chart data field names to encoding channels ('x', 'y', and 'z') +* @param {(string|Array)} [options.colors] - symbol colors +* @param {ArrayLikeObject} [options.data=[]] - chart data +* @param {string} [options.description=''] - chart description +* @param {number} [options.height=480] - chart height (in pixels) +* @param {Array} [options.labels=[]] - data labels +* @param {Object} [options.padding] - chart padding +* @param {number} [options.padding.bottom=0] - chart bottom padding (in pixels) +* @param {number} [options.padding.left=0] - chart left padding (in pixels) +* @param {number} [options.padding.right=0] - chart right padding (in pixels) +* @param {number} [options.padding.top=0] - chart top padding (in pixels) +* @param {(string|Array)} [options.symbols=['circle']] - symbol(s) +* @param {(number|Array)} [options.symbolsOpacity=[1.0]] - symbol opacity +* @param {(number|Array)} [options.symbolsSize=[100]] - symbol size(s) in pixels squared +* @param {Object} [options.theme] - chart theme +* @param {(string|Array)} [options.title=''] - chart title +* @param {string} [options.viewer] - default chart viewer +* @param {number} [options.width=600] - chart width (in pixels) +* @param {(string|Array)} [options.xTitle='x'] - x-axis label +* @param {(string|Object)} [options.xFormat] - x-axis tick format +* @param {number} [options.xMax] - maximum value of the x-axis domain +* @param {number} [options.xMin] - minimum value of the x-axis domain +* @param {string} [options.xScaleType='linear'] - x-axis scale type +* @param {(number|string|Object)} [options.xTickCount] - number of x-axis tick marks +* @param {(string|Object)} [options.yFormat] - y-axis tick format +* @param {number} [options.yMax] - maximum value of the y-axis domain +* @param {number} [options.yMin] - minimum value of the y-axis domain +* @param {string} [options.yScaleType='linear'] - y-axis scale type +* @param {(number|string|Object)} [options.yTickCount] - number of y-axis tick marks +* @param {(string|Array)} [options.yTitle='y'] - y-axis label +* @throws {TypeError} must provide a valid first argument +* @throws {TypeError} must provide a valid second argument +* @throws {TypeError} options argument must be an object +* @throws {Error} must provide valid options +* @returns {ScatterChart} scatter chart instance +* +* @example +* var plot = new ScatterChart(); +* // returns +*/ +function ScatterChart( x, y, options ) { + var scales; + var nargs; + var opts; + var k; + var v; + var s; + var i; + + nargs = arguments.length; + if ( !( this instanceof ScatterChart ) ) { + if ( nargs < 1 ) { + return new ScatterChart(); + } + if ( nargs === 1 ) { + return new ScatterChart( x ); + } + if ( nargs === 2 ) { + return new ScatterChart( x, y ); + } + return new ScatterChart( x, y, options ); + } + opts = defaults(); + + // Set internal properties according to the default configuration... + for ( i = 0; i < properties.length; i++ ) { + k = properties[ i ]; + if ( hasProp( opts, k ) ) { + this[ '_'+k ] = opts[ k ]; + } + } + // Case: new ScatterChart( arg ) + if ( nargs === 1 ) { + // Case: new ScatterChart( ndarray ) + if ( isndarrayLike( x ) ) { + opts.data = [ x ]; + } + // Case: new ScatterChart( collection ) + else if ( isCollection( x ) ) { + opts.data = [ x ]; + } + // Case: new ScatterChart( options ) + else if ( isObject( x ) ) { + opts = objectAssignIn( opts, x ); + } + // Case: new ScatterChart( ??? ) + else { + throw new TypeError( format( 'invalid argument. First argument must be either an array-like object, an ndarray, or an options argument. Value: `%s`.', x ) ); + } + } + // Case: new ScatterChart( arg1, arg2 ) + else if ( nargs === 2 ) { + // Case: new ScatterChart( ndarray, ??? ) + if ( isndarrayLike( x ) ) { + // Case: new ScatterChart( ndarray, ndarray ) + if ( isndarrayLike( y ) ) { + opts.data = [ x, y ]; + } + // Case: new ScatterChart( ndarray, collection ) + else if ( isCollection( y ) ) { + for ( i = 0; i < y.length; i++ ) { + if ( !isndarrayLike( y[ i ] ) ) { + throw new TypeError( 'invalid argument. Second argument must be an ndarray or an array of ndarrays.' ); + } + } + opts.data = [ x, y ]; + } + // Case: new ScatterChart( ndarray, options ) + else if ( isObject( y ) ) { + opts = objectAssignIn( opts, y ); + opts.data = [ x ]; // always override `opts.data` if it exists + } + // Case: new ScatterChart( ndarray, ??? ) + else { + throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray, an array of ndarrays, or an options argument. Value: `%s`.', y ) ); + } + } + // Case: new ScatterChart( collection, ??? ) + else if ( isCollection( x ) ) { + // Case: new ScatterChart( collection, ndarray ) + if ( isndarrayLike( y ) ) { + for ( i = 0; i < x.length; i++ ) { + if ( !isndarrayLike( x[ i ] ) ) { + throw new TypeError( 'invalid argument. First argument must be an ndarray or an array of ndarrays.' ); + } + } + opts.data = [ x, y ]; + } + // Case: new ScatterChart( collection, collection ) + else if ( isCollection( y ) ) { + opts.data = [ x, y ]; + } + // Case: new ScatterChart( collection, options ) + else if ( isObject( y ) ) { + opts = objectAssignIn( opts, y ); + opts.data = [ x ]; // always override `opts.data` if it exists + } + // Case: new ScatterChart( collection, ??? ) + else { + throw new TypeError( format( 'invalid argument. First argument must be either an array-like object, an ndarray, or an options argument. Value: `%s`.', y ) ); + } + } + // Case: new ScatterChart( ???, ??? ) + else { + throw new TypeError( format( 'invalid argument. First argument must be either an array-like object or an ndarray. Value: `%s`.', x ) ); + } + } + // Case: new ScatterChart( x, y, options ) + else if ( nargs > 2 ) { + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + opts = objectAssignIn( opts, options ); + + // Case: new ScatterChart( ndarray, ???, options ) + if ( isndarrayLike( x ) ) { + // Case: new ScatterChart( ndarray, ndarray, options ) + if ( isndarrayLike( y ) ) { + opts.data = [ x, y ]; // always override `opts.data` if it exists + } + // Case: new ScatterChart( ndarray, collection, options ) + else if ( isCollection( y ) ) { + for ( i = 0; i < y.length; i++ ) { + if ( !isndarrayLike( y[ i ] ) ) { + throw new TypeError( 'invalid argument. Second argument must be an ndarray or an array of ndarrays.' ); + } + } + opts.data = [ x, y ]; // always override `opts.data` if it exists + } + // Case: new ScatterChart( ndarray, ???, options ) + else { + throw new TypeError( format( 'invalid argument. Second argument must be an ndarray or an array of ndarrays.' ) ); + } + } + // Case: new ScatterChart( collection, ???, options ) + else if ( isCollection( x ) ) { + // Case: new ScatterChart( collection, ndarray, options ) + if ( isndarrayLike( y ) ) { + for ( i = 0; i < x.length; i++ ) { + if ( !isndarrayLike( x[ i ] ) ) { + throw new TypeError( 'invalid argument. First argument must be an ndarray or an array of ndarrays.' ); + } + } + opts.data = [ x, y ]; // always override `opts.data` if it exists + } + // Case: new ScatterChart( collection, collection, options ) + else if ( isCollection( y ) ) { + opts.data = [ x, y ]; // always override `opts.data` if it exists + } + // Case: new ScatterChart( collection, ???, options ) + else { + throw new TypeError( format( 'invalid argument. Second argument must be an array-like object or an ndarray.' ) ); + } + } + // Case: new ScatterChart( ???, ???, options ) + else { + throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', x ) ); + } + } + QuantitativeChart.call( this, opts ); + + // Initialize internal encoding scales... + scales = this.config.scales; + for ( i = 0; i < INTERNAL_ORDINAL_SCALES.length; i++ ) { + s = new OrdinalScale({ + 'name': scale2default( INTERNAL_ORDINAL_SCALES[ i ] ) + }); + scales.push( s ); + } + this.config.scales = scales; + + // Initialize a legend instance: + this._chartLegend = new Legend({ + 'fill': 'colorScale', + 'shape': 'symbolsScale', + 'size': 'symbolsSizeScale', + 'opacity': 'symbolsOpacityScale', + + // FIXME: rather than hardcode defaults, create a default scatter chart theme which inherits from the quantitative chart theme + 'orient': 'bottom', + 'direction': 'horizontal', + 'offset': 10, // px + 'padding': 5, // px + 'columnPadding': 20 // px + }); + + // Validate provided options by attempting to assign option values to corresponding fields... + for ( i = 0; i < properties.length; i++ ) { + k = properties[ i ]; + if ( !hasProp( opts, k ) ) { + continue; + } + v = opts[ 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 the `QuantitativeChart` prototype. +*/ +inherit( ScatterChart, QuantitativeChart ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof ScatterChart +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( ScatterChart, 'name', 'ScatterChart' ); + +/** +* Generates a list of mark objects. +* +* @private +* @name _marks +* @memberof ScatterChart.prototype +* @type {Array} +*/ +setNonEnumerableReadOnlyAccessor( ScatterChart.prototype, '_marks', function getMarks() { + var scaleNames; + var dataNames; + var scales; + var marks; + var data; + var M; + var N; + var i; + + // Resolve visualization datasets: + data = this.config.data; + N = data.length; + + // If no data, no marks to generate... + if ( N === 0 ) { + return []; + } + // Resolve the list of dataset names: + dataNames = pluck( data, 'name' ); + + // Resolve the visualization scales: + scales = this.config.scales; + scaleNames = pluck( scales, 'name' ); + + // Resolve existing visualization marks: + marks = this.config.marks; + M = marks.length; + + // If we have fewer datasets than marks, prune the marks array... + if ( M > N ) { + // Note that, by pruning the marks array, we effectively invalidate the removed mark encoding instances, as any changes to them will no longer propagate back to the chart; the pruned mark encodings can, however, be explicitly rebound... + marks = slice( marks, 0, N ); + M = N; + } + // Update internal encoding scales: + this._updateScales( dataNames, scales ); + + // Update existing marks (note: reusing existing marks is important in order to avoid triggering an infinite loop of "change" events)... + for ( i = 0; i < M; i++ ) { + updateSymbolMark( marks[ i ], dataNames[ i ], scaleNames ); + } + // Create new marks... + for ( i = M; i < N; i++ ) { + marks.push( symbolMark( dataNames[ i ], scaleNames ) ); + } + return marks; +}); + +/** +* Updates internal encoding scales. +* +* @private +* @name _updateScales +* @memberof ScatterChart.prototype +* @type {Function} +* @param {Array} names - data set names +* @param {Array} scales - list of scales +*/ +setNonEnumerableReadOnly( ScatterChart.prototype, '_updateScales', function updateScales( names, scales ) { + var s; + + s = getScale( scales, 'color' ); + s.domain = names; + s.range = this._colors; + + s = getScale( scales, 'opacity' ); + s.domain = names; + s.range = this._symbolsOpacity; + + s = getScale( scales, 'shape' ); + s.domain = names; + s.range = symbols2shapes( this._symbols ); + + s = getScale( scales, 'size' ); + s.domain = names; + s.range = this._symbolsSize; +}); + +/** +* Symbol colors. +* +* @name colors +* @memberof ScatterChart.prototype +* @type {Array} +* +* @example +* var chart = new ScatterChart({ +* 'colors': [ '#000', 'steelblue' ] +* }); +* // returns +* +* var v = chart.colors; +* // returns [ '#000', 'steelblue' ] +*/ +setReadWriteAccessor( ScatterChart.prototype, 'colors', getColors, setColors ); + +/** +* Boolean indicating whether to display a chart legend. +* +* @name legend +* @memberof ScatterChart.prototype +* @type {boolean} +* @default false +* +* @example +* var chart = new ScatterChart({ +* 'legend': true +* }); +* // returns +* +* var v = chart.legend; +* // returns true +*/ +setReadWriteAccessor( ScatterChart.prototype, 'legend', getLegend, setLegend ); + +/** +* Symbol color scale. +* +* @name colorScale +* @memberof ScatterChart.prototype +* @type {Scale} +* +* @example +* var chart = new ScatterChart(); +* // returns +* +* var v = chart.colorScale; +* // returns +*/ +setReadOnlyAccessor( ScatterChart.prototype, 'colorScale', function getColorScale() { + return getScale( this.config.scales, 'color' ); +}); + +/** +* Symbol(s). +* +* @name symbols +* @memberof ScatterChart.prototype +* @type {Array} +* @default [ 'circle' ] +* +* @example +* var chart = new ScatterChart({ +* 'symbols': [ 'circle', 'square' ] +* }); +* // returns +* +* var v = chart.symbols; +* // returns [ 'circle', 'square' ] +*/ +setReadWriteAccessor( ScatterChart.prototype, 'symbols', getSymbols, setSymbols ); + +/** +* Symbol scale. +* +* @name symbolsScale +* @memberof ScatterChart.prototype +* @type {Scale} +* +* @example +* var chart = new ScatterChart(); +* // returns +* +* var v = chart.symbolsScale; +* // returns +*/ +setReadOnlyAccessor( ScatterChart.prototype, 'symbolsScale', function getSymbolsScale() { + return getScale( this.config.scales, 'shape' ); +}); + +/** +* Symbol opacity. +* +* @name symbolsOpacity +* @memberof ScatterChart.prototype +* @type {Array} +* @default [ 1.0 ] +* +* @example +* var chart = new ScatterChart({ +* 'symbolsOpacity': [ 1.0, 0.5 ] +* }); +* // returns +* +* var v = chart.symbolsOpacity; +* // returns [ 1.0, 0.5 ] +*/ +setReadWriteAccessor( ScatterChart.prototype, 'symbolsOpacity', getSymbolsOpacity, setSymbolsOpacity ); + +/** +* Symbol opacity scale. +* +* @name symbolsOpacityScale +* @memberof ScatterChart.prototype +* @type {Scale} +* +* @example +* var chart = new ScatterChart(); +* // returns +* +* var v = chart.symbolsOpacityScale; +* // returns +*/ +setReadOnlyAccessor( ScatterChart.prototype, 'symbolsOpacityScale', function getSymbolsOpacityScale() { + return getScale( this.config.scales, 'opacity' ); +}); + +/** +* Symbol size(s) (in pixels squared). +* +* @name symbolsSize +* @memberof ScatterChart.prototype +* @type {Array} +* @default [ 100 ] +* +* @example +* var chart = new ScatterChart({ +* 'symbolsSize': [ 100, 200 ] +* }); +* // returns +* +* var v = chart.symbolsSize; +* // returns [ 100, 200 ] +*/ +setReadWriteAccessor( ScatterChart.prototype, 'symbolsSize', getSymbolsSize, setSymbolsSize ); + +/** +* Symbol size scale. +* +* @name symbolsSizeScale +* @memberof ScatterChart.prototype +* @type {Scale} +* +* @example +* var chart = new ScatterChart(); +* // returns +* +* var v = chart.symbolsSizeScale; +* // returns +*/ +setReadOnlyAccessor( ScatterChart.prototype, 'symbolsSizeScale', function getSymbolsSizeScale() { + return getScale( this.config.scales, 'size' ); +}); + +/** +* Renders a chart. +* +* @name render +* @memberof ScatterChart.prototype +* @type {Function} +* @param {Function} clbk - callback to invoke after rendering the chart +* @throws {TypeError} must provide a function +* +* @example +* // TODO: add example +*/ +setNonEnumerableReadOnly( ScatterChart.prototype, 'render', function render( clbk ) { + if ( !isFunction( clbk ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', clbk ) ); + } + spec2svg( this.toJSON(), this.config.config, clbk ); +}); + +/** +* Serializes a chart to a JSON object. +* +* ## Notes +* +* - This method is implicitly invoked by `JSON.stringify`. +* +* @name toJSON +* @memberof ScatterChart.prototype +* @type {Function} +* @returns {Object} JSON object +* +* @example +* var chart = new ScatterChart(); +* +* var v = chart.toJSON(); +* // returns {...} +*/ +setNonEnumerableReadOnly( ScatterChart.prototype, 'toJSON', function toJSON() { + this.config.marks = this._marks; + return QuantitativeChart.prototype.toJSON.call( this ); +}); + + +// EXPORTS // + +module.exports = ScatterChart; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json new file mode 100644 index 000000000000..f75324f738b8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json @@ -0,0 +1,7 @@ +[ + "colors", + "legend", + "symbols", + "symbolsOpacity", + "symbolsSize" +] diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/get.js new file mode 100644 index 000000000000..f4a2bcc2344f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/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' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the symbol opacities. +* +* @private +* @returns {Array} opacities +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/properties.js new file mode 100644 index 000000000000..a55d69d258c8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/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( 'symbolsOpacity' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/set.js new file mode 100644 index 000000000000..9b3d1447cb98 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/set.js @@ -0,0 +1,75 @@ +/** +* @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 isProbabilityArray = require( '@stdlib/assert/is-probability-array' ).primitives; +var isProbability = require( '@stdlib/assert/is-probability' ).isPrimitive; +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'scatter-chart:set:'+prop.name ); + + +// MAIN // + +/** +* Sets symbol opacities. +* +* @private +* @param {(Array|number)} value - input value +* @throws {TypeError} must be a number or an array of numbers +* @returns {void} +*/ +function set( value ) { + var isNum = isProbability( value ); + if ( !isNum && !isProbabilityArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number or an array of numbers on the interval [0,1]. Value: `%s`.', prop.name, value ) ); + } + if ( isNum ) { + value = [ value ]; + } + if ( !hasEqualValues( value, this[ prop.private ] ) ) { + debug( 'Current value: [%s]. New value: [%s].', join( this[ prop.private ], ', ' ), join( value, ', ' ) ); + + // Perform a defensive copy as we will be caching the specified symbol opacities: + value = copy( value ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Update the symbol opacity range: + this.symbolsOpacityScale.range = value; + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/get.js new file mode 100644 index 000000000000..f3013adc0303 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/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' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the symbol sizes (in pixels squared). +* +* @private +* @returns {Array} sizes +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/properties.js new file mode 100644 index 000000000000..a6663320c9b2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/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( 'symbolsSize' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/set.js new file mode 100644 index 000000000000..43c6fbcf9ede --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/set.js @@ -0,0 +1,75 @@ +/** +* @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 isNumberArray = require( '@stdlib/assert/is-number-array' ).primitives; +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'scatter-chart:set:'+prop.name ); + + +// MAIN // + +/** +* Sets symbol sizes (in pixels squared). +* +* @private +* @param {(Array|number)} value - input value +* @throws {TypeError} must be a number or an array of numbers +* @returns {void} +*/ +function set( value ) { + var isNum = isNumber( value ); + if ( !isNum && !isNumberArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number or an array of numbers. Value: `%s`.', prop.name, value ) ); + } + if ( isNum ) { + value = [ value ]; + } + if ( !hasEqualValues( value, this[ prop.private ] ) ) { + debug( 'Current value: [%s]. New value: [%s].', join( this[ prop.private ], ', ' ), join( value, ', ' ) ); + + // Perform a defensive copy as we will be caching the specified symbol sizes: + value = copy( value ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Update the symbol size range: + this.symbolsSizeScale.range = value; + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/get.js new file mode 100644 index 000000000000..7d1f7d2caaac --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/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' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the symbols. +* +* @private +* @returns {Array} symbols +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/properties.js new file mode 100644 index 000000000000..67947a9093d6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/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( 'symbols' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/set.js new file mode 100644 index 000000000000..21d204568410 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/set.js @@ -0,0 +1,76 @@ +/** +* @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 isSymbolArray = require( '@stdlib/plot/base/assert/is-symbol-array' ); +var isSymbol = require( '@stdlib/plot/base/assert/is-symbol' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var symbols2shapes = require( '@stdlib/plot/base/symbols2shapes' ); +var format = require( '@stdlib/string/format' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'scatter-chart:set:'+prop.name ); + + +// MAIN // + +/** +* Sets symbols. +* +* @private +* @param {(Array|string)} value - input value +* @throws {TypeError} must be a string or an array of strings +* @returns {void} +*/ +function set( value ) { + var isStr = isSymbol( value ); + if ( !isStr && !isSymbolArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a symbol or an array of symbols. Value: `%s`.', prop.name, value ) ); + } + if ( isStr ) { + value = [ value ]; + } + if ( !hasEqualValues( value, this[ prop.private ] ) ) { + debug( 'Current value: [%s]. New value: [%s].', join( this[ prop.private ], ', ' ), join( value, ', ' ) ); + + // Perform a defensive copy as we will be caching the specified symbols: + value = copy( value ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Convert the symbols to symbol mark shapes: + this.symbolsScale.range = symbols2shapes( value ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/package.json b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/package.json new file mode 100644 index 000000000000..e57bb2b7af75 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/plot/charts/scatter", + "version": "0.0.0", + "description": "Scatter chart 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": { + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "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", + "figure", + "fig", + "graph", + "chart", + "diagram", + "data", + "visualize", + "visualization", + "dataviz", + "explore", + "exploratory", + "analysis", + "quantitative", + "scatter" + ] +} From 7752cae2cb419a5cc6649f5e71810fe6bc3700fc Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Sun, 16 Aug 2026 13:39:33 +0530 Subject: [PATCH 2/4] chore: suggested changes --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../charts/scatter/ctor/examples/index.js | 8 +- .../charts/scatter/ctor/lib/colors/set.js | 2 +- .../plot/charts/scatter/ctor/lib/defaults.js | 6 +- .../plot/charts/scatter/ctor/lib/index.js | 8 +- .../charts/scatter/ctor/lib/legend/set.js | 4 +- .../plot/charts/scatter/ctor/lib/main.js | 222 +++++++++--------- .../charts/scatter/ctor/lib/properties.json | 4 +- .../get.js | 0 .../properties.js | 2 +- .../set.js | 4 +- .../lib/{symbols-size => symbol-size}/get.js | 0 .../properties.js | 2 +- .../lib/{symbols-size => symbol-size}/set.js | 4 +- .../charts/scatter/ctor/lib/symbols/set.js | 2 +- .../plot/charts/scatter/ctor/package.json | 2 +- 15 files changed, 135 insertions(+), 135 deletions(-) rename lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/{symbols-opacity => symbol-opacity}/get.js (100%) rename lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/{symbols-opacity => symbol-opacity}/properties.js (94%) rename lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/{symbols-opacity => symbol-opacity}/set.js (95%) rename lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/{symbols-size => symbol-size}/get.js (100%) rename lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/{symbols-size => symbol-size}/properties.js (94%) rename lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/{symbols-size => symbol-size}/set.js (95%) diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js index a0fac93debf7..1f55feea085c 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js @@ -20,17 +20,17 @@ var uniform = require( '@stdlib/random/uniform' ); var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); -var ScatterChart = require( './../lib' ); +var Scatterplot = require( './../lib' ); var a = new Float64Vector( [ 10.0, 20.0, 30.0, 40.0, 50.0 ] ); var b = new Float64Vector( [ 20.0, 30.0, 40.0, 50.0, 60.0 ] ); var y = uniform( [ 100, 5 ], a, b ); -var chart = new ScatterChart( y, { +var chart = new Scatterplot( y, { 'symbols': [ 'o', 'square' ], - 'symbolsOpacity': [ 1.0, 0.4 ], - 'symbolsSize': [ 100, 50 ], + 'symbolOpacity': [ 1.0, 0.4 ], + 'symbolSize': [ 100, 50 ], 'legend': true }); console.log( chart.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js index 55779a34a460..2cdc708a4cf1 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js @@ -34,7 +34,7 @@ var prop = require( './properties.js' ); // VARIABLES // -var debug = logger( 'scatter-chart:set:'+prop.name ); +var debug = logger( 'scatterplot:set:'+prop.name ); // MAIN // diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js index 01c64a8d50fc..95362e7517ce 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js @@ -46,11 +46,11 @@ function defaults() { // Symbol(s): 'symbols': [ 'circle' ], - // Symbol opacity: - 'symbolsOpacity': [ 1.0 ], + // Symbol opacity (note: default to semi-transparent symbols in order to convey whether data points lie beneath a given point, while remaining sufficiently opaque to avoid accessibility concerns): + 'symbolOpacity': [ 0.6 ], // Symbol size(s) (in pixels squared): - 'symbolsSize': [ 100 ] + 'symbolSize': [ 100 ] }; } diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/index.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/index.js index 3279081d7735..65ccde15a407 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/index.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/index.js @@ -19,15 +19,15 @@ 'use strict'; /** -* Scatter chart constructor. +* Scatterplot constructor. * * @module @stdlib/plot/charts/scatter/ctor * * @example -* var ScatterChart = require( '@stdlib/plot/charts/scatter/ctor' ); +* var Scatterplot = require( '@stdlib/plot/charts/scatter/ctor' ); * -* var chart = new ScatterChart(); -* // returns +* var chart = new Scatterplot(); +* // returns * * // TODO: update example */ diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/set.js index af672e0c5b75..08af5b675c4a 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/set.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/legend/set.js @@ -30,13 +30,13 @@ var prop = require( './properties.js' ); // VARIABLES // -var debug = logger( 'scatter-chart:set:'+prop.name ); +var debug = logger( 'scatterplot:set:'+prop.name ); // MAIN // /** -* Sets a boolean flag indicating whether a layout should be re-calculated on every view update. +* Sets a boolean flag indicating whether to display a chart legend. * * @private * @param {boolean} value - input value diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js index 4c6a5d88fdde..c6a059534b0a 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js @@ -56,17 +56,17 @@ var setColors = require( './colors/set.js' ); var getLegend = require( './legend/get.js' ); var setLegend = require( './legend/set.js' ); -var getSymbolsOpacity = require( './symbols-opacity/get.js' ); -var setSymbolsOpacity = require( './symbols-opacity/set.js' ); -var getSymbolsSize = require( './symbols-size/get.js' ); -var setSymbolsSize = require( './symbols-size/set.js' ); +var getSymbolOpacity = require( './symbol-opacity/get.js' ); +var setSymbolOpacity = require( './symbol-opacity/set.js' ); +var getSymbolSize = require( './symbol-size/get.js' ); +var setSymbolSize = require( './symbol-size/set.js' ); var getSymbols = require( './symbols/get.js' ); var setSymbols = require( './symbols/set.js' ); // VARIABLES // -var debug = logger( 'scatter-chart:main' ); +var debug = logger( 'scatterplot:main' ); var SCALE_TO_INDEX = { 'x': 0, @@ -78,9 +78,9 @@ var SCALE_TO_INDEX = { }; var SCALE_TO_DEFAULT_NAME = { 'color': 'colorScale', - 'opacity': 'symbolsOpacityScale', + 'opacity': 'symbolOpacityScale', 'shape': 'symbolsScale', - 'size': 'symbolsSizeScale' + 'size': 'symbolSizeScale' }; var SCALE_TO_ENCODING = { 'color': 'fill', @@ -259,7 +259,7 @@ function updateSymbolMark( mark, name, scales ) { // MAIN // /** -* Scatter chart constructor. +* Scatterplot constructor. * * @constructor * @param {(ndarrayLike|Collection)} [x] - x-values @@ -278,8 +278,8 @@ function updateSymbolMark( mark, name, scales ) { * @param {number} [options.padding.right=0] - chart right padding (in pixels) * @param {number} [options.padding.top=0] - chart top padding (in pixels) * @param {(string|Array)} [options.symbols=['circle']] - symbol(s) -* @param {(number|Array)} [options.symbolsOpacity=[1.0]] - symbol opacity -* @param {(number|Array)} [options.symbolsSize=[100]] - symbol size(s) in pixels squared +* @param {(number|Array)} [options.symbolOpacity=[0.6]] - symbol opacity +* @param {(number|Array)} [options.symbolSize=[100]] - symbol size(s) in pixels squared * @param {Object} [options.theme] - chart theme * @param {(string|Array)} [options.title=''] - chart title * @param {string} [options.viewer] - default chart viewer @@ -300,13 +300,13 @@ function updateSymbolMark( mark, name, scales ) { * @throws {TypeError} must provide a valid second argument * @throws {TypeError} options argument must be an object * @throws {Error} must provide valid options -* @returns {ScatterChart} scatter chart instance +* @returns {Scatterplot} scatterplot instance * * @example -* var plot = new ScatterChart(); -* // returns +* var plot = new Scatterplot(); +* // returns */ -function ScatterChart( x, y, options ) { +function Scatterplot( x, y, options ) { var scales; var nargs; var opts; @@ -316,17 +316,17 @@ function ScatterChart( x, y, options ) { var i; nargs = arguments.length; - if ( !( this instanceof ScatterChart ) ) { + if ( !( this instanceof Scatterplot ) ) { if ( nargs < 1 ) { - return new ScatterChart(); + return new Scatterplot(); } if ( nargs === 1 ) { - return new ScatterChart( x ); + return new Scatterplot( x ); } if ( nargs === 2 ) { - return new ScatterChart( x, y ); + return new Scatterplot( x, y ); } - return new ScatterChart( x, y, options ); + return new Scatterplot( x, y, options ); } opts = defaults(); @@ -337,34 +337,34 @@ function ScatterChart( x, y, options ) { this[ '_'+k ] = opts[ k ]; } } - // Case: new ScatterChart( arg ) + // Case: new Scatterplot( arg ) if ( nargs === 1 ) { - // Case: new ScatterChart( ndarray ) + // Case: new Scatterplot( ndarray ) if ( isndarrayLike( x ) ) { opts.data = [ x ]; } - // Case: new ScatterChart( collection ) + // Case: new Scatterplot( collection ) else if ( isCollection( x ) ) { opts.data = [ x ]; } - // Case: new ScatterChart( options ) + // Case: new Scatterplot( options ) else if ( isObject( x ) ) { opts = objectAssignIn( opts, x ); } - // Case: new ScatterChart( ??? ) + // Case: new Scatterplot( ??? ) else { throw new TypeError( format( 'invalid argument. First argument must be either an array-like object, an ndarray, or an options argument. Value: `%s`.', x ) ); } } - // Case: new ScatterChart( arg1, arg2 ) + // Case: new Scatterplot( arg1, arg2 ) else if ( nargs === 2 ) { - // Case: new ScatterChart( ndarray, ??? ) + // Case: new Scatterplot( ndarray, ??? ) if ( isndarrayLike( x ) ) { - // Case: new ScatterChart( ndarray, ndarray ) + // Case: new Scatterplot( ndarray, ndarray ) if ( isndarrayLike( y ) ) { opts.data = [ x, y ]; } - // Case: new ScatterChart( ndarray, collection ) + // Case: new Scatterplot( ndarray, collection ) else if ( isCollection( y ) ) { for ( i = 0; i < y.length; i++ ) { if ( !isndarrayLike( y[ i ] ) ) { @@ -373,19 +373,19 @@ function ScatterChart( x, y, options ) { } opts.data = [ x, y ]; } - // Case: new ScatterChart( ndarray, options ) + // Case: new Scatterplot( ndarray, options ) else if ( isObject( y ) ) { opts = objectAssignIn( opts, y ); opts.data = [ x ]; // always override `opts.data` if it exists } - // Case: new ScatterChart( ndarray, ??? ) + // Case: new Scatterplot( ndarray, ??? ) else { throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray, an array of ndarrays, or an options argument. Value: `%s`.', y ) ); } } - // Case: new ScatterChart( collection, ??? ) + // Case: new Scatterplot( collection, ??? ) else if ( isCollection( x ) ) { - // Case: new ScatterChart( collection, ndarray ) + // Case: new Scatterplot( collection, ndarray ) if ( isndarrayLike( y ) ) { for ( i = 0; i < x.length; i++ ) { if ( !isndarrayLike( x[ i ] ) ) { @@ -394,39 +394,39 @@ function ScatterChart( x, y, options ) { } opts.data = [ x, y ]; } - // Case: new ScatterChart( collection, collection ) + // Case: new Scatterplot( collection, collection ) else if ( isCollection( y ) ) { opts.data = [ x, y ]; } - // Case: new ScatterChart( collection, options ) + // Case: new Scatterplot( collection, options ) else if ( isObject( y ) ) { opts = objectAssignIn( opts, y ); opts.data = [ x ]; // always override `opts.data` if it exists } - // Case: new ScatterChart( collection, ??? ) + // Case: new Scatterplot( collection, ??? ) else { throw new TypeError( format( 'invalid argument. First argument must be either an array-like object, an ndarray, or an options argument. Value: `%s`.', y ) ); } } - // Case: new ScatterChart( ???, ??? ) + // Case: new Scatterplot( ???, ??? ) else { throw new TypeError( format( 'invalid argument. First argument must be either an array-like object or an ndarray. Value: `%s`.', x ) ); } } - // Case: new ScatterChart( x, y, options ) + // Case: new Scatterplot( x, y, options ) else if ( nargs > 2 ) { if ( !isObject( options ) ) { throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); } opts = objectAssignIn( opts, options ); - // Case: new ScatterChart( ndarray, ???, options ) + // Case: new Scatterplot( ndarray, ???, options ) if ( isndarrayLike( x ) ) { - // Case: new ScatterChart( ndarray, ndarray, options ) + // Case: new Scatterplot( ndarray, ndarray, options ) if ( isndarrayLike( y ) ) { opts.data = [ x, y ]; // always override `opts.data` if it exists } - // Case: new ScatterChart( ndarray, collection, options ) + // Case: new Scatterplot( ndarray, collection, options ) else if ( isCollection( y ) ) { for ( i = 0; i < y.length; i++ ) { if ( !isndarrayLike( y[ i ] ) ) { @@ -435,14 +435,14 @@ function ScatterChart( x, y, options ) { } opts.data = [ x, y ]; // always override `opts.data` if it exists } - // Case: new ScatterChart( ndarray, ???, options ) + // Case: new Scatterplot( ndarray, ???, options ) else { throw new TypeError( format( 'invalid argument. Second argument must be an ndarray or an array of ndarrays.' ) ); } } - // Case: new ScatterChart( collection, ???, options ) + // Case: new Scatterplot( collection, ???, options ) else if ( isCollection( x ) ) { - // Case: new ScatterChart( collection, ndarray, options ) + // Case: new Scatterplot( collection, ndarray, options ) if ( isndarrayLike( y ) ) { for ( i = 0; i < x.length; i++ ) { if ( !isndarrayLike( x[ i ] ) ) { @@ -451,16 +451,16 @@ function ScatterChart( x, y, options ) { } opts.data = [ x, y ]; // always override `opts.data` if it exists } - // Case: new ScatterChart( collection, collection, options ) + // Case: new Scatterplot( collection, collection, options ) else if ( isCollection( y ) ) { opts.data = [ x, y ]; // always override `opts.data` if it exists } - // Case: new ScatterChart( collection, ???, options ) + // Case: new Scatterplot( collection, ???, options ) else { throw new TypeError( format( 'invalid argument. Second argument must be an array-like object or an ndarray.' ) ); } } - // Case: new ScatterChart( ???, ???, options ) + // Case: new Scatterplot( ???, ???, options ) else { throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an ndarray. Value: `%s`.', x ) ); } @@ -481,10 +481,10 @@ function ScatterChart( x, y, options ) { this._chartLegend = new Legend({ 'fill': 'colorScale', 'shape': 'symbolsScale', - 'size': 'symbolsSizeScale', - 'opacity': 'symbolsOpacityScale', + 'size': 'symbolSizeScale', + 'opacity': 'symbolOpacityScale', - // FIXME: rather than hardcode defaults, create a default scatter chart theme which inherits from the quantitative chart theme + // FIXME: rather than hardcode defaults, create a default scatterplot theme which inherits from the quantitative chart theme 'orient': 'bottom', 'direction': 'horizontal', 'offset': 10, // px @@ -514,28 +514,28 @@ function ScatterChart( x, y, options ) { /* * Inherit from the `QuantitativeChart` prototype. */ -inherit( ScatterChart, QuantitativeChart ); +inherit( Scatterplot, QuantitativeChart ); /** * Constructor name. * * @private * @name name -* @memberof ScatterChart +* @memberof Scatterplot * @readonly * @type {string} */ -setNonEnumerableReadOnly( ScatterChart, 'name', 'ScatterChart' ); +setNonEnumerableReadOnly( Scatterplot, 'name', 'Scatterplot' ); /** * Generates a list of mark objects. * * @private * @name _marks -* @memberof ScatterChart.prototype +* @memberof Scatterplot.prototype * @type {Array} */ -setNonEnumerableReadOnlyAccessor( ScatterChart.prototype, '_marks', function getMarks() { +setNonEnumerableReadOnlyAccessor( Scatterplot.prototype, '_marks', function getMarks() { var scaleNames; var dataNames; var scales; @@ -589,12 +589,12 @@ setNonEnumerableReadOnlyAccessor( ScatterChart.prototype, '_marks', function get * * @private * @name _updateScales -* @memberof ScatterChart.prototype +* @memberof Scatterplot.prototype * @type {Function} * @param {Array} names - data set names * @param {Array} scales - list of scales */ -setNonEnumerableReadOnly( ScatterChart.prototype, '_updateScales', function updateScales( names, scales ) { +setNonEnumerableReadOnly( Scatterplot.prototype, '_updateScales', function updateScales( names, scales ) { var s; s = getScale( scales, 'color' ); @@ -603,7 +603,7 @@ setNonEnumerableReadOnly( ScatterChart.prototype, '_updateScales', function upda s = getScale( scales, 'opacity' ); s.domain = names; - s.range = this._symbolsOpacity; + s.range = this._symbolOpacity; s = getScale( scales, 'shape' ); s.domain = names; @@ -611,61 +611,61 @@ setNonEnumerableReadOnly( ScatterChart.prototype, '_updateScales', function upda s = getScale( scales, 'size' ); s.domain = names; - s.range = this._symbolsSize; + s.range = this._symbolSize; }); /** * Symbol colors. * * @name colors -* @memberof ScatterChart.prototype +* @memberof Scatterplot.prototype * @type {Array} * * @example -* var chart = new ScatterChart({ +* var chart = new Scatterplot({ * 'colors': [ '#000', 'steelblue' ] * }); -* // returns +* // returns * * var v = chart.colors; * // returns [ '#000', 'steelblue' ] */ -setReadWriteAccessor( ScatterChart.prototype, 'colors', getColors, setColors ); +setReadWriteAccessor( Scatterplot.prototype, 'colors', getColors, setColors ); /** * Boolean indicating whether to display a chart legend. * * @name legend -* @memberof ScatterChart.prototype +* @memberof Scatterplot.prototype * @type {boolean} * @default false * * @example -* var chart = new ScatterChart({ +* var chart = new Scatterplot({ * 'legend': true * }); -* // returns +* // returns * * var v = chart.legend; * // returns true */ -setReadWriteAccessor( ScatterChart.prototype, 'legend', getLegend, setLegend ); +setReadWriteAccessor( Scatterplot.prototype, 'legend', getLegend, setLegend ); /** * Symbol color scale. * * @name colorScale -* @memberof ScatterChart.prototype +* @memberof Scatterplot.prototype * @type {Scale} * * @example -* var chart = new ScatterChart(); -* // returns +* var chart = new Scatterplot(); +* // returns * * var v = chart.colorScale; * // returns */ -setReadOnlyAccessor( ScatterChart.prototype, 'colorScale', function getColorScale() { +setReadOnlyAccessor( Scatterplot.prototype, 'colorScale', function getColorScale() { return getScale( this.config.scales, 'color' ); }); @@ -673,110 +673,110 @@ setReadOnlyAccessor( ScatterChart.prototype, 'colorScale', function getColorScal * Symbol(s). * * @name symbols -* @memberof ScatterChart.prototype +* @memberof Scatterplot.prototype * @type {Array} * @default [ 'circle' ] * * @example -* var chart = new ScatterChart({ +* var chart = new Scatterplot({ * 'symbols': [ 'circle', 'square' ] * }); -* // returns +* // returns * * var v = chart.symbols; * // returns [ 'circle', 'square' ] */ -setReadWriteAccessor( ScatterChart.prototype, 'symbols', getSymbols, setSymbols ); +setReadWriteAccessor( Scatterplot.prototype, 'symbols', getSymbols, setSymbols ); /** * Symbol scale. * * @name symbolsScale -* @memberof ScatterChart.prototype +* @memberof Scatterplot.prototype * @type {Scale} * * @example -* var chart = new ScatterChart(); -* // returns +* var chart = new Scatterplot(); +* // returns * * var v = chart.symbolsScale; * // returns */ -setReadOnlyAccessor( ScatterChart.prototype, 'symbolsScale', function getSymbolsScale() { +setReadOnlyAccessor( Scatterplot.prototype, 'symbolsScale', function getSymbolsScale() { return getScale( this.config.scales, 'shape' ); }); /** * Symbol opacity. * -* @name symbolsOpacity -* @memberof ScatterChart.prototype +* @name symbolOpacity +* @memberof Scatterplot.prototype * @type {Array} -* @default [ 1.0 ] +* @default [ 0.6 ] * * @example -* var chart = new ScatterChart({ -* 'symbolsOpacity': [ 1.0, 0.5 ] +* var chart = new Scatterplot({ +* 'symbolOpacity': [ 1.0, 0.5 ] * }); -* // returns +* // returns * -* var v = chart.symbolsOpacity; +* var v = chart.symbolOpacity; * // returns [ 1.0, 0.5 ] */ -setReadWriteAccessor( ScatterChart.prototype, 'symbolsOpacity', getSymbolsOpacity, setSymbolsOpacity ); +setReadWriteAccessor( Scatterplot.prototype, 'symbolOpacity', getSymbolOpacity, setSymbolOpacity ); /** * Symbol opacity scale. * -* @name symbolsOpacityScale -* @memberof ScatterChart.prototype +* @name symbolOpacityScale +* @memberof Scatterplot.prototype * @type {Scale} * * @example -* var chart = new ScatterChart(); -* // returns +* var chart = new Scatterplot(); +* // returns * -* var v = chart.symbolsOpacityScale; +* var v = chart.symbolOpacityScale; * // returns */ -setReadOnlyAccessor( ScatterChart.prototype, 'symbolsOpacityScale', function getSymbolsOpacityScale() { +setReadOnlyAccessor( Scatterplot.prototype, 'symbolOpacityScale', function getSymbolOpacityScale() { return getScale( this.config.scales, 'opacity' ); }); /** * Symbol size(s) (in pixels squared). * -* @name symbolsSize -* @memberof ScatterChart.prototype +* @name symbolSize +* @memberof Scatterplot.prototype * @type {Array} * @default [ 100 ] * * @example -* var chart = new ScatterChart({ -* 'symbolsSize': [ 100, 200 ] +* var chart = new Scatterplot({ +* 'symbolSize': [ 100, 200 ] * }); -* // returns +* // returns * -* var v = chart.symbolsSize; +* var v = chart.symbolSize; * // returns [ 100, 200 ] */ -setReadWriteAccessor( ScatterChart.prototype, 'symbolsSize', getSymbolsSize, setSymbolsSize ); +setReadWriteAccessor( Scatterplot.prototype, 'symbolSize', getSymbolSize, setSymbolSize ); /** * Symbol size scale. * -* @name symbolsSizeScale -* @memberof ScatterChart.prototype +* @name symbolSizeScale +* @memberof Scatterplot.prototype * @type {Scale} * * @example -* var chart = new ScatterChart(); -* // returns +* var chart = new Scatterplot(); +* // returns * -* var v = chart.symbolsSizeScale; +* var v = chart.symbolSizeScale; * // returns */ -setReadOnlyAccessor( ScatterChart.prototype, 'symbolsSizeScale', function getSymbolsSizeScale() { +setReadOnlyAccessor( Scatterplot.prototype, 'symbolSizeScale', function getSymbolSizeScale() { return getScale( this.config.scales, 'size' ); }); @@ -784,7 +784,7 @@ setReadOnlyAccessor( ScatterChart.prototype, 'symbolsSizeScale', function getSym * Renders a chart. * * @name render -* @memberof ScatterChart.prototype +* @memberof Scatterplot.prototype * @type {Function} * @param {Function} clbk - callback to invoke after rendering the chart * @throws {TypeError} must provide a function @@ -792,7 +792,7 @@ setReadOnlyAccessor( ScatterChart.prototype, 'symbolsSizeScale', function getSym * @example * // TODO: add example */ -setNonEnumerableReadOnly( ScatterChart.prototype, 'render', function render( clbk ) { +setNonEnumerableReadOnly( Scatterplot.prototype, 'render', function render( clbk ) { if ( !isFunction( clbk ) ) { throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', clbk ) ); } @@ -807,17 +807,17 @@ setNonEnumerableReadOnly( ScatterChart.prototype, 'render', function render( clb * - This method is implicitly invoked by `JSON.stringify`. * * @name toJSON -* @memberof ScatterChart.prototype +* @memberof Scatterplot.prototype * @type {Function} * @returns {Object} JSON object * * @example -* var chart = new ScatterChart(); +* var chart = new Scatterplot(); * * var v = chart.toJSON(); * // returns {...} */ -setNonEnumerableReadOnly( ScatterChart.prototype, 'toJSON', function toJSON() { +setNonEnumerableReadOnly( Scatterplot.prototype, 'toJSON', function toJSON() { this.config.marks = this._marks; return QuantitativeChart.prototype.toJSON.call( this ); }); @@ -825,4 +825,4 @@ setNonEnumerableReadOnly( ScatterChart.prototype, 'toJSON', function toJSON() { // EXPORTS // -module.exports = ScatterChart; +module.exports = Scatterplot; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json index f75324f738b8..98dbde475fbe 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json @@ -2,6 +2,6 @@ "colors", "legend", "symbols", - "symbolsOpacity", - "symbolsSize" + "symbolOpacity", + "symbolSize" ] diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-opacity/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/get.js rename to lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-opacity/get.js diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-opacity/properties.js similarity index 94% rename from lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/properties.js rename to lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-opacity/properties.js index a55d69d258c8..f294acc264bd 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/properties.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-opacity/properties.js @@ -25,7 +25,7 @@ var property2object = require( '@stdlib/plot/vega/base/property2object' ); // MAIN // -var obj = property2object( 'symbolsOpacity' ); +var obj = property2object( 'symbolOpacity' ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-opacity/set.js similarity index 95% rename from lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/set.js rename to lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-opacity/set.js index 9b3d1447cb98..0b41c657bdba 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-opacity/set.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-opacity/set.js @@ -34,7 +34,7 @@ var prop = require( './properties.js' ); // VARIABLES // -var debug = logger( 'scatter-chart:set:'+prop.name ); +var debug = logger( 'scatterplot:set:'+prop.name ); // MAIN // @@ -65,7 +65,7 @@ function set( value ) { this[ prop.private ] = value; // Update the symbol opacity range: - this.symbolsOpacityScale.range = value; + this.symbolOpacityScale.range = value; } } diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-size/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/get.js rename to lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-size/get.js diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-size/properties.js similarity index 94% rename from lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/properties.js rename to lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-size/properties.js index a6663320c9b2..3cc1aa8eec5d 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/properties.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-size/properties.js @@ -25,7 +25,7 @@ var property2object = require( '@stdlib/plot/vega/base/property2object' ); // MAIN // -var obj = property2object( 'symbolsSize' ); +var obj = property2object( 'symbolSize' ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-size/set.js similarity index 95% rename from lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/set.js rename to lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-size/set.js index 43c6fbcf9ede..1389e401f271 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols-size/set.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbol-size/set.js @@ -34,7 +34,7 @@ var prop = require( './properties.js' ); // VARIABLES // -var debug = logger( 'scatter-chart:set:'+prop.name ); +var debug = logger( 'scatterplot:set:'+prop.name ); // MAIN // @@ -65,7 +65,7 @@ function set( value ) { this[ prop.private ] = value; // Update the symbol size range: - this.symbolsSizeScale.range = value; + this.symbolSizeScale.range = value; } } diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/set.js index 21d204568410..0594c7d4b000 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/set.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/symbols/set.js @@ -35,7 +35,7 @@ var prop = require( './properties.js' ); // VARIABLES // -var debug = logger( 'scatter-chart:set:'+prop.name ); +var debug = logger( 'scatterplot:set:'+prop.name ); // MAIN // diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/package.json b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/package.json index e57bb2b7af75..22959c85b26c 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/package.json +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/plot/charts/scatter", "version": "0.0.0", - "description": "Scatter chart constructor.", + "description": "Scatterplot constructor.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From bbec9a762bb28df15ca136f46d85e3e5759e2ca1 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 16 Aug 2026 01:24:11 -0700 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/plot/charts/scatter/ctor/lib/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js index c6a059534b0a..01116cdc214c 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js @@ -56,12 +56,13 @@ var setColors = require( './colors/set.js' ); var getLegend = require( './legend/get.js' ); var setLegend = require( './legend/set.js' ); + var getSymbolOpacity = require( './symbol-opacity/get.js' ); var setSymbolOpacity = require( './symbol-opacity/set.js' ); -var getSymbolSize = require( './symbol-size/get.js' ); -var setSymbolSize = require( './symbol-size/set.js' ); var getSymbols = require( './symbols/get.js' ); var setSymbols = require( './symbols/set.js' ); +var getSymbolSize = require( './symbol-size/get.js' ); +var setSymbolSize = require( './symbol-size/set.js' ); // VARIABLES // From a3b946bd9543822a18b2f4d70c543a9c0cc794b7 Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Mon, 17 Aug 2026 12:57:27 +0530 Subject: [PATCH 4/4] chore: add edge support --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../charts/scatter/ctor/examples/index.js | 6 + .../charts/scatter/ctor/lib/colors/get.js | 12 +- .../charts/scatter/ctor/lib/colors/set.js | 54 ++- .../plot/charts/scatter/ctor/lib/defaults.js | 11 +- .../scatter/ctor/lib/edge-colors/get.js | 52 +++ .../ctor/lib/edge-colors/properties.js | 33 ++ .../scatter/ctor/lib/edge-colors/set.js | 101 +++++ .../scatter/ctor/lib/edge-opacity/get.js | 52 +++ .../ctor/lib/edge-opacity/properties.js | 33 ++ .../scatter/ctor/lib/edge-opacity/set.js | 101 +++++ .../charts/scatter/ctor/lib/edge-width/get.js | 52 +++ .../scatter/ctor/lib/edge-width/properties.js | 33 ++ .../charts/scatter/ctor/lib/edge-width/set.js | 101 +++++ .../charts/scatter/ctor/lib/is_edge_symbol.js | 62 +++ .../plot/charts/scatter/ctor/lib/main.js | 363 +++++++++++++++--- .../charts/scatter/ctor/lib/properties.json | 3 + 16 files changed, 1006 insertions(+), 63 deletions(-) create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/get.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/properties.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/set.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/get.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/properties.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/set.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/get.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/properties.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/set.js create mode 100644 lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/is_edge_symbol.js diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js index 1f55feea085c..ea87996a3bb6 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/examples/index.js @@ -31,6 +31,12 @@ var chart = new Scatterplot( y, { 'symbols': [ 'o', 'square' ], 'symbolOpacity': [ 1.0, 0.4 ], 'symbolSize': [ 100, 50 ], + 'edgeColors': [ '#000' ], + 'edgeWidth': [ 1 ], 'legend': true }); console.log( chart.toJSON() ); + +// Render "hollow" symbols by "unsetting" the symbol colors: +chart.colors = void 0; +console.log( chart.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/get.js index 838d44f30169..29aa892fb8c1 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/get.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/get.js @@ -31,11 +31,19 @@ var prop = require( './properties.js' ); /** * Returns the symbol colors. * +* ## Notes +* +* - If symbol colors are "unset", the function returns `undefined`. +* * @private -* @returns {Array} colors +* @returns {(Array|void)} colors */ function get() { - return copy( this[ prop.private ] ); + var v = this[ prop.private ]; + if ( v === void 0 ) { + return v; + } + return copy( v ); } diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js index 2cdc708a4cf1..892f7380d337 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js @@ -42,31 +42,57 @@ var debug = logger( 'scatterplot:set:'+prop.name ); /** * Sets symbol colors. * +* ## Notes +* +* - Providing `undefined` "unsets" symbol colors, in which case symbols are rendered without a fill (i.e., as "hollow" symbols). +* * @private -* @param {(Array|string)} value - input value -* @throws {TypeError} must be a string or an array of strings +* @param {(Array|string|void)} value - input value +* @throws {TypeError} must be a string, an array of strings, or undefined * @returns {void} */ function set( value ) { - var isStr = isString( value ); + var isStr; + var curr; + + curr = this[ prop.private ]; + + // Case: unset the symbol colors... + if ( value === void 0 ) { + if ( curr === void 0 ) { + return; + } + debug( 'Current value: [%s]. New value: undefined.', join( curr, ', ' ) ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Clear the edge color range, as the scale should no longer resolve values: + this.colorScale.range = []; + return; + } + isStr = isString( value ); if ( !isStr && !isStringArray( value ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a string or an array of strings. Value: `%s`.', prop.name, value ) ); + throw new TypeError( format( 'invalid assignment. `%s` must be a string, an array of strings, or undefined. Value: `%s`.', prop.name, value ) ); } if ( isStr ) { value = [ value ]; } - if ( !hasEqualValues( value, this[ prop.private ] ) ) { - debug( 'Current value: [%s]. New value: [%s].', join( this[ prop.private ], ', ' ), join( value, ', ' ) ); + if ( curr === void 0 ) { + debug( 'Current value: undefined. New value: [%s].', join( value, ', ' ) ); + } else if ( hasEqualValues( value, curr ) ) { + return; + } else { + debug( 'Current value: [%s]. New value: [%s].', join( curr, ', ' ), join( value, ', ' ) ); + } + // Perform a defensive copy as we will be caching the specified symbol colors: + value = copy( value ); - // Perform a defensive copy as we will be caching the specified symbol colors: - value = copy( value ); + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; - // Cache the value before updating the scale to ensure consistent state: - this[ prop.private ] = value; - - // Update the color range: - this.colorScale.range = value; - } + // Update the edge color range: + this.colorScale.range = value; } diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js index 95362e7517ce..7a37b3000512 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js @@ -37,9 +37,18 @@ var category10 = require( '@stdlib/plot/color-schemes/category10' ); */ function defaults() { return { - // Symbol colors: + // Symbol colors (note: `undefined` indicates that symbols should not have a fill): 'colors': category10(), + // Symbol edge colors (note: `undefined` indicates that symbols should not have edges): + 'edgeColors': void 0, + + // Symbol edge opacity (note: `undefined` indicates that symbol edges should inherit the symbol opacity): + 'edgeOpacity': void 0, + + // Symbol edge width(s) (in pixels) (note: `undefined` indicates that symbol edges should use the default edge width): + 'edgeWidth': void 0, + // Boolean indicating whether to display a legend: 'legend': false, diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/get.js new file mode 100644 index 000000000000..fead5c25029d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/get.js @@ -0,0 +1,52 @@ +/** +* @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' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the symbol edge colors. +* +* ## Notes +* +* - If symbol edges are "unset", the function returns `undefined`. +* +* @private +* @returns {(Array|void)} colors +*/ +function get() { + var v = this[ prop.private ]; + if ( v === void 0 ) { + return v; + } + return copy( v ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/properties.js new file mode 100644 index 000000000000..e7b252eb59fd --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/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( 'edgeColors' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/set.js new file mode 100644 index 000000000000..c28fd1f79430 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/set.js @@ -0,0 +1,101 @@ +/** +* @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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'scatterplot:set:'+prop.name ); + + +// MAIN // + +/** +* Sets symbol edge colors. +* +* ## Notes +* +* - Providing `undefined` "unsets" symbol edge colors, in which case symbols are rendered without edges. +* +* @private +* @param {(Array|string|void)} value - input value +* @throws {TypeError} must be a string, an array of strings, or undefined +* @returns {void} +*/ +function set( value ) { + var isStr; + var curr; + + curr = this[ prop.private ]; + + // Case: unset the symbol edge colors... + if ( value === void 0 ) { + if ( curr === void 0 ) { + return; + } + debug( 'Current value: [%s]. New value: undefined.', join( curr, ', ' ) ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Clear the edge color range, as the scale should no longer resolve values: + this.edgeColorScale.range = []; + return; + } + isStr = isString( value ); + if ( !isStr && !isStringArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string, an array of strings, or undefined. Value: `%s`.', prop.name, value ) ); + } + if ( isStr ) { + value = [ value ]; + } + if ( curr === void 0 ) { + debug( 'Current value: undefined. New value: [%s].', join( value, ', ' ) ); + } else if ( hasEqualValues( value, curr ) ) { + return; + } else { + debug( 'Current value: [%s]. New value: [%s].', join( curr, ', ' ), join( value, ', ' ) ); + } + // Perform a defensive copy as we will be caching the specified symbol edge colors: + value = copy( value ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Update the edge color range: + this.edgeColorScale.range = value; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/get.js new file mode 100644 index 000000000000..e4ef353839ef --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/get.js @@ -0,0 +1,52 @@ +/** +* @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' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the symbol edge opacities. +* +* ## Notes +* +* - If symbol edge opacities are "unset", the function returns `undefined`. +* +* @private +* @returns {(Array|void)} opacities +*/ +function get() { + var v = this[ prop.private ]; + if ( v === void 0 ) { + return v; + } + return copy( v ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/properties.js new file mode 100644 index 000000000000..7776075ecd47 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/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( 'edgeOpacity' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/set.js new file mode 100644 index 000000000000..382f04eaf036 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-opacity/set.js @@ -0,0 +1,101 @@ +/** +* @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 isProbabilityArray = require( '@stdlib/assert/is-probability-array' ).primitives; +var isProbability = require( '@stdlib/assert/is-probability' ).isPrimitive; +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'scatterplot:set:'+prop.name ); + + +// MAIN // + +/** +* Sets symbol edge opacities. +* +* ## Notes +* +* - Providing `undefined` "unsets" symbol edge opacities, in which case symbol edges inherit the symbol opacity. +* +* @private +* @param {(Array|number|void)} value - input value +* @throws {TypeError} must be a number, an array of numbers, or undefined +* @returns {void} +*/ +function set( value ) { + var isNum; + var curr; + + curr = this[ prop.private ]; + + // Case: unset the symbol edge opacities... + if ( value === void 0 ) { + if ( curr === void 0 ) { + return; + } + debug( 'Current value: [%s]. New value: undefined.', join( curr, ', ' ) ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Clear the edge opacity range, as the scale should no longer resolve values: + this.edgeOpacityScale.range = []; + return; + } + isNum = isProbability( value ); + if ( !isNum && !isProbabilityArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number, an array of numbers on the interval [0,1], or undefined. Value: `%s`.', prop.name, value ) ); + } + if ( isNum ) { + value = [ value ]; + } + if ( curr === void 0 ) { + debug( 'Current value: undefined. New value: [%s].', join( value, ', ' ) ); + } else if ( hasEqualValues( value, curr ) ) { + return; + } else { + debug( 'Current value: [%s]. New value: [%s].', join( curr, ', ' ), join( value, ', ' ) ); + } + // Perform a defensive copy as we will be caching the specified symbol edge opacities: + value = copy( value ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Update the edge opacity range: + this.edgeOpacityScale.range = value; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/get.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/get.js new file mode 100644 index 000000000000..149c83915bb4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/get.js @@ -0,0 +1,52 @@ +/** +* @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' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the symbol edge widths (in pixels). +* +* ## Notes +* +* - If symbol edge widths are "unset", the function returns `undefined`. +* +* @private +* @returns {(Array|void)} widths +*/ +function get() { + var v = this[ prop.private ]; + if ( v === void 0 ) { + return v; + } + return copy( v ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/properties.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/properties.js new file mode 100644 index 000000000000..ad420c49af67 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/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( 'edgeWidth' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/set.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/set.js new file mode 100644 index 000000000000..586be36a985c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-width/set.js @@ -0,0 +1,101 @@ +/** +* @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 isNumberArray = require( '@stdlib/assert/is-number-array' ).primitives; +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'scatterplot:set:'+prop.name ); + + +// MAIN // + +/** +* Sets symbol edge widths (in pixels). +* +* ## Notes +* +* - Providing `undefined` "unsets" symbol edge widths, in which case symbol edges are rendered using the default edge width. +* +* @private +* @param {(Array|number|void)} value - input value +* @throws {TypeError} must be a number, an array of numbers, or undefined +* @returns {void} +*/ +function set( value ) { + var isNum; + var curr; + + curr = this[ prop.private ]; + + // Case: unset the symbol edge widths... + if ( value === void 0 ) { + if ( curr === void 0 ) { + return; + } + debug( 'Current value: [%s]. New value: undefined.', join( curr, ', ' ) ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Clear the edge width range, as the scale should no longer resolve values: + this.edgeWidthScale.range = []; + return; + } + isNum = isNumber( value ); + if ( !isNum && !isNumberArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number, an array of numbers, or undefined. Value: `%s`.', prop.name, value ) ); + } + if ( isNum ) { + value = [ value ]; + } + if ( curr === void 0 ) { + debug( 'Current value: undefined. New value: [%s].', join( value, ', ' ) ); + } else if ( hasEqualValues( value, curr ) ) { + return; + } else { + debug( 'Current value: [%s]. New value: [%s].', join( curr, ', ' ), join( value, ', ' ) ); + } + // Perform a defensive copy as we will be caching the specified symbol edge widths: + value = copy( value ); + + // Cache the value before updating the scale to ensure consistent state: + this[ prop.private ] = value; + + // Update the edge width range: + this.edgeWidthScale.range = value; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/is_edge_symbol.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/is_edge_symbol.js new file mode 100644 index 000000000000..942b70aceac8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/is_edge_symbol.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. +*/ + +'use strict'; + +// MODULES // + +var contains = require( '@stdlib/array/base/assert/contains' ); +var symbol2alias = require( '@stdlib/plot/base/symbol2alias' ); + + +// VARIABLES // + +// List of symbols which lack a "face". +var EDGE_SYMBOLS = [ + 'asterisk', + 'cross', + 'line', + 'stroke', + 'x' +]; + + +// MAIN // + +/** +* Tests whether a symbol lacks a "face" and is thus drawn entirely from its edge. +* +* @private +* @param {string} symbol - symbol alias or shorthand +* @returns {boolean} boolean indicating whether a symbol lacks a face +* +* @example +* var bool = isEdgeSymbol( 'x' ); +* // returns true +* +* bool = isEdgeSymbol( 'o' ); +* // returns false +*/ +function isEdgeSymbol( symbol ) { + return contains( EDGE_SYMBOLS, symbol2alias( symbol ) ); +} + + +// EXPORTS // + +module.exports = isEdgeSymbol; diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js index 01116cdc214c..cc5217b61a3e 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/main.js @@ -47,6 +47,8 @@ var SymbolMark = require( '@stdlib/plot/vega/mark/symbol/ctor' ); var Legend = require( '@stdlib/plot/vega/legend/ctor' ); var spec2svg = require( '@stdlib/plot/vega/base/spec2svg' ); var format = require( '@stdlib/string/format' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var isEdgeSymbol = require( './is_edge_symbol.js' ); var properties = require( './properties.json' ); var defaults = require( './defaults.js' ); @@ -54,6 +56,13 @@ var defaults = require( './defaults.js' ); var getColors = require( './colors/get.js' ); var setColors = require( './colors/set.js' ); +var getEdgeColors = require( './edge-colors/get.js' ); +var setEdgeColors = require( './edge-colors/set.js' ); +var getEdgeOpacity = require( './edge-opacity/get.js' ); +var setEdgeOpacity = require( './edge-opacity/set.js' ); +var getEdgeWidth = require( './edge-width/get.js' ); +var setEdgeWidth = require( './edge-width/set.js' ); + var getLegend = require( './legend/get.js' ); var setLegend = require( './legend/set.js' ); @@ -75,31 +84,39 @@ var SCALE_TO_INDEX = { 'color': 2, 'opacity': 3, 'shape': 4, - 'size': 5 + 'size': 5, + 'edgeColor': 6, + 'edgeOpacity': 7, + 'edgeWidth': 8 }; var SCALE_TO_DEFAULT_NAME = { 'color': 'colorScale', 'opacity': 'symbolOpacityScale', 'shape': 'symbolsScale', - 'size': 'symbolSizeScale' -}; -var SCALE_TO_ENCODING = { - 'color': 'fill', - 'opacity': 'fillOpacity', - 'shape': 'shape', - 'size': 'size' + 'size': 'symbolSizeScale', + 'edgeColor': 'edgeColorScale', + 'edgeOpacity': 'edgeOpacityScale', + 'edgeWidth': 'edgeWidthScale' }; var INTERNAL_ORDINAL_SCALES = [ 'color', 'opacity', 'shape', - 'size' + 'size', + 'edgeColor', + 'edgeOpacity', + 'edgeWidth' ]; -var UPDATE_ORDINAL_SCALES = [ - 'color', - 'opacity', + +// List of symbol mark encoding channels which are resolved from ordinal scales and whose presence depends on which chart properties have been set... +var ORDINAL_ENCODING_CHANNELS = [ + 'fill', + 'fillOpacity', 'shape', - 'size' + 'size', + 'stroke', + 'strokeOpacity', + 'strokeWidth' ]; @@ -147,17 +164,6 @@ function scale2default( id ) { return SCALE_TO_DEFAULT_NAME[ id ]; } -/** -* Returns the encoding name for a specified scale identifier. -* -* @private -* @param {string} id - identifier -* @returns {string} encoding name -*/ -function scale2encoding( id ) { - return SCALE_TO_ENCODING[ id ]; -} - /** * Returns a field value reference. * @@ -194,18 +200,24 @@ function ordinalValue( scale, value ) { * @private * @param {string} name - dataset name * @param {Array} scales - scale names +* @param {Object} channels - object mapping encoding channels to scale names * @returns {SymbolEncoding} symbol mark encoding */ -function encoding( name, scales ) { +function encoding( name, scales, channels ) { + var keys; + var opts; + var i; + + opts = { + 'x': fieldValue( getScale( scales, 'x' ), 'x' ), + 'y': fieldValue( getScale( scales, 'y' ), 'y' ) + }; + keys = objectKeys( channels ); + for ( i = 0; i < keys.length; i++ ) { + opts[ keys[ i ] ] = ordinalValue( channels[ keys[ i ] ], name ); + } return new SymbolEncoding({ - 'update': new SymbolEncodingSet({ - 'fill': ordinalValue( getScale( scales, 'color' ), name ), - 'fillOpacity': ordinalValue( getScale( scales, 'opacity' ), name ), - 'shape': ordinalValue( getScale( scales, 'shape' ), name ), - 'size': ordinalValue( getScale( scales, 'size' ), name ), - 'x': fieldValue( getScale( scales, 'x' ), 'x' ), - 'y': fieldValue( getScale( scales, 'y' ), 'y' ) - }) + 'update': new SymbolEncodingSet( opts ) }); } @@ -215,14 +227,15 @@ function encoding( name, scales ) { * @private * @param {string} name - dataset name * @param {Array} scales - scale names +* @param {Object} channels - object mapping encoding channels to scale names * @returns {SymbolMark} symbol mark */ -function symbolMark( name, scales ) { +function symbolMark( name, scales, channels ) { return new SymbolMark({ 'from': new DataSource({ 'data': name }), - 'encode': encoding( name, scales ) + 'encode': encoding( name, scales, channels ) }); } @@ -233,11 +246,13 @@ function symbolMark( name, scales ) { * @param {SymbolMark} mark - symbol mark * @param {string} name - dataset name * @param {Array} scales - scale names +* @param {Object} channels - object mapping encoding channels to scale names * @returns {SymbolMark} symbol mark */ -function updateSymbolMark( mark, name, scales ) { +function updateSymbolMark( mark, name, scales, channels ) { var encoding; - var id; + var scale; + var ch; var v; var i; @@ -247,10 +262,23 @@ function updateSymbolMark( mark, name, scales ) { encoding.x.scale = getScale( scales, 'x' ); encoding.y.scale = getScale( scales, 'y' ); - for ( i = 0; i < UPDATE_ORDINAL_SCALES.length; i++ ) { - id = UPDATE_ORDINAL_SCALES[ i ]; - v = encoding[ scale2encoding( id ) ]; - v.scale = getScale( scales, id ); + for ( i = 0; i < ORDINAL_ENCODING_CHANNELS.length; i++ ) { + ch = ORDINAL_ENCODING_CHANNELS[ i ]; + scale = channels[ ch ]; + + // Case: the channel should no longer be encoded (e.g., after "unsetting" symbol edge colors)... + if ( scale === void 0 ) { + encoding[ ch ] = void 0; + continue; + } + v = encoding[ ch ]; + + // Case: the channel was not previously encoded (e.g., after setting symbol edge colors)... + if ( v === void 0 ) { + encoding[ ch ] = ordinalValue( scale, name ); + continue; + } + v.scale = scale; v.value = name; } return mark; @@ -268,7 +296,10 @@ function updateSymbolMark( mark, name, scales ) { * @param {Options} [options] - constructor options * @param {string} [options.background] - background color * @param {Object} [options.channels={'x':'x','y':'y'}] - object mapping chart data field names to encoding channels ('x', 'y', and 'z') -* @param {(string|Array)} [options.colors] - symbol colors +* @param {(string|Array|void)} [options.colors] - symbol colors (`undefined` renders symbols without a fill) +* @param {(string|Array|void)} [options.edgeColors] - symbol edge colors (`undefined` renders symbols without edges) +* @param {(number|Array|void)} [options.edgeOpacity] - symbol edge opacity (`undefined` inherits the symbol opacity) +* @param {(number|Array|void)} [options.edgeWidth] - symbol edge width(s) (in pixels) * @param {ArrayLikeObject} [options.data=[]] - chart data * @param {string} [options.description=''] - chart description * @param {number} [options.height=480] - chart height (in pixels) @@ -539,6 +570,7 @@ setNonEnumerableReadOnly( Scatterplot, 'name', 'Scatterplot' ); setNonEnumerableReadOnlyAccessor( Scatterplot.prototype, '_marks', function getMarks() { var scaleNames; var dataNames; + var symbols; var scales; var marks; var data; @@ -574,13 +606,19 @@ setNonEnumerableReadOnlyAccessor( Scatterplot.prototype, '_marks', function getM // Update internal encoding scales: this._updateScales( dataNames, scales ); + // Update the chart legend, as which channels a legend should display depends on which chart properties have been set: + this._updateLegend(); + + // Resolve the symbol assigned to each dataset, noting that, as symbols are resolved from an ordinal scale, symbols cycle when provided fewer symbols than datasets... + symbols = this._symbols; + // Update existing marks (note: reusing existing marks is important in order to avoid triggering an infinite loop of "change" events)... for ( i = 0; i < M; i++ ) { - updateSymbolMark( marks[ i ], dataNames[ i ], scaleNames ); + updateSymbolMark( marks[ i ], dataNames[ i ], scaleNames, this._resolveChannels( scaleNames, symbols[ i%symbols.length ] ) ); } // Create new marks... for ( i = M; i < N; i++ ) { - marks.push( symbolMark( dataNames[ i ], scaleNames ) ); + marks.push( symbolMark( dataNames[ i ], scaleNames, this._resolveChannels( scaleNames, symbols[ i%symbols.length ] ) ) ); } return marks; }); @@ -598,9 +636,10 @@ setNonEnumerableReadOnlyAccessor( Scatterplot.prototype, '_marks', function getM setNonEnumerableReadOnly( Scatterplot.prototype, '_updateScales', function updateScales( names, scales ) { var s; + // Note: for "unset" properties, we assign an empty range, as the corresponding scale should not resolve values and is not referenced by any mark encoding... s = getScale( scales, 'color' ); s.domain = names; - s.range = this._colors; + s.range = ( this._colors === void 0 ) ? [] : this._colors; s = getScale( scales, 'opacity' ); s.domain = names; @@ -613,14 +652,120 @@ setNonEnumerableReadOnly( Scatterplot.prototype, '_updateScales', function updat s = getScale( scales, 'size' ); s.domain = names; s.range = this._symbolSize; + + s = getScale( scales, 'edgeColor' ); + s.domain = names; + s.range = ( this._edgeColors === void 0 ) ? [] : this._edgeColors; + + s = getScale( scales, 'edgeOpacity' ); + s.domain = names; + s.range = ( this._edgeOpacity === void 0 ) ? [] : this._edgeOpacity; + + s = getScale( scales, 'edgeWidth' ); + s.domain = names; + s.range = ( this._edgeWidth === void 0 ) ? [] : this._edgeWidth; +}); + +/** +* Resolves the ordinal encoding channels for a dataset having a specified symbol. +* +* ## Notes +* +* - The method returns an object mapping symbol mark encoding channels to the names of the scales from which channel values should be resolved. Channels which should not be encoded are omitted, thus allowing a symbol to, e.g., be rendered without a fill or without an edge. +* - A symbol which lacks a "face" (e.g., `x` and `line`) is drawn entirely from its edge. Accordingly, for such symbols, edge properties take precedence over their fill counterparts, and we encode both the fill and the stroke in order to support both closed (e.g., `x`) and open (e.g., `line`) symbol paths. +* +* @private +* @name _resolveChannels +* @memberof Scatterplot.prototype +* @type {Function} +* @param {Array} scales - scale names +* @param {string} symbol - symbol assigned to a dataset +* @returns {Object} object mapping encoding channels to scale names +*/ +setNonEnumerableReadOnly( Scatterplot.prototype, '_resolveChannels', function resolveChannels( scales, symbol ) { + var opacity; + var color; + var out; + + out = { + 'shape': getScale( scales, 'shape' ), + 'size': getScale( scales, 'size' ) + }; + if ( this._edgeWidth !== void 0 ) { + out.strokeWidth = getScale( scales, 'edgeWidth' ); + } + // Case: the symbol lacks a face, and thus edge properties take precedence over their fill counterparts... + if ( isEdgeSymbol( symbol ) ) { + if ( this._edgeColors === void 0 ) { + color = ( this._colors === void 0 ) ? void 0 : getScale( scales, 'color' ); + } else { + color = getScale( scales, 'edgeColor' ); + } + // Case: neither symbol colors nor symbol edge colors are set, and thus the symbol has no color to encode... + if ( color === void 0 ) { + return out; + } + if ( this._edgeOpacity === void 0 ) { + opacity = getScale( scales, 'opacity' ); + } else { + opacity = getScale( scales, 'edgeOpacity' ); + } + out.fill = color; + out.fillOpacity = opacity; + out.stroke = color; + out.strokeOpacity = opacity; + return out; + } + if ( this._colors !== void 0 ) { + out.fill = getScale( scales, 'color' ); + out.fillOpacity = getScale( scales, 'opacity' ); + } + if ( this._edgeColors !== void 0 ) { + out.stroke = getScale( scales, 'edgeColor' ); + } + if ( this._edgeOpacity !== void 0 ) { + out.strokeOpacity = getScale( scales, 'edgeOpacity' ); + } + return out; +}); + +/** +* Updates the chart legend. +* +* ## Notes +* +* - Which channels a legend should display depends on which chart properties have been set. E.g., if symbol colors have been "unset" in order to render "hollow" symbols, a legend should convey symbol edge colors, rather than symbol fill colors. +* +* @private +* @name _updateLegend +* @memberof Scatterplot.prototype +* @type {Function} +*/ +setNonEnumerableReadOnly( Scatterplot.prototype, '_updateLegend', function updateLegend() { + var legend = this._chartLegend; + + legend.fill = ( this._colors === void 0 ) ? void 0 : 'colorScale'; + legend.stroke = ( this._edgeColors === void 0 ) ? void 0 : 'edgeColorScale'; + legend.strokeWidth = ( this._edgeWidth === void 0 ) ? void 0 : 'edgeWidthScale'; + + // Case: symbols are "hollow", and thus a legend should convey the edge opacity, rather than the (unused) fill opacity... + if ( this._colors === void 0 && this._edgeOpacity !== void 0 ) { + legend.opacity = 'edgeOpacityScale'; + } else { + legend.opacity = 'symbolOpacityScale'; + } }); /** * Symbol colors. * +* ## Notes +* +* - Assigning `undefined` "unsets" symbol colors, in which case symbols are rendered without a fill (i.e., as "hollow" symbols). +* * @name colors * @memberof Scatterplot.prototype -* @type {Array} +* @type {(Array|void)} * * @example * var chart = new Scatterplot({ @@ -633,6 +778,78 @@ setNonEnumerableReadOnly( Scatterplot.prototype, '_updateScales', function updat */ setReadWriteAccessor( Scatterplot.prototype, 'colors', getColors, setColors ); +/** +* Symbol edge colors. +* +* ## Notes +* +* - Assigning `undefined` "unsets" symbol edge colors, in which case symbols are rendered without edges. +* - For symbols which lack a "face" (e.g., `x` and `line`), symbol edge colors take precedence over symbol colors. +* +* @name edgeColors +* @memberof Scatterplot.prototype +* @type {(Array|void)} +* @default undefined +* +* @example +* var chart = new Scatterplot({ +* 'edgeColors': [ '#000', 'steelblue' ] +* }); +* // returns +* +* var v = chart.edgeColors; +* // returns [ '#000', 'steelblue' ] +*/ +setReadWriteAccessor( Scatterplot.prototype, 'edgeColors', getEdgeColors, setEdgeColors ); + +/** +* Symbol edge opacity. +* +* ## Notes +* +* - Assigning `undefined` "unsets" symbol edge opacities, in which case symbol edges inherit the symbol opacity. +* +* @name edgeOpacity +* @memberof Scatterplot.prototype +* @type {(Array|void)} +* @default undefined +* +* @example +* var chart = new Scatterplot({ +* 'edgeColors': [ '#000' ], +* 'edgeOpacity': [ 1.0, 0.5 ] +* }); +* // returns +* +* var v = chart.edgeOpacity; +* // returns [ 1.0, 0.5 ] +*/ +setReadWriteAccessor( Scatterplot.prototype, 'edgeOpacity', getEdgeOpacity, setEdgeOpacity ); + +/** +* Symbol edge width(s) (in pixels). +* +* ## Notes +* +* - Assigning `undefined` "unsets" symbol edge widths, in which case symbol edges are rendered using the default edge width. +* +* @name edgeWidth +* @memberof Scatterplot.prototype +* @type {(Array|void)} +* @default undefined +* +* @example +* var chart = new Scatterplot({ +* 'edgeColors': [ '#000' ], +* 'edgeWidth': [ 1, 2 ] +* }); +* // returns +* +* var v = chart.edgeWidth; +* // returns [ 1, 2 ] +*/ +setReadWriteAccessor( Scatterplot.prototype, 'edgeWidth', getEdgeWidth, setEdgeWidth ); + /** * Boolean indicating whether to display a chart legend. * @@ -670,6 +887,60 @@ setReadOnlyAccessor( Scatterplot.prototype, 'colorScale', function getColorScale return getScale( this.config.scales, 'color' ); }); +/** +* Symbol edge color scale. +* +* @name edgeColorScale +* @memberof Scatterplot.prototype +* @type {Scale} +* +* @example +* var chart = new Scatterplot(); +* // returns +* +* var v = chart.edgeColorScale; +* // returns +*/ +setReadOnlyAccessor( Scatterplot.prototype, 'edgeColorScale', function getEdgeColorScale() { + return getScale( this.config.scales, 'edgeColor' ); +}); + +/** +* Symbol edge opacity scale. +* +* @name edgeOpacityScale +* @memberof Scatterplot.prototype +* @type {Scale} +* +* @example +* var chart = new Scatterplot(); +* // returns +* +* var v = chart.edgeOpacityScale; +* // returns +*/ +setReadOnlyAccessor( Scatterplot.prototype, 'edgeOpacityScale', function getEdgeOpacityScale() { + return getScale( this.config.scales, 'edgeOpacity' ); +}); + +/** +* Symbol edge width scale. +* +* @name edgeWidthScale +* @memberof Scatterplot.prototype +* @type {Scale} +* +* @example +* var chart = new Scatterplot(); +* // returns +* +* var v = chart.edgeWidthScale; +* // returns +*/ +setReadOnlyAccessor( Scatterplot.prototype, 'edgeWidthScale', function getEdgeWidthScale() { + return getScale( this.config.scales, 'edgeWidth' ); +}); + /** * Symbol(s). * diff --git a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json index 98dbde475fbe..40547b775765 100644 --- a/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json +++ b/lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/properties.json @@ -1,5 +1,8 @@ [ "colors", + "edgeColors", + "edgeOpacity", + "edgeWidth", "legend", "symbols", "symbolOpacity",