diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/clip/get.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/clip/get.js new file mode 100644 index 000000000000..3b52b6fca379 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/clip/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the setting indicating whether to clip marks to a specified shape. +* +* @private +* @returns {(boolean|Clip)} clip configuration +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/clip/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/clip/properties.js new file mode 100644 index 000000000000..c11defca131d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/clip/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( 'clip' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/clip/set.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/clip/set.js new file mode 100644 index 000000000000..f3abdd339ab2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/clip/set.js @@ -0,0 +1,67 @@ +/** +* @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 isClip = require( '@stdlib/plot/vega/base/assert/is-clip' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var Clip = require( '@stdlib/plot/vega/mark/clip' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the setting indicating whether to clip marks to a specified shape. +* +* @private +* @param {(boolean|Clip)} value - input value +* @throws {TypeError} must be either a boolean or a Clip instance +* @returns {void} +*/ +function set( value ) { + if ( isBoolean( value ) && value ) { + value = new Clip(); + } else if ( !isClip( value ) && !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be either a boolean, an clip instance, or a signal. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + this._removeChangeListener( this[ prop.private ] ); + debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + this._addChangeListener( this[ prop.private ] ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/description/get.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/description/get.js new file mode 100644 index 000000000000..5a07a23b8bbf --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/description/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the text description of a mark for ARIA accessibility. +* +* @private +* @returns {(string|void)} mark description +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/description/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/description/properties.js new file mode 100644 index 000000000000..58e0d898ddeb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/description/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( 'description' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/description/set.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/description/set.js new file mode 100644 index 000000000000..f5c4ff75d98a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/description/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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the text description of a mark for ARIA accessibility. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(string|void)} value - input value +* @throws {TypeError} must be a string +* @returns {void} +*/ +function set( value ) { + if ( !isString( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. 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/base/ctor/lib/interactive/get.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/interactive/get.js new file mode 100644 index 000000000000..53209537821e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/interactive/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 a mark can serve as an input event source. +* +* @private +* @returns {(boolean|Signal)} boolean flag or signal +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/interactive/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/interactive/properties.js new file mode 100644 index 000000000000..7448e9d47cb7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/interactive/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( 'interactive' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/interactive/set.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/interactive/set.js new file mode 100644 index 000000000000..3a7e7fcdf761 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/interactive/set.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var isObject = require( '@stdlib/assert/is-object' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:set:'+prop.name ); + + +// MAIN // + +/** +* Sets a boolean indicating whether a mark can serve as an input event source. +* +* @private +* @param {boolean} value - input value +* @throws {TypeError} must be a boolean +* @returns {void} +*/ +function set( value ) { + if ( !isBoolean( value ) && !isObject( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be either boolean or a signal. 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/base/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/main.js index 93d0846e4457..9617f2bd0aa7 100644 --- a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/main.js +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/main.js @@ -41,14 +41,35 @@ var defaults = require( './defaults.js' ); var getARIA = require( './aria/get.js' ); var setARIA = require( './aria/set.js' ); +var getClip = require( './clip/get.js' ); +var setClip = require( './clip/set.js' ); + +var getDescription = require( './description/get.js' ); +var setDescription = require( './description/set.js' ); + var getEncode = require( './encode/get.js' ); var setEncode = require( './encode/set.js' ); var getFrom = require( './from/get.js' ); var setFrom = require( './from/set.js' ); +var getInteractive = require( './interactive/get.js' ); +var setInteractive = require( './interactive/set.js' ); + +var getName = require( './name/get.js' ); +var setName = require( './name/set.js' ); + var getProperties = require( './properties/get.js' ); +var getRole = require( './role/get.js' ); +var setRole = require( './role/set.js' ); + +var getSort = require( './sort/get.js' ); +var setSort = require( './sort/set.js' ); + +var getStyle = require( './style/get.js' ); +var setStyle = require( './style/set.js' ); + var getTriggers = require( './triggers/get.js' ); var setTriggers = require( './triggers/set.js' ); @@ -73,15 +94,15 @@ var debug = logger( 'vega:mark:main' ); * @param {Options} options - constructor options * @param {string} options.type - mark type * @param {boolean} [options.aria=true] - boolean indicating whether to include ARIA attributes in SVG output -* @param {(boolean|Signal|Object)} [options.clip=false] - setting indicating whether to clip marks to a specified shape +* @param {(boolean|Clip)} [options.clip=false] - setting indicating whether to clip marks to a specified shape * @param {string} [options.description] - text description of a mark for ARIA accessibility * @param {Object} [options.encode] - object containing visual encoding rules for mark properties * @param {Object} [options.from] - object describing the data a mark should visualize -* @param {boolean} [options.interactive=true] - boolean indicating whether a mark can serve as an input event source +* @param {(boolean|Signal)} [options.interactive=true] - boolean indicating whether a mark can serve as an input event source * @param {(string|Object)} [options.key] - data field to use as a unique key for data binding * @param {string} [options.name] - unique name * @param {Array} [options.triggers=[]] - list of triggers for modifying mark properties in response to signal changes -* @param {Object} [options.sort] - comparator for sorting mark items +* @param {Compare} [options.sort] - comparator for sorting mark items * @param {Array} [options.transforms=[]] - list of post-encoding transforms to apply after any "encode" blocks and which operate directly on mark scenegraph items * @param {string} [options.role] - metadata string indicating the role of a mark * @param {(string|Array)} [options.style] - custom styles to apply to a mark @@ -97,18 +118,24 @@ var debug = logger( 'vega:mark:main' ); * // returns */ function Mark( options ) { + var self; var opts; var keys; var v; var k; var i; if ( !( this instanceof Mark ) ) { - return new Mark( options ); + if ( arguments.length ) { + return new Mark( options ); + } + return new Mark(); } - EventEmitter.call( this ); if ( !isObject( options ) ) { throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); } + self = this; + EventEmitter.call( this ); + // Resolve the default configuration: opts = defaults(); @@ -127,6 +154,15 @@ function Mark( options ) { if ( !hasProp( options, 'type' ) ) { throw new TypeError( 'invalid argument. Options argument must specify the mark type.' ); } + // Define an internal change event listener: + this._onChange = onChange; + + // Add change listeners to default event emitters: + if ( this._clip && typeof this._clip.on === 'function' ) { + this._addChangeListener( this._clip ); + } + this._addChangeListener( this._sort ); + // Validate provided options by attempting to assign option values to corresponding fields... for ( i = 0; i < properties.length; i++ ) { k = properties[ i ]; @@ -148,6 +184,17 @@ function Mark( options ) { } } return this; + + /** + * Callback invoked upon a change event. + * + * @private + * @param {Object} event - event object + */ + function onChange( event ) { + debug( 'Received a change event: %s', JSON.stringify( event ) ); + self.emit( 'change', event ); + } } /* @@ -166,6 +213,76 @@ inherit( Mark, EventEmitter ); */ setNonEnumerableReadOnly( Mark, 'name', 'Mark' ); +/** +* Adds an internal listener to a change event on a child instance. +* +* @private +* @name _addChangeListener +* @memberof Mark.prototype +* @type {Function} +* @param {Object} emitter - event emitter +* @returns {Mark} visualization instance +*/ +setNonEnumerableReadOnly( Mark.prototype, '_addChangeListener', function addChangeListener( emitter ) { + if ( emitter && typeof emitter.on === 'function' ) { + emitter.on( 'change', this._onChange ); + } + return this; +}); + +/** +* Adds internal listeners to change events on child instances. +* +* @private +* @name _addChangeListeners +* @memberof Mark.prototype +* @type {Function} +* @param {ArrayLikeObject} emitters - list of event emitters +* @returns {Mark} visualization instance +*/ +setNonEnumerableReadOnly( Mark.prototype, '_addChangeListeners', function addChangeListeners( emitters ) { + var i; + for ( i = 0; i < emitters.length; i++ ) { + this._addChangeListener( emitters[ i ] ); + } + return this; +}); + +/** +* Removes an internal listener to a change event on a child instance. +* +* @private +* @name _removeChangeListener +* @memberof Mark.prototype +* @type {Function} +* @param {Object} emitter - event emitter +* @returns {Mark} visualization instance +*/ +setNonEnumerableReadOnly( Mark.prototype, '_removeChangeListener', function removeChangeListener( emitter ) { + if ( emitter && typeof emitter.removeListener === 'function' ) { + emitter.removeListener( 'change', this._onChange ); + } + return this; +}); + +/** +* Removes internal listeners to change events on child instances. +* +* @private +* @name _removeChangeListeners +* @memberof Mark.prototype +* @type {Function} +* @param {ArrayLikeObject} emitters - list of event emitters +* @returns {Mark} visualization instance +*/ +setNonEnumerableReadOnly( Mark.prototype, '_removeChangeListeners', function removeChangeListeners( emitters ) { + var i; + for ( i = 0; i < emitters.length; i++ ) { + this._removeChangeListener( emitters[ i ] ); + } + return this; +}); + /** * Boolean indicating whether to include ARIA attributes in SVG output. * @@ -185,6 +302,46 @@ setNonEnumerableReadOnly( Mark, 'name', 'Mark' ); */ setReadWriteAccessor( Mark.prototype, 'aria', getARIA, setARIA ); +/** +* Setting indicating whether to clip marks to a specified shape. +* +* @name clip +* @memberof Mark.prototype +* @type {(boolean|Clip)} +* @default false +* +* @example +* var Clip = require( '@stdlib/plot/vega/mark/clip' ); +* +* var clip = new Clip(); +* var mark = new Mark({ +* 'type': 'line', +* 'clip': clip +* }); +* +* var v = mark.clip; +* // returns +*/ +setReadWriteAccessor( Mark.prototype, 'clip', getClip, setClip ); + +/** +* Text description of a mark for ARIA accessibility in SVG output. +* +* @name description +* @memberof Mark.prototype +* @type {(string|void)} +* +* @example +* var mark = new Mark({ +* 'type': 'line', +* 'description': '' +* }); +* +* var v = mark.description; +* // returns '' +*/ +setReadWriteAccessor( Mark.prototype, 'description', getDescription, setDescription ); + /** * Visual encoding rules for mark properties. * @@ -229,6 +386,43 @@ setReadWriteAccessor( Mark.prototype, 'encode', getEncode, setEncode ); */ setReadWriteAccessor( Mark.prototype, 'from', getFrom, setFrom ); +/** +* Boolean indicating whether a mark can serve as an input event source. +* +* @name interactive +* @memberof Mark.prototype +* @type {(boolean|Signal)} +* @default true +* +* @example +* var mark = new Mark({ +* 'type': 'line', +* 'interactive': true +* }); +* +* var v = mark.interactive; +* // returns true +*/ +setReadWriteAccessor( Mark.prototype, 'interactive', getInteractive, setInteractive ); + +/** +* Unique name. +* +* @name name +* @memberof Mark.prototype +* @type {(string|void)} +* +* @example +* var mark = new Mark({ +* 'type': 'line', +* 'name': '' +* }); +* +* var v = mark.name; +* // returns '' +*/ +setReadWriteAccessor( Mark.prototype, 'name', getName, setName ); + /** * Mark properties. * @@ -246,6 +440,65 @@ setReadWriteAccessor( Mark.prototype, 'from', getFrom, setFrom ); */ setNonEnumerableReadOnlyAccessor( Mark.prototype, 'properties', getProperties ); +/** +* Metadata string indicating the role of a mark. +* +* @name role +* @memberof Mark.prototype +* @type {(string|void)} +* +* @example +* var mark = new Mark({ +* 'type': 'line', +* 'role': '' +* }); +* +* var v = mark.role; +* // returns '' +*/ +setReadWriteAccessor( Mark.prototype, 'role', getRole, setRole ); + +/** +* Comparator for sorting mark items. +* +* @name sort +* @memberof Mark.prototype +* @type {(Compare|void)} +* +* @example +* var Compare = require( '@stdlib/plot/vega/compare/ctor' ); +* +* var compare = new Compare({ +* 'field': 'amount' +* }); +* var mark = new Mark({ +* 'type': 'line', +* 'sort': compare +* }); +* +* var v = mark.sort; +* // returns +*/ +setReadWriteAccessor( Mark.prototype, 'sort', getSort, setSort ); + +/** +* Custom styles to apply to a mark. +* +* @name style +* @memberof Mark.prototype +* @type {(string|Array)} +* +* @example +* var mark = new Mark({ +* 'type': 'line', +* 'style': [ '' ] +* }); +* +* var v = mark.style; +* // returns [ '' ] +*/ +setReadWriteAccessor( Mark.prototype, 'style', getStyle, setStyle ); + /** * List of triggers for modifying mark properties in response to signal changes. * diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/name/get.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/name/get.js new file mode 100644 index 000000000000..b9ce2f7cd45c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/name/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the unique name. +* +* @private +* @returns {(string|void)} mark name +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/name/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/name/properties.js new file mode 100644 index 000000000000..73c88d38ea23 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/name/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( 'name' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/name/set.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/name/set.js new file mode 100644 index 000000000000..eceb4e35b8f8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/name/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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the unique name. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(string|void)} value - input value +* @throws {TypeError} must be a string +* @returns {void} +*/ +function set( value ) { + if ( !isString( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. 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/base/ctor/lib/role/get.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/role/get.js new file mode 100644 index 000000000000..39bfb31806d7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/role/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the metadata string indicating the role of a mark. +* +* @private +* @returns {(string|void)} mark role +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/role/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/role/properties.js new file mode 100644 index 000000000000..2211e8226fd1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/role/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( 'role' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/role/set.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/role/set.js new file mode 100644 index 000000000000..95c5782bc70b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/role/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 isUndefined = require( '@stdlib/assert/is-undefined' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the metadata string indicating the role of a mark. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(string|void)} value - input value +* @throws {TypeError} must be a string +* @returns {void} +*/ +function set( value ) { + if ( !isString( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. 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/base/ctor/lib/sort/get.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/sort/get.js new file mode 100644 index 000000000000..280925a2bd11 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/sort/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the comparator for sorting mark items. +* +* @private +* @returns {(Object|void)} comparator +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/sort/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/sort/properties.js new file mode 100644 index 000000000000..9a3846787a90 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/sort/properties.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'sort' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/sort/set.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/sort/set.js new file mode 100644 index 000000000000..be9d09ec54bc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/sort/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 isCompare = require( '@stdlib/plot/vega/base/assert/is-compare' ); +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:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the comparator for sorting mark items. +* +* @private +* @param {(Object|void)} value - input value +* @throws {TypeError} must be a Compare instance +* @returns {void} +*/ +function set( value ) { + if ( !isCompare( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be either a clip instance, or a signal. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + this._removeChangeListener( this[ prop.private ] ); + debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + this._addChangeListener( this[ prop.private ] ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/style/get.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/style/get.js new file mode 100644 index 000000000000..092b43382f67 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/style/get.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var copy = require( '@stdlib/array/base/copy-indexed' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the custom styles to apply to a mark. +* +* @private +* @returns {Array} mark style +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/style/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/style/properties.js new file mode 100644 index 000000000000..555d3c7660f3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/style/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( 'style' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/style/set.js b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/style/set.js new file mode 100644 index 000000000000..9510d53fad91 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/base/ctor/lib/style/set.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the custom styles to apply to a mark. +* +* @private +* @param {(string|StringArray)} value - input value +* @throws {TypeError} must be a string +* @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.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) ); + this[ prop.private ] = copy( value ); + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set;