diff --git a/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/examples/index.js b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/examples/index.js new file mode 100644 index 000000000000..960afb53e6c1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/examples/index.js @@ -0,0 +1,45 @@ +/** +* @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 RuleEncodingSet = require( '@stdlib/plot/vega/mark/rule/encoding-set' ); +var RuleEncoding = require( '@stdlib/plot/vega/mark/rule/encoding' ); +var RuleMark = require( './../lib' ); + +var mark = new RuleMark({ + 'encode': new RuleEncoding({ + 'enter': new RuleEncodingSet({ + 'stroke': new Value({ + 'value': '#000' + }) + }), + 'update': new RuleEncodingSet({ + 'stroke': new Value({ + 'value': 'steelblue' + }) + }), + 'exit': new RuleEncodingSet({ + 'stroke': new Value({ + 'value': '#fff' + }) + }) + }) +}); +console.log( mark.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/change_event.js b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/change_event.js new file mode 100644 index 000000000000..359afbfa206b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/rule/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': 'mark', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/defaults.js b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/defaults.js new file mode 100644 index 000000000000..2094acda35d1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/defaults.js @@ -0,0 +1,51 @@ +/** +* @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 RuleEncoding = require( '@stdlib/plot/vega/mark/rule/encoding' ); + + +// MAIN // + +/** +* Returns defaults. +* +* @private +* @returns {Object} default options +* +* @example +* var o = defaults(); +* // returns {...} +*/ +function defaults() { + return { + // Visual encoding rules for rule mark properties: + 'encode': new RuleEncoding(), + + // Mark type: + 'type': 'rule' + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/encode/get.js b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/encode/get.js new file mode 100644 index 000000000000..13cb2e26efad --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/encode/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 set of visual encoding rules for rule mark properties. +* +* @private +* @returns {(RuleEncoding|void)} encodings +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/encode/properties.js b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/encode/properties.js new file mode 100644 index 000000000000..534754763d4e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/encode/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( 'encode' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/encode/set.js b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/encode/set.js new file mode 100644 index 000000000000..0f2876fcd781 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/encode/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 isRuleMarkEncoding = require( '@stdlib/plot/vega/base/assert/is-rule-mark-encoding' ); +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:rule:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the visual encoding rules for rule mark properties. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(Encoding|void)} value - input value +* @throws {TypeError} must be a rule mark encoding instance +* @returns {void} +*/ +function set( value ) { + if ( !isRuleMarkEncoding( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a rule mark encoding instance. Value: `%s`.', prop.name, value ) ); + } + if ( value !== 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 ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/index.js b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/index.js new file mode 100644 index 000000000000..f92c28952831 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/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'; + +/** +* Rule mark constructor. +* +* @module @stdlib/plot/vega/mark/rule/ctor +* +* @example +* var RuleMark = require( '@stdlib/plot/vega/mark/rule/ctor' ); +* +* var mark = new RuleMark(); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/main.js new file mode 100644 index 000000000000..46f9d2674e9d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/lib/main.js @@ -0,0 +1,162 @@ +/** +* @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 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 transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' ); +var Mark = require( '@stdlib/plot/vega/mark/base/ctor' ); +var format = require( '@stdlib/string/format' ); +var defaults = require( './defaults.js' ); + +// Note: keep the following in alphabetical order according to the `require` path... +var getEncode = require( './encode/get.js' ); +var setEncode = require( './encode/set.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:mark:rule:main' ); + + +// MAIN // + +/** +* Rule mark constructor. +* +* @constructor +* @param {Options} options - constructor options +* @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 {string} [options.description] - text description of a mark for ARIA accessibility +* @param {RuleEncoding} [options.encode] - visual encoding rules for mark properties +* @param {DataSource} [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 {(string|Object)} [options.key] - data field to use as a unique key for data binding +* @param {string} [options.name] - unique name +* @param {string} [options.role] - metadata string indicating the role of a mark +* @param {Object} [options.sort] - comparator for sorting mark items +* @param {(string|Array)} [options.style] - custom styles to apply to a mark +* @param {Array} [options.transforms=[]] - list of post-encoding transforms to apply after any "encode" blocks and which operate directly on mark scenegraph items +* @param {Array} [options.triggers=[]] - list of triggers for modifying mark properties in response to signal changes +* @param {number} [options.zindex=0] - integer z-index indicating the layering of a mark relative to other marks +* @throws {TypeError} options argument must be an object +* @throws {Error} must provide valid options +* @returns {RuleMark} rule mark instance +* +* @example +* var mark = new RuleMark(); +* // returns +*/ +function RuleMark( options ) { + var nargs; + var props; + var v; + var k; + var i; + + nargs = arguments.length; + if ( !( this instanceof RuleMark ) ) { + if ( nargs === 0 ) { + return new RuleMark(); + } + return new RuleMark( options ); + } + Mark.call( this, defaults() ); // note: explicitly called without provided options, 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... + props = this.properties; + for ( i = 0; i < props.length; i++ ) { + k = props[ i ]; + if ( !hasProp( options, k ) ) { + continue; + } + v = options[ k ]; + try { + this[ k ] = v; + } catch ( err ) { + debug( 'Encountered an error. Error: %s', err.message ); + + // FIXME: retain thrown error type + throw new Error( transformErrorMessage( err.message ) ); + } + } + } + return this; +} + +/* +* Inherit from the `Mark` prototype. +*/ +inherit( RuleMark, Mark ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof RuleMark +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( RuleMark, 'name', 'RuleMark' ); + +/** +* Visual encoding rules for rule mark properties. +* +* @name encode +* @memberof RuleMark.prototype +* @type {(RuleEncoding|void)} +* +* @example +* var Value = require( '@stdlib/plot/vega/value/ctor' ); +* var EncodingSet = require( '@stdlib/plot/vega/mark/rule/encoding-set' ); +* var Encoding = require( '@stdlib/plot/vega/mark/rule/encoding' ); +* +* var mark = new RuleMark({ +* 'encode': new Encoding({ +* 'enter': new EncodingSet({ +* 'stroke': new Value({ +* 'value': 'steelblue' +* }) +* }) +* }) +* }); +* +* var v = mark.encode; +* // returns {...} +*/ +setReadWriteAccessor( RuleMark.prototype, 'encode', getEncode, setEncode ); + + +// EXPORTS // + +module.exports = RuleMark; diff --git a/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/package.json b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/package.json new file mode 100644 index 000000000000..2d1cf326cc0c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/mark/rule/ctor/package.json @@ -0,0 +1,62 @@ +{ + "name": "@stdlib/plot/vega/mark/rule/ctor", + "version": "0.0.0", + "description": "Rule mark 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", + "mark", + "rule", + "encoding", + "constructor", + "ctor" + ], + "__stdlib__": {} +}