From b2a1838093bb1aed04f3eceea2e6356aeea7f33c Mon Sep 17 00:00:00 2001 From: Sachinn-64 Date: Thu, 23 Jul 2026 15:44:08 +0530 Subject: [PATCH] feat: add plot/vega/mark/symbol/encoding --- .../mark/symbol/encoding/examples/index.js | 39 +++ .../mark/symbol/encoding/lib/change_event.js | 41 +++ .../mark/symbol/encoding/lib/custom/index.js | 91 ++++++ .../mark/symbol/encoding/lib/enter/get.js | 43 +++ .../symbol/encoding/lib/enter/properties.js | 33 +++ .../mark/symbol/encoding/lib/enter/set.js | 66 +++++ .../vega/mark/symbol/encoding/lib/exit/get.js | 43 +++ .../symbol/encoding/lib/exit/properties.js | 33 +++ .../vega/mark/symbol/encoding/lib/exit/set.js | 66 +++++ .../mark/symbol/encoding/lib/hover/get.js | 43 +++ .../symbol/encoding/lib/hover/properties.js | 33 +++ .../mark/symbol/encoding/lib/hover/set.js | 66 +++++ .../vega/mark/symbol/encoding/lib/index.js | 40 +++ .../vega/mark/symbol/encoding/lib/main.js | 267 ++++++++++++++++++ .../mark/symbol/encoding/lib/update/get.js | 43 +++ .../symbol/encoding/lib/update/properties.js | 33 +++ .../mark/symbol/encoding/lib/update/set.js | 66 +++++ .../vega/mark/symbol/encoding/package.json | 62 ++++ 18 files changed, 1108 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/change_event.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/custom/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/get.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/properties.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/set.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/get.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/properties.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/set.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/get.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/properties.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/set.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/get.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/properties.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/set.js create mode 100644 lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/package.json diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/examples/index.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/examples/index.js new file mode 100644 index 000000000000..a3978f5c478f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/examples/index.js @@ -0,0 +1,39 @@ +/** +* @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 Value = require( '@stdlib/plot/vega/value/ctor' ); +var SymbolEncodingSet = require( '@stdlib/plot/vega/mark/symbol/encoding-set' ); +var SymbolEncoding = require( './../lib' ); + +var update = new SymbolEncodingSet({ + 'x': new Value({ + 'field': 'x', + 'scale': 'xScale' + }), + 'y': new Value({ + 'field': 'y', + 'scale': 'yScale' + }) +}); + +var encoding = new SymbolEncoding({ + 'update': update +}); +console.log( encoding.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/change_event.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/change_event.js new file mode 100644 index 000000000000..359afbfa206b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/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': 'mark', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/custom/index.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/custom/index.js new file mode 100644 index 000000000000..ba4b07157ff5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/custom/index.js @@ -0,0 +1,91 @@ +/** +* @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 isSymbolEncodingSet = require( '@stdlib/plot/vega/base/assert/is-symbol-mark-encoding-set' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var property2object = require( '@stdlib/plot/vega/base/property2object' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:symbol:encoding:set:custom' ); + + +// MAIN // + +/** +* Returns a getter and setter for a custom encoding set. +* +* @private +* @param {string} name - encoding set name +* @returns {Object} object containing a getter and setter +*/ +function factory( name ) { + var prop = property2object( name ); + return { + 'get': get, + 'set': set + }; + + /** + * Returns an encoding set specifying visual encoding properties for a custom encoding set. + * + * @private + * @returns {(SymbolEncodingSet|void)} encoding set + */ + function get() { + return this[ prop.private ]; + } + + /** + * Sets the encoding set specifying visual encoding properties for a custom encoding set. + * + * ## Notes + * + * - Providing `undefined` "unsets" the configured value. + * + * @private + * @param {(SymbolEncodingSet|void)} value - input value + * @throws {TypeError} must be a symbol mark encoding set + * @returns {void} + */ + function set( value ) { + if ( !isSymbolEncodingSet( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a symbol mark encoding set. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/get.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/get.js new file mode 100644 index 000000000000..57fa0d715d92 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/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 an encoding set specifying visual encoding properties when marks are newly added to a visualization scene. +* +* @private +* @returns {(SymbolEncodingSet|void)} encoding set +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/properties.js new file mode 100644 index 000000000000..b95d3285baf0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/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( 'enter' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/set.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/set.js new file mode 100644 index 000000000000..f576ef01851a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/enter/set.js @@ -0,0 +1,66 @@ +/** +* @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 isSymbolEncodingSet = require( '@stdlib/plot/vega/base/assert/is-symbol-mark-encoding-set' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:symbol:encoding:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the encoding set specifying visual encoding properties when marks are newly added to a visualization scene. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(SymbolEncodingSet|void)} value - input value +* @throws {TypeError} must be a symbol mark encoding set +* @returns {void} +*/ +function set( value ) { + if ( !isSymbolEncodingSet( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a symbol mark encoding set. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/get.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/get.js new file mode 100644 index 000000000000..1fdaaa587930 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/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 an encoding set specifying visual encoding properties when marks are removed from a visualization scene. +* +* @private +* @returns {(SymbolEncodingSet|void)} encoding set +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/properties.js new file mode 100644 index 000000000000..e78fe16d5008 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/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( 'exit' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/set.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/set.js new file mode 100644 index 000000000000..f1adac1f130d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/exit/set.js @@ -0,0 +1,66 @@ +/** +* @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 isSymbolEncodingSet = require( '@stdlib/plot/vega/base/assert/is-symbol-mark-encoding-set' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:symbol:encoding:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the encoding set specifying visual encoding properties when marks are removed from a visualization scene. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(SymbolEncodingSet|void)} value - input value +* @throws {TypeError} must be a symbol mark encoding set +* @returns {void} +*/ +function set( value ) { + if ( !isSymbolEncodingSet( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a symbol mark encoding set. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/get.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/get.js new file mode 100644 index 000000000000..78d4952ba6fc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/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 an encoding set specifying visual encoding properties when the mouse cursor hovers over a mark instance. +* +* @private +* @returns {(SymbolEncodingSet|void)} encoding set +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/properties.js new file mode 100644 index 000000000000..509a45b37120 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/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( 'hover' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/set.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/set.js new file mode 100644 index 000000000000..e9b27070b982 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/hover/set.js @@ -0,0 +1,66 @@ +/** +* @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 isSymbolEncodingSet = require( '@stdlib/plot/vega/base/assert/is-symbol-mark-encoding-set' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:symbol:encoding:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the encoding set specifying visual encoding properties when the mouse cursor hovers over a mark instance. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(SymbolEncodingSet|void)} value - input value +* @throws {TypeError} must be a symbol mark encoding set +* @returns {void} +*/ +function set( value ) { + if ( !isSymbolEncodingSet( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a symbol mark encoding set. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/index.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/index.js new file mode 100644 index 000000000000..69b95bcb769f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/index.js @@ -0,0 +1,40 @@ +/** +* @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'; + +/** +* Symbol mark encoding constructor. +* +* @module @stdlib/plot/vega/mark/symbol/encoding +* +* @example +* var SymbolEncoding = require( '@stdlib/plot/vega/mark/symbol/encoding' ); +* +* var encoding = new SymbolEncoding(); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/main.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/main.js new file mode 100644 index 000000000000..18ce0158b45b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/main.js @@ -0,0 +1,267 @@ +/** +* @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 stdlib/no-empty-lines-between-requires */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isObject = require( '@stdlib/assert/is-object' ); +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); +var hasProp = require( '@stdlib/assert/has-property' ); +var inherit = require( '@stdlib/utils/inherit' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' ); +var Encoding = require( '@stdlib/plot/vega/mark/base/encoding' ); +var format = require( '@stdlib/string/format' ); +var customEncodingProperty = require( './custom' ); + +// Note: keep the following in alphabetical order according to the `require` path... +var getEnter = require( './enter/get.js' ); +var setEnter = require( './enter/set.js' ); +var getExit = require( './exit/get.js' ); +var setExit = require( './exit/set.js' ); + +var getHover = require( './hover/get.js' ); +var setHover = require( './hover/set.js' ); + +var getUpdate = require( './update/get.js' ); +var setUpdate = require( './update/set.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:symbol:encoding:main' ); +var KNOWN_SETS = [ + 'enter', + 'exit', + 'hover', + 'update' +]; +var isKnownSet = contains( KNOWN_SETS ); + + +// MAIN // + +/** +* Symbol mark encoding constructor. +* +* @constructor +* @param {Options} options - constructor options +* @param {SymbolEncodingSet} [options.enter] - encoding set specifying visual properties when marks are newly added to a visualization scene +* @param {SymbolEncodingSet} [options.exit] - encoding set specifying visual properties when marks are removed from a visualization scene +* @param {SymbolEncodingSet} [options.hover] - encoding set specifying visual properties when the mouse cursor hovers over a mark instance +* @param {SymbolEncodingSet} [options.update] - encoding set specifying visual properties when a visualization scene updates +* @throws {TypeError} options argument must be an object +* @throws {Error} must provide valid options +* @returns {SymbolEncoding} encoding instance +* +* @example +* var encoding = new SymbolEncoding(); +* // returns +*/ +function SymbolEncoding( options ) { + var nargs; + var keys; + var v; + var k; + var o; + var i; + + nargs = arguments.length; + if ( !( this instanceof SymbolEncoding ) ) { + if ( nargs === 0 ) { + return new SymbolEncoding(); + } + return new SymbolEncoding( options ); + } + Encoding.call( this ); // note: explicitly called without arguments, as we want to perform our own validation + if ( nargs ) { + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + // Validate provided options by attempting to assign option values to corresponding fields... + for ( i = 0; i < this._properties.length; i++ ) { + k = this._properties[ i ]; + if ( !hasProp( options, k ) ) { + continue; + } + v = options[ k ]; + try { + this[ k ] = v; + } catch ( err ) { + debug( 'Encountered an error. Error: %s', err.message ); + + // FIXME: retain thrown error type + throw new Error( transformErrorMessage( err.message ) ); + } + } + } + // Check for custom encoding set names... + keys = objectKeys( options ); + for ( i = 0; i < keys.length; i++ ) { + k = keys[ i ]; + if ( isKnownSet( k ) ) { + continue; + } + // Consider any unknown property to be a custom encoding set: + v = options[ k ]; + + // Define a read-write accessor specific to this instance for handling the custom encoding set: + o = customEncodingProperty( k ); + setReadWriteAccessor( this, k, o.get( k ), o.set( k ) ); + + // Assign the option value to the corresponding field: + 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 ) ); + } + // Add the property name to the encoding's list of property to ensure proper JSON serialization: + this._properties.push( k ); // note: this is inherited from the parent class + } + return this; +} + +/* +* Inherit from the `Encoding` prototype. +*/ +inherit( SymbolEncoding, Encoding ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof SymbolEncoding +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( SymbolEncoding, 'name', 'SymbolEncoding' ); + +/** +* Encoding specifying visual encoding properties when marks are newly added to a visualization scene. +* +* @name enter +* @memberof SymbolEncoding.prototype +* @type {(SymbolEncodingSet|void)} +* +* @example +* var Value = require( '@stdlib/plot/vega/value/ctor' ); +* var SymbolEncodingSet = require( '@stdlib/plot/vega/mark/symbol/encoding-set' ); +* +* var encodingSet = new SymbolEncodingSet({ +* 'stroke': new Value({ +* 'value': 'steelblue' +* }) +* }); +* var encoding = new SymbolEncoding({ +* 'enter': encodingSet +* }); +* +* var v = encoding.enter; +* // returns +*/ +setReadWriteAccessor( SymbolEncoding.prototype, 'enter', getEnter, setEnter ); + +/** +* Encoding specifying visual encoding properties when marks are removed from a visualization scene. +* +* @name exit +* @memberof SymbolEncoding.prototype +* @type {(SymbolEncodingSet|void)} +* +* @example +* var Value = require( '@stdlib/plot/vega/value/ctor' ); +* var SymbolEncodingSet = require( '@stdlib/plot/vega/mark/symbol/encoding-set' ); +* +* var encodingSet = new SymbolEncodingSet({ +* 'stroke': new Value({ +* 'value': 'steelblue' +* }) +* }); +* var encoding = new SymbolEncoding({ +* 'exit': encodingSet +* }); +* +* var v = encoding.exit; +* // returns +*/ +setReadWriteAccessor( SymbolEncoding.prototype, 'exit', getExit, setExit ); + +/** +* Encoding specifying visual encoding properties when the mouse cursor hovers over a mark instance. +* +* @name hover +* @memberof SymbolEncoding.prototype +* @type {(SymbolEncodingSet|void)} +* +* @example +* var Value = require( '@stdlib/plot/vega/value/ctor' ); +* var SymbolEncodingSet = require( '@stdlib/plot/vega/mark/symbol/encoding-set' ); +* +* var encodingSet = new SymbolEncodingSet({ +* 'stroke': new Value({ +* 'value': 'steelblue' +* }) +* }); +* var encoding = new SymbolEncoding({ +* 'hover': encodingSet +* }); +* +* var v = encoding.hover; +* // returns +*/ +setReadWriteAccessor( SymbolEncoding.prototype, 'hover', getHover, setHover ); + +/** +* Encoding specifying visual encoding properties when a visualization scene updates. +* +* @name update +* @memberof SymbolEncoding.prototype +* @type {(SymbolEncodingSet|void)} +* +* @example +* var Value = require( '@stdlib/plot/vega/value/ctor' ); +* var SymbolEncodingSet = require( '@stdlib/plot/vega/mark/symbol/encoding-set' ); +* +* var encodingSet = new SymbolEncodingSet({ +* 'stroke': new Value({ +* 'value': 'steelblue' +* }) +* }); +* var encoding = new SymbolEncoding({ +* 'update': encodingSet +* }); +* +* var v = encoding.update; +* // returns +*/ +setReadWriteAccessor( SymbolEncoding.prototype, 'update', getUpdate, setUpdate ); + + +// EXPORTS // + +module.exports = SymbolEncoding; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/get.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/get.js new file mode 100644 index 000000000000..55b3f5f9a58d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/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 an encoding set specifying visual encoding properties when a visualization scene updates. +* +* @private +* @returns {(SymbolEncodingSet|void)} encoding set +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/properties.js new file mode 100644 index 000000000000..dd943d43c513 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/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( 'update' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/set.js b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/set.js new file mode 100644 index 000000000000..fa6897485aec --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/lib/update/set.js @@ -0,0 +1,66 @@ +/** +* @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 isSymbolEncodingSet = require( '@stdlib/plot/vega/base/assert/is-symbol-mark-encoding-set' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:symbol:encoding:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the encoding set specifying visual encoding properties when a visualization scene updates. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(SymbolEncodingSet|void)} value - input value +* @throws {TypeError} must be a symbol mark encoding set +* @returns {void} +*/ +function set( value ) { + if ( !isSymbolEncodingSet( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a symbol mark encoding set. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/package.json b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/package.json new file mode 100644 index 000000000000..90139ffdb10d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/symbol/encoding/package.json @@ -0,0 +1,62 @@ +{ + "name": "@stdlib/plot/vega/mark/symbol/encoding", + "version": "0.0.0", + "description": "Symbol mark encoding constructor.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "vega", + "line", + "mark", + "encoding", + "constructor", + "ctor" + ], + "__stdlib__": {} +}