diff --git a/lib/node_modules/@stdlib/plot/unicode/base/examples/safe-area-example.js b/lib/node_modules/@stdlib/plot/unicode/base/examples/safe-area-example.js new file mode 100644 index 000000000000..77192800d162 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/examples/safe-area-example.js @@ -0,0 +1,110 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 basePlot = require( './../lib' ); +var str; +var opt = { + 'plotAreaHeight': 12, + 'plotAreaWidth': 102, + 'axisTicsLabels': [ [1, 10], [ 1, 2 ], [ 2, 66, 666, 666 ], [ 9666, 55, 5 ] ], + 'labelFormate': [ '%s', '%s', '%s', '%s' ], + 'zAxis': false, + 'wAxis': false, + 'backgroundColor': 'Bwhite', + 'foregroundColor': 'Fblack', + 'xTicsLabelSpace': 2, + 'yTicsLabelSpace': 1, + 'zTicsLabelSpace': 3, + 'wTicsLabelSpace': 4, + 'ticsLabelsBckColor': 'Byellow', + 'autoInitialization': true, + 'xAxisPos': 40, + 'yAxisPos': 5, + 'zAxisPos': 101, + 'xTicsSpacing': 9, + 'yTicsSpacing': 9, + 'zTicsSpacing': 9, + 'wTicsSpacing': 9, + 'wAxisPos': 11 +}; +var instance = basePlot( opt ); +instance.initialize(); +str = instance.render(); +console.log( str ); + +// Adding string + +// Note : as you can see 'hel' is on one side and remaining text is on other side this is because of the label space and we are adding the string as a safe area mode +instance.setString({ + 'row': 4, + 'column': 37, + 'value': 'hello Stdlib!', + 'foregroundColor': 'Fwhite', + 'backgroundColor': 'Bgray', + 'safeArea': true +}); + +// Note : in Safe area mode we have to provide the coordinates in range of the plotAreaHeight and plotAreaWidth. +instance.setString({ + 'row': 5, + 'column': 37, + 'value': 'hello Stdlib!', + 'foregroundColor': 'Fwhite', + 'backgroundColor': 'Bgray', + 'safeArea': true +}); + +// Now it is going to be Visible +instance.ticsLabelsBckColor = 'Bblue'; + +str = instance.render(); +console.log( str ); + +// This line require to reinitialization ( autoInitialization is on ) +instance.xTicsLabelSpace = 5; +str = instance.render(); +console.log( str ); + +// Adding bar in safe area +instance.setBar({ + 'startPos': [ 0, 12 ], + 'height': 7, + 'width': 2, + 'safeArea': true, + 'overWrite': true, + 'glyph': 'block', + 'foregroundColor': 'Fred' +}); + +str = instance.render(); +console.log( str ); + +// Adding bar without safe area mode +instance.setBar({ + 'startPos': [ 0, 16 ], + 'height': 7, + 'width': 2, + 'overwrite': true, + 'safeArea': false, + 'glyph': 'block', + 'foregroundColor': 'Fred' +}); +str = instance.render(); +console.log( str ); diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/ansi_regexp.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/ansi_regexp.js new file mode 100644 index 000000000000..cdbfd22378c9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/ansi_regexp.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 // + +/** +* Regular expression to match ANSI escape sequences. +* +* @private +* @type {RegExp} +*/ +var RE = /([\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?(?:\u0007|\u001B\u005C|\u009C))|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~])))/g; // eslint-disable-line no-control-regex, no-useless-escape + + +// EXPORTS // + +module.exports = RE; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/background-color.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/background-color.js new file mode 100644 index 000000000000..c6a2b4d4922d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/background-color.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var isValidBackgroundColor = require( './utils/is-valid-background-color.js' ); +var isValidRowCol = require( './utils/is-valid-row-col.js' ); + +/** +* Method to add background color on specific row and col. +* +* @private +* @name setBackgroundColor +* @param {number} row - row number +* @param {number} col - col number +* @param {string} color - color name +* @param {boolean} overwrite - overwrite +* @param {boolean} safeArea - safeArea +* @returns {void} +*/ +function setBackgroundColor( row, col, color, overwrite, safeArea ) { + var a; + var b; + var r; + var c; + + r = row; + c = col; + if ( safeArea ) { + r = this.getSafeRow( row ); + c = this.getSafeColumn( col ); + } + a = ( isValidRowCol( r, c, this._height, this._width ) && isValidBackgroundColor( color ) ); + + // If color is already set to default we can change it + b = a && ( overwrite || this._backgroundColorMatrix[ r ][ c ] === this._backgroundColor ); + if ( b ) { + this._backgroundColorMatrix[ r ][ c ] = color; + } +} + +module.exports = setBackgroundColor; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/bar.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/bar.js new file mode 100644 index 000000000000..579b548c4ffe --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/bar.js @@ -0,0 +1,261 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var max = require( '@stdlib/math/base/special/fast/max' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isNonNegativeNumberArray = require( '@stdlib/assert/is-nonnegative-number-array' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var isString = require( '@stdlib/assert/is-string' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ); +var isValidBackgroundColor = require( './utils/is-valid-background-color.js' ); +var isValidForegroundColor = require( './utils/is-valid-foreground-color.js' ); +var isValidGlyph = require( './utils/is-valid-glyph.js' ); + + +// FUNCTIONS // + +/** +* Method which return the default option. +* +* @private +* @name defaults +* @returns {Object} - out +*/ +function defaults( ) { + var out = {}; + + out.startPos = []; + out.height = 0; + out.width = 0; + out.overwrite = false; + out.safeArea = false; + out.glyph = void 0; + out.foregroundColor = void 0; + out.backgroundColor = void 0; + return out; +} + +/** +* Method to validate the object. +* +* @private +* @name validate +* @param {Object} opts - destination object +* @param {Object} options - function options +* @returns {Object} - out +*/ +function validate( opts, options ) { + if ( !isPlainObject( options ) ) { + return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + + if ( hasOwnProp( options, 'startPos' ) ) { + opts.startPos = options.startPos; + if ( !isNonNegativeNumberArray( options.startPos ) || !options.startPos.length === 2 ) { + return new TypeError( format( 'invalid option. `%s` option must be a non-negative-number array with length 2. Option: `%s`.', 'startPos', options.startPos ) ); + } + } + else { + return new TypeError( format( 'invalid option. `%s` property is expected: `%s`.', 'startPos', options.startPos ) ); + } + + if ( hasOwnProp( options, 'height' ) ) { + opts.height = options.height; + if ( !isNonNegativeNumber( options.height ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a non-negative-number. Option: `%s`.', 'height', options.height ) ); + } + } + else { + return new TypeError( format( 'invalid option. `%s` property is expected: `%s`.', 'height', options.height ) ); + } + + if ( hasOwnProp( options, 'width' ) ) { + opts.width = options.width; + if ( !isNonNegativeNumber( options.width ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a non-negative-number. Option: `%s`.', 'width', options.width ) ); + } + } + else { + return new TypeError( format( 'invalid option. `%s` property is expected: `%s`.', 'width', options.width ) ); + } + + if ( hasOwnProp( options, 'overwrite' ) ) { + opts.overwrite = options.overwrite; + if ( !isBoolean( options.overwrite ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'overwrite', options.overwrite ) ); + } + } + if ( hasOwnProp( options, 'safeArea' ) ) { + opts.safeArea = options.safeArea; + if ( !isBoolean( options.safeArea ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'safeArea', options.safeArea ) ); + } + } + if ( hasOwnProp( options, 'glyph' ) ) { + opts.glyph = options.glyph; + if ( !isString( options.glyph ) || !isValidGlyph( options.glyph ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a string and a valid glyph. Option: `%s`.', 'glyph', options.glyph ) ); + } + } + if ( hasOwnProp( options, 'backgroundColor' ) ) { + opts.backgroundColor = options.backgroundColor; + if ( !isString( options.backgroundColor ) || !isValidBackgroundColor( options.backgroundColor ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a string and a valid background color code. Option: `%s`.', 'backgroundColor', options.backgroundColor ) ); + } + } + if ( hasOwnProp( options, 'foregroundColor' ) ) { + opts.foregroundColor = options.foregroundColor; + if ( !isString( options.foregroundColor ) || !isValidForegroundColor( options.foregroundColor ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a string and a valid foreground color code. Option: `%s`.', 'foregroundColor', options.foregroundColor ) ); + } + } +} + +/** +* Fill between 2 straight points. +* +* @private +* @name connectPoints +* @param {Array} p1 - point1 +* @param {Array} p2 - point2 +* @param {string} glyph - glyph to use +* @param {boolean} overwrite - overwrite +* @param {boolean} safeArea - weather to put coordinates in safe area or not +* @param {string} foregroundColor - glyph to use +* @param {string} backgroundColor - glyph to use +* @returns {void} +*/ +function connectPoints( p1, p2, glyph, overwrite, safeArea, foregroundColor, backgroundColor ) { + var strideX; + var strideY; + var tempX; + var tempY; + var mxd; + var dx; + var dy; + var x; + var y; + var i; + + if ( !( p1[ 0 ] === p2[ 0 ] || p1[ 1 ] === p2[ 1 ] ) ) { + return; + } + + dx = p2[ 0 ] - p1[ 0 ]; + dy = p2[ 1 ] - p1[ 1 ]; + mxd = max( abs( dx ), abs( dy ) ); + strideX = dx / mxd; + strideY = dy / mxd; + x = p1[ 0 ]; + y = p1[ 1 ]; + tempX = x; + tempY = y; + + for ( i = 0; i <= mxd; i++ ) { + if ( glyph ) { + this.setGlyph( tempX, tempY, glyph, overwrite, safeArea ); + } + if ( foregroundColor ) { + this.setForegroundColor( tempX, tempY, foregroundColor, overwrite, safeArea ); + } + if ( backgroundColor ) { + this.setBackgroundColor( tempX, tempY, backgroundColor, overwrite, safeArea ); + } + x += strideX; + y += strideY; + tempX = floor( x ); + tempY = floor( y ); + } +} + + +// MAIN // + +/** +* Method to draw the bar. +* +* @name bar +* @param {Options} options - options +* @param {Array} [options.startPos] - left bottom part of bar +* @param {number} [options.height] - height +* @param {number} [options.width] - width +* @param {boolean} [options.overwrite] - overwrite +* @param {boolean} [options.safeArea] - weather to put coordinates in safe area or not +* @param {string} [options.glyph] - glyph to use +* @param {string} [options.forgroundColor] - glyph to use +* @param {string} [options.backgroundColor] - glyph to use +* @throws {Error} must provide valid options +* @returns {void} +*/ +function bar( options ) { + var opts; + var err; + var bl; + var tl; + var br; + var p1; + var p2; + var i; + + opts = defaults(); + if ( arguments.length ) { + err = validate( opts, options ); + if ( err ) { + throw err; + } + } + else { + return new TypeError( format( 'invalid option. `%s` options object is expected', 'bar' ) ); + } + + // Bottom left point; + bl = opts.startPos; + + // Top left point; + tl = [ opts.startPos[ 0 ] + opts.height - 1, opts.startPos[ 1 ] ]; + + // Bottom right point; + br = [ opts.startPos[ 0 ], opts.startPos[ 1 ] + opts.width - 1 ]; + + // Row , Col + p1 = [ bl[ 0 ], bl[ 1 ] ]; + p2 = [ br[ 0 ], br[ 1 ] ]; + + for ( i = 0; i <= ( tl[ 0 ] - bl[ 0 ] ); i++ ) { + connectPoints.call( this, p1, p2, opts.glyph, opts.overwrite, opts.safeArea, opts.foregroundColor, opts.backgroundColor ); + p1[ 0 ] += 1; + p2[ 0 ] += 1; + } + + if ( !this._quite ) { + this.emit( 'change' ); + } +} + +module.exports = bar; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/colors-set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/colors-set.js new file mode 100644 index 000000000000..28f94a5d075e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/colors-set.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/* Bblack + + B black + + |_| |_____| + B-background/ Color + F-foreground +*/ + +var colorsSet = { + 'Bblack': '\x1b[40m', + 'Bwhite': '\x1b[47m', + 'Bred': '\x1b[101m', + 'Bmagenta': '\x1b[105m', + 'Bblue': '\x1b[104m', + 'Bgray': '\x1b[100m', + 'Bgreen': '\x1b[102m', + 'Byellow': '\x1b[103m', + 'Bcyan': '\x1b[106m', + 'BbrightRed': '\x1b[101m', + 'BbrightGreen': '\x1b[102m', + 'BbrightYellow': '\x1b[103m', + 'BbrightBlue': '\x1b[104m', + 'BbrightMagenta': '\x1b[105m', + 'BbrightCyan': '\x1b[106m', + 'BbrightWhite': '\x1b[107m', + 'Fwhite': '\x1b[37m', + 'Fblack': '\x1b[30m', + 'Fred': '\x1b[91m', + 'Fgreen': '\x1b[92m', + 'Fblue': '\x1b[34m', + 'Fyellow': '\x1b[93m', + 'Fmagenta': '\x1b[35m', + 'Fcyan': '\x1b[36m', + 'Fgray': '\x1b[90m', + 'FbrightRed': '\x1b[91m', + 'FbrightGreen': '\x1b[92m', + 'FbrightYellow': '\x1b[93m', + 'FbrightBlue': '\x1b[94m', + 'FbrightMagenta': '\x1b[95m', + 'FbrightCyan': '\x1b[96m', + 'FbrightWhite': '\x1b[97m', + 'Freset': '\x1b[0m', + 'Default': '\x1b[0m' +}; + +module.exports = colorsSet; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/defaults.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/defaults.js new file mode 100644 index 000000000000..15ab38e8341b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/defaults.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +/** +* Method which return the default option. +* +* @private +* @name defaults +* @returns {Object} - out +*/ +function defaults( ) { + var out = {}; + + // Boolean indicating whether to automatically re-render on a `change` event: + out.autoRender = false; + + // Boolean indicating whether to automatically re-render on a `change` event: + out.autoInitialization = false; + + // Default background color code + out.backgroundColor = 'Bwhite'; + + // Default foreground color code + out.foregroundColor = 'Fblack'; + + out.ticsLabelBckColor = 'Bwhite'; + + // Default glyph code + out.glyph = 'space'; + + // Default horizontel tics glyph + out.horizontalTicsGlyph = 'topTee'; + + // Default horizontel tics glyph + out.horizontalAxisGlyph = 'horizontal'; + + out.axisIntersectionGlyph = 'crossIntersection'; + + // Default plot area height + out.plotAreaHeight = 15; + + // Default plot area height + out.plotAreaWidth = 80; + + // Default vertical tics glyph + out.verticalTicsGlyph = 'rightTee'; + + // Default vertical tics glyph + out.verticalAxisGlyph = 'vertical'; + + // Label formate + out.labelFormate = [ '%s', '%s', '%s', '%s' ]; + + // Axis tics Labels + out.xAxisTicsLabels = []; + out.yAxisTicsLabels = []; + out.zAxisTicsLabels = []; + out.wAxisTicsLabels = []; + + out.axisTicsLabels = [ out.xAxisTicsLabels, out.yAxisTicsLabels, out.zAxisTicsLabels, out.wAxisTicsLabels ]; + + out.xAxisPos = 0; + out.yAxisPos = 0; + out.zAxisPos = 0; + out.wAxisPos = 0; + + out.xAxis = false; + out.yAxis = false; + out.zAxis = false; + out.wAxis = false; + + out.xTicSpacing = 1; + out.yTicSpacing = 1; + out.zTicSpacing = 1; + out.wTicSpacing = 1; + out.ticsSpacing = [ out.xTicSpacing, out.yTicSpacing, out.zTicSpacing, out.zTicSpacing ]; + + out.xTicsLabelSpace = 1; + out.yTicsLabelSpace = 1; + out.zTicsLabelSpace = 1; + out.wTicsLabelSpace = 1; + + return out; +} + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/every_by2.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/every_by2.js new file mode 100644 index 000000000000..7ce28c7872ed --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/every_by2.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 // + +/** +* Tests whether all element pairs from two arrays pass a test implemented by a binary predicate function. +* +* @private +* @param {Collection} x - first input array +* @param {Collection} y - second input array +* @param {Function} predicate - predicate function +* @param {*} thisArg - predicate function execution context +* @returns {boolean} boolean indicating whether all elements pass a test +*/ +function everyBy2( x, y, predicate, thisArg ) { // FIXME: move to array/base + var len; + var i; + + len = x.length; + if ( len !== y.length ) { + return false; + } + for ( i = 0; i < len; i++ ) { + if ( !predicate.call( thisArg, x[ i ], y[ i ], i, [ x, y ] ) ) { + return false; + } + } + return true; +} + + +// EXPORTS // + +module.exports = everyBy2; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/forground-color.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/forground-color.js new file mode 100644 index 000000000000..6bc34e513cda --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/forground-color.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var isValidForegroundColor = require( './utils/is-valid-foreground-color.js' ); +var isValidRowCol = require( './utils/is-valid-row-col.js' ); + +/** +* Set forground color on specific row and col. +* +* @private +* @name setForegroundColor +* @param {number} row - row number +* @param {number} col - col number +* @param {string} color - color name +* @param {boolean} overwrite - overwrite +* @param {boolean} safeArea - safeArea +* @returns {void} +*/ +function setForgroundColor( row, col, color, overwrite, safeArea ) { + var a; + var b; + var r; + var c; + + r = row; + c = col; + if ( safeArea ) { + r = this.getSafeRow( row ); + c = this.getSafeColumn( col ); + } + + a = ( isValidRowCol( r, c, this._height, this._width ) && isValidForegroundColor( color ) ); + + // If color is already set to default we can change it + b = a && ( overwrite || this._foregroundColorMatrix[ r ][ c ] === this._foregroundColor ); + if ( b ) { + this._foregroundColorMatrix[ r ][ c ] = color; + } +} + +module.exports = setForgroundColor; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/glyph.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/glyph.js new file mode 100644 index 000000000000..7c04172ceb49 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/glyph.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var isValidGlyph = require( './utils/is-valid-glyph.js' ); +var isValidRowCol = require( './utils/is-valid-row-col.js' ); + +/** +* Method to add glyph. +* +* @private +* @name setGlyph +* @param {number} row - row number +* @param {number} col - col number +* @param {string} glyph - glyph name +* @param {boolean} overwrite - overwrite +* @param {boolean} safeArea - safeArea +* @returns {void} +*/ +function setGlyph( row, col, glyph, overwrite, safeArea ) { + var a; + var b; + var r; + var c; + + r = row; + c = col; + if ( safeArea ) { + r = this.getSafeRow( row ); + c = this.getSafeColumn( col ); + } + a = ( isValidRowCol( r, c, this._height, this._width ) && isValidGlyph( glyph ) ); + + // If glyph is already set to default we can change it + b = a && ( overwrite || this._glyphMatrix[ r ][ c ] === this._glyph ); + + if ( b ) { + this._glyphMatrix[ r ][ c ] = glyph; + } +} + +module.exports = setGlyph; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/glyphs-set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/glyphs-set.js new file mode 100644 index 000000000000..418c125e278f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/glyphs-set.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 fromCodePoint = require( '@stdlib/string/from-code-point' ); + +var i; +var glyphsSet = { + 'space': ' ', + 'null': '', + 'block': '█', + 'vertical': '│', + 'horizontal': '─', + 'verticalTic': '', + 'LBcorner': '└', + 'RBcorner': '┘', + 'LTcorner': '┌', + 'RTcorner': '┐', + 'topTee': '┬', + 'rightTee': '┤', + 'bottomTee': '┴', + 'leftTee': '├', + 'crossIntersection': '┼', + 'dot': '.' +}; + +// Standard Keyboard Characters + +for ( i = 32; i < 127; i++ ) { + glyphsSet[ 'asci' + i.toString() ] = fromCodePoint( i ); +} +module.exports = glyphsSet; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/index.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/index.js new file mode 100644 index 000000000000..ee95d7506474 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/index.js @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Create a Base plot. +* +* @module @stdlib/plot/unicode/base +*/ +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/initialize.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/initialize.js new file mode 100644 index 000000000000..da33d4439e9d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/initialize.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var normalize = require( './normalize.js' ); + +/** +* Initialize the array on the bases of calculated require row and col. +* +* @private +* @name initialize +* @returns {void} +*/ +function initialize() { + var bckColorArr; + var frdColorArr; + var glyphArr; + var val; + var i; + var j; + + this._plotArea = {}; + if ( this._axisDataObjs ) { + // X axis + if ( this._axisDataObjs[ 0 ].axis ) { + // Resizing the normalizeLabels array + this._axisDataObjs[ 0 ].normalizeLabels.length = this._axisDataObjs[ 0 ].rawLabels.length; + for ( i = 0; i < this._axisDataObjs[ 0 ].rawLabels.length; i++ ) { + val = normalize( this._axisDataObjs[ 0 ].rawLabels[ i ], this._axisDataObjs[ 0 ].labelFormate, 'graphemes' ); + this._axisDataObjs[ 0 ].normalizeLabels[ i ] = val; + } + } + + // Y axis + if ( this._axisDataObjs[ 1 ].axis ) { + // Resizing the normalizeLabels array + this._axisDataObjs[ 1 ].normalizeLabels.length = this._axisDataObjs[ 1 ].rawLabels.length; + for ( i = 0; i < this._axisDataObjs[ 1 ].rawLabels.length; i++ ) { + val = normalize( this._axisDataObjs[ 1 ].rawLabels[ i ], this._axisDataObjs[ 1 ].labelFormate, 'graphemes' ); + this._axisDataObjs[ 1 ].normalizeLabels[ i ] = val; + } + } + + // Z Axis + if ( this._axisDataObjs[ 2 ].axis ) { + // Resizing the normalizeLabels array + this._axisDataObjs[ 2 ].normalizeLabels.length = this._axisDataObjs[ 2 ].rawLabels.length; + for ( i = 0; i < this._axisDataObjs[ 2 ].rawLabels.length; i++ ) { + val = normalize( this._axisDataObjs[ 2 ].rawLabels[ i ], this._axisDataObjs[ 2 ].labelFormate, 'graphemes' ); + this._axisDataObjs[ 2 ].normalizeLabels[ i ] = val; + } + } + + // W axis + if ( this._axisDataObjs[ 3 ].axis ) { + // Resizing the normalizeLabels array + this._axisDataObjs[ 3 ].normalizeLabels.length = this._axisDataObjs[ 3 ].rawLabels.length; + for ( i = 0; i < this._axisDataObjs[ 3 ].rawLabels.length; i++ ) { + val = normalize( this._axisDataObjs[ 3 ].rawLabels[ i ], this._axisDataObjs[ 3 ].labelFormate, 'graphemes' ); + this._axisDataObjs[ 3 ].normalizeLabels[ i ] = val; + } + } + } + + // Setting plot area + // Note: plotArea provide the bounderis of the plot area ( it is the area where actual plot representation is present ) + this._plotArea.x = ( !this.xAxisPos ) * ( this.xTicsLabelSpace ); // Zero indexed + this._plotArea.y = ( !this.yAxisPos ) * ( this.yTicsLabelSpace ); // Zero indexed + this._plotArea.z = this._plotAreaWidth + this.xTicsLabelSpace + ( ( this.zAxisPos < this.plotAreaWidth - 1 ) ? this.zTicsLabelSpace : 0 ) - 1; // Zero indexed + this._plotArea.w = this._plotAreaHeight + this.yTicsLabelSpace + ( ( this.wAxisPos < this.plotAreaHeight - 1 ) ? this.wTicsLabelSpace : 0 ) - 1; // Zero indexed + + // Setting height and width for the matrix array + this._height = ( this.yTicsLabelSpace * this.yAxis ) + ( this.wTicsLabelSpace * this.wAxis ) + this._plotAreaHeight; // Axis tics space + plotAreaHeight + this._width = ( this.xTicsLabelSpace * this.xAxis ) + ( this.zTicsLabelSpace * this.zAxis ) + this._plotAreaWidth; // Axis tics space + plotAreaWidth + + // Initializing the metrices + this._glyphMatrix.length = this._height; + this._backgroundColorMatrix.length = this._height; + this._foregroundColorMatrix.length = this._height; + for ( i = 0; i < this._height; i++ ) { + bckColorArr = []; + frdColorArr = []; + glyphArr = []; + for ( j = 0; j < this._width; j++ ) { + glyphArr.push( this.glyph ); + frdColorArr.push( this.foregroundColor ); + bckColorArr.push( this.backgroundColor ); + } + this._glyphMatrix[ i ] = glyphArr; + this._backgroundColorMatrix[ i ] = bckColorArr; + this._foregroundColorMatrix[ i ] = frdColorArr; + } +} + +module.exports = initialize; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/main.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/main.js new file mode 100644 index 000000000000..63829e5e2fc5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/main.js @@ -0,0 +1,863 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-lines */ + +'use strict'; + +// MODULES // + +var EventEmitter = require( 'events' ).EventEmitter; +var logger = require( 'debug' ); +var setReadWriteAccessor = require( '@stdlib/utils/define-nonenumerable-read-write-accessor' ); +var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var defineProperty = require( '@stdlib/utils/define-property' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var inherit = require( '@stdlib/utils/inherit' ); +var isObject = require( '@stdlib/assert/is-plain-object' ); +var pick = require( '@stdlib/utils/pick' ); +var format = require( '@stdlib/string/format' ); +var defaults = require( './defaults.js' ); +var setAutoRender = require( './props/auto-render/set.js' ); +var getAutoRender = require( './props/auto-render/get.js' ); +var setAutoInitialization = require( './props/auto-initialization/set.js' ); +var getAutoInitialization = require( './props/auto-initialization/get.js' ); +var setAxisTicsLabels = require( './props/axis-tics-labels/set.js' ); +var getAxisTicsLabels = require( './props/axis-tics-labels/get.js' ); +var setXAxisPos = require( './props/x-axis-pos/set.js' ); +var getXAxisPos = require( './props/x-axis-pos/get.js' ); +var setYAxisPos = require( './props/y-axis-pos/set.js' ); +var getYAxisPos = require( './props/y-axis-pos/get.js' ); +var setZAxisPos = require( './props/z-axis-pos/set.js' ); +var getZAxisPos = require( './props/z-axis-pos/get.js' ); +var setWAxisPos = require( './props/w-axis-pos/set.js' ); +var getWAxisPos = require( './props/w-axis-pos/get.js' ); +var setXAxis = require( './props/x-axis/set.js' ); +var getXAxis = require( './props/x-axis/get.js' ); +var setYAxis = require( './props/y-axis/set.js' ); +var getYAxis = require( './props/y-axis/get.js' ); +var setZAxis = require( './props/z-axis/set.js' ); +var getZAxis = require( './props/z-axis/get.js' ); +var setWAxis = require( './props/w-axis/set.js' ); +var getWAxis = require( './props/w-axis/get.js' ); +var setWAxisTicsLabels = require( './props/w-axis-tics-labels/set.js' ); +var getWAxisTicsLabels = require( './props/w-axis-tics-labels/get.js' ); +var setXAxisTicsLabels = require( './props/x-axis-tics-labels/set.js' ); +var getXAxisTicsLabels = require( './props/x-axis-tics-labels/get.js' ); +var setYAxisTicsLabels = require( './props/y-axis-tics-labels/set.js' ); +var getYAxisTicsLabels = require( './props/y-axis-tics-labels/get.js' ); +var setZAxisTicsLabels = require( './props/z-axis-tics-labels/set.js' ); +var getZAxisTicsLabels = require( './props/z-axis-tics-labels/get.js' ); +var setBackgroundColor = require( './props/background-color/set.js' ); +var backgroundColor = require( './background-color.js' ); +var foregroundColor = require( './forground-color.js' ); +var glyph = require( './glyph.js' ); +var bar = require( './bar.js' ); +var string = require( './string.js' ); +var getBackgroundColor = require( './props/background-color/get.js' ); +var setForegroundColor = require( './props/foreground-color/set.js' ); +var getForegroundColor = require( './props/foreground-color/get.js' ); +var setAxisTicsLabelBckColor = require( './props/tics-labels-bck-color/set.js' ); +var getAxisTicsLabelBckColor = require( './props/tics-labels-bck-color/get.js' ); +var setGlyph = require( './props/glyph/set.js' ); +var getGlyph = require( './props/glyph/get.js' ); +var getHeight = require( './props/height/get.js' ); +var setHorizontalTicsGlyph = require( './props/horizontal-tics-glyph/set.js' ); +var getHorizontalTicsGlyph = require( './props/horizontal-tics-glyph/get.js' ); +var setAxisIntersectionGlyph = require( './props/axis-intersection-glyph/set.js' ); +var getAxisIntersectionGlyph = require( './props/axis-intersection-glyph/get.js' ); +var setHorizontalAxisGlyph = require( './props/horizontal-axis-glyph/set.js' ); +var getHorizontalAxisGlyph = require( './props/horizontal-axis-glyph/get.js' ); +var setVerticalAxisGlyph = require( './props/vertical-axis-glyph/set.js' ); +var getVerticalAxisGlyph = require( './props/vertical-axis-glyph/get.js' ); +var setLabelFormate = require( './props/label-formate/set.js' ); +var getLabelFormate = require( './props/label-formate/get.js' ); +var setPlotAreaHeight = require( './props/plot-area-height/set.js' ); +var getPlotAreaHeight = require( './props/plot-area-height/get.js' ); +var setPlotAreaWidth = require( './props/plot-area-width/set.js' ); +var getPlotAreaWidth = require( './props/plot-area-width/get.js' ); +var setTicsStride = require( './props/tics-spacing/set.js' ); +var getTicsStride = require( './props/tics-spacing/get.js' ); +var setXTicSpacing = require( './props/x-tic-spacing/set.js' ); +var getXTicSpacing = require( './props/x-tic-spacing/get.js' ); +var setYTicSpacing = require( './props/y-tic-spacing/set.js' ); +var getYTicSpacing = require( './props/y-tic-spacing/get.js' ); +var setZTicSpacing = require( './props/z-tic-spacing/set.js' ); +var getZTicSpacing = require( './props/z-tic-spacing/get.js' ); +var setWTicSpacing = require( './props/w-tic-spacing/set.js' ); +var getWTicSpacing = require( './props/w-tic-spacing/get.js' ); +var setVerticalTicsGlyph = require( './props/vertical-tics-glyph/set.js' ); +var setXTicsLabelSpace = require( './props/x-tics-label-space/set.js' ); +var getXTicsLabelSpace = require( './props/x-tics-label-space/get.js' ); +var setYTicsLabelSpace = require( './props/y-tics-label-space/set.js' ); +var getYTicsLabelSpace = require( './props/y-tics-label-space/get.js' ); +var setZTicsLabelSpace = require( './props/z-tics-label-space/set.js' ); +var getZTicsLabelSpace = require( './props/z-tics-label-space/get.js' ); +var setWTicsLabelSpace = require( './props/w-tics-label-space/set.js' ); +var getWTicsLabelSpace = require( './props/w-tics-label-space/get.js' ); +var getVerticalTicsGlyph = require( './props/vertical-tics-glyph/get.js' ); +var getSafeRow = require( './safe-row.js' ); +var getSafeColumn = require( './safe-column.js' ); +var getWidth = require( './props/width/get.js' ); +var getPlotArea = require( './props/plot-area/get.js' ); +var render = require( './render.js' ); +var initialize = require( './initialize.js' ); + + +// VARIABLES // + +var debug = logger( 'table:unicode:main' ); + +// List of private properties (note: keep in alphabetical order): +var PRIVATE_PROPS = [ + '_autoInitialization', + '_autoRender', + '_axisIntersectionGlyph', + '_axisTicsLabelBckColor', + '_backgroundColor', + '_foregroundColor', + '_glyph', + '_height', + '_horizontalAxisGlyph', + '_horizontalTicsGlyph', + '_plotArea', + '_plotAreaHeight', + '_plotAreaWidth', + '_quiet', + '_ticsLabelsBckColor', + '_verticalAxisGlyph', + '_verticalTicsGlyph', + '_width' +]; + +// List of options properties (note: keep in alphabetical order): +var OPTIONS_PROPS = [ + 'autoInitialization', + 'autoRender', + 'axisIntersectionGlyph', + 'axisTicsLabels', + 'backgroundColor', + 'foregroundColor', + 'glyph', + 'horizontalAxisGlyph', + 'horizontalTicsGlyph', + 'labelFormate', + 'plotAreaHeight', + 'plotAreaWidth', + 'ticsLabelsBckColor', + 'ticsSpacing', + 'verticalAxisGlyph', + 'verticalTicsGlyph', + 'wAxis', + 'wAxisPos', + 'wAxisTicsLabels', + 'wTicsLabelSpace', + 'wTicsSpacing', + 'xAxis', + 'xAxisPos', + 'xAxisTicsLabels', + 'xTicsLabelSpace', + 'xTicsSpacing', + 'yAxis', + 'yAxisPos', + 'yAxisTicsLabels', + 'yTicsLabelSpace', + 'yTicsSpacing', + 'zAxis', + 'zAxisPos', + 'zAxisTicsLabels', + 'zTicsLabelSpace', + 'zTicsSpacing' +]; + + +// FUNCTIONS // + +/** +* Initializes private instance properties. +* +* @private +* @param {PlotBase} plotBase - plotBase instance +* @param {Object} defaults - default property values +* @returns {PlotBase} plotBase instance +*/ +function initializePrivateProperties( plotBase, defaults ) { // eslint-disable-line id-length + var definedValue; + var i; + for ( i = 0; i < PRIVATE_PROPS.length; i++ ) { + definedValue = defaults[ PRIVATE_PROPS[ i ].substring( 1 ) ]; + defineProperty( plotBase, PRIVATE_PROPS[ i ], { + 'configurable': false, + 'enumerable': false, + 'writable': true, + + // eslint-disable-next-line no-undefined + 'value': ( definedValue === undefined ) ? null : definedValue + }); + } + return plotBase; +} + + +// MAIN // + +/** +* Unicode table constructor. +* +* @constructor +* @param {Options} [options] - plot base options +* @param {boolean} [option.autoInitialization] - plot base options +* @param {boolean} [option.autoRender] - plot base options +* @param {string} [option.axisIntersectionGlyph='crossIntersection'] - plot base options +* @param {Array} [option.axisTicsLabels=[ [], [], [], [] ]] - plot base options +* @param {string} [option.backgroundColor='Bwhite'] - plot base options +* @param {string} [option.foregroundColor='Fblack'] - plot base options +* @param {string} [option.glyph='space'] - plot base options +* @param {string} [option.horizontalTicsGlyph='topTee'] - plot base options +* @param {string} [option.horizontalAxisGlyph='horizontal'] - plot base options +* @param {Array} [option.labelFormate=[ '%s', '%s', '%s', '%s']] - plot base options +* @param {NonNegativeInteger} [option.ploatAreaHeight=15] - plot base options +* @param {NonNegativeInteger} [option.plotAreaWidth=80] - plot base options +* @param {string} [option.ticsLabelsBckColor='Bwhite'] - plot base options +* @param {Array} [option.ticsSpacing=[ 1, 1, 1, 1]] - plot base options +* @param {string} [option.ticsLabelFrdColor='Fblack'] - plot base options +* @param {string} [option.verticalAxisGlyph='vertical'] - plot base options +* @param {NonNegativeInteger} [option.verticalTicsGlyph=80] - plot base options +* @param {boolean} [option.wAxis=false] - plot base options +* @param {NonNegativeInteger} [option.wAxisPos=0] - plot base options +* @param {Array} [option.wAxisTicsLabels=[]] - plot base options +* @param {NonNegativeInteger} [option.wTicsLabelSpace=1] - plot base options +* @param {NonNegativeInteger} [option.wTicsSpacing=1] - plot base options +* @param {boolean} [option.xAxis=false] - plot base options +* @param {NonNegativeInteger} [option.xAxisPos=0] - plot base options +* @param {Array} [option.xAxisTicsLabels=[]] - plot base options +* @param {NonNegativeInteger} [option.xTicsLabelSpace=1] - plot base options +* @param {NonNegativeInteger} [option.xTicsSpacing=1] - plot base options +* @param {boolean} [option.yAxis=false] - plot base options +* @param {NonNegativeInteger} [option.yAxisPos=0] - plot base options +* @param {Array} [option.yAxisTicsLabels=[]] - plot base options +* @param {NonNegativeInteger} [option.yTicsLabelSpace=1] - plot base options +* @param {NonNegativeInteger} [option.yTicsSpacing=1] - plot base options +* @param {boolean} [option.zAxis=false] - plot base options +* @param {NonNegativeInteger} [option.zAxisPos=0] - plot base options +* @param {Array} [option.zAxisTicsLabels=[]] - plot base options +* @param {NonNegativeInteger} [option.zTicsLabelSpace=1] - plot base options +* @param {NonNegativeInteger} [option.zTicsSpacing=1] - plot base options +* @throws {TypeError} data argument must be an object, an array of objects, an array of arrays, or a two-dimensional ndarray +* @throws {TypeError} options argument must be an object +* @throws {TypeError} must provide valid options +* @returns {PlotBase} plotBase instance +*/ +function PlotBase() { + var options; + var nargs; + var opts; + var keys; + var self; + var key; + var i; + + nargs = arguments.length; + if ( !( this instanceof PlotBase ) ) { + if ( nargs === 0 ) { + return new PlotBase(); + } + return new PlotBase( arguments[ 0 ] ); + } + + defineProperty( this, '_axisDataObjs', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [ + // X + { + 'rawLabels': [], + 'normalizeLabels': [], + 'labelFormate': '%s', + 'axis': false, + 'ticsSpacing': 1, + 'position': 'default', + 'ticsLabelSpace': 1, + 'axisPos': 0 + }, + + // Y + { + 'rawLabels': [], + 'normalizeLabels': [], + 'labelFormate': '%s', + 'axis': false, + 'ticsSpacing': 1, + 'position': 'default', + 'ticsLabelSpace': 1, + 'axisPos': 0 + }, + + // Z + { + 'rawLabels': [], + 'normalizeLabels': [], + 'labelFormate': '%s', + 'axis': false, + 'ticsSpacing': 1, + 'position': 'default', + 'ticsLabelSpace': 1, + 'axisPos': 0 + }, + + // W + { + 'rawLabels': [], + 'normalizeLabels': [], + 'labelFormate': '%s', + 'axis': false, + 'ticsSpacing': 1, + 'position': 'default', + 'ticsLabelSpace': 1, + 'axisPos': 0 + } + ] + }); + defineProperty( this, '_foregroundColorMatrix', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + defineProperty( this, '_backgroundColorMatrix', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + defineProperty( this, '_glyphMatrix', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + + // Initialize private instance properties: + initializePrivateProperties( this, defaults() ); + this._quiet = false; + + // Resolve input arguments... + if ( nargs === 0 ) { + options = {}; + } else { + options = arguments[ 0 ]; + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + } + + // Extract provided options while ignoring any extraneous/unsupported options properties: + opts = pick( options, OPTIONS_PROPS ); + debug( 'Creating an instance with the following configuration: %s.', JSON.stringify( opts ) ); + + // Validate provided options by assigning values to plotBase properties... + keys = objectKeys( opts ); + for ( i = 0; i < keys.length; i++ ) { + key = keys[ i ]; + this[ key ] = opts[ key ]; + } + + // Add event listeners: + this.on( 'change', onChange ); + this.on( 'render', onRender ); + this.on( 'initialize', onInitalization ); + self = this; + return this; + + /** + * Callback invoked upon receiving a `change` event. + * + * @private + */ + function onChange() { + /* eslint-disable no-underscore-dangle */ + debug( 'Received a change event.' ); + if ( self._autoRender ) { + self.render(); + } + } + + /** + * Callback invoked upon receiving a `render` event. + * + * @private + * @param {string} str - render string + */ + function onRender() { + debug( 'Received a render event.' ); + } + + /** + * Callback invoked upon receiving a `initialize` event. + * + * @private + * @param {string} table - rendered table + */ + function onInitalization() { + debug( 'Received a initialize event.' ); + if ( self.autoInitialization ) { + self.initialize(); + } + } +} + +/* +* Inherit from the `EventEmitter` prototype. +*/ +inherit( PlotBase, EventEmitter ); + +/** +* Initialization mode. +* +* ## Notes +* +* - If `true`, an instance automatically re-initialize a plot base on each `initialize` event. +* +* @name autoInitialization +* @memberof UnicodeTable.prototype +* @type {boolean} +* @throws {TypeError} must be a boolean +* @default false +* +* @example +* var plotBase = new PlotBase(); +* +* plotBase.autoInitialization = true; +* +* var v = plotBase.autoInitialization; +* // returns true +*/ +setReadWriteAccessor( PlotBase.prototype, 'autoInitialization', getAutoInitialization, setAutoInitialization ); + +/** +* Rendering mode. +* +* ## Notes +* +* - If `true`, an instance automatically re-renders a base plot on each `change` event. +* +* @name autoRender +* @memberof UnicodeTable.prototype +* @type {boolean} +* @throws {TypeError} must be a boolean +* @default false +* +* @example +* var plotBase = new PlotBase(); +* +* plotBase.autoRender = true; +* +* var v = plotBase.autoRender; +* // returns true +*/ +setReadWriteAccessor( PlotBase.prototype, 'autoRender', getAutoRender, setAutoRender ); + +/** +* @name axisIntersectionGlyph +* @memberof PlotBase.prototype +* @type {string} +* @throws {TypeError} must be valid glyph code string +*/ +setReadWriteAccessor( PlotBase.prototype, 'axisIntersectionGlyph', getAxisIntersectionGlyph, setAxisIntersectionGlyph ); + +/** +* @name axisTicsLabels +* @memberof PlotBase.prototype +* @type {Array} +* @throws {TypeError} must be an array +*/ +setReadWriteAccessor( PlotBase.prototype, 'axisTicsLabels', getAxisTicsLabels, setAxisTicsLabels ); + +/** +* @name backgroundColor +* @memberof PlotBase.prototype +* @type {string} +* @throws {TypeError} must be valid background color code string +*/ +setReadWriteAccessor( PlotBase.prototype, 'backgroundColor', getBackgroundColor, setBackgroundColor ); + +/** +* @name foregroundColor +* @memberof PlotBase.prototype +* @type {string} +* @throws {TypeError} must be valid foreground color code string +*/ +setReadWriteAccessor( PlotBase.prototype, 'foregroundColor', getForegroundColor, setForegroundColor ); + +/** +* @name glyph +* @memberof PlotBase.prototype +* @type {string} +* @throws {TypeError} must be valid glyph code string +*/ +setReadWriteAccessor( PlotBase.prototype, 'glyph', getGlyph, setGlyph ); + +/** +* @name horizontalAxisGlyph +* @memberof PlotBase.prototype +* @type {string} +* @throws {TypeError} must be valid glyph code string +*/ +setReadWriteAccessor( PlotBase.prototype, 'horizontalAxisGlyph', getHorizontalAxisGlyph, setHorizontalAxisGlyph ); + +/** +* @name horiontalTicsGlyph +* @memberof PlotBase.prototype +* @type {string} +* @throws {TypeError} must be valid glyph code string +*/ +setReadWriteAccessor( PlotBase.prototype, 'horizontalTicsGlyph', getHorizontalTicsGlyph, setHorizontalTicsGlyph ); + +/** +* @name labelFormate +* @memberof PlotBase.prototype +* @type {Array} +* @throws {TypeError} must be the array of string type with formates string +*/ +setReadWriteAccessor( PlotBase.prototype, 'labelFormate', getLabelFormate, setLabelFormate ); + +/** +* @name plotAreaHeight +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be non negative number +*/ +setReadWriteAccessor( PlotBase.prototype, 'plotAreaHeight', getPlotAreaHeight, setPlotAreaHeight ); + +/** +* @name plotAreaWidth +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be non negative number +*/ +setReadWriteAccessor( PlotBase.prototype, 'plotAreaWidth', getPlotAreaWidth, setPlotAreaWidth ); + +/** +* @name ticsLabelsBckColor +* @memberof PlotBase.prototype +* @type {string} +* @throws {TypeError} must be valid background color code string +*/ +setReadWriteAccessor( PlotBase.prototype, 'ticsLabelsBckColor', getAxisTicsLabelBckColor, setAxisTicsLabelBckColor ); + +/** +* @name ticsSpacing +* @memberof PlotBase.prototype +* @type {Array} +* @throws {TypeError} must be an array +*/ +setReadWriteAccessor( PlotBase.prototype, 'ticsSpacing', getTicsStride, setTicsStride ); + +/** +* @name verticalAxisGlyph +* @memberof PlotBase.prototype +* @type {string} +* @throws {TypeError} must be valid glyph code string +*/ +setReadWriteAccessor( PlotBase.prototype, 'verticalAxisGlyph', getVerticalAxisGlyph, setVerticalAxisGlyph ); + +/** +* @name verticalTicsGlyph +* @memberof PlotBase.prototype +* @type {string} +* @throws {TypeError} must be an valid glyph string code +*/ +setReadWriteAccessor( PlotBase.prototype, 'verticalTicsGlyph', getVerticalTicsGlyph, setVerticalTicsGlyph ); + +/** +* @name wAxis +* @memberof PlotBase.prototype +* @type {Array} +* @throws {TypeError} must be a boolean +*/ +setReadWriteAccessor( PlotBase.prototype, 'wAxis', getWAxis, setWAxis ); + +/** +* @name wAxisPos +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be a NonNegativeInteger +*/ +setReadWriteAccessor( PlotBase.prototype, 'wAxisPos', getWAxisPos, setWAxisPos ); + +/** +* @name wAxisTicsLabels +* @memberof PlotBase.prototype +* @type {Array} +* @throws {TypeError} must be a array +*/ +setReadWriteAccessor( PlotBase.prototype, 'wAxisTicsLabels', getWAxisTicsLabels, setWAxisTicsLabels ); + +/** +* @name wTicsLabelSpace +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be an array +*/ +setReadWriteAccessor( PlotBase.prototype, 'wTicsLabelSpace', getWTicsLabelSpace, setWTicsLabelSpace ); + +/** +* @name wTicsSpacing +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be an non negative number +*/ +setReadWriteAccessor( PlotBase.prototype, 'wTicsSpacing', getWTicSpacing, setWTicSpacing ); + +/** +* @name xAxis +* @memberof PlotBase.prototype +* @type {boolean} +* @throws {TypeError} must be a boolean +*/ +setReadWriteAccessor( PlotBase.prototype, 'xAxis', getXAxis, setXAxis ); + +/** +* @name xAxisPos +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be a NonNegativeInteger +*/ +setReadWriteAccessor( PlotBase.prototype, 'xAxisPos', getXAxisPos, setXAxisPos ); + +/** +* @name xAxisTicsLabels +* @memberof PlotBase.prototype +* @type {Array} +* @throws {TypeError} must be a array +*/ +setReadWriteAccessor( PlotBase.prototype, 'xAxisTicsLabels', getXAxisTicsLabels, setXAxisTicsLabels ); + +/** +* @name xTicsLabelSpace +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be an array +*/ +setReadWriteAccessor( PlotBase.prototype, 'xTicsLabelSpace', getXTicsLabelSpace, setXTicsLabelSpace ); + +/** +* @name xTicsSpacing +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be an array +*/ +setReadWriteAccessor( PlotBase.prototype, 'xTicsSpacing', getXTicSpacing, setXTicSpacing ); + +/** +* @name yAxis +* @memberof PlotBase.prototype +* @type {boolean} +* @throws {TypeError} must be a boolean +*/ +setReadWriteAccessor( PlotBase.prototype, 'yAxis', getYAxis, setYAxis ); + +/** +* @name yAxisPos +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be a NonNegativeInteger +*/ +setReadWriteAccessor( PlotBase.prototype, 'yAxisPos', getYAxisPos, setYAxisPos ); + +/** +* @name yAxisTicsLabels +* @memberof PlotBase.prototype +* @type {Array} +* @throws {TypeError} must be a array +*/ +setReadWriteAccessor( PlotBase.prototype, 'yAxisTicsLabels', getYAxisTicsLabels, setYAxisTicsLabels ); + +/** +* @name yTicsLabelSpace +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be an array +*/ +setReadWriteAccessor( PlotBase.prototype, 'yTicsLabelSpace', getYTicsLabelSpace, setYTicsLabelSpace ); + +/** +* @name yTicsSpacing +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be an array +*/ +setReadWriteAccessor( PlotBase.prototype, 'yTicsSpacing', getYTicSpacing, setYTicSpacing ); + +/** +* @name zAxis +* @memberof PlotBase.prototype +* @type {boolean} +* @throws {TypeError} must be a boolean +*/ +setReadWriteAccessor( PlotBase.prototype, 'zAxis', getZAxis, setZAxis ); + +/** +* @name zAxisPos +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be a NonNegativeInteger +*/ +setReadWriteAccessor( PlotBase.prototype, 'zAxisPos', getZAxisPos, setZAxisPos ); + +/** +* @name zAxisTicsLabels +* @memberof PlotBase.prototype +* @type {Array} +* @throws {TypeError} must be a array +*/ +setReadWriteAccessor( PlotBase.prototype, 'zAxisTicsLabels', getZAxisTicsLabels, setZAxisTicsLabels ); + +/** +* @name zTicsLabelSpace +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be an array +*/ +setReadWriteAccessor( PlotBase.prototype, 'zTicsLabelSpace', getZTicsLabelSpace, setZTicsLabelSpace ); + +/** +* @name zTicsSpacing +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be an array +*/ +setReadWriteAccessor( PlotBase.prototype, 'zTicsSpacing', getZTicSpacing, setZTicSpacing ); + +/** +* @name width +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +*/ +setReadOnlyAccessor( PlotBase.prototype, 'width', getWidth ); + +/** +* @name height +* @memberof PlotBase.prototype +* @type {NonNegativeInteger} +*/ +setReadOnlyAccessor( PlotBase.prototype, 'height', getHeight ); + +/** +* @name plotArea +* @memberof PlotBase.prototype +* @type {Object} +*/ +setReadOnlyAccessor( PlotBase.prototype, 'plotArea', getPlotArea ); + +/** +* Renders a plot. +* +* @name render +* @memberof PlotBase.prototype +* @type {Function} +* @returns {string} rendered table +*/ +setReadOnly( PlotBase.prototype, 'render', render ); + +/** +* Set background color. +* +* @name setBackgroundColor +* @memberof PlotBase.prototype +* @type {Function} +* @returns {void} +*/ +setReadOnly( PlotBase.prototype, 'setBackgroundColor', backgroundColor ); + +/** +* Set foreground color. +* +* @name setForegroundColor +* @memberof PlotBase.prototype +* @type {Function} +* @returns {void} +*/ +setReadOnly( PlotBase.prototype, 'setForegroundColor', foregroundColor ); + +/** +* Set glyph. +* +* @name glyph +* @memberof PlotBase.prototype +* @type {Function} +* @returns {void} +*/ +setReadOnly( PlotBase.prototype, 'setGlyph', glyph ); + +/** +* Set Bar. +* +* @name setBar +* @memberof PlotBase.prototype +* @type {Function} +* @returns {void} +*/ +setReadOnly( PlotBase.prototype, 'setBar', bar ); + +/** +* Set string. +* +* @name boxFrame +* @memberof PlotBase.prototype +* @type {Function} +* @returns {void} +*/ +setReadOnly( PlotBase.prototype, 'setString', string ); + +/** +* Get safe row number. +* +* @name getSafeRow +* @memberof PlotBase.prototype +* @type {Function} +* @returns {void} +*/ +setReadOnly( PlotBase.prototype, 'getSafeRow', getSafeRow ); + +/** +* Get safe column number. +* +* @name getSafeColumn +* @memberof PlotBase.prototype +* @type {Function} +* @returns {void} +*/ +setReadOnly( PlotBase.prototype, 'getSafeColumn', getSafeColumn ); + +/** +* Initialize the matrices( backgroundColorMatrix, glyphMatrix ... ). +* +* @name in +* @memberof PlotBase.prototype +* @type {Function} +* @returns {void} +*/ +setReadOnly( PlotBase.prototype, 'initialize', initialize ); + + +// EXPORTS // + +module.exports = PlotBase; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/normalize.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/normalize.js new file mode 100644 index 000000000000..92e7e69a913c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/normalize.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 format = require( '@stdlib/string/format' ); +var normalizeString = require( './normalize_string.js' ); + + +// MAIN // + +/** +* Normalizes data. +* +* @private +* @param {string} val - linear data +* @param {string} fmts - format strings +* @param {string} units - width units +* @returns {Collection} modified data buffer +*/ +function normalize( val, fmts, units ) { + var raw; + var tmp; + var v; + + raw = val; + + // Generate a formatted string: + v = format( fmts, raw ); + + // Normalize the string to a data object: + tmp = normalizeString( v, units ); + + // Cache the original datum: + tmp.raw = raw; + return tmp; +} + + +// EXPORTS // + +module.exports = normalize; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/normalize_string.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/normalize_string.js new file mode 100644 index 000000000000..8f7124d58122 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/normalize_string.js @@ -0,0 +1,209 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 splitGraphemeClusters = require( '@stdlib/string/split-grapheme-clusters' ); +var constantFunction = require( '@stdlib/utils/constant-function' ); +var wcswidth = require( './wcswidth.js' ); +var RE_ANSI = require( './ansi_regexp.js' ); + +// TODO: replace with regexp/ansi-escape-sequence + + +// FUNCTIONS // + +/** +* Removes empty strings from a list of strings. +* +* @private +* @param {StringArray} arr - array of strings +* @returns {StringArray} mutated input array +* +* @example +* var arr = [ '', 'a', 'b', '', 'c', '' ]; +* +* var out = compress( arr ); +* // returns [ 'a', 'b', 'c' ] +* +* @example +* var arr = [ '', '' ]; +* +* var out = compress( arr ); +* // returns [] +*/ +function compress( arr ) { // TODO: consider make this an array/base utility (e.g., remove falsy values; array/base/remove-falsy?) + var i; + var j; + + j = 0; + for ( i = 0; i < arr.length; i++ ) { + if ( arr[ i ] ) { + arr[ j ] = arr[ i ]; + j += 1; + } + } + arr.length = j; + return arr; +} + +/** +* Returns a mask indicating whether an element is an ANSI escape sequence. +* +* @private +* @param {StringArray} arr - array of strings +* @returns {NonNegativeIntegerArray} mask array +*/ +function ansiMask( arr ) { + var out; + var i; + + out = []; + for ( i = 0; i < arr.length; i++ ) { + out.push( ( RE_ANSI.test( arr[ i ] ) ) ? 1 : 0 ); + } + return out; +} + +/** +* Splits each string into individual grapheme clusters according to a provided mask array. +* +* @private +* @param {StringArray} arr - input array +* @param {NonNegativeIntegerArray} msk - mask array +* @returns {Array} output arrays +*/ +function splitGraphemes( arr, msk ) { + var tmp; + var oa; + var om; + var i; + var j; + + oa = []; + om = []; + for ( i = 0; i < arr.length; i++ ) { + // Check whether the string is "masked"... + if ( msk[ i ] === 1 ) { + // Copy over without splitting into grapheme clusters... + oa.push( arr[ i ] ); + om.push( msk[ i ] ); + continue; + } + tmp = splitGraphemeClusters( arr[ i ] ); + for ( j = 0; j < tmp.length; j++ ) { + oa.push( tmp[ j ] ); + om.push( msk[ i ] ); + } + } + return [ oa, om ]; +} + +/** +* Computes column widths for a list of strings according to a provided mask array. +* +* @private +* @param {StringArray} arr - input array +* @param {NonNegativeIntegerArray} msk - mask array +* @param {string} units - width units +* @returns {NonNegativeIntegerArray} list of column widths +*/ +function computeWidths( arr, msk, units ) { // TODO: eventually make this into a separate string utility package + var out; + var f; + var i; + + if ( units === 'graphemes' ) { + f = constantFunction( 1 ); + } else { // units === 'columns' + f = wcswidth; + } + + out = []; + for ( i = 0; i < arr.length; i++ ) { + if ( msk[ i ] ) { + out.push( 0 ); + } else { + out.push( f( arr[ i ] ) ); + } + } + return out; +} + +/** +* Computes the sum of an array according to a provided mask array. +* +* @private +* @param {NonNegativeIntegerArray} arr - input array +* @param {NonNegativeIntegerArray} msk - mask array +* @returns {NonNegativeInteger} sum +*/ +function sum( arr, msk ) { // TODO: replace with blas/ext/base/* msk sum package + var s; + var i; + + s = 0; + for ( i = 0; i < arr.length; i++ ) { + if ( msk[ i ] === 0 ) { + s += arr[ i ]; + } + } + return s; +} + + +// MAIN // + +/** +* Normalizes data belonging to a single table cell. +* +* @private +* @param {string} value - input string +* @param {string} units - width units +* @returns {Object} normalized results +*/ +function normalize( value, units ) { + var tmp; + var msk; + var w; + + // Split the formatted string according to whether a substring is an ANSI escape sequence: + tmp = compress( value.split( RE_ANSI ) ); + + // Create a mask array which flags whether a substring is an ANSI escape sequence: + msk = ansiMask( tmp ); + + // Expand each non-ANSI escape sequence into individual grapheme clusters: + tmp = splitGraphemes( tmp, msk ); + + // For each grapheme cluster, compute the expected width: + w = computeWidths( tmp[ 0 ], tmp[ 1 ], units ); + + return { + 'value': value, + 'graphemes': tmp[ 0 ], + 'width': sum( w, tmp[ 1 ] ) + }; +} + + +// EXPORTS // + +module.exports = normalize; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-initialization/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-initialization/get.js new file mode 100644 index 000000000000..31fa1ae0b580 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-initialization/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the initialize mode. +* +* @private +* @returns {boolean} initialize mode +*/ +function get() { + return this._autoInitialization; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-initialization/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-initialization/set.js new file mode 100644 index 000000000000..dd1a85504c2c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-initialization/set.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + +/* +Note : reinitialization will need to be occurs when there is change in size of the plot area or need to recalculate it. +*/ + +// MAIN // + +/** +* Sets the initialization mode. +* +* @private +* @param {boolean} value - boolean indicating whether to automatically re-initialize on a `initialize` event +* @throws {TypeError} must be a boolean +*/ +function set( value ) { + if ( !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', 'autoInitialization', value ) ); + } + if ( value !== this._autoInitialization ) { + this._autoInitialization = value; + if ( !this._quiet ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-render/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-render/get.js new file mode 100644 index 000000000000..cdb60cfc9c29 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-render/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the rendering mode. +* +* @private +* @returns {boolean} rendering mode +*/ +function get() { + return this._autoRender; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-render/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-render/set.js new file mode 100644 index 000000000000..90f0e2c275ff --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/auto-render/set.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the rendering mode. +* +* @private +* @param {boolean} value - boolean indicating whether to automatically re-render on a `change` event +* @throws {TypeError} must be a boolean +*/ +function set( value ) { + if ( !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', 'autoRender', value ) ); + } + if ( value !== this._autoRender ) { + this._autoRender = value; + if ( !this._quiet ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-intersection-glyph/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-intersection-glyph/get.js new file mode 100644 index 000000000000..48d0e3397d98 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-intersection-glyph/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get glyph. +* +* @private +* @returns {string} glyph +*/ +function get() { + return this._axisIntersectionGlyph; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-intersection-glyph/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-intersection-glyph/set.js new file mode 100644 index 000000000000..5a5ac9dab93f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-intersection-glyph/set.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var isValidGlyph = require( './../../utils/is-valid-glyph.js' ); + +/* +Glyphs which require to be in place intersection of the axis +*/ + +/** +* Set axis intersection glyph. +* +* @private +* @param {string} value - string indicating glyph name +* @throws {TypeError} must be a string +* @throws {Error} must be a valid glyph name +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'glyph', value ) ); + } + if ( !isValidGlyph( value ) ) { + throw new Error( format( 'invalid value, `%s` not a valid glyph value. Value: `%s`.', 'glyph', value ) ); + } + if ( this._axisIntersectionGlyph !== value ) { + this._axisIntersecctionGlyph = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-tics-labels/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-tics-labels/get.js new file mode 100644 index 000000000000..c52efc502de8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-tics-labels/get.js @@ -0,0 +1,39 @@ +/* eslint-disable max-len */ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the axis data. +* +* @private +* @returns {Array} axises data +*/ +function get() { + return [ this.xAxisTicsLabels, this.yAxisTicsLabels, this.zAxisTicsLabels, this.wAxisTicsLabels ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-tics-labels/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-tics-labels/set.js new file mode 100644 index 000000000000..170efcf97210 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/axis-tics-labels/set.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the axis tics label. +* It is the short hand for xAxisData, yAxisData, zAxisData and wAxisData +* +* @private +* @param {Collection} value - array of axis data +* @throws {TypeError} must be a array of array with length 4 +*/ +function set( value ) { + if ( !isCollection( value ) || value.length !== 4 ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a array of array with length 4. Value: `%s`.', 'axisTicsLabels', value ) ); + } + this.xAxisTicsLabels = value[ 0 ]; + this.yAxisTicsLabels = value[ 1 ]; + this.zAxisTicsLabels = value[ 2 ]; + this.wAxisTicsLabels = value[ 3 ]; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/background-color/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/background-color/get.js new file mode 100644 index 000000000000..83cd2e56e16b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/background-color/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get background color. +* +* @private +* @returns {string} background color code +*/ +function get() { + return this._backgroundColor; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/background-color/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/background-color/set.js new file mode 100644 index 000000000000..8d932edb409c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/background-color/set.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var isValidBackgroundColor = require( './../../utils/is-valid-background-color.js' ); + + +// MAIN // + +/** +* Set background color. +* +* @private +* @param {string} value - string indicating color name +* @throws {TypeError} must be a valid background color code +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'background-color', value ) ); + } + if ( !isValidBackgroundColor( value ) ) { + throw new TypeError( format( 'invalid assignment, `%s` not a valid background color code. Value: `%s`.', 'background-color', value ) ); + } + if ( value !== this._backgroundColor ) { + this._backgroundColor = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/foreground-color/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/foreground-color/get.js new file mode 100644 index 000000000000..f2d501b800c6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/foreground-color/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get background color. +* +* @private +* @returns {string} background color +*/ +function get() { + return this._foregroundColor; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/foreground-color/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/foreground-color/set.js new file mode 100644 index 000000000000..dfc8ce73f725 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/foreground-color/set.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var isValidForegroundColor = require( './../../utils/is-valid-foreground-color.js' ); + + +// MAIN // + +/** +* Set forground color. +* +* @private +* @param {string} value - string indicating color name +* @throws {TypeError} must be a valid forground color code +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'forground-color', value ) ); + } + if ( !isValidForegroundColor( value ) ) { + throw new TypeError( format( 'invalid value, `%s` must be a valid forground color code. Value: `%s`.', 'forground-color', value ) ); + } + if ( this._foregroundColor !== value ) { + this._foregroundColor = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/glyph/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/glyph/get.js new file mode 100644 index 000000000000..ce7b836dceb0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/glyph/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get glyph. +* +* @private +* @returns {string} glyph +*/ +function get() { + return this._glyph; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/glyph/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/glyph/set.js new file mode 100644 index 000000000000..e0f7b56297e5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/glyph/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var isValidGlyph = require( './../../utils/is-valid-glyph.js' ); + +/** +* Set glyph. +* +* @private +* @param {string} value - string indicating glyph name +* @throws {TypeError} must be a glyph string code +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'glyph', value ) ); + } + if ( !isValidGlyph( value ) ) { + throw new TypeError( format( 'invalid value, `%s` must be a valid glyph code. Value: `%s`.', 'glyph', value ) ); + } + if ( this._glyph !== value ) { + this._glyph = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/height/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/height/get.js new file mode 100644 index 000000000000..f249855ba273 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/height/get.js @@ -0,0 +1,39 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get height of the plot. +* this height represent the whole height which include the margin, spaces for labels and all which is calculated by base on the requirement. +* +* @private +* @returns {number} height of the whole canvas +*/ +function get() { + return this._height; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-axis-glyph/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-axis-glyph/get.js new file mode 100644 index 000000000000..e3eed75901cc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-axis-glyph/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get glyph. +* +* @private +* @returns {string} glyph +*/ +function get() { + return this._horizontalAxisGlyph; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-axis-glyph/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-axis-glyph/set.js new file mode 100644 index 000000000000..20be7b6d37de --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-axis-glyph/set.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var isValidGlyph = require( './../../utils/is-valid-glyph.js' ); + +/** +* Set horizontel axis glyph. +* Glyph to use to draw horizontel axis. +* +* @private +* @param {string} value - string indicating glyph name +* @throws {TypeError} must be a valid glyph code +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'glyph', value ) ); + } + if ( !isValidGlyph( value ) ) { + throw new TypeError( format( 'invalid value, `%s` must be a valid glyph value. Value: `%s`.', 'horizontalAxisGlyph', value ) ); + } + if ( this._horizontalAxisGlyph !== value ) { + this._horizontalAxisGlyph = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-tics-glyph/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-tics-glyph/get.js new file mode 100644 index 000000000000..82ffc92e499d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-tics-glyph/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get horizontal tics glyph. +* +* @private +* @returns {string} glyph +*/ +function get() { + return this._horizontalTicsGlyph; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-tics-glyph/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-tics-glyph/set.js new file mode 100644 index 000000000000..f0fe5e613b37 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/horizontal-tics-glyph/set.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var isValidGlyph = require( './../../utils/is-valid-glyph.js' ); + +/** +* Set horizontel tics glyph. +* Glyph to represent the tics on horizontal axis +* +* @private +* @param {string} value - string indicating glyph name +* @throws {TypeError} must be a valid glyph string code +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'horizontalTicsGlyph', value ) ); + } + if ( !isValidGlyph( value ) ) { + throw new TypeError( format( 'invalid value, `%s` must be a valid glyph code. Value: `%s`.', 'horizontalTicsGlyph', value ) ); + } + if ( this._horizontalTicsGlyph !== value ) { + this._horizontalTicsGlyph = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/label-formate/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/label-formate/get.js new file mode 100644 index 000000000000..3d37fe141e8e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/label-formate/get.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the label formate of axies. +* +* @private +* @returns {Array} axises data +*/ +function get() { + var arr = []; + var i; + + for ( i = 0; i < 4; i++ ) { + arr.push( this._axisDataObj[i].formate ); + } + return arr; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/label-formate/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/label-formate/set.js new file mode 100644 index 000000000000..76341f3dfe96 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/label-formate/set.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isStringArray = require( '@stdlib/assert/is-string-array' ); +var format = require( '@stdlib/string/format' ); + +/** +* Validate the array. +* +* @private +* @param {Collection} value - array of axises data +* @throws {TypeError} +*/ +function validate( value ) { + if ( !isStringArray( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a Array of string. Value: `%s`.', 'axis-label-format', value ) ); + } + if ( value.length !== 4 ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a Array of length 4. Value: `%s`.', 'axis-label-format', value ) ); + } +} + + +// MAIN // + +/** +* Sets the axis label formate. +* +* @private +* @param {Array} value - Array of string represent the formate string for axis labels. +* @throws {TypeError} must be array of string with length 4. +*/ +function set( value ) { + var isChange = false; + var i; + + validate( value ); + for ( i = 0; i < 4; i++ ) { + if ( this._axisDataObjs[ i ].labelFormate !== value ) { + this._axisDataObjs[ i ].labelFormate = value[ i ]; + isChange = true; + } + } + if ( isChange && !this._quite ) { + this.emit( 'change' ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-height/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-height/get.js new file mode 100644 index 000000000000..1f101cbc2e57 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-height/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get height. +* +* @private +* @returns {NonNegativeInteger} height +*/ +function set() { + return this._plotAreaHeight; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-height/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-height/set.js new file mode 100644 index 000000000000..c31dce8cd59b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-height/set.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Set plotarea height. +* Note: plot area is the spaces where the specific plot draw there plots this readonly property give row and column coordinates of this area. +* +* @private +* @param {NonNegativeInteger} value -height +* @throws {TypeError} must be a non negative number +* @throws {Error} must be a valid glyph name +*/ +function set( value ) { + if ( !isNonNegativeInteger( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a non negative number. Value: `%s`.', 'height', value ) ); + } + if ( this._plotAreaHeight !== value ) { + this._plotAreaHeight = value; + if ( !this._quite ) { + // Change in plot area require the re initialization of array of glyph, backgroundColor and foregroundColor + this.emit( 'initialize' ); + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-width/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-width/get.js new file mode 100644 index 000000000000..86cce53ae1b6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-width/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get width. +* +* @private +* @returns {NonNegativeInteger} width +*/ +function set() { + return this._plotAreaWidth; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-width/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-width/set.js new file mode 100644 index 000000000000..113e6256d3da --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area-width/set.js @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Set plotArea width. +* Note: plot area is the spaces where the specific plot draw there plots this readonly property give row and column coordinates of this area. +* +* @private +* @param {NonNegativeInteger} value - width +* @throws {TypeError} must be a non negative number +* @throws {Error} must be a valid glyph name +*/ +function set( value ) { + if ( !isNonNegativeInteger( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a non negative number. Value: `%s`.', 'width', value ) ); + } + if ( this._plotAreaWidth !== value ) { + this._plotAreaWidth = value; + if ( !this._quite ) { + // Change in plot area require the re initialization of buffer + this.emit( 'initialize' ); + + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area/get.js new file mode 100644 index 000000000000..517263d00744 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/plot-area/get.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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/utils/copy' ); + + +// MAIN // + +/** +* Get coordinates of the plotArea. +* Note: plot area is the spaces where the specific plot draw there plots this readonly property give row and column coordinates of this area. +* +* @private +* @returns {Object} plot area coordinates +*/ +function get() { + return copy( this._plotArea ); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-labels-bck-color/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-labels-bck-color/get.js new file mode 100644 index 000000000000..feda2c7d0075 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-labels-bck-color/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get axis tics label background color. +* +* @private +* @returns {string} background color code +*/ +function get() { + return this._ticsLabelsBckColor; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-labels-bck-color/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-labels-bck-color/set.js new file mode 100644 index 000000000000..d5294be90828 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-labels-bck-color/set.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var isValidBackgroundColor = require( './../../utils/is-valid-background-color.js' ); + + +// MAIN // + +/** +* Set axisTicsLabelColor. +* +* @private +* @param {string} value - string indicating color name +* @throws {TypeError} must be a valid background color code +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'ticsLabelBckColor', value ) ); + } + if ( !isValidBackgroundColor( value ) ) { + throw new TypeError( format( 'invalid assignment, `%s` not a valid background color code. Value: `%s`.', 'ticsLabelBckColor', value ) ); + } + if ( value !== this._axisTicsLabelColor ) { + this._ticsLabelsBckColor = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-spacing/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-spacing/get.js new file mode 100644 index 000000000000..83ef9d6fc2bf --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-spacing/get.js @@ -0,0 +1,39 @@ +/* eslint-disable max-len */ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the tics spacing of axies. +* +* @private +* @returns {Array} tics space of the axes +*/ +function get() { + return [ this.xTicSpacing, this.yTicSpacing, this.zTicSpacing, this.wTicSpacing ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-spacing/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-spacing/set.js new file mode 100644 index 000000000000..6af8b4693cf0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/tics-spacing/set.js @@ -0,0 +1,76 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); + +/** +* Validate the array. +* +* @private +* @param {Collection} value - array of axises data +* @throws {TypeError} +*/ +function validate( value ) { + if ( !isCollection( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a collection. Value: `%s`.', 'axis-label-format', value ) ); + } + if ( value.length !== 4 ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a Array of length 4. Value: `%s`.', 'axis-label-format', value ) ); + } +} + + +// MAIN // + +/** +* Set the tics spacing. +* Note: space require between each tics label in axis is in control of the specific plot package. +* It is the short hand for xTicSpacing, yTicSpacing, zTicSpacing and wTicSpacing +* Example : +* Tics spacing 1 +┬┬──────────────────────────────────────────────── +12 +* Tics spacing 10 +┬─────────┬─────────────────────────────────────── +1 2 +* +* @private +* @param {Array} value - Array of tics space. +* @throws {TypeError} must be a array of number with length 4 +* +* @example +*/ +function set( value ) { + validate( value ); + this.xTicsSpacing = value[ 0 ]; + this.yTicsSpacing = value[ 1 ]; + this.zTicsSpacing = value[ 2 ]; + this.wTicsSpacing = value[ 3 ]; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-axis-glyph/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-axis-glyph/get.js new file mode 100644 index 000000000000..3062f53d5588 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-axis-glyph/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get verticalAxisGlyph. +* +* @private +* @returns {string} glyph +*/ +function get() { + return this._verticalAxisGlyph; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-axis-glyph/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-axis-glyph/set.js new file mode 100644 index 000000000000..8b97c61c05b3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-axis-glyph/set.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var isValidGlyph = require( './../../utils/is-valid-glyph.js' ); + +/** +* Set vertical axis glyph. +* Glyph to use to draw horizontel axis. +* +* @private +* @param {string} value - string indicating glyph name +* @throws {TypeError} must be a valid glyph string code +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'verticalAxisGlyph', value ) ); + } + if ( !isValidGlyph( value ) ) { + throw new TypeError( format( 'invalid assignment, `%s` must be a valid glyph code. Value: `%s`.', 'verticalAxisGlyph', value ) ); + } + if ( this._verticalAxisGlyph !== value ) { + this._verticalAxisGlyph = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-tics-glyph/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-tics-glyph/get.js new file mode 100644 index 000000000000..ca4911d9ba7b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-tics-glyph/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get verticalTicsGlyph. +* +* @private +* @returns {string} glyph +*/ +function get() { + return this._verticalTicsGlyph; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-tics-glyph/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-tics-glyph/set.js new file mode 100644 index 000000000000..f0d241651eb7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/vertical-tics-glyph/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var isValidGlyph = require( './../../utils/is-valid-glyph.js' ); + +/** +* Set vertical tics glyph. +* Glyph to represent the tics on vertical axis +* @private +* @param {string} value - string indicating glyph name +* @throws {TypeError} must be a valid glyph string code +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'verticalTicsGlyph', value ) ); + } + if ( !isValidGlyph( value ) ) { + throw new TypeError( format( 'invalid assignment, `%s` must be a valid glyph code. Value: `%s`.', 'verticalTicsGlyph', value ) ); + } + if ( value !== this._verticalTicsGlyph ) { + this._verticalTicsGlyph = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-pos/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-pos/get.js new file mode 100644 index 000000000000..66e35cc4b5dc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-pos/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the position of w axies. +* +* @private +* @returns {Number} position ( height / row number ) +*/ +function get() { + return this._axisDataObjs[ 3 ].position; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-pos/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-pos/set.js new file mode 100644 index 000000000000..248e3e6c3ed5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-pos/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the position of the w axis. +* Note: w axis is horizontel axis, this setter take the height( row Number ) for position. +* +* @private +* @param {Number} value - position ( height/ row number ). +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` non negative number is expected. Value: `%s`.', 'wAxisPos', value ) ); + } + if ( this._axisDataObjs[ 3 ].position !== value ) { + this._axisDataObjs[ 3 ].position = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-tics-labels/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-tics-labels/get.js new file mode 100644 index 000000000000..33e7d7cef923 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-tics-labels/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the array of tics labels of w axis. +* +* @private +* @returns {Array} axises tics label +*/ +function get() { + return this._axisDataObjs[3].rawLabels; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-tics-labels/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-tics-labels/set.js new file mode 100644 index 000000000000..70a82cf39949 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis-tics-labels/set.js @@ -0,0 +1,90 @@ +/* eslint-disable max-len */ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNumber = require( '@stdlib/assert/is-number' ); +var isString = require( '@stdlib/assert/is-string' ); +var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); +var everyBy2 = require( './../../every_by2.js' ); + + +// FUNCTIONS // + +/** +* Predicate function which tests whether two elements are equal. +* +* @private +* @param {Object} v1 - first value +* @param {Object} v2 - second value +* @returns {boolean} boolean indicating whether two elements are equal +*/ +function predicate( v1, v2 ) { + return ( v1 === v2 ); +} + + +// MAIN // + +/** +* Sets the w axis tics label. +* +* @private +* @param {Array} value - Array of the labels for tics. +* @throws {TypeError} must be a array of string or number literals +*/ +function set( value ) { + var isChange; + var data; + var i; + + data = this._axisDataObjs[ 3 ].rawLabels; + if ( !isCollection( value )) { + throw new TypeError( format( 'invalid assignment. `%s` must be an array. Value: `%s`.', 'wAxisTicsLabels', value ) ); + } + if ( !this._axisDataObjs[ 3 ].axis && data.length === value.length && everyBy2( data, value, predicate ) ) { + isChange = false; + } + else { + isChange = true; + } + if ( isChange ) { + this.wAxis = true; + data.length = value.length; + for ( i = 0; i < value.length; i++ ) { + if ( !isNumber( value[ i ] ) && !isString( value[ i ] ) ) { + throw new TypeError( format( 'invalid assignment. `%s` number or string is expected. Value: `%s`.', 'wAxisTicsLabel', value ) ); + } + data[ i ] = value[ i ]; + } + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis/get.js new file mode 100644 index 000000000000..8fb7ee2d6194 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the rendering mode. +* +* @private +* @returns {boolean} rendering mode +*/ +function get() { + return this._axisDataObjs[ 3 ].axis; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis/set.js new file mode 100644 index 000000000000..ea050b55e3c6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-axis/set.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the x axis. +* +* @private +* @param {boolean} value - boolean indicating whether to render x axis +* @throws {TypeError} must be a boolean +*/ +function set( value ) { + if ( !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', 'wAxis', value ) ); + } + if ( value !== this._axisDataObjs[ 3 ].axis ) { + this._axisDataObjs[ 3 ].axis = value; + if ( !this._quiet ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tic-spacing/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tic-spacing/get.js new file mode 100644 index 000000000000..a16385c24ffb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tic-spacing/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the tics spacing of w axies. +* +* @private +* @returns {Number} tics space of the axes +*/ +function get() { + return this._axisDataObjs[ 3 ].ticsSpacing; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tic-spacing/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tic-spacing/set.js new file mode 100644 index 000000000000..1b2657ac4ff4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tic-spacing/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the tics spacing of w axis. +* Note: space require between each tics label in axis is in control of the specific plot package. +* +* @private +* @param {Number} value - tics spacing +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` non negative number is expected. Value: `%s`.', 'w-tic-spacing', value ) ); + } + if ( this._axisDataObjs[ 3 ].ticsSpacing !== value ) { + this._axisDataObjs[ 3 ].ticsSpacing = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tics-label-space/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tics-label-space/get.js new file mode 100644 index 000000000000..35738629fa80 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tics-label-space/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the tics label space of w axies. +* +* @private +* @returns {Number} tics space of the axes +*/ +function get() { + return this._axisDataObjs[ 3 ].ticsLabelSpace; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tics-label-space/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tics-label-space/set.js new file mode 100644 index 000000000000..432334a24e56 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/w-tics-label-space/set.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the tics label space of w axis. +* Note: it is the space which is used to write the labels of the axis tics. +* +* @private +* @param {Number} value - tics label space +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` non negative number is expected. Value: `%s`.', 'wTicsLabelSpace', value ) ); + } + if ( this._axisDataObjs[ 3 ].ticsLabelSpace !== value ) { + this._axisDataObjs[ 3 ].ticsLabelSpace = value; + if ( !this._quite ) { + // Change in label space cause the change in matrices + this.emit( 'initialize' ); + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/width/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/width/get.js new file mode 100644 index 000000000000..ebbbb5d08101 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/width/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Get width of the plot. +* +* @private +* @returns {number} width of the whole canvas +*/ +function get() { + return this._width; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-pos/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-pos/get.js new file mode 100644 index 000000000000..d50c5efa57c2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-pos/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the position( column number ) of x axies. +* +* @private +* @returns {Number} position( column number ) +*/ +function get() { + return this._axisDataObjs[ 0 ].position; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-pos/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-pos/set.js new file mode 100644 index 000000000000..a0702611cd80 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-pos/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the position of the x axis. +* Note: x axis is vertical axis,so this setter take the width( column Number ) for position. +* +* @private +* @param {Number} value - position width( column number ) +* @throws {TypeError} must be non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` non negative number is expected. Value: `%s`.', 'xAxisPos', value ) ); + } + if ( this._axisDataObjs[ 0 ].position !== value ) { + this._axisDataObjs[ 0 ].position = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-tics-labels/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-tics-labels/get.js new file mode 100644 index 000000000000..e4b76dbe5fd9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-tics-labels/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the x axis tics labels. +* +* @private +* @returns {Array} x axis tics labels +*/ +function get() { + return this._axisDataObjs[ 0 ].rawLabels; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-tics-labels/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-tics-labels/set.js new file mode 100644 index 000000000000..4c21a6d5985a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis-tics-labels/set.js @@ -0,0 +1,90 @@ +/* eslint-disable max-len */ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isCollection = require( '@stdlib/assert/is-collection' ); +var isNumber = require( '@stdlib/assert/is-number' ); +var isString = require( '@stdlib/assert/is-string' ); +var format = require( '@stdlib/string/format' ); +var everyBy2 = require( './../../every_by2.js' ); + + +// FUNCTIONS // + +/** +* Predicate function which tests whether two elements are equal. +* +* @private +* @param {Object} v1 - first value +* @param {Object} v2 - second value +* @returns {boolean} boolean indicating whether two elements are equal +*/ +function predicate( v1, v2 ) { + return ( v1 === v2 ); +} + + +// MAIN // + +/** +* Sets the x axis tics labels. +* +* @private +* @param {Array} value - Array of tics labels +* @throws {TypeError} must be a array of string or number literals +*/ +function set( value ) { + var isChange; + var data; + var i; + + data = this._axisDataObjs[ 0 ].rawLabels; + data.length = value.length; + if ( !isCollection( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` array is expected. Value: `%s`.', 'xAxisTicsLabel', value ) ); + } + if ( !this._axisDataObjs[ 0 ].axis && data.length === value.length && everyBy2( data, value, predicate ) ) { + isChange = false; + } + else { + isChange = true; + } + if ( isChange ) { + this.xAxis = true; + for ( i = 0; i < value.length; i++ ) { + if ( !isNumber( value[ i ] ) && !isString( value[ i ] ) ) { + throw new TypeError( format( 'invalid assignment. `%s` number or string is expected. Value: `%s`.', 'xAxisTicsLabel', value ) ); + } + data[ i ] = value[ i ]; + } + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis/get.js new file mode 100644 index 000000000000..72c602fc244c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the x axis. +* +* @private +* @returns {boolean} x axis +*/ +function get() { + return this._axisDataObjs[ 0 ].axis; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis/set.js new file mode 100644 index 000000000000..c5fb0ca49f83 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-axis/set.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the x axis. +* +* @private +* @param {boolean} value - boolean indicating whether to render x axis +* @throws {TypeError} must be a boolean +*/ +function set( value ) { + if ( !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', 'xAxis', value ) ); + } + if ( value !== this._axisDataObjs[ 0 ].axis ) { + this._axisDataObjs[ 0 ].axis = value; + if ( !this._quiet ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tic-spacing/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tic-spacing/get.js new file mode 100644 index 000000000000..95510bade4ff --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tic-spacing/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the tics spacing of x axies. +* +* @private +* @returns {Number} tics space of the x axes +*/ +function get() { + return this._axisDataObjs[ 0 ].ticsSpacing; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tic-spacing/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tic-spacing/set.js new file mode 100644 index 000000000000..45c85fc81955 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tic-spacing/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the tics spacing of x axis. +* Note: space require between each tics label in axis is in control of the specific plot package. +* +* @private +* @param {Number} value - tics spacing +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a negative number. Value: `%s`.', 'xTicSpacing', value ) ); + } + if ( this._axisDataObjs[ 0 ].ticsSpacing !== value ) { + this._axisDataObjs[ 0 ].ticsSpacing = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tics-label-space/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tics-label-space/get.js new file mode 100644 index 000000000000..4f82a001a8d0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tics-label-space/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the tics label space of x axies. +* +* @private +* @returns {Number} tics label space of the axes +*/ +function get() { + return this._axisDataObjs[ 0 ].ticsLableSpace; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tics-label-space/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tics-label-space/set.js new file mode 100644 index 000000000000..e7beaba0d364 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/x-tics-label-space/set.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the tics label space of x axis. +* Note: it is the space which is used to write the labels of the axis tics. +* +* @private +* @param {Number} value - tics label space +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` non negative number is expected. Value: `%s`.', 'xTicsLabelSpace', value ) ); + } + if ( this._axisDataObjs[ 0 ].ticsLableSpace !== value ) { + this._axisDataObjs[ 0 ].ticsLableSpace = value; + if ( !this._quite ) { + // Change in label space cause the change in matrices + this.emit( 'initialize' ); + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-pos/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-pos/get.js new file mode 100644 index 000000000000..806d7b8aca0b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-pos/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the position( row Number ) of y axis. +* +* @private +* @returns {Number} position( row Number ) +*/ +function get() { + return this._axisDataObjs[ 1 ].position; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-pos/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-pos/set.js new file mode 100644 index 000000000000..86f775fcca6b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-pos/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the position of the y axis. +* Note: y axis is horizontel axis, this setter take the height( row Number ) for position. +* +* @private +* @param {Number} value - position( row Number ) +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a non negative number. Value: `%s`.', 'yAxisPos', value ) ); + } + if ( this._axisDataObjs[ 1 ].position !== value ) { + this._axisDataObjs[ 1 ].position = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-tics-labels/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-tics-labels/get.js new file mode 100644 index 000000000000..90ecb6e6a04c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-tics-labels/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the y axis tics label. +* +* @private +* @returns {Array} y axis tics label +*/ +function get() { + return this._axisDataObjs[ 1 ].rawLabels; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-tics-labels/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-tics-labels/set.js new file mode 100644 index 000000000000..d25055d6b480 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis-tics-labels/set.js @@ -0,0 +1,90 @@ +/* eslint-disable max-len */ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNumber = require( '@stdlib/assert/is-number' ); +var isString = require( '@stdlib/assert/is-string' ); +var format = require( '@stdlib/string/format' ); +var isCollection = require( '@stdlib/assert/is-collection' ); +var everyBy2 = require( './../../every_by2.js' ); + + +// FUNCTIONS // + +/** +* Predicate function which tests whether two elements are equal. +* +* @private +* @param {Object} v1 - first value +* @param {Object} v2 - second value +* @returns {boolean} boolean indicating whether two elements are equal +*/ +function predicate( v1, v2 ) { + return ( v1 === v2 ); +} + + +// MAIN // + +/** +* Sets the y axis tics label. +* +* @private +* @param {Array} value - Array of tics labels +* @throws {TypeError} must be array of literals +*/ +function set( value ) { + var isChange; + var data; + var i; + + data = this._axisDataObjs[ 1 ].rawLabels; + data.length = value.length; + if ( !isCollection( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be array. Value: `%s`.', 'yAxisTicsLabels', value ) ); + } + if ( !this._axisDataObjs[ 1 ].axis && data.length === value.length && everyBy2( data, value, predicate ) ) { + isChange = false; + } + else { + isChange = true; + } + if ( isChange ) { + this.yAxis = true; + for ( i = 0; i < value.length; i++ ) { + if ( !isString( value[ i ] ) && !isNumber( value[ i ] ) ) { + throw new TypeError( format( 'invalid assignment. `%s` number or string is expected. Value: `%s`.', 'yAxisTicsLabel', value ) ); + } + data[ i ] = value[ i ]; + } + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis/get.js new file mode 100644 index 000000000000..baad94616195 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the x axis. +* +* @private +* @returns {boolean} x axis +*/ +function get() { + return this._axisDataObjs[ 1 ].axis; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis/set.js new file mode 100644 index 000000000000..778b933887aa --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-axis/set.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the y axis. +* +* @private +* @param {boolean} value - boolean indicating whether to render y axis +* @throws {TypeError} must be a boolean +*/ +function set( value ) { + if ( !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', 'yAxis', value ) ); + } + if ( value !== this._axisDataObjs[ 1 ].axis ) { + this._axisDataObjs[ 1 ].axis = value; + if ( !this._quiet ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tic-spacing/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tic-spacing/get.js new file mode 100644 index 000000000000..81aed9b72a6a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tic-spacing/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the tics spacing of y axies. +* +* @private +* @returns {Number} tics space of the y axes +*/ +function get() { + return this._axisDataObjs[ 1 ].ticsSpacing; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tic-spacing/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tic-spacing/set.js new file mode 100644 index 000000000000..681bcf795f86 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tic-spacing/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the tics spacing of y axis. +* Note: space require between each tics label in axis is in control of the specific plot package. +* +* @private +* @param {Number} value - space betwen tics +* @throws {TypeError} must be non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a non negative number. Value: `%s`.', 'yTicSpacing', value ) ); + } + if ( this._axisDataObjs[ 1 ].ticsSpacing !== value ) { + this._axisDataObjs[ 1 ].ticsSpacing = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tics-label-space/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tics-label-space/get.js new file mode 100644 index 000000000000..e6c4567589a3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tics-label-space/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the tics label space of y axies. +* +* @private +* @returns {Number} tics label space of the axes +*/ +function get() { + return this._axisDataObjs[ 1 ].ticsLableSpace; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tics-label-space/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tics-label-space/set.js new file mode 100644 index 000000000000..7b64e999aa0d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/y-tics-label-space/set.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the tics label space of y axis. +* Note: it is the space which is used to write the labels of the axis tics. +* +* @private +* @param {Number} value - tics label spacing +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` non negative number is expected. Value: `%s`.', 'yTicsLabelSpace', value ) ); + } + if ( this._axisDataObjs[ 1 ].ticsLableSpace !== value ) { + this._axisDataObjs[ 1 ].ticsLableSpace = value; + if ( !this._quite ) { + // Change in label space cause the change in matrices + this.emit( 'initialize' ); + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-pos/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-pos/get.js new file mode 100644 index 000000000000..7b6473ce3693 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-pos/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the position( column number ) of z axies. +* +* @private +* @returns {Number} position( column number ) of z axies +*/ +function get() { + return this._axisDataObjs[ 2 ].position; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-pos/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-pos/set.js new file mode 100644 index 000000000000..8ecae9b1f9da --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-pos/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the position of the z axis. +* Note: z axis is vertical axis, this setter take the column Number for position. +* +* @private +* @param {Number} value - Position( column number ) +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a non negative number. Value: `%s`.', 'zAxisPos', value ) ); + } + if ( this._axisDataObjs[ 2 ].position !== value ) { + this._axisDataObjs[ 2 ].position = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-tics-labels/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-tics-labels/get.js new file mode 100644 index 000000000000..24f93d4b8bce --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-tics-labels/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the z axis labels. +* +* @private +* @returns {Array} z axis labels +*/ +function get() { + return this._axisDataObjs[ 2 ].rawLabels; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-tics-labels/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-tics-labels/set.js new file mode 100644 index 000000000000..dad15c2a8cde --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis-tics-labels/set.js @@ -0,0 +1,90 @@ +/* eslint-disable max-len */ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNumber = require( '@stdlib/assert/is-number' ); +var isString = require( '@stdlib/assert/is-string' ); +var isCollection = require( '@stdlib/assert/is-collection' ); +var format = require( '@stdlib/string/format' ); +var everyBy2 = require( './../../every_by2.js' ); + + +// FUNCTIONS // + +/** +* Predicate function which tests whether two elements are equal. +* +* @private +* @param {Object} v1 - first value +* @param {Object} v2 - second value +* @returns {boolean} boolean indicating whether two elements are equal +*/ +function predicate( v1, v2 ) { + return ( v1 === v2 ); +} + + +// MAIN // + +/** +* Sets the z axis tics label. +* +* @private +* @param {Array} value - Array of tics label +* @throws {TypeError} must be an array of string and number literals +*/ +function set( value ) { + var isChange; + var data; + var i; + + data = this._axisDataObjs[ 2 ].rawLabels; + data.length = value.length; + if ( !isCollection( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a array. Value: `%s`.', 'zAxisTicsLabel', value ) ); + } + if ( !this._axisDataObjs[ 2 ].axis && data.length === value.length && everyBy2( data, value, predicate ) ) { + isChange = false; + } + else { + isChange = true; + } + if ( isChange ) { + this.zAxis = true; + for ( i = 0; i < value.length; i++ ) { + if ( !isNumber( value[ i ] ) && !isString( value[ i ] ) ) { + throw new TypeError( format( 'invalid assignment. `%s` number or string is expected. Value: `%s`.', 'zAxisTicsLabel', value ) ); + } + data[ i ] = value[ i ]; + } + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis/get.js new file mode 100644 index 000000000000..681fcafc2120 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the x axis. +* +* @private +* @returns {boolean} x axis +*/ +function get() { + return this._axisDataObjs[ 2 ].axis; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis/set.js new file mode 100644 index 000000000000..01f1d5c3709c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-axis/set.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the z axis. +* +* @private +* @param {boolean} value - boolean indicating whether to render z axis +* @throws {TypeError} must be a boolean +*/ +function set( value ) { + if ( !isBoolean( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', 'zAxis', value ) ); + } + if ( value !== this._axisDataObjs[ 2 ].axis ) { + this._axisDataObjs[ 2 ].axis = value; + if ( !this._quiet ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tic-spacing/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tic-spacing/get.js new file mode 100644 index 000000000000..f8a375f412c4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tic-spacing/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the tics spacing of z axies. +* +* @private +* @returns {Number} tics space of the z axes +*/ +function get() { + return this._axisDataObjs[ 2 ].ticsSpacing; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tic-spacing/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tic-spacing/set.js new file mode 100644 index 000000000000..a7fbe5033531 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tic-spacing/set.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the tics spacing of z axis. +* Note: space require between each tics label in axis is in control of the specific plot package. +* +* @private +* @param {Number} value - tics spacing +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s`non negative number is expected. Value: `%s`.', 'zTicSpacing', value ) ); + } + if ( this._axisDataObjs[ 2 ].ticsSpacing !== value ) { + this._axisDataObjs[ 2 ].ticsSpacing = value; + if ( !this._quite ) { + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tics-label-space/get.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tics-label-space/get.js new file mode 100644 index 000000000000..fc83c5b19bdd --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tics-label-space/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +// MAIN // + +/** +* Returns the tics label space of z axies. +* +* @private +* @returns {Number} tics label space of the axes +*/ +function get() { + return this._axisDataObjs[ 2 ].ticsLabelSpace; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tics-label-space/set.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tics-label-space/set.js new file mode 100644 index 000000000000..ea49ff3db2ce --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/props/z-tics-label-space/set.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the tics label space of z axis. +* Note: it is the space which is used to write the labels of the axis tics. +* +* @private +* @param {Number} value - tics spacing +* @throws {TypeError} must be a non negative number +*/ +function set( value ) { + if ( !isNonNegativeNumber( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` non negative number is expected. Value: `%s`.', 'zTicsLabelSpace', value ) ); + } + if ( this._axisDataObjs[ 2 ].ticsLabelSpace !== value ) { + this._axisDataObjs[ 2 ].ticsLabelSpace = value; + if ( !this._quite ) { + // Change in label space cause the change in matrices + this.emit( 'initialize' ); + this.emit( 'change' ); + } + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/remove_ansi.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/remove_ansi.js new file mode 100644 index 000000000000..1f7574f6ce0b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/remove_ansi.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 replace = require( '@stdlib/string/base/replace' ); +var RE_ANSI = require( './ansi_regexp.js' ); + + +// MAIN // + +/** +* Removes ANSI escape sequences from a string. +* +* @private +* @param {string} str - input string +* @returns {string} output string +*/ +function removeANSI( str ) { + return replace( str, RE_ANSI, '' ); +} + + +// EXPORTS // + +module.exports = removeANSI; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/render.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/render.js new file mode 100644 index 000000000000..cca98ee22d9e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/render.js @@ -0,0 +1,362 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 */ +/* eslint-disable no-underscore-dangle */ +/* eslint-disable max-lines-per-function */ +/* eslint-disable max-statements */ +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var colorsSet = require( './colors-set.js' ); +var glyphsSet = require( './glyphs-set.js' ); +var isLegal = require( './utils/is-valid-row-col.js' ); + + +// FUNCTIONS // + +/** +* Process a color. +* @private +* @param {string} colorCode color code +* @returns {string} color encoding +*/ +function processColor( colorCode ) { + return colorsSet[ colorCode ]; +} + +/** +* Process a glyph. +* @private +* @param {string} glyphCode glyph code +* @returns {string} glyph encoding +*/ +function processGlyph( glyphCode ) { + return glyphsSet[ glyphCode ]; +} + +/** +* Is intialized. +* @private +* @param {BasePlot} basePlot - BasePlot instance +* @returns {boolean} Is intialized +*/ +function isInitialized( basePlot ) { + var cond1; + var cond2; + + cond1 = basePlot._backgroundColorMatrix.length && basePlot._foregroundColorMatrix.length && basePlot._glyphMatrix.length; + cond2 = basePlot._plotArea && hasOwnProp( basePlot._plotArea, 'x' ) && hasOwnProp( basePlot._plotArea, 'y' ) && hasOwnProp( basePlot._plotArea, 'z' ) && hasOwnProp( basePlot._plotArea, 'w' ); + return cond1 && cond2; +} + + +// MAIN // + +/** +* Render... +* +* @private +* @returns {string} render string +*/ +function render() { + var background; + var foreground; + var tmpQuite; + var plotStr = ''; + var height; + var width; + var temp; + var opts; + var xPos; + var yPos; + var zPos; + var wPos; + var ptr; + var pos; + var val; + var bl; + var i; + var j; + + if ( !isInitialized( this ) ) { + return ''; + } + + // Setting axis position to actual row or column + xPos = this.xAxisPos + this.xTicsLabelSpace; + yPos = this.yAxisPos + this.yTicsLabelSpace; + zPos = this.zAxisPos + this.xTicsLabelSpace; + wPos = this.wAxisPos + this.yTicsLabelSpace; + + // Rendering the axis tics and label + + // x-axis + if ( this._axisDataObjs[ 0 ].axis ) { + // Setting labels area background color + if ( this.ticsLabelsBckColor && this.ticsLabelsBckColor !== this.backgroundColor ) { + bl = [ this.plotArea.y, xPos - this.xTicsLabelSpace ]; + height = this.plotArea.w - this.plotArea.y + 1; + width = this.xTicsLabelSpace + 1; + tmpQuite = this._quite; + this._quite = true; + opts = { + 'startPos': bl, + 'height': height, + 'width': width, + 'backgroundColor': this.ticsLabelsBckColor, + 'overwrite': true + }; + this.setBar( opts ); + this._quite = tmpQuite; + } + + // Labels and tics + ptr = [ this.plotArea.y, xPos ]; + temp = this._axisDataObjs[ 0 ].normalizeLabels; + pos = ptr[ 0 ]; + + // Iterating from each labels + for ( i = 0; i < temp.length && pos <= this.plotArea.w; i++ ) { + val = temp[ i ].value; + tmpQuite = this._quite; + this._quite = true; + this.setString({ + 'row': pos, + 'column': ptr[ 1 ] - temp[ i ].width, + 'value': val, + 'overwrite': true + }); + this._quite = tmpQuite; + + // Setting tic + this.setGlyph( pos, ptr[ 1 ], this.verticalTicsGlyph, true ); + pos += this._axisDataObjs[ 0 ].ticsSpacing; + } + + // Setting axis glyh + pos = this.plotArea.y; + for ( i = this.plotArea.y; i <= this.plotArea.w; i++ ) { + this.setGlyph( i, ptr[ 1 ], this.verticalAxisGlyph, false ); + pos += 1; + } + } + + // y-axis + + if ( this._axisDataObjs[ 1 ].axis ) { + // Setting labels area background color + if ( this.ticsLabelsBckColor && this.ticsLabelsBckColor !== this.backgroundColor ) { + bl = [ yPos - this.yTicsLabelSpace, this.plotArea.x ]; + height = this.yTicsLabelSpace + 1; + width = this.plotArea.z - this.plotArea.x + 1; + tmpQuite = this._quite; + this._quite = true; + opts = { + 'startPos': bl, + 'height': height, + 'width': width, + 'backgroundColor': this.ticsLabelsBckColor, + 'overwrite': true + }; + this.setBar( opts ); + this._quite = tmpQuite; + } + + // Rendering labels and tics + ptr = [ yPos, this.plotArea.x ]; + temp = this._axisDataObjs[ 1 ].normalizeLabels; + pos = ptr[ 1 ]; + + // Iterating from each labels + for ( i = 0; i < temp.length && pos <= this.plotArea.z; i++ ) { + val = temp[ i ].value; + + // Labels should be of size of ticSpacing in horizontal axis + val = val.substring( 0, this._axisDataObjs[ 1 ].ticsSpacing ); + tmpQuite = this._quite; + this._quite = true; + this.setString({ + 'row': ptr[ 0 ] - 1, + 'column': pos, + 'value': val, + 'overwrite': true + }); + this._quite = tmpQuite; + + // Setting tic + this.setGlyph( ptr[ 0 ], pos, this.horizontalTicsGlyph, true ); + pos += this._axisDataObjs[ 1 ].ticsSpacing; + } + + // Setting axis glyh + for ( i = this.plotArea.x; i <= this.plotArea.z; i++ ) { + this.setGlyph( ptr[ 0 ], i, this.horizontalAxisGlyph, false ); + } + } + + // z-axis + + if ( this._axisDataObjs[ 2 ].axis ) { + // Setting labels area background color + if ( this.ticsLabelsBckColor && this.ticsLabelsBckColor !== this.backgroundColor ) { + bl = [ this.plotArea.y, zPos ]; + height = this.plotArea.w - this.plotArea.y + 1; + width = this.zTicsLabelSpace + 1; + tmpQuite = this._quite; + this._quite = true; + opts = { + 'startPos': bl, + 'height': height, + 'width': width, + 'backgroundColor': this.ticsLabelsBckColor, + 'overwrite': true + }; + this.setBar( opts ); + this._quite = tmpQuite; + } + + // Label and tics + ptr = [ this.plotArea.y + 1, zPos ]; + temp = this._axisDataObjs[ 2 ].normalizeLabels; + pos = ptr[ 0 ]; + + // Iterating from each labels + for ( i = 0; i < temp.length && pos <= this.plotArea.w; i++ ) { + val = temp[ i ].value; + tmpQuite = this._quite; + this._quite = true; + this.setString({ + 'row': pos, + 'column': ptr[ 1 ] + 1, + 'value': val, + 'overwrite': true + }); + this._quite = tmpQuite; + + // Setting tic + this.setGlyph( pos, ptr[ 1 ], this.verticalTicsGlyph, true ); + pos += this._axisDataObjs[ 2 ].ticsSpacing; + } + + // Setting axis glyh + for ( i = this.plotArea.y; i <= this.plotArea.w; i++ ) { + this.setGlyph( i, ptr[ 1 ], this.verticalAxisGlyph, false ); + } + } + + // w-axis + + if ( this._axisDataObjs[ 3 ].axis ) { + // Setting labels area background color + if ( this.ticsLabelsBckColor && this.ticsLabelsBckColor !== this.backgroundColor ) { + bl = [ wPos, this.plotArea.x ]; + height = this.wTicsLabelSpace + 1; + width = this.plotArea.z - this.plotArea.x + 1; + tmpQuite = this._quite; + this._quite = true; + opts = { + 'startPos': bl, + 'height': height, + 'width': width, + 'backgroundColor': this.ticsLabelsBckColor, + 'overwrite': true + }; + this.setBar( opts ); + this._quite = tmpQuite; + } + ptr = [ wPos, this.plotArea.x + 1 ]; + temp = this._axisDataObjs[ 3 ].normalizeLabels; + pos = ptr[ 1 ]; + + // Iterating from each labels + for ( i = 0; i < temp.length && pos <= this.plotArea.z; i++ ) { + val = temp[ i ].value; + tmpQuite = this._quite; + this._quite = true; + this.setString({ + 'row': ptr[ 0 ] + 1, + 'column': pos, + 'value': val, + 'overwrite': true + }); + this._quite = tmpQuite; + + // Setting tic + this.setGlyph( ptr[ 0 ], pos, this.horizontalTicsGlyph, true ); + pos += this._axisDataObjs[ 3 ].ticsSpacing; + } + + // Setting axis glyh + for ( i = this.plotArea.x; i <= this.plotArea.z; i++ ) { + this.setGlyph( ptr[ 0 ], i, this.horizontalAxisGlyph, false ); + } + } + + // Intersections glyph + + if ( this.xAxis && this.yAxis ) { + this.setGlyph( yPos, xPos, this.axisIntersectionGlyph, true ); + } + if ( this.wAxis && this.xAxis ) { + this.setGlyph( wPos, xPos, this.axisIntersectionGlyph, true ); + } + if ( this.wAxis && this.zAxis ) { + this.setGlyph( wPos, zPos, this.axisIntersectionGlyph, true ); + } + if ( this.yAxis && this.zAxis ) { + this.setGlyph( yPos, zPos, this.axisIntersectionGlyph, true ); + } + + // Final Render... + for ( i = this._height - 1; i >= 0; i-- ) { + plotStr += '\r'; + for ( j = 0; j < this._width; j++ ) { + // If background color is not same as previous then only we need to change it + + if ( !isLegal( i, j - 1, this._height, this._width ) || this._backgroundColorMatrix[ i ][ j ] !== this._backgroundColorMatrix[ i ][ j - 1 ] ) { + background = processColor( this._backgroundColorMatrix[ i ][ j ] ); + plotStr += background; + } + + // If forward color is not same as previous then only we need to change it + + if ( !isLegal( i, j - 1, this._height, this._width ) || this._foregroundColorMatrix[ i ][ j ] !== this._foregroundColorMatrix[ i ][ j - 1 ] ) { + foreground = processColor( this._foregroundColorMatrix[ i ][ j ] ); + plotStr += foreground; + } + plotStr += processGlyph( this._glyphMatrix[ i ][ j ] ); + } + plotStr += processColor( 'Default' ); + plotStr += '\n'; + } + + if ( this.autoRender ) { + this.emit( 'render', plotStr ); + } + return plotStr; +} + + +// EXPORTS // + +module.exports = render; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/safe-column.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/safe-column.js new file mode 100644 index 000000000000..5dc4d5a8d5c1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/safe-column.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 format = require( '@stdlib/string/format' ); + +/** +* Method to provide teh safe column number. +* Note: This method provide the column number which present in plot area and does'nt collide with the axis labels and axis. +* +* @private +* @name getSafeRow +* @param {number} pos - position +* @throws {TypeError} - must be a valid pos respective to the plot area +* @returns {void} +*/ +function getSafeColumn( pos ) { + var column; + + // Note: If axis are there then they will acquired there 1 respective space so pos should always the valid according to remaining space + if ( pos < 0 || pos >= this.plotAreaWidth - this.xAxis - this.yAxis ) { + throw new TypeError( format( 'invalid option. `%s` must be valid respective to the plot are remaining space. Option: `%s`.', 'position', pos ) ); + } + column = this.plotArea.x + pos; + if ( pos >= this.xAxisPos ) { + column = pos + this.xTicsLabelSpace + 1; + } + + return column; +} + +module.exports = getSafeColumn; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/safe-row.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/safe-row.js new file mode 100644 index 000000000000..e8e4ae465e79 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/safe-row.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 format = require( '@stdlib/string/format' ); + +/** +* Method to provide teh safe row number. +* Note: This method provide the row number which present in plot area and does'nt collide with the axis labels and axis. +* +* @private +* @name getSafeRow +* @param {number} pos - position +* @throws {TypeError} - must be a valid position respective to the plot area +* @returns {void} +*/ +function getSafeRow( pos ) { + var row; + + // Note: If axis are there then they will acquired there 1 respective space so position should always need to valid according to remaining space + if ( pos < 0 || pos >= ( this.plotAreaHeight - this.yAxis - this.zAxis ) ) { + throw new TypeError( format( 'invalid option. `%s` must be valid respective to the plot are remaining space. Option: `%s`.', 'getSafeRow', pos ) ); + } + row = this.plotArea.y + pos; + if ( pos >= this.yAxisPos ) { + row = pos + this.yTicsLabelSpace + 1; + } + + return row; +} + +module.exports = getSafeRow; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/string.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/string.js new file mode 100644 index 000000000000..29ff04e773f1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/string.js @@ -0,0 +1,186 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var isAsci = require( '@stdlib/assert/is-ascii' ); +var format = require( '@stdlib/string/format' ); +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ); +var isString = require( '@stdlib/assert/is-string' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ); +var isValidBackgroundColor = require( './utils/is-valid-background-color.js' ); +var isValidForegroundColor = require( './utils/is-valid-foreground-color.js' ); + + +// FUNCTIONS // + +/** +* Method which return the default option. +* +* @private +* @name defaults +* @returns {Object} - out +*/ +function defaults( ) { + var out = {}; + + out.row = 0; + out.column = 0; + out.value = ''; + out.overwrite = false; + out.safeArea = false; + out.foregroundColor = void 0; + out.backgroundColor = void 0; + return out; +} + +/** +* Method to validate the object. +* +* @private +* @name validate +* @param {Object} opts - destination object +* @param {Object} options - function options +* @returns {Object} - out +*/ +function validate( opts, options ) { + if ( !isPlainObject( options ) ) { + return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + + if ( hasOwnProp( options, 'row' ) ) { + opts.row = options.row; + if ( !isNonNegativeNumber( options.row ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a non-negative-number. Option: `%s`.', 'height', options.row ) ); + } + } + else { + return new TypeError( format( 'invalid option. `%s` property is expected: `%s`.', 'row', options.row ) ); + } + + if ( hasOwnProp( options, 'column' ) ) { + opts.column = options.column; + if ( !isNonNegativeNumber( options.column ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a non-negative-number. Option: `%s`.', 'height', options.column ) ); + } + } + else { + return new TypeError( format( 'invalid option. `%s` property is expected: `%s`.', 'column', options.column ) ); + } + + if ( hasOwnProp( options, 'value' ) ) { + opts.value = options.value; + if ( !isString( options.value ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'value', options.value ) ); + } + } + else { + return new TypeError( format( 'invalid option. `%s` property is expected: `%s`.', 'value', options.value ) ); + } + + if ( hasOwnProp( options, 'overwrite' ) ) { + opts.overwrite = options.overwrite; + if ( !isBoolean( options.overwrite ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'overwrite', options.overwrite ) ); + } + } + if ( hasOwnProp( options, 'safeArea' ) ) { + opts.safeArea = options.safeArea; + if ( !isBoolean( options.safeArea ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'safeArea', options.safeArea ) ); + } + } + if ( hasOwnProp( options, 'backgroundColor' ) ) { + opts.backgroundColor = options.backgroundColor; + if ( !isString( options.backgroundColor ) || !isValidBackgroundColor( options.backgroundColor ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a string and a valid background color code. Option: `%s`.', 'backgroundColor', options.backgroundColor ) ); + } + } + if ( hasOwnProp( options, 'foregroundColor' ) ) { + opts.foregroundColor = options.foregroundColor; + if ( !isString( options.foregroundColor ) || !isValidForegroundColor( options.foregroundColor ) ) { + return new TypeError( format( 'invalid option. `%s` option must be a string and a valid foreground color code. Option: `%s`.', 'foregroundColor', options.foregroundColor ) ); + } + } +} + + +// MAIN // + +/** +* Add string. +* +* @private +* @name addString +* @param {Options} options - options +* @param {number} [options.row] - row number of start position +* @param {number} [options.column] - row number of start position +* @param {string} [options.value] - string value +* @param {boolean} [options.overwrite] - overwrite +* @param {boolean} [options.safeArea] - weather to put coordinates in safe area or not +* @param {string} [options.forgroundColor] - forgroundColor to use +* @param {string} [options.backgroundColor] - foregroundColor to use +* @throws {Error} must provide valid options +* @returns {void} +*/ +function addString( options ) { + var opts; + var err; + var chr; + var r; + var c; + var i; + + opts = defaults(); + if ( arguments.length ) { + err = validate( opts, options ); + if ( err ) { + throw err; + } + } + else { + return new TypeError( format( 'invalid option. `%s` options object is expected', 'addString' ) ); + } + r = opts.row; + c = opts.column; + for ( i = 0; i < opts.value.length; i++ ) { + chr = opts.value[ i ]; + if ( isAsci( chr ) ) { + this.setGlyph( r, c, 'asci' + chr.charCodeAt( 0 ), opts.overwrite, opts.safeArea ); + } + if ( opts.foregroundColor ) { + this.setForegroundColor( r, c, opts.foregroundColor, opts.overwrite, opts.safeArea ); + } + if ( opts.backgroundColor ) { + this.setBackgroundColor( r, c, opts.backgroundColor, opts.overwrite, opts.safeArea ); + } + c+=1; + } + if ( !this._quite ) { + this.emit( 'change' ); + } +} + +module.exports = addString; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-background-color.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-background-color.js new file mode 100644 index 000000000000..6c694da7db05 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-background-color.js @@ -0,0 +1,39 @@ +/* eslint-disable no-undefined */ + +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 colorsSet = require( './../colors-set.js' ); + +/** +* Method to check weather value is valid background color values. +* +* @private +* @name isValidBackgroundColor +* @param {string} value - color value +* @returns {boolean} is valid background color +*/ +function isValidBackgroundColor( value ) { + return colorsSet[value] !== undefined && value.startsWith( 'B' ); +} + +module.exports = isValidBackgroundColor; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-foreground-color.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-foreground-color.js new file mode 100644 index 000000000000..65430f561ca9 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-foreground-color.js @@ -0,0 +1,39 @@ +/* eslint-disable no-undefined */ + +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 colorsSet = require( './../colors-set.js' ); + +/** +* Method to check weather value is valid foreground color values. +* +* @private +* @name isValidForegroundColor +* @param {string} value - color value +* @returns {boolean} is valid forground color +*/ +function isValidForegroundColor( value ) { + return colorsSet[value] !== undefined && value.startsWith( 'F' ); +} + +module.exports = isValidForegroundColor; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-glyph.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-glyph.js new file mode 100644 index 000000000000..cd53c861af51 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-glyph.js @@ -0,0 +1,39 @@ +/* eslint-disable no-undefined */ + +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 glyphsSet = require( './../glyphs-set.js' ); + +/** +* Method to check weather value is valid glyph code. +* +* @private +* @name isValidForegroundColor +* @param {string} value - color value +* @returns {boolean} is valid forground color +*/ +function isValidForegroundColor( value ) { + return glyphsSet[value] !== undefined; +} + +module.exports = isValidForegroundColor; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-row-col.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-row-col.js new file mode 100644 index 000000000000..306592aff455 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/utils/is-valid-row-col.js @@ -0,0 +1,37 @@ + +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Method to check weather row and col is valid. +* +* @private +* @name isValid +* @param {number} row - row number +* @param {number} col - col number +* @param {number} height - height +* @param {number} width - width +* @returns {void} +*/ +function isValid( row, col, height, width ) { + return row >= 0 && row < height && col >= 0 && col < width; +} + +module.exports = isValid; diff --git a/lib/node_modules/@stdlib/plot/unicode/base/lib/wcswidth.js b/lib/node_modules/@stdlib/plot/unicode/base/lib/wcswidth.js new file mode 100644 index 000000000000..46998e14e985 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/base/lib/wcswidth.js @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 removeANSI = require( './remove_ansi.js' ); + + +// MAIN // + +/** +* Returns the width of a Unicode string when rendered to a terminal. +* +* @private +* @param {string} str - input string +* @returns {NonNegativeInteger} number of columns +*/ +function wcswidth( str ) { + return removeANSI( str ).length; // FIXME: implement wcswidth! +} + + +// EXPORTS // + +module.exports = wcswidth;