diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/examples/index.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/examples/index.js new file mode 100644 index 000000000000..55f2cc804c30 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/examples/index.js @@ -0,0 +1,27 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var LabelTransform = require( './../lib' ); + +var transform = new LabelTransform({ + 'size': [ 500, 300 ] +}); + +console.log( transform.toJSON() ); diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/get.js new file mode 100644 index 000000000000..ce17187b51eb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/get.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var copy = require( '@stdlib/array/base/copy' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the list of anchor directions to test for each label. +* +* @private +* @returns {StringArray} anchor directions +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/properties.js new file mode 100644 index 000000000000..46d8fc92c323 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/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( 'anchor' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/set.js new file mode 100644 index 000000000000..4cde203716da --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/set.js @@ -0,0 +1,75 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var arraylikefcn = require( '@stdlib/assert/tools/array-like-function' ); +var isLabelTransformAnchorDirection = require( '@stdlib/plot/vega/base/assert/is-label-transform-anchor-direction' ); +var anchorDirections = require( '@stdlib/plot/vega/transform/label/anchor-directions' ); +var join = require( '@stdlib/array/base/join' ); +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:label-transform:set:'+prop.name ); + +// Function to test whether a value is an array of supported anchor directions: +var isLabelTransformAnchorDirectionArray = arraylikefcn( isLabelTransformAnchorDirection ); + + +// MAIN // + +/** +* Sets the list of anchor directions to test for each label. +* +* @private +* @param {(string|StringArray)} value - input value +* @throws {TypeError} must be an anchor direction or an array of anchor directions +* @returns {void} +*/ +function set( value ) { + var isDirection = isLabelTransformAnchorDirection( value ); + if ( !isDirection && !isLabelTransformAnchorDirectionArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be an anchor direction or an array of anchor directions, where each direction is one of the following: "%s". Value: `%s`.', prop.name, join( anchorDirections(), '", "' ), value ) ); + } + if ( isDirection ) { + value = [ value ]; + } else { + value = copy( 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 ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/as/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/as/get.js new file mode 100644 index 000000000000..6433dd20dbf7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/as/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 output fields written by the transform. +* +* @private +* @returns {StringArray} output fields +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/as/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/as/properties.js new file mode 100644 index 000000000000..3f2304dc2f08 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/as/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( 'as' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/as/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/as/set.js new file mode 100644 index 000000000000..27df447c0a5f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/as/set.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var 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:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the output fields written by the transform. +* +* @private +* @param {StringArray} value - input value +* @throws {TypeError} must be an array of strings +* @returns {void} +*/ +function set( value ) { + if ( !isStringArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be an array of strings. Value: `%s`.', prop.name, 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; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-base-mark/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-base-mark/get.js new file mode 100644 index 000000000000..990bd2d5c000 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-base-mark/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 flag specifying whether labels should not overlap the base mark. +* +* @private +* @returns {boolean} boolean flag +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-base-mark/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-base-mark/properties.js new file mode 100644 index 000000000000..f52d555ead8e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-base-mark/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( 'avoidBaseMark' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-base-mark/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-base-mark/set.js new file mode 100644 index 000000000000..b5c3c9cdc43d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-base-mark/set.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets a boolean flag specifying whether labels should not overlap the base mark. +* +* @private +* @param {boolean} value - input value +* @throws {TypeError} must be a boolean +* @returns {void} +*/ +function set( value ) { + if ( !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-marks/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-marks/get.js new file mode 100644 index 000000000000..9ca57233548d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-marks/get.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var copy = require( '@stdlib/array/base/copy' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the list of named marks that the labels should not overlap. +* +* @private +* @returns {StringArray} named marks +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-marks/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-marks/properties.js new file mode 100644 index 000000000000..408c05ec583b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-marks/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( 'avoidMarks' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-marks/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-marks/set.js new file mode 100644 index 000000000000..3d378edcda37 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/avoid-marks/set.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var isEmptyCollection = require( '@stdlib/assert/is-empty-collection' ); +var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); +var copy = require( '@stdlib/array/base/copy' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the list of named marks that the labels should not overlap. +* +* @private +* @param {StringArray} value - input value +* @throws {TypeError} must be an array of strings +* @returns {void} +*/ +function set( value ) { + if ( !isStringArray( value ) && !isEmptyCollection( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be an array of strings. Value: `%s`.', prop.name, value ) ); + } + if ( !hasEqualValues( value, this[ prop.private ] ) ) { + debug( 'Current value: ["%s"]. New value: ["%s"].', join( this[ prop.private ], '", "' ), join( value, '", "' ) ); + this[ prop.private ] = copy( value ); + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/change_event.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/change_event.js new file mode 100644 index 000000000000..e444f9c667b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/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': 'transform', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/defaults.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/defaults.js new file mode 100644 index 000000000000..363f7c2a4fe6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/defaults.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. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns defaults. +* +* @private +* @returns {Object} default options +* +* @example +* var o = defaults(); +* // returns {...} +*/ +function defaults() { + return { + // List of anchor directions to test for each label (all directions except "middle"): + 'anchor': [ 'top-left', 'left', 'bottom-left', 'top', 'bottom', 'top-right', 'right', 'bottom-right' ], + + // Output fields written by the transform: + 'as': [ 'x', 'y', 'opacity', 'align', 'baseline' ], + + // Boolean flag specifying whether labels should not overlap the base mark: + 'avoidBaseMark': true, + + // List of named marks that the labels should not overlap: + 'avoidMarks': [], + + // Anchor position of labels for line marks: + 'lineAnchor': 'end', + + // Index of a mark in a group mark to use as the base mark: + 'markIndex': 0, + + // Labeling method to use for area marks: + 'method': 'naive', + + // List of label offsets (in pixels) for each anchor direction: + 'offset': [ 1 ], + + // Padding in pixels by which a label may extend past the chart bounding box: + 'padding': 0 + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/index.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/index.js new file mode 100644 index 000000000000..0cdf9c7774d9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/index.js @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Label transform constructor. +* +* @module @stdlib/plot/vega/transform/label/ctor +* +* @example +* var LabelTransform = require( '@stdlib/plot/vega/transform/label/ctor' ); +* +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ] +* }); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/line-anchor/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/line-anchor/get.js new file mode 100644 index 000000000000..334ae08320a2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/line-anchor/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 anchor position of labels for line marks. +* +* @private +* @returns {string} line anchor position +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/line-anchor/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/line-anchor/properties.js new file mode 100644 index 000000000000..ffeb01824d66 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/line-anchor/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( 'lineAnchor' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/line-anchor/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/line-anchor/set.js new file mode 100644 index 000000000000..cff27fcc27e5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/line-anchor/set.js @@ -0,0 +1,63 @@ +/** +* @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 isLabelTransformLineAnchorPosition = require( '@stdlib/plot/vega/base/assert/is-label-transform-line-anchor-position' ); +var lineAnchorPositions = require( '@stdlib/plot/vega/transform/label/line-anchor-positions' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the anchor position of labels for line marks. +* +* @private +* @param {string} value - input value +* @throws {TypeError} must be a valid line anchor position +* @returns {void} +*/ +function set( value ) { + if ( !isLabelTransformLineAnchorPosition( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', prop.name, join( lineAnchorPositions(), '", "' ), 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/transform/label/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/main.js new file mode 100644 index 000000000000..27b0e0a204e7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/main.js @@ -0,0 +1,521 @@ +/** +* @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-restricted-syntax, no-invalid-this, stdlib/no-empty-lines-between-requires */ + +'use strict'; + +// MODULES // + +var EventEmitter = require( 'events' ).EventEmitter; +var logger = require( 'debug' ); +var isObject = require( '@stdlib/assert/is-object' ); +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); // eslint-disable-line id-length +var 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 instance2json = require( '@stdlib/plot/vega/base/to-json' ); +var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' ); +var format = require( '@stdlib/string/format' ); +var properties = require( './properties.json' ); +var defaults = require( './defaults.js' ); + +// Note: keep the following in alphabetical order according to the `require` path... +var getAnchor = require( './anchor/get.js' ); +var setAnchor = require( './anchor/set.js' ); + +var getAs = require( './as/get.js' ); +var setAs = require( './as/set.js' ); + +var getAvoidBaseMark = require( './avoid-base-mark/get.js' ); +var setAvoidBaseMark = require( './avoid-base-mark/set.js' ); + +var getAvoidMarks = require( './avoid-marks/get.js' ); +var setAvoidMarks = require( './avoid-marks/set.js' ); + +var getLineAnchor = require( './line-anchor/get.js' ); +var setLineAnchor = require( './line-anchor/set.js' ); + +var getMarkIndex = require( './mark-index/get.js' ); +var setMarkIndex = require( './mark-index/set.js' ); + +var getMethod = require( './method/get.js' ); +var setMethod = require( './method/set.js' ); + +var getOffset = require( './offset/get.js' ); +var setOffset = require( './offset/set.js' ); + +var getPadding = require( './padding/get.js' ); +var setPadding = require( './padding/set.js' ); + +var getProperties = require( './properties/get.js' ); + +var getSize = require( './size/get.js' ); +var setSize = require( './size/set.js' ); + +var getSort = require( './sort/get.js' ); +var setSort = require( './sort/set.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:label-transform:main' ); + + +// MAIN // + +/** +* Label transform constructor. +* +* @constructor +* @param {Options} options - constructor options +* @param {NumericArray} options.size - two-element array specifying the chart size as a `[width, height]` array +* @param {(string|StringArray)} [options.anchor=['top-left','left','bottom-left','top','bottom','top-right','right','bottom-right']] - list of anchor directions to test for each label relative to its base mark's bounding box +* @param {StringArray} [options.as=['x','y','opacity','align','baseline']] - output fields written by the transform +* @param {boolean} [options.avoidBaseMark=true] - boolean flag specifying whether labels should not overlap the base mark +* @param {StringArray} [options.avoidMarks=[]] - list of named marks that the labels should not overlap +* @param {string} [options.lineAnchor='end'] - anchor position of labels for line marks +* @param {NonNegativeInteger} [options.markIndex=0] - index of a mark in a group mark to use as the base mark +* @param {string} [options.method='naive'] - labeling method to use for area marks +* @param {(number|NumericArray)} [options.offset=[1]] - list of label offsets (in pixels) for each anchor direction +* @param {number} [options.padding=0] - padding in pixels by which a label may extend past the chart bounding box +* @param {Field} [options.sort] - field indicating the order in which labels should be placed, in ascending order +* @throws {TypeError} options argument must be an object +* @throws {Error} must provide valid options +* @returns {LabelTransform} label transform instance +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ] +* }); +* // returns +*/ +function LabelTransform( options ) { + var self; + var opts; + var keys; + var v; + var k; + var i; + if ( !( this instanceof LabelTransform ) ) { + return new LabelTransform( options ); + } + self = this; + EventEmitter.call( this ); + + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + + // Check for required properties... + if ( !hasProp( options, 'size' ) ) { + throw new TypeError( 'invalid argument. Options argument must specify a chart size.' ); + } + + // Resolve the default configuration: + opts = defaults(); + + // Set internal properties according to the default configuration... + keys = objectKeys( opts ); + for ( i = 0; i < keys.length; i++ ) { + k = keys[ i ]; + this[ '_'+k ] = opts[ k ]; + } + + // Define an internal change event listener: + this._onChange = onChange; + + // Add change listeners to default event emitters: + if ( this._sort && typeof this._sort.on === 'function' ) { + 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 ]; + 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; + + /** + * 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 ); + } +} + +/* +* Inherit from the `EventEmitter` prototype. +*/ +inherit( LabelTransform, EventEmitter ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof LabelTransform +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( LabelTransform, 'name', 'LabelTransform' ); + +/** +* Adds an internal listener to a change event on a child instance. +* +* @private +* @name _addChangeListener +* @memberof LabelTransform.prototype +* @type {Function} +* @param {Object} emitter - event emitter +* @returns {LabelTransform} label transform instance +*/ +setNonEnumerableReadOnly( LabelTransform.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 LabelTransform.prototype +* @type {Function} +* @param {ArrayLikeObject} emitters - list of event emitters +* @returns {LabelTransform} label transform instance +*/ +setNonEnumerableReadOnly( LabelTransform.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 LabelTransform.prototype +* @type {Function} +* @param {Object} emitter - event emitter +* @returns {LabelTransform} label transform instance +*/ +setNonEnumerableReadOnly( LabelTransform.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 LabelTransform.prototype +* @type {Function} +* @param {ArrayLikeObject} emitters - list of event emitters +* @returns {LabelTransform} label transform instance +*/ +setNonEnumerableReadOnly( LabelTransform.prototype, '_removeChangeListeners', function removeChangeListeners( emitters ) { + var i; + for ( i = 0; i < emitters.length; i++ ) { + this._removeChangeListener( emitters[ i ] ); + } + return this; +}); + +/** +* List of anchor directions to test for each label relative to its base mark's bounding box. +* +* @name anchor +* @memberof LabelTransform.prototype +* @type {Array} +* @default ['top-left','left','bottom-left','top','bottom','top-right','right','bottom-right'] +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ], +* 'anchor': [ 'top', 'bottom' ] +* }); +* +* var v = transform.anchor; +* // returns [ 'top', 'bottom' ] +*/ +setReadWriteAccessor( LabelTransform.prototype, 'anchor', getAnchor, setAnchor ); + +/** +* Output fields written by the transform. +* +* @name as +* @memberof LabelTransform.prototype +* @type {StringArray} +* @default ['x','y','opacity','align','baseline'] +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ] +* }); +* +* var v = transform.as; +* // returns [ 'x', 'y', 'opacity', 'align', 'baseline' ] +*/ +setReadWriteAccessor( LabelTransform.prototype, 'as', getAs, setAs ); + +/** +* Boolean flag specifying whether labels should not overlap the base mark. +* +* @name avoidBaseMark +* @memberof LabelTransform.prototype +* @type {boolean} +* @default true +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ], +* 'avoidBaseMark': false +* }); +* +* var v = transform.avoidBaseMark; +* // returns false +*/ +setReadWriteAccessor( LabelTransform.prototype, 'avoidBaseMark', getAvoidBaseMark, setAvoidBaseMark ); + +/** +* List of named marks that the labels should not overlap. +* +* @name avoidMarks +* @memberof LabelTransform.prototype +* @type {StringArray} +* @default [] +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ], +* 'avoidMarks': [ 'trend' ] +* }); +* +* var v = transform.avoidMarks; +* // returns [ 'trend' ] +*/ +setReadWriteAccessor( LabelTransform.prototype, 'avoidMarks', getAvoidMarks, setAvoidMarks ); + +/** +* Anchor position of labels for line marks. +* +* @name lineAnchor +* @memberof LabelTransform.prototype +* @type {string} +* @default 'end' +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ], +* 'lineAnchor': 'start' +* }); +* +* var v = transform.lineAnchor; +* // returns 'start' +*/ +setReadWriteAccessor( LabelTransform.prototype, 'lineAnchor', getLineAnchor, setLineAnchor ); + +/** +* Index of a mark in a group mark to use as the base mark. +* +* @name markIndex +* @memberof LabelTransform.prototype +* @type {NonNegativeInteger} +* @default 0 +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ], +* 'markIndex': 1 +* }); +* +* var v = transform.markIndex; +* // returns 1 +*/ +setReadWriteAccessor( LabelTransform.prototype, 'markIndex', getMarkIndex, setMarkIndex ); + +/** +* Labeling method to use for area marks. +* +* @name method +* @memberof LabelTransform.prototype +* @type {string} +* @default 'naive' +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ], +* 'method': 'floodfill' +* }); +* +* var v = transform.method; +* // returns 'floodfill' +*/ +setReadWriteAccessor( LabelTransform.prototype, 'method', getMethod, setMethod ); + +/** +* List of label offsets (in pixels) for each anchor direction. +* +* @name offset +* @memberof LabelTransform.prototype +* @type {NumericArray} +* @default [ 1 ] +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ], +* 'offset': [ 2 ] +* }); +* +* var v = transform.offset; +* // returns [ 2 ] +*/ +setReadWriteAccessor( LabelTransform.prototype, 'offset', getOffset, setOffset ); + +/** +* Padding in pixels by which a label may extend past the chart bounding box. +* +* @name padding +* @memberof LabelTransform.prototype +* @type {number} +* @default 0 +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ], +* 'padding': 4 +* }); +* +* var v = transform.padding; +* // returns 4 +*/ +setReadWriteAccessor( LabelTransform.prototype, 'padding', getPadding, setPadding ); + +/** +* Label transform properties. +* +* @name properties +* @memberof LabelTransform.prototype +* @type {Array} +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ] +* }); +* +* var v = transform.properties; +* // returns [...] +*/ +setNonEnumerableReadOnlyAccessor( LabelTransform.prototype, 'properties', getProperties ); + +/** +* Two-element array specifying the chart size as a `[width, height]` array. +* +* @name size +* @memberof LabelTransform.prototype +* @type {NumericArray} +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ] +* }); +* +* var v = transform.size; +* // returns [ 500, 300 ] +*/ +setReadWriteAccessor( LabelTransform.prototype, 'size', getSize, setSize ); + +/** +* Field indicating the order in which labels should be placed, in ascending order. +* +* @name sort +* @memberof LabelTransform.prototype +* @type {(Field|void)} +* +* @example +* var Field = require( '@stdlib/plot/vega/field/ctor' ); +* +* var field = new Field({ +* 'field': 'priority' +* }); +* +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ], +* 'sort': field +* }); +* +* var v = transform.sort; +* // returns +*/ +setReadWriteAccessor( LabelTransform.prototype, 'sort', getSort, setSort ); + +/** +* Serializes an instance to a JSON object. +* +* ## Notes +* +* - This method is implicitly invoked by `JSON.stringify`. +* +* @name toJSON +* @memberof LabelTransform.prototype +* @type {Function} +* @returns {Object} JSON object +* +* @example +* var transform = new LabelTransform({ +* 'size': [ 500, 300 ] +* }); +* +* var v = transform.toJSON(); +* // returns {...} +*/ +setNonEnumerableReadOnly( LabelTransform.prototype, 'toJSON', function toJSON() { + return instance2json( this, properties ); +}); + + +// EXPORTS // + +module.exports = LabelTransform; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/mark-index/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/mark-index/get.js new file mode 100644 index 000000000000..a993e283bc92 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/mark-index/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 index of a mark in a group mark to use as the base mark. +* +* @private +* @returns {NonNegativeInteger} mark index +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/mark-index/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/mark-index/properties.js new file mode 100644 index 000000000000..0f2e5981719c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/mark-index/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( 'markIndex' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/mark-index/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/mark-index/set.js new file mode 100644 index 000000000000..9986506c56d6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/mark-index/set.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the index of a mark in a group mark to use as the base mark. +* +* @private +* @param {NonNegativeInteger} value - input value +* @throws {TypeError} must be a nonnegative integer +* @returns {void} +*/ +function set( value ) { + if ( !isNonNegativeInteger( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative integer. 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/transform/label/ctor/lib/method/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/method/get.js new file mode 100644 index 000000000000..473dfa4561a2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/method/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 labeling method to use for area marks. +* +* @private +* @returns {string} labeling method +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/method/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/method/properties.js new file mode 100644 index 000000000000..75519f7b2d1b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/method/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( 'method' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/method/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/method/set.js new file mode 100644 index 000000000000..0257cf25a34d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/method/set.js @@ -0,0 +1,63 @@ +/** +* @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 isLabelTransformMethod = require( '@stdlib/plot/vega/base/assert/is-label-transform-method' ); +var labelMethods = require( '@stdlib/plot/vega/transform/label/methods' ); +var join = require( '@stdlib/array/base/join' ); +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the labeling method to use for area marks. +* +* @private +* @param {string} value - input value +* @throws {TypeError} must be a valid labeling method +* @returns {void} +*/ +function set( value ) { + if ( !isLabelTransformMethod( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', prop.name, join( labelMethods(), '", "' ), 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/transform/label/ctor/lib/offset/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/offset/get.js new file mode 100644 index 000000000000..72bde6ece3f2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/offset/get.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var copy = require( '@stdlib/array/base/copy' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the list of label offsets (in pixels) for each anchor direction. +* +* @private +* @returns {NumericArray} label offsets +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/offset/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/offset/properties.js new file mode 100644 index 000000000000..d1b5fccec871 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/offset/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( 'offset' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/offset/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/offset/set.js new file mode 100644 index 000000000000..db1273d50e0b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/offset/set.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var isNumberArray = require( '@stdlib/assert/is-number-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:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the list of label offsets (in pixels) for each anchor direction. +* +* @private +* @param {(number|NumericArray)} value - input value +* @throws {TypeError} must be a number or an array of numbers +* @returns {void} +*/ +function set( value ) { + var isNum = isNumber( value ); + if ( !isNum && !isNumberArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number or an array of numbers. Value: `%s`.', prop.name, value ) ); + } + if ( isNum ) { + value = [ value ]; + } else { + value = copy( 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 ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/padding/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/padding/get.js new file mode 100644 index 000000000000..720e37c408aa --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/padding/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 padding in pixels by which a label may extend past the chart bounding box. +* +* @private +* @returns {number} padding +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/padding/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/padding/properties.js new file mode 100644 index 000000000000..7c8d98d6884c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/padding/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( 'padding' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/padding/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/padding/set.js new file mode 100644 index 000000000000..0b7803784a1a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/padding/set.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the padding in pixels by which a label may extend past the chart bounding box. +* +* @private +* @param {number} value - input value +* @throws {TypeError} must be a number +* @returns {void} +*/ +function set( value ) { + if ( !isNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number. 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/transform/label/ctor/lib/properties.json b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/properties.json new file mode 100644 index 000000000000..8ce947b75778 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/properties.json @@ -0,0 +1,13 @@ +[ + "anchor", + "as", + "avoidBaseMark", + "avoidMarks", + "lineAnchor", + "markIndex", + "method", + "offset", + "padding", + "size", + "sort" +] diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/properties/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/properties/get.js new file mode 100644 index 000000000000..f3cbb28454ea --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/properties/get.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var properties = require( './../properties.json' ); + + +// MAIN // + +/** +* Returns the list of enumerable properties. +* +* @private +* @returns {Array} properties +*/ +function get() { + return properties.slice(); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/size/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/size/get.js new file mode 100644 index 000000000000..d6b60c83d896 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/size/get.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var copy = require( '@stdlib/array/base/copy-indexed' ); +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the two-element array specifying the chart size as a `[width, height]` array. +* +* @private +* @returns {NumericArray} chart size +*/ +function get() { + return copy( this[ prop.private ] ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/size/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/size/properties.js new file mode 100644 index 000000000000..bf1bd182f0eb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/size/properties.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'size' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/size/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/size/set.js new file mode 100644 index 000000000000..d31d0a3dcdac --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/size/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 isNumberArray = require( '@stdlib/assert/is-number-array' ).primitives; +var isUndefined = require( '@stdlib/assert/is-undefined' ); +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:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the two-element array specifying the chart size as a `[width, height]` array. +* +* @private +* @param {NumericArray} value - input value +* @throws {TypeError} must be an array of numbers +* @returns {void} +*/ +function set( value ) { + if ( !isNumberArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be an array of numbers. Value: `%s`.', prop.name, value ) ); + } + if ( isUndefined( this[ prop.private ] ) || !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; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/sort/get.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/sort/get.js new file mode 100644 index 000000000000..795bb742a4b4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/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 field indicating the order in which labels should be placed. +* +* @private +* @returns {(Field|void)} sort field +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/sort/properties.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/sort/properties.js new file mode 100644 index 000000000000..9a3846787a90 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/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/transform/label/ctor/lib/sort/set.js b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/sort/set.js new file mode 100644 index 000000000000..abf69b7ac0ee --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/sort/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 isField = require( '@stdlib/plot/vega/base/assert/is-field' ); +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:label-transform:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the field indicating the order in which labels should be placed. +* +* ## Notes +* +* - Providing `undefined` "unsets" the configured value. +* +* @private +* @param {(Field|void)} value - input value +* @throws {TypeError} must be a field instance +* @returns {void} +*/ +function set( value ) { + if ( !isField( value ) && !isUndefined( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a field instance. 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/transform/label/ctor/package.json b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/package.json new file mode 100644 index 000000000000..2951914b5a48 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/transform/label/ctor/package.json @@ -0,0 +1,61 @@ +{ + "name": "@stdlib/plot/vega/transform/label/ctor", + "version": "0.0.0", + "description": "Label transform 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", + "transform", + "label", + "constructor", + "ctor" + ], + "__stdlib__": {} +}