diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/default.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/default.js new file mode 100644 index 000000000000..9bfaabef3d98 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/default.js @@ -0,0 +1,47 @@ +/** +* @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 // + + +// MAIN // + +/** +* Returns default options. +* +* @private +* @returns {Object} default options +*/ +function defaults() { + var out = {}; + out.rows = void 0; + out.cols = void 0; + out.xaxis = []; + out.yaxis = []; + out.barColor = 'Fbl'; + out.labelColor = 'Fbl'; + out.marker = 'block'; + return out; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/example/index.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/example/index.js new file mode 100644 index 000000000000..e3fed3fcd096 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/example/index.js @@ -0,0 +1,66 @@ +/** +* @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 barchart = require( '@stdlib/plot/unicode/static_plots/bar' ); + +/* +1) some blocks are not generating Ex : 8th bar +2) labelColor is not working +*/ +var options = { + 'xaxis': [ 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + 'yaxis': [ 10, + 1, + 5, + 6, + 7, + 22, + 10, + 35, + 40, + 10, + 11, + 12, + 13, + 15 + ], + 'rows': 20, + 'cols': 100, + 'barColor': 'Frd', + 'labelColor': 'Frd' +}; +var inst = new barchart(options); + +inst.draw(); +inst.render(); diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/index.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/index.js new file mode 100644 index 000000000000..0c9b1241daa2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/index.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'; + +/** +* Base class for unicode bar chart. +* +* @module @stdlib/plot/unicode/static_plot/bar +* +* @example +* var base = require( '@stdlib/plot/unicode/static_plot/bar' ); +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/main.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/main.js new file mode 100644 index 000000000000..70dd49845563 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/main.js @@ -0,0 +1,466 @@ +/* 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-restricted-syntax, no-underscore-dangle, no-invalid-this */ + +'use strict'; + +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var defineProperty = require( '@stdlib/utils/define-property' ); +var min = require( '@stdlib/math/base/special/min' ); +var round = require( '@stdlib/math/base/special/round' ); +var max = require( '@stdlib/math/base/special/max' ); +var minmaxn = require( '@stdlib/math/base/special/minmaxn' ); +var mergeFcn = require( '@stdlib/utils/merge' ).factory; +var objectKeys = require( '@stdlib/utils/keys' ); +var ceil = require( '@stdlib/math/base/special/ceil' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var defaults = require( './default.js' ); +var setXaxis = require( './props/xaxis/set.js' ); +var getXaxis = require( './props/xaxis/get.js' ); +var setYaxis = require( './props/yaxis/set.js' ); +var getYaxis = require( './props/yaxis/get.js' ); +var setRows = require( './props/rows/set.js' ); +var getRows = require( './props/rows/get.js' ); +var setCols = require( './props/cols/set.js' ); +var getCols = require( './props/cols/get.js' ); +var setBarColor = require( './props/barColor/set.js' ); +var getBarColor = require( './props/barColor/get.js' ); +var setLabelColor = require( './props/labelColor/set.js' ); +var getLabelColor = require( './props/labelColor/get.js' ); +var setMarker = require( './props/marker/set.js' ); +var getMarker = require( './props/marker/get.js' ); +var primitive = require( './../base/lib' ); + + +// VARIABLES // + +var merge = mergeFcn({ + 'extend': false +}); + +// List of private properties (note: keep in alphabetical order): +var PRIVATE_PROPS = [ + '_x', + '_y', + '_rows', + '_cols', + '_barColor', + '_marker', + '_labelColor' +]; + +var Poptions = { + 'padBottom': 2 +}; + + +// MAIN // + +/** +* BarPlot constructor. +* +* @constructor +* @param {Options} options - constructor options +* @param {number} [rows] - number of character in height for plot +* @param {number} [cols] - number of character in width for plot +* @param {Array} [xaxis] - xaxis data +* @param {Array} [yaxis] - yaxis data +* @throws {TypeError} must provide valid options +* @returns {Plot} Plot instance +* +* @example +* var barplot = new BarPlot(); +*/ +function BarPlot() { + var options; + var nargs; + var keys; + var opts; + var key; + var i; + + for ( i = 0; i < PRIVATE_PROPS; i++ ) { + defineProperty( this, PRIVATE_PROPS[ i ], { + 'configurable': false, + 'enumerable': false, + 'writable': true, + 'value': null + }); + } + defineProperty( this, '_primitive', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': new primitive(Poptions) + }); + nargs = arguments.length; + opts = defaults(); + if ( nargs ) { + options = arguments[ 0 ]; + } + else { + options = {}; + } + opts = merge( opts, options ); + keys = objectKeys( opts ); + for ( i = 0; i < keys.length; i++ ) { + key = keys[ i ]; + this[ key ] = opts[ key ]; + } + + // Initilize primitive class + + this._primitive.setSize = { + 'rows': this._rows, + 'cols': this._cols + }; + return this; +} + +/** + * Main method which add label, draw bars according to the requirement. + * + * @name draw + * @memberof Primitive.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly(BarPlot.prototype, 'draw', function draw() { + var finalCordx; + var finalCordy; + var ybar; + var xbar; + var xlim; + var ylim; + var temp; + var i; + + finalCordx = []; + finalCordy = []; + this.addLableX(); + this._primitive.drawFrame(); + temp = scaleBar( this._x, this._y, this._cols - this._primitive._padLeft - this._primitive._padRight ); + xbar = temp[ 0 ]; + ybar = temp[ 1 ]; + xlim = getLim( xbar ); + ylim = getLim( ybar ); + for ( i = 0; i < xbar.length; i++ ) { + finalCordx.push( scale( xbar[ i ], this._cols - this._primitive._padLeft - this._primitive._padRight, xlim, this._primitive._padLeft ) ); + } + this.addCategory( finalCordx ); + for ( i = 0; i < ybar.length; i++ ) { + finalCordy.push( scale( ybar[ i ], this._rows - this._primitive._padBottom - this._primitive._padTop, ylim, this._primitive._padBottom ) ); + } + for ( i = 0; i < xbar.length; i++ ) { + this._primitive.drawRectangle( finalCordy[ i ], finalCordx[ i ], this._barColor, this._marker ); + } +}); + +/** + * Render and display the result. + * + * @name render + * @memberof Primitive.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly(BarPlot.prototype, 'render', function render() { + this._primitive.build(); + this._primitive.show(); +}); + +/** + * Add x label and tics. + * + * @name addLableX + * @memberof Primitive.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly(BarPlot.prototype, 'addLableX', function addLableX() { + var pointGap; + var xpos; + var step; + var elm; + var mx; + var y; + var i; + + pointGap = 1; + xpos = this._primitive._padBottom; + y = []; + mx = minmaxn.apply( null, this._y ); + + // Adding extra padding on left according to the number range of the tics + this._primitive.padLeft += mx[ 1 ].toString().length + 2; + + // Calculating steps of number according the rows + step = ( mx[ 1 ] - mx[ 0 ] ) / ( this._rows - this._primitive._padTop - this._primitive._padBottom ); + + // Changing precision of step to 1 dig after decimal + step = ceil( step * 10 ) / 10; + i = mx[ 0 ]; + while ( i <= mx[ 1 ] ) { + elm = new Array( 3 ); + elm[ 1 ] = 0; + elm[ 0 ] = xpos; + elm[ 2 ] = i.toString(); + y.push( elm ); + i += step; + i = round( i * 10 ) / 10; + xpos += pointGap; + } + this._primitive.addTic( false, this._labelColor, [], y ); +}); + +/** + * Add categories for the bars. + * + * @name addCategory + * @memberof Primitive.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly(BarPlot.prototype, 'addCategory', function addCategory( BarPositions ) { + var temp; + var cat; + var elm; + var i; + + cat = []; + for ( i = 0; i < BarPositions.length; i++ ) { + // row, col, str + elm = new Array( 3 ); + + // Taking middle + temp = floor( ( BarPositions[i][1] + BarPositions[i][0] ) / 2 ); + elm[ 0 ] = 0; + elm[ 1 ] = temp; + elm[ 2 ] = ( i + 1 ).toString(); + cat.push( elm ); + } + this._primitive.addTic( true, this._labelColor, cat ); +}); + +/** + * @name xaxis + * @memberof Primitive.prototype + * @type {Array} + * @throws {TypeError} + * + */ +defineProperty( BarPlot.prototype, 'xaxis', { + 'configurable': false, + 'enumerable': true, + 'set': setXaxis, + 'get': getXaxis +}); + +/** + * @name yaxis + * @memberof Primitive.prototype + * @type {Array} + * @throws {TypeError} + * + */ +defineProperty( BarPlot.prototype, 'yaxis', { + 'configurable': false, + 'enumerable': true, + 'set': setYaxis, + 'get': getYaxis +}); + +/** + * @name rows + * @memberof Primitive.prototype + * @type {number} + * @throws {TypeError} + * + */ +defineProperty( BarPlot.prototype, 'rows', { + 'configurable': false, + 'enumerable': true, + 'set': setRows, + 'get': getRows +}); + +/** + * @name cols + * @memberof Primitive.prototype + * @type {number} + * @throws {TypeError} + * + */ +defineProperty( BarPlot.prototype, 'cols', { + 'configurable': false, + 'enumerable': true, + 'set': setCols, + 'get': getCols +}); + +/** + * @name barColor + * @memberof Primitive.prototype + * @type {string} + * @throws {TypeError} + * + */ +defineProperty( BarPlot.prototype, 'barColor', { + 'configurable': false, + 'enumerable': true, + 'set': setBarColor, + 'get': getBarColor +}); + +/** + * @name labelColor + * @memberof Primitive.prototype + * @type {string} + * @throws {TypeError} + * + */ +defineProperty( BarPlot.prototype, 'labelColor', { + 'configurable': false, + 'enumerable': true, + 'set': setLabelColor, + 'get': getLabelColor +}); + +/** + * @name marker + * @memberof Primitive.prototype + * @type {string} + * @throws {TypeError} + * + */ +defineProperty( BarPlot.prototype, 'marker', { + 'configurable': false, + 'enumerable': true, + 'set': setMarker, + 'get': getMarker +}); + +/** +* Find the best suitable width of the bars according to the width. +* +* @private +* +* @type {Function} +* @param {Array} x - date of x axis +* @param {Array} y - data of y axis +* @param {number} containerWidth - width of the container +* @returns {Array} array of scale represent width and height of bar +* */ +function scaleBar( x, y, containerWidth ) { + var dataPoints; + var widthHalf; + var barWidth; + var awidth; + var width; + var bins; + var xbar; + var ybar; + var i; + + width = 0.8; + dataPoints = x.length; + awidth = floor( containerWidth / dataPoints ); + + // Scaling the width scale, with 101 character width and 10 data points bar width scale of 0.8 works great, so scale is realtive to it, by scale them with the ratio of ( containerWidht / dataPoints ) / ( 101 / 10 ) + width *= ( ( containerWidth / dataPoints ) * ( 10 / 101 ) ); + + // 0.8 is the max width we can use because we also need to care about the spaces between bars + width = min( width, 0.8 ); + + // This normalization is done to reduce the rounding error, effect of this can be seen when the width is of 16 char or less and atleast 14 bars + barWidth = floor( awidth * width ); + width *= ( barWidth / ( awidth * width ) ); + bins = x.length; + widthHalf = width / 2; + xbar = []; + ybar = []; + for ( i = 0; i < bins; i++ ) { + xbar.push( [ x[ i ] - widthHalf, x[ i ] + widthHalf ] ); + ybar.push( [ 0, y[ i ] ] ); + } + return [ xbar, ybar ]; +} + +/** +* Convert the elms value in scale of between bins and pad. +* +* @private +* +* @type {Function} +* @param {Array} elms - array of value need to scale +* @param {Number} bins - upper value under which we have to scale +* @param {Array} lim - array of high and low value of data +* @param {number} pad - pading from left +* @returns {Array} array of range value +* */ +function scale( elms, bins, lim, pad ) { + var sElm; + var elm; + var arr; + var i; + + arr = []; + for ( i = 0; i < elms.length; i++ ) { + elm = elms[i]; + + // Converting value in range of 0 to 1 + sElm = ( elm - lim[ 0 ] ) / ( lim[ 1 ] - lim[ 0 ] ); + arr.push( round( pad + ( ( bins - 1 ) * sElm ) ) ); + } + return arr; +} + +/** +* Helper function which give the higher and lower value of the bars. +* +* @private +* +* @name getLim +* @type {Function} +* @param {Array} elms - target elements +* @returns {Array} return min and max value of elms +* */ +function getLim( elms ) { + var temp; + var mn; + var mx; + var i; + + for ( i = 0; i < elms.length; i++ ) { + temp = elms[i]; + mn = min( mn, temp[ 0 ] ); + mx = max( mx, temp[ 1 ] ); + } + return [ mn, mx ]; +} + + +// EXPORTS // + +module.exports = BarPlot; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/barColor/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/barColor/get.js new file mode 100644 index 000000000000..8d56889be0f2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/barColor/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the rendering mode. +* +* @private +* @returns {Array} rendering mode +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._barColor; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/barColor/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/barColor/set.js new file mode 100644 index 000000000000..24b71ce7ef24 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/barColor/set.js @@ -0,0 +1,51 @@ +/** +* @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' ); + + +// VARIABLES // + +var colors = require( '@stdlib/plot/unicode/static_plots/marker/colors.js' ); + + +// MAIN // + +/** +* Sets the rendering mode. +* +* @private +* @param {string} color - indicate the color code. +* @throws {TypeError} must be a number +*/ +function set( color ) { + /* eslint-disable no-invalid-this */ + if ( !( color in colors ) ) { + throw new TypeError( format( 'invalid color code.' ) ); + } + this._barColor = color; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/cols/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/cols/get.js new file mode 100644 index 000000000000..b5f96079a601 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/cols/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the rendering mode. +* +* @private +* @returns {Array} rendering mode +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._cols; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/cols/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/cols/set.js new file mode 100644 index 000000000000..5c922543aa35 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/cols/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. +*/ + +'use strict'; + +// MODULES // + +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the rendering mode. +* +* @private +* @param {Array} num - num indicate scale value of the height. +* @throws {TypeError} must be a number +* @throws {RangeError} must be in range of 0 to 1 +*/ +function set( num ) { + /* eslint-disable no-invalid-this */ + if ( !num ) { + this._cols = process.stdout.columns; + return; + } + if ( !isNumber( num ) ) { + throw new TypeError( format( 'invalid assignment. must be a array.' ) ); + } + this._cols = num; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/labelColor/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/labelColor/get.js new file mode 100644 index 000000000000..ae05599b8659 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/labelColor/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the rendering mode. +* +* @private +* @returns {Array} rendering mode +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._labelColors; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/labelColor/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/labelColor/set.js new file mode 100644 index 000000000000..14f8bc0906a6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/labelColor/set.js @@ -0,0 +1,47 @@ +/** +* @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 colors = require( '@stdlib/plot/unicode/static_plots/marker/colors.js' ); + + +// MAIN // + +/** +* Sets the rendering mode. +* +* @private +* @param {string} color - indicate the color code. +* @throws {TypeError} must be a number +*/ +function set( color ) { + /* eslint-disable no-invalid-this */ + if ( !( color in colors ) ) { + throw new TypeError( format( 'invalid color code.' ) ); + } + this._labelColor = color; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/marker/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/marker/get.js new file mode 100644 index 000000000000..b5f96079a601 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/marker/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the rendering mode. +* +* @private +* @returns {Array} rendering mode +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._cols; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/marker/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/marker/set.js new file mode 100644 index 000000000000..1ec4295956cf --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/marker/set.js @@ -0,0 +1,51 @@ +/** +* @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' ); + + +// VARIABLES // + +var markers = require( '@stdlib/plot/unicode/static_plots/marker/markers.js' ); + + +// MAIN // + +/** +* Sets the rendering mode. +* +* @private +* @param {string} marker - indicate the marker code. +* @throws {TypeError} must be a number +*/ +function set( marker ) { + /* eslint-disable no-invalid-this */ + if ( !( marker in markers ) ) { + throw new TypeError( format( 'invalid color code.' ) ); + } + this._marker = marker; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/rows/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/rows/get.js new file mode 100644 index 000000000000..40baa01c6474 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/rows/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the rendering mode. +* +* @private +* @returns {Array} rendering mode +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._rows; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/rows/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/rows/set.js new file mode 100644 index 000000000000..00efb5b5f697 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/rows/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. +*/ + +'use strict'; + +// MODULES // + +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the rendering mode. +* +* @private +* @param {number} num - num indicate scale value of the height. +* @throws {TypeError} must be a number +* @throws {RangeError} must be in range of 0 to 1 +*/ +function set( num ) { + /* eslint-disable no-invalid-this */ + if ( !num ) { + this._rows = process.stdout.rows; + return; + } + if ( !isNumber( num ) ) { + throw new TypeError( format( 'invalid assignment. must be a array.' ) ); + } + this._rows = num; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/xaxis/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/xaxis/get.js new file mode 100644 index 000000000000..7f66915fb99a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/xaxis/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the rendering mode. +* +* @private +* @returns {Array} rendering mode +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._x; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/xaxis/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/xaxis/set.js new file mode 100644 index 000000000000..836361da4c75 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/xaxis/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'; + +// MODULES // + +var isArray = require( '@stdlib/assert/is-array' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the rendering mode. +* +* @private +* @param {Array} num - num indicate scale value of the height. +* @throws {TypeError} must be a number +* @throws {RangeError} must be in range of 0 to 1 +*/ +function set( num ) { + /* eslint-disable no-invalid-this */ + if ( !isArray( num ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a array. Value: `%s`.', 'autoRender', num ) ); + } + this._x = num; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/yaxis/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/yaxis/get.js new file mode 100644 index 000000000000..8d7798e69fe7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/yaxis/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the rendering mode. +* +* @private +* @returns {Array} rendering mode +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._y; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/yaxis/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/yaxis/set.js new file mode 100644 index 000000000000..2a5ab7263487 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/bar/props/yaxis/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'; + +// MODULES // + +var isArray = require( '@stdlib/assert/is-array' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the rendering mode. +* +* @private +* @param {Array} num - num indicate scale value of the height. +* @throws {TypeError} must be a number +* @throws {RangeError} must be in range of 0 to 1 +*/ +function set( num ) { + /* eslint-disable no-invalid-this */ + if ( !isArray( num ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a array. Value: `%s`.', 'autoRender', num ) ); + } + this._y = num; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/default.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/default.js new file mode 100644 index 000000000000..7d42f457756d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/default.js @@ -0,0 +1,49 @@ +/** +* @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 // + +/** +* Returns default options. +* +* @private +* @returns {Object} default options +* +* @example +* var opts = defaults(); +* // returns {...} +*/ +function defaults() { + var out = {}; + out.padBottom = 1; + out.padLeft = 1; + out.padRight = 1; + out.padTop = 1; + out.setSize = { + 'rows': 0, + 'cols': 0 + }; + return out; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/index.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/index.js new file mode 100644 index 000000000000..f41cf103961c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/index.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'; + +/** +* Base class for base constructure for unicode. +* +* @module @stdlib/plot/unicode/static_plots/base +* +* @example +* var base = require( '@stdlib/plot/unicode/static_plots/base' ); +*/ + +// MODULES // + +var main = require( './plotbase.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/pallete.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/pallete.js new file mode 100644 index 000000000000..9106fcb2261e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/pallete.js @@ -0,0 +1,254 @@ +/** +* @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-underscore-dangle */ +/* eslint-disable no-invalid-this */ +/* eslint-disable max-len */ +/* eslint-disable no-restricted-syntax */ + +'use strict'; + +var defineProperty = require( '@stdlib/utils/define-property' ); +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var markers = require( '@stdlib/plot/unicode/static_plots/marker/markers.js' ); +var ansiColors = require( '@stdlib/plot/unicode/static_plots/marker/colors.js' ); + + +// VARIABLES // + +var defaults = { + 'backgroundColor': 'Bwh', + 'forwardColor': 'Frd', + 'marker': 'sp' +}; + + +// MAIN // + +/** +* Pallete constructor. +* +* @constructor +* @param {PlotBase} PlotBase - PlotBase instance +* @throws {TypeError} must provide valid options +* @returns {Pallete} Pallete instance +* +* @example +* var pallete = new Pallete(); +*/ +function Pallete( PlotBase ) { + defineProperty( this, '_sketch', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + defineProperty( this, '_colors', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + defineProperty( this, '_backgrounds', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + defineProperty( this, '_plotBase', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': PlotBase + }); + + return this; +} + +/** + * Weather row and col is legal or not. + * + * @name isLegal + * @memberof Primitive.prototype + * @type {Function} + * @param {number} row + * @param {number} col + * @returns {void} + * + */ +setNonEnumerableReadOnly( Pallete.prototype, 'isLegal', function isLegal( row, col ) { + return row < this._sketch.length && col < this._sketch[0].length && row >= 0 && col >=0; +} ); + +/** + * Set the ansi character on specific row and column. + * + * @name setSketch + * @memberof Primitive.prototype + * @type {Function} + * @param {number} row + * @param {number} col + * @param {number} mark + * @param {boolean} overwrite + * @returns {void} + * + */ +setNonEnumerableReadOnly( Pallete.prototype, 'setSketch', function setSketch( row, col, mark, overwrite ) { + if ( this.isLegal( row, col ) && ( overwrite || ( this._sketch[ row ][ col ] === defaults[ 'marker' ] ) ) ) { + this._sketch[ row ][ col ] = mark; + } +} ); + +/** + * Add horizontel String on matrix. + * + * @name addHorizontelString + * @memberof Primitive.prototype + * @type {Function} + * @param {number} row + * @param {number} col + * @param {string} str + * @param {string} color + * @param {boolean} overwrite + * @returns {void} + * + */ +setNonEnumerableReadOnly( Pallete.prototype, 'addHorizontelString', function addHorizontelString( row, col, str, color, overwrite ) { + var ch; + var c; + + c = col; + for ( ch of str ) { + this.setElement( row, c, ch, color, overwrite || false ); + c += 1; + } +} ); + +/** + * Set color on the color matrix on specific row and col. + * + * @name setColor + * @memberof Primitive.prototype + * @type {Function} + * @param {number} row + * @param {number} col + * @param {string} color + * @param {boolean} overwrite + * @returns {void} + * + */ +setNonEnumerableReadOnly( Pallete.prototype, 'setColor', function setColor(row, col, color, overwrite ) { + if ( this.isLegal( row, col ) && ( overwrite || ( this._colors[ row ][ col ] === defaults[ 'forwardColor' ] ) ) ) { + this._colors[ row ][ col ] = color; + } +}); + +/** + * Set ansi element and color in matrix. + * + * @name setElement + * @memberof Primitive.prototype + * @type {Function} + * @param {number} row + * @param {number} col + * @param {string} marker + * @param {string} color + * @param {boolean} overwrite + * @returns {void} + * + */ +setNonEnumerableReadOnly( Pallete.prototype, 'setElement', function setElement( row, col, marker, color, overwrite ) { + if ( marker ) { + this.setSketch( row, col, marker, overwrite ); + } + if ( color) { + this.setColor( row, col, color, overwrite ); + } +} ); + +/** + * Final render the code name by convert them to ansiCode. + * + * @name setcanvas + * @memberof Primitive.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly( Pallete.prototype, 'setcanvas', function setcanvas() { + var remainwidth = process.stdout.columns - 0; + var background; + var canva = ''; + var color; + var i; + var j; + + for ( i = this._sketch.length - 1; i >= 0; i-- ) { + canva += '\r'; + for ( j = 0; j < this._sketch[ 0 ].length && j < remainwidth; j++ ) { + // If background color is not same as previous then only we need to change it + if ( !this.isLegal( i, j - 1 ) || this._backgrounds[ i ][ j ] !== this._backgrounds[ i ][ j - 1 ] ) { + background = ansiColors[ this._backgrounds[ i ][ j ] ]; + canva += background; + } + // If forward color is not same as previous then only we need to change it + if ( !this.isLegal( i, j - 1 ) || this._colors[ i ][ j ] !== this._colors[ i ][ j - 1 ] ) { + color = ansiColors[ this._colors[ i ][ j ] ]; + canva += color; + } + canva += markers[ this._sketch[ i ][ j ] ]; + } + canva += ansiColors[ 'def' ]; + canva += '\n'; + } + this.canva = canva; + return canva; +} ); + +/** + * Initilize the matrices according to the row and column size. + * + * @name set_matrices + * @memberof Primitive.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly( Pallete.prototype, 'setMatrices', function setMatrices() { + var temp1; + var temp2; + var temp3; + var i; + var j; + + for ( i = 0; i < this._plotBase._rows; i++ ) { + temp1 = []; + temp2 = []; + temp3 = []; + for ( j = 0; j < this._plotBase._cols; j++ ) { + temp1.push( defaults[ 'marker' ] ); + temp2.push( defaults[ 'forwardColor' ] ); + temp3.push( defaults[ 'backgroundColor' ] ); + } + this._sketch.push( temp1 ); + this._colors.push( temp2 ); + this._backgrounds.push( temp3 ); + } +} ); + +module.exports = Pallete; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/plotbase.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/plotbase.js new file mode 100644 index 000000000000..5dd7d8b06541 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/plotbase.js @@ -0,0 +1,456 @@ +/** +* @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 */ +/* eslint-disable no-restricted-syntax */ + +'use strict'; + +// MODULES // + +var defineProperty = require( '@stdlib/utils/define-property' ); +var minn = require( '@stdlib/math/base/special/minn' ); +var maxn = require( '@stdlib/math/base/special/maxn' ); +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var mergeFcn = require( '@stdlib/utils/merge' ).factory; +var objectKeys = require( '@stdlib/utils/keys' ); +var min = require( '@stdlib/math/base/special/min' ); +var max = require( '@stdlib/math/base/special/max' ); +var setSize= require( './props/setSize/set.js' ); +var getSize = require( './props/setSize/get.js' ); +var setpadTop= require( './props/padTop/set.js' ); +var getpadTop = require( './props/padTop/get.js' ); +var setpadBottom= require( './props/padBottom/set.js' ); +var getpadBottom = require( './props/padBottom/get.js' ); +var setpadLeft = require( './props/padLeft/set.js' ); +var getpadLeft = require( './props/padLeft/get.js' ); +var setpadRight = require( './props/padRight/set.js' ); +var getpadRight = require( './props/padRight/get.js' ); +var Pallete = require( './pallete.js' ); +var defaults = require( './default.js' ); + + +// VARIABLES // + +// List of private properties (note: keep in alphabetical order): +var PRIVATE_PROPS = [ + '_cols', + '_padBottom', + '_padLeft', + '_padRight', + '_padTop', + '_rows', + '_setSize' +]; + + +// FUNCTIONS // + +var merge = mergeFcn({ + 'extend': false +}); + + +// MAIN // + +/** +* PlotBase constructor. +* +* @constructor +* @param {Options} options - constructor options +* @param {number} [Options.padBottom] - padding bottom +* @param {number} [Options.padLeft] - padding left +* @param {number} [Options.padRight] - padding right +* @param {number} [Options.padTop] - padding top +* @param {Object} [Options.setSize] - size object with character width and height +* @throws {TypeError} must provide valid options +* @returns {PlotBase} PlotBase instance +* +* @example +* var PlotBase = new PlotBase(); +*/ +function PlotBase( ) { + var options; + var nargs; + var keys; + var opts; + var key; + var i; + + defineProperty( this, '_x', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + + defineProperty( this, '_y', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + + defineProperty( this, '_marker', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + + defineProperty( this, '_color', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': [] + }); + + defineProperty( this, '_palt', { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': new Pallete(this) + }); + + for ( i = 0; i < PRIVATE_PROPS; i++ ) { + defineProperty( this, PRIVATE_PROPS[ i ], { + 'configurable': false, + 'enumerable': false, + 'writable': true, + 'value': null + }); + } + + nargs = arguments.length; + opts = defaults(); + if ( nargs ) { + options = arguments[ 0 ]; + } + else { + options = {}; + } + opts = merge( opts, options ); + keys = objectKeys( opts ); + for ( i = 0; i < keys.length; i++ ) { + key = keys[ i ]; + this[ key ] = opts[ key ]; + } + return this; +} + +/** + * Add all the ansi codes to the matrix. + * + * @name build + * @memberof PlotBase.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly(PlotBase.prototype, 'build', function build() { + var finalC =[]; + var temp; + var i; + var j; + + for ( i = 0; i < this._x.length; i++ ) { + finalC.push( fillCord( this._x[ i ], this._y[ i ] ) ); + } + + for ( i = 0; i < finalC.length; i++ ) { + temp = finalC[ i ]; + for ( j = 0; j < temp.length; j++ ) { + this._palt.setElement( temp[ j ][ 0 ], temp[ j ][ 1 ], this._marker[ i ], this._color[ i ] ); + } + } +}); + +/** + * Display the rendered plots. + * + * @name show + * @memberof PlotBase.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly(PlotBase.prototype, 'show', function show() { + var canva = this._palt.setcanvas(); + process.stdout.write( canva ); +}); + +/** + * Fill all the metrices representing the each structure of plot. + * + * @name draw + * @memberof PlotBase.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly(PlotBase.prototype, 'draw', function draw( x, y, color, marker ) { + this._x.push( x ); + this._y.push( y ); + this._marker.push( marker || ' ' ); + this._color.push( color || 'wh' ); +}); + +/** + * Logic for rectangle structure. + * + * @name drawRectangle + * @memberof PlotBase.prototype + * @type {Function} + * @returns {void} + * + */ +setNonEnumerableReadOnly(PlotBase.prototype, 'drawRectangle', function drawRectangle( xb, yb, color, marker ) { + var xm = minn.apply( null, xb ); + var xM = maxn.apply( null, xb ); + var ym = minn.apply( null, yb ); + var yM = maxn.apply( null, yb ); + var x = [ xm, xm, xM, xM, xm ]; + var y = [ ym, yM, yM, ym, ym ]; + this.draw( x, y, color, marker ); +}); + +/** + * Add label and tics to the axis. + * + * @name addTic + * @memberof PlotBase.prototype + * @type {Function} + * @param {boolean} overwrite // weather overwrite is enable or not + * @param {string} color // color code for the tics + * @param {Array} x // tics and label for the bottom horizontel axis + * @param {Array} y // tics and label for the left vertical axis + * @param {Array} z // tics and label for the top horizontel axis + * @param {Array} w // tics and label for the right horizontel axis + * @param {boolean} overwrite + * @returns {void} + * + */ +setNonEnumerableReadOnly(PlotBase.prototype, 'addTic', function addTic( overwrite, color, x, y, z, w ) { + var i; + + if ( x && x.length > 0 ) { + for ( i = 0; i < x.length; i++ ) { + this._palt.setElement( this._padBottom - 1, x[ i ][ 1 ], 'HorTic', color, overwrite ); + this._palt.addHorizontelString( x[ i ][ 0 ], x[ i ][ 1 ], x[ i ][ 2 ].toString(), color, overwrite ); + } + } + if ( z && z.length > 0 ) { + for ( i = 0; i < z.length; i++ ) { + this._palt.setElement( this._padBottom - 1, z[ i ][ 1 ], 'HorTic', color, overwrite ); + this._palt.addHorizontelString( z[ i ][ 0 ], z[ i ][ 1 ], z[ i ][ 2 ].toString(), color, overwrite ); + } + } + if ( y && y.length > 0 ) { + for ( i = 0; i < y.length; i++ ) { + this._palt.setElement( y[ i ][ 0 ], this._padLeft - 1, 'VerTic', color, overwrite ); + this._palt.addHorizontelString( y[ i ][ 0 ], y[ i ][ 1 ], y[ i ][ 2 ].toString(), color, overwrite ); + } + } + if ( w && w.length > 0 ) { + for ( i = 0; i < w.length; i++ ) { + this._palt.setElement( w[ i ][ 0 ], this._padLeft - 1, 'VerTic', color, overwrite ); + this._palt.addHorizontelString( w[ i ][ 0 ], w[ i ][ 1 ], w[ i ][ 2 ].toString(), color, overwrite ); + } + } +}); + +/** + * Draw the frame. + * + * @name drawFrame + * @memberof PlotBase.prototype + * @type {Function} + * @param {boolean} overwrite // overwrite is enable or not + * @param {string} color // color code for the frame + * @returns {void} + * + */ +setNonEnumerableReadOnly( PlotBase.prototype, 'drawFrame', function drawFrame( overwrite, color ) { + var i; + + for ( i = this._padBottom-1; i < this._rows; i++ ) { + this._palt.setElement( i, this._padLeft - 1, 'vertical', color, overwrite ); + this._palt.setElement( i, this._cols-1, 'vertical', color, overwrite ); + } + + for ( i = this._padLeft-1; i < this._cols; i++ ) { + this._palt.setElement( this._padBottom - 1, i, 'horizontal', color, overwrite ); + this._palt.setElement( this._rows-1, i, 'horizontal', color, overwrite ); + } + + // Corners + + this._palt.setElement( this._padBottom - 1, this._padLeft - 1, 'LBcorner', color, true ); + this._palt.setElement( this._padBottom - 1, this._cols-1, 'RBcorner', color, true ); + this._palt.setElement( this._rows-1, this._padLeft - 1, 'LTcorner', color, true ); + this._palt.setElement( this._rows-1, this._cols-1, 'RTcorner', color, true ); +}); + +/** + * @name setSize + * @memberof PlotBase.prototype + * @type {Object} + * @throws {TypeError} + * + */ +defineProperty( PlotBase.prototype, 'setSize', { + 'configurable': false, + 'enumerable': true, + 'set': setSize, + 'get': getSize +}); + +/** + * @name padBottom + * @memberof PlotBase.prototype + * @type {number} + * @throws {TypeError} + * + */ +defineProperty( PlotBase.prototype, 'padBottom', { + 'configurable': false, + 'enumerable': true, + 'set': setpadBottom, + 'get': getpadBottom +}); + +/** + * @name padTop + * @memberof PlotBase.prototype + * @type {number} + * @throws {TypeError} + * + */ +defineProperty( PlotBase.prototype, 'padTop', { + 'configurable': false, + 'enumerable': true, + 'set': setpadTop, + 'get': getpadTop +}); + +/** + * @name padLeft + * @memberof PlotBase.prototype + * @type {number} + * @throws {TypeError} + * + */ +defineProperty( PlotBase.prototype, 'padLeft', { + 'configurable': false, + 'enumerable': true, + 'set': setpadLeft, + 'get': getpadLeft +}); + +/** + * @name padRight + * @memberof PlotBase.prototype + * @type {number} + * @throws {TypeError} + * + */ +defineProperty( PlotBase.prototype, 'padRight', { + 'configurable': false, + 'enumerable': true, + 'set': setpadRight, + 'get': getpadRight +}); + +/** +* Provide the cordinate under the closed structure to fill them. +* @private +* @name fillCord +* @type {Function} +* @param {Array} sx - vertices x cordinate of structure +* @param {Array} sy - vertices y cordinate of structure +* @returns {Array} cordinate of filled structure +* */ +function fillCord( sx, sy ) { + var lcord; + var temp; + var L1; + var L2; + var i; + + lcord = []; + L1 = []; + L2 = []; + + // If not closed structure fill is not possible + if ( sx[ 0 ] !== sx[ sy.length - 1 ] || sx.length < 3 ) { + return; + } + + L1 = fillLine( [ sx[ 0 ], sx[ 1 ] ], [ sy[ 0 ], sy[ 1 ] ] ); + L2 = fillLine( [sx[ 2 ], sx[ 3 ] ], [ sy[ 2 ], sy[ 3 ] ] ); + + for ( i = 0; i < L1.length; i++ ) { + temp = fillLine( [ L1[ i ][ 0 ], L2[ i ][ 0 ] ], [ L1[ i ][ 1 ], L2[ i ][ 1 ] ] ); + lcord = lcord.concat(temp); + } + return lcord; +} + +/** +* Provide the coordinates between 2 points for line. +* +* @private +* +* @name fillLine +* @type {Function} +* @param {Array} sx - x coordinates of points of line +* @param {Array} sy - y coordinates of points of line +* @returns {Array} Array of all coordinates of line +* */ +function fillLine( sx, sy ) { + var lcord =[]; + var mx; + var Mx; + var my; + var My; + var i; + + if ( sx.length < 2 ) { + return; + } + + mx = min( sx[ 0 ], sx[ 1 ] ); + Mx = max( sx[ 0 ], sx[ 1 ] ); + my = min( sy[ 0 ], sy[ 1 ] ); + My = max( sy[ 0 ], sy[ 1 ] ); + if ( Mx-mx === 0 ) { + for ( i = my; i <= My; i++ ) { + lcord.push( [ mx, i ] ); + } + return lcord; + } + if ( My-my === 0 ) { + for ( i = mx; i <= Mx; i++ ) { + lcord.push( [ i, my ] ); + } + return lcord; + } + return lcord; +} +module.exports= PlotBase; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padBottom/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padBottom/get.js new file mode 100644 index 000000000000..864af090b1ff --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padBottom/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the bottom pading. +* +* @private +* @returns {number} // bottom padding +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._padBottom; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padBottom/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padBottom/set.js new file mode 100644 index 000000000000..d4b20f3591e7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padBottom/set.js @@ -0,0 +1,47 @@ +/** +* @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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the bottom pad. +* +* @private +* @param {number} num - bottom padding. +* @throws {TypeError} must be a number +*/ +function set( num ) { + /* eslint-disable no-invalid-this */ + if ( !isNumber( num ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'autoRender', num ) ); + } + this._padBottom = num; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padLeft/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padLeft/get.js new file mode 100644 index 000000000000..ad27dc94e0bc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padLeft/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the left pading. +* +* @private +* @returns {number} // left padings +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._padLeft; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padLeft/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padLeft/set.js new file mode 100644 index 000000000000..e673d7d63829 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padLeft/set.js @@ -0,0 +1,47 @@ +/** +* @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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the left pading. +* +* @private +* @param {number} num - num character pading from left. +* @throws {TypeError} must be a number +*/ +function set( num ) { + /* eslint-disable no-invalid-this */ + if ( !isNumber( num ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'autoRender', num ) ); + } + this._padLeft = num; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padRight/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padRight/get.js new file mode 100644 index 000000000000..d87c72013466 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padRight/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the right pading. +* +* @private +* @returns {number} // right padding +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._padRight; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padRight/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padRight/set.js new file mode 100644 index 000000000000..1d394c5f8149 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padRight/set.js @@ -0,0 +1,47 @@ +/** +* @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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the right pading. +* +* @private +* @param {number} num - num character pading from right. +* @throws {TypeError} must be a number +*/ +function set( num ) { + /* eslint-disable no-invalid-this */ + if ( !isNumber( num ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'autoRender', num ) ); + } + this._padRight = num; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padTop/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padTop/get.js new file mode 100644 index 000000000000..90c66808ee4f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padTop/get.js @@ -0,0 +1,35 @@ +/** +* @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'; + +/** +* Returns the top pading. +* +* @private +* @returns {number} // top padding +*/ +function get() { + /* eslint-disable no-invalid-this */ + return this._padTop; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padTop/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padTop/set.js new file mode 100644 index 000000000000..225c63d708e0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/padTop/set.js @@ -0,0 +1,47 @@ +/** +* @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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Sets the top pading. +* +* @private +* @param {number} num - number of character pading from top. +* @throws {TypeError} must be a number +*/ +function set( num ) { + /* eslint-disable no-invalid-this */ + if ( !isNumber( num ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a number. Value: `%s`.', 'autoRender', num ) ); + } + this._padTop = num; +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/setSize/get.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/setSize/get.js new file mode 100644 index 000000000000..f0b8f237fad2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/setSize/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. +*/ + +'use strict'; + +/** +* Returns the rendering mode. +* +* @private +* @returns {number} rendering mode +*/ +function get() { + /* eslint-disable no-invalid-this */ + return { + 'rows': this._rows, + 'cols': this._cols + }; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/setSize/set.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/setSize/set.js new file mode 100644 index 000000000000..e9ff5f88dc7f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/base/lib/props/setSize/set.js @@ -0,0 +1,50 @@ +/** +* @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 isObject = require( '@stdlib/assert/is-object' ); + + +// MAIN // + +/** +* Sets the rendering mode. +* +* @private +* @param {number} num - num indicate scale value of the height. +* @throws {TypeError} must be a number +* @throws {RangeError} must be in range of 0 to 1 +*/ +function set( num ) { + /* eslint-disable no-invalid-this */ + if ( !isObject( num ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a object. Value: `%s`.', 'autoRender', num ) ); + } + this._rows = num['rows']; + this._cols = num['cols']; + this._palt.setMatrices(); +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/marker/colors.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/marker/colors.js new file mode 100644 index 000000000000..e849623febf1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/marker/colors.js @@ -0,0 +1,33 @@ +/** +* @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 colors = { + 'Fwh': '\x1b[37m', + 'Fbl': '\x1b[30m', + 'Frd': '\x1b[31m', + 'Fbu': '\x1b[94m', + 'Bwh': '\x1b[47m', + 'Bbl': '\x1b[40m', + 'Bbu': '\x1b[104m', + 'Byl': '\x1b[43m', + 'def': '\x1b[0m' +}; + +module.exports = colors; diff --git a/lib/node_modules/@stdlib/plot/unicode/static_plots/marker/markers.js b/lib/node_modules/@stdlib/plot/unicode/static_plots/marker/markers.js new file mode 100644 index 000000000000..6bf4954f4986 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/unicode/static_plots/marker/markers.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. +*/ + +'use strict'; + +var markers; +var temp; +var i; + +markers = { + 'sp': ' ', + 'null': '', + 'block': '█', + 'vertical': '│', + 'horizontal': '─', + 'LBcorner': '└', + 'RBcorner': '┘', + 'LTcorner': '┌', + 'RTcorner': '┐', + 'HorTic': '┬', + 'VerTic': '┤', + '[0,0,0,0]': ' ', + '[1,0,0,0]': '▘', + '[0,0,1,0]': '▖', + '[0,0,0,1]': '▗', + '[0,1,0,0]': '▝', + '[1,0,1,0]': '▌', + '[0,1,0,1]': '▐', + '[0,0,1,1]': '▄', + '[1,1,0,0]': '▀', + '[1,0,0,1]': '▚', + '[0,1,1,0]': '▞', + '[1,1,1,0]': '▛', + '[1,0,1,1]': '▙', + '[0,1,1,1]': '▟', + '[1,1,0,1]': '▜', + '[1,1,1,1]': '█' +}; + +for ( i = 0; i < 10; i++ ) { + temp = '' + i; + markers[temp] = temp; +} + +markers['.'] = '.'; + +module.exports = markers;