diff --git a/etc/npm/deps.txt b/etc/npm/deps.txt index 105531f4058c..222efdfbb9fe 100644 --- a/etc/npm/deps.txt +++ b/etc/npm/deps.txt @@ -1 +1 @@ -acorn@"^8.1.0" acorn-loose@"^8.0.2" acorn-walk@"^8.0.2" d3-format@"^1.0.0" d3-scale@"^1.0.0" d3-shape@"^1.0.0" d3-time-format@"^2.0.0" debug@"^2.6.9" glob@"^7.0.5" minimist@"^1.2.0" readable-stream@"^2.1.4" resolve@"^1.1.7" vdom-to-html@"^2.3.0" virtual-dom@"^2.1.1" 0x@"^4.10.2" @cspell/eslint-plugin@"^8.8.0" @commitlint/cli@"^17.4.4" @commitlint/cz-commitlint@"^17.4.4" @conventional-commits/parser@"^0.4.1" @kaciras/deasync@"^1.0.1" @types/node@"^13.9.0" @typescript-eslint/parser@"^6.9.1" @typescript-eslint/eslint-plugin@"^6.9.1" ajv@"^5.2.2" browser-pack-flat@"^3.0.0" browserify@"^17.0.0" bundle-collapser@"^1.3.0" c8@"^7.12.0" chai@"^3.5.0" cheerio@"^1.0.0-rc.12" commitizen@"^4.3.0" common-shakeify@"^0.6.0" conventional-changelog-conventionalcommits@"^5.0.0" doctrine@"^3.0.0" editorconfig-checker@"^6.0.0" envify@"^4.0.0" eslint@"^8.57.0" eslint-plugin-n@"^17.17.0" eslint-plugin-expect-type@"^0.2.3" eslint-plugin-import@"^2.29.0" eslint-plugin-jsdoc@"^46.8.2" eslint-plugin-stdlib@"file:./etc/eslint/plugin" exorcist@"^2.0.0" factor-bundle@"^2.5.0" gh-pages@"git+https://github.com/Planeshifter/gh-pages.git#main" inquirer@"^8.0.0" jscodeshift@"^0.15.0" jsdoc@"^3.4.0" lunr@"^2.3.9" mathjax-node@"^2.0.1" mathjax-node-sre@"^3.0.0" mkdirp@"^0.5.1" mustache@"^4.0.0" parse-link-header@"^1.0.1" plato@"^1.5.0" process@"^0.11.10" proxyquire@"^2.0.0" proxyquire-universal@"^2.0.0" proxyquireify@"^3.1.1" read-installed@"^4.0.3" rehype@"^9.0.0" rehype-highlight@"^3.0.0" remark@"^11.0.1" remark-cli@"^7.0.0" remark-frontmatter@"^1.2.0" remark-html@"^10.0.0" remark-lint@"^6.0.0" remark-lint-blockquote-indentation@"^1.0.0" remark-lint-checkbox-character-style@"^1.0.0" remark-lint-checkbox-content-indent@"^1.0.0" remark-lint-code-block-style@"^1.0.0" remark-lint-definition-case@"^1.0.0" remark-lint-definition-spacing@"^1.0.0" remark-lint-emphasis-marker@"^1.0.0" remark-lint-fenced-code-flag@"^1.0.0" remark-lint-fenced-code-marker@"^1.0.0" remark-lint-file-extension@"^1.0.0" remark-lint-final-definition@"^1.0.0" remark-lint-final-newline@"^1.0.0" remark-lint-first-heading-level@"^1.1.0" remark-lint-hard-break-spaces@"^1.0.1" remark-lint-heading-increment@"^1.0.0" remark-lint-heading-style@"^1.0.0" remark-lint-linebreak-style@"^1.0.0" remark-lint-link-title-style@"^1.0.0" remark-lint-list-item-bullet-indent@"^1.0.0" remark-lint-list-item-content-indent@"^1.0.0" remark-lint-list-item-indent@"^1.0.0" remark-lint-list-item-spacing@"^1.1.0" remark-lint-maximum-heading-length@"^1.0.0" remark-lint-maximum-line-length@"^1.0.0" remark-lint-no-auto-link-without-protocol@"^1.0.0" remark-lint-no-blockquote-without-marker@"^2.0.0" remark-lint-no-consecutive-blank-lines@"^1.0.0" remark-lint-no-duplicate-definitions@"^1.0.0" remark-lint-no-duplicate-headings@"^1.0.0" remark-lint-no-duplicate-headings-in-section@"^1.0.0" remark-lint-no-emphasis-as-heading@"^1.0.0" remark-lint-no-empty-url@"^1.0.1" remark-lint-no-file-name-articles@"^1.0.0" remark-lint-no-file-name-consecutive-dashes@"^1.0.0" remark-lint-no-file-name-irregular-characters@"^1.0.0" remark-lint-no-file-name-mixed-case@"^1.0.0" remark-lint-no-file-name-outer-dashes@"^1.0.1" remark-lint-no-heading-content-indent@"^1.0.0" remark-lint-no-heading-indent@"^1.0.0" remark-lint-no-heading-like-paragraph@"^1.0.0" remark-lint-no-heading-punctuation@"^1.0.0" remark-lint-no-html@"^1.0.0" remark-lint-no-inline-padding@"^1.0.0" remark-lint-no-literal-urls@"^1.0.0" remark-lint-no-missing-blank-lines@"^1.0.0" remark-lint-no-multiple-toplevel-headings@"^1.0.0" remark-lint-no-paragraph-content-indent@"^1.0.1" remark-lint-no-reference-like-url@"^1.0.0" remark-lint-no-shell-dollars@"^1.0.0" remark-lint-no-shortcut-reference-image@"^1.0.0" remark-lint-no-shortcut-reference-link@"^1.0.1" remark-lint-no-table-indentation@"^1.0.0" remark-lint-no-tabs@"^1.0.0" remark-lint-no-trailing-spaces@"^3.0.2" remark-lint-no-undefined-references@"^1.0.0" remark-lint-no-unused-definitions@"^1.0.0" remark-lint-ordered-list-marker-style@"^1.0.0" remark-lint-ordered-list-marker-value@"^1.0.0" remark-lint-rule-style@"^1.0.0" remark-lint-strong-marker@"^1.0.0" remark-lint-table-cell-padding@"^1.0.0" remark-lint-table-pipe-alignment@"^1.0.0" remark-lint-table-pipes@"^1.0.0" remark-lint-unordered-list-marker-style@"^1.0.0" remark-slug@"^5.0.0" remark-unlink@"^2.0.0" remark-validate-links@"^9.0.1" remark-vdom@"^8.0.0" semver@"^6.0.0" source-map-explorer@"^2.5.3" spdx-license-ids@"^3.0.0" tap-min@"git+https://github.com/Planeshifter/tap-min.git" tap-spec@"5.x.x" tap-summary@"^4.0.0" tap-xunit@"^2.2.0" tape@"git+https://github.com/kgryte/tape.git#fix/globby" to-vfile@"^6.0.0" typedoc@"git+https://github.com/kgryte/typedoc.git#0.16.11-patch" typescript@"4.3.5" uglify-js@"^3.17.4" uglifyify@"^5.0.0" unified-lint-rule@"^1.0.1" unist-util-visit@"^2.0.0" unist-util-visit-parents@"^3.1.1" yaml@"^1.0.0" node-gyp@"^9.3.1" +acorn@"^8.1.0" acorn-loose@"^8.0.2" acorn-walk@"^8.0.2" d3-format@"^1.0.0" d3-scale@"^1.0.0" d3-shape@"^1.0.0" d3-time-format@"^2.0.0" debug@"^2.6.9" glob@"^7.0.5" minimist@"^1.2.0" readable-stream@"^2.1.4" resolve@"^1.1.7" vdom-to-html@"^2.3.0" virtual-dom@"^2.1.1" @babel/cli@"^7.28.0" @babel/core@"^7.28.0" @babel/preset-env@"^7.28.0" @commitlint/cli@"^17.4.4" @commitlint/cz-commitlint@"^17.4.4" @conventional-commits/parser@"^0.4.1" @cspell/eslint-plugin@"^8.8.0" @kaciras/deasync@"^1.0.1" @mathjax/src@"^4.0.0" @types/node@"^13.9.0" @typescript-eslint/eslint-plugin@"^6.9.1" @typescript-eslint/parser@"^6.9.1" 0x@"^4.10.2" ajv@"^5.2.2" browser-pack-flat@"^3.0.0" browserify@"^17.0.0" bundle-collapser@"^1.3.0" c8@"^7.12.0" chai@"^3.5.0" cheerio@"^1.0.0-rc.12" commitizen@"^4.3.0" common-shakeify@"^0.6.0" conventional-changelog-conventionalcommits@"^5.0.0" doctrine@"^3.0.0" editorconfig-checker@"^6.0.0" envify@"^4.0.0" eslint@"^8.57.0" eslint-plugin-n@"^17.17.0" eslint-plugin-expect-type@"^0.2.3" eslint-plugin-import@"^2.29.0" eslint-plugin-jsdoc@"^46.8.2" eslint-plugin-stdlib@"file:./etc/eslint/plugin" exorcist@"^2.0.0" factor-bundle@"^2.5.0" gh-pages@"git+https://github.com/Planeshifter/gh-pages.git#main" inquirer@"^8.0.0" jscodeshift@"^0.15.0" jsdoc@"^3.4.0" lunr@"^2.3.9" mathjax@"^4.0.0" mkdirp@"^0.5.1" mustache@"^4.0.0" parse-link-header@"^1.0.1" plato@"^1.5.0" process@"^0.11.10" proxyquire@"^2.0.0" proxyquire-universal@"^2.0.0" proxyquireify@"^3.1.1" read-installed@"^4.0.3" rehype@"^9.0.0" rehype-highlight@"^3.0.0" remark@"^11.0.1" remark-cli@"^7.0.0" remark-frontmatter@"^1.2.0" remark-html@"^10.0.0" remark-lint@"^6.0.0" remark-lint-blockquote-indentation@"^1.0.0" remark-lint-checkbox-character-style@"^1.0.0" remark-lint-checkbox-content-indent@"^1.0.0" remark-lint-code-block-style@"^1.0.0" remark-lint-definition-case@"^1.0.0" remark-lint-definition-spacing@"^1.0.0" remark-lint-emphasis-marker@"^1.0.0" remark-lint-fenced-code-flag@"^1.0.0" remark-lint-fenced-code-marker@"^1.0.0" remark-lint-file-extension@"^1.0.0" remark-lint-final-definition@"^1.0.0" remark-lint-final-newline@"^1.0.0" remark-lint-first-heading-level@"^1.1.0" remark-lint-hard-break-spaces@"^1.0.1" remark-lint-heading-increment@"^1.0.0" remark-lint-heading-style@"^1.0.0" remark-lint-linebreak-style@"^1.0.0" remark-lint-link-title-style@"^1.0.0" remark-lint-list-item-bullet-indent@"^1.0.0" remark-lint-list-item-content-indent@"^1.0.0" remark-lint-list-item-indent@"^1.0.0" remark-lint-list-item-spacing@"^1.1.0" remark-lint-maximum-heading-length@"^1.0.0" remark-lint-maximum-line-length@"^1.0.0" remark-lint-no-auto-link-without-protocol@"^1.0.0" remark-lint-no-blockquote-without-marker@"^2.0.0" remark-lint-no-consecutive-blank-lines@"^1.0.0" remark-lint-no-duplicate-definitions@"^1.0.0" remark-lint-no-duplicate-headings@"^1.0.0" remark-lint-no-duplicate-headings-in-section@"^1.0.0" remark-lint-no-emphasis-as-heading@"^1.0.0" remark-lint-no-empty-url@"^1.0.1" remark-lint-no-file-name-articles@"^1.0.0" remark-lint-no-file-name-consecutive-dashes@"^1.0.0" remark-lint-no-file-name-irregular-characters@"^1.0.0" remark-lint-no-file-name-mixed-case@"^1.0.0" remark-lint-no-file-name-outer-dashes@"^1.0.1" remark-lint-no-heading-content-indent@"^1.0.0" remark-lint-no-heading-indent@"^1.0.0" remark-lint-no-heading-like-paragraph@"^1.0.0" remark-lint-no-heading-punctuation@"^1.0.0" remark-lint-no-html@"^1.0.0" remark-lint-no-inline-padding@"^1.0.0" remark-lint-no-literal-urls@"^1.0.0" remark-lint-no-missing-blank-lines@"^1.0.0" remark-lint-no-multiple-toplevel-headings@"^1.0.0" remark-lint-no-paragraph-content-indent@"^1.0.1" remark-lint-no-reference-like-url@"^1.0.0" remark-lint-no-shell-dollars@"^1.0.0" remark-lint-no-shortcut-reference-image@"^1.0.0" remark-lint-no-shortcut-reference-link@"^1.0.1" remark-lint-no-table-indentation@"^1.0.0" remark-lint-no-tabs@"^1.0.0" remark-lint-no-trailing-spaces@"^3.0.2" remark-lint-no-undefined-references@"^1.0.0" remark-lint-no-unused-definitions@"^1.0.0" remark-lint-ordered-list-marker-style@"^1.0.0" remark-lint-ordered-list-marker-value@"^1.0.0" remark-lint-rule-style@"^1.0.0" remark-lint-strong-marker@"^1.0.0" remark-lint-table-cell-padding@"^1.0.0" remark-lint-table-pipe-alignment@"^1.0.0" remark-lint-table-pipes@"^1.0.0" remark-lint-unordered-list-marker-style@"^1.0.0" remark-slug@"^5.0.0" remark-unlink@"^2.0.0" remark-validate-links@"^9.0.1" remark-vdom@"^8.0.0" semver@"^6.0.0" source-map-explorer@"^2.5.3" spdx-license-ids@"^3.0.0" speech-rule-engine@"^5.0.0-beta.1" tap-min@"git+https://github.com/Planeshifter/tap-min.git" tap-spec@"5.x.x" tap-summary@"^4.0.0" tap-xunit@"^2.2.0" tape@"git+https://github.com/kgryte/tape.git#fix/globby" to-vfile@"^6.0.0" typedoc@"git+https://github.com/kgryte/typedoc.git#0.16.11-patch" typescript@"4.3.5" uglify-js@"^3.17.4" uglifyify@"^5.0.0" unified-lint-rule@"^1.0.1" unist-util-visit@"^2.0.0" unist-util-visit-parents@"^3.1.1" vega@"^6.1.2" vega-embed@"^7.0.2" vega-lite@"^6.2.0" yaml@"^1.0.0" node-gyp@"^9.3.1" diff --git a/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/lib/main.js b/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/lib/main.js index 83bdda49ba65..bf69e6ca243c 100644 --- a/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/lib/main.js @@ -48,7 +48,7 @@ var render = require( './render.js' ); * var opts = { * 'className': 'equation', * 'align': 'center', -* 'raw': '\\operatorname{erf}(x) = \\frac{2}{\\sqrt\\pi}\\int_0^x e^{-t^2}\\,\\mathrm dt' +* 'raw': '\\operatorname{erf}(x) = \\frac{2}{\\sqrt\\pi}\\int_0^x e^{-t^2}\\,\\mathrm dt', * 'label': 'eqn:erf' * }; * createElement( opts, done ); diff --git a/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/test/fixtures/expected.txt b/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/test/fixtures/expected.txt index ad48d5ee98d1..1c7ad850c6b0 100644 --- a/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/test/fixtures/expected.txt +++ b/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/test/fixtures/expected.txt @@ -1,21 +1,3 @@
- -y equals m x plus b - - - +
diff --git a/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/test/test.js b/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/test/test.js index 3cffa1474a6e..b1f1aeb144c6 100644 --- a/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/test/test.js +++ b/lib/node_modules/@stdlib/_tools/markdown/inline-svg-equation/test/test.js @@ -176,7 +176,7 @@ tape( 'the function returns an HTML string for inlining an SVG equation in Markd }); tape( 'if not provided an option, the function will set a corresponding HTML attribute to either a default value (if one exists) or an empty string', function test( t ) { - var expected = '
\n \n\n\n\n\n
'; + var expected = '
\n \n
'; createElement( done ); diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/README.md b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/README.md index e41ab8d54b9c..d80308a3df5e 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/README.md +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/README.md @@ -44,7 +44,7 @@ var tex2svg = require( '@stdlib/_tools/utils/tex-equation-to-svg' ); #### tex2svg( str\[, options], clbk ) -Converts a [TeX][tex] or [LaTeX][latex] `string` to an SVG. +Converts a [TeX][tex] or [LaTeX][latex] string to an SVG. ```javascript var eqn = 'y = mx + b'; @@ -57,19 +57,18 @@ function clbk( error, svg ) { } console.log( svg ); /* e.g., => - 'y equals m x plus b' + '' */ } ``` -The function accepts the following `options`: +The function accepts the following options: - **width**: container width in `ex` (used for linebreaking and tags). Default: `100`. - **ex**: `ex` size in pixels. Default: `6`. -- **inline**: `boolean` indicating whether to format an input `string` as an inline equation. Default: `false`. -- **linebreaks**: `boolean` indicating whether to perform linebreaking. Default: `true`. +- **inline**: boolean indicating whether to format an input string as an inline equation. Default: `false`. -By default, the function formats an input `string` as a displayed equation. To format the `string` as a text (inline) equation, set the `inline` option to `true`. +By default, the function formats an input string as a displayed equation. To format the string as a text (inline) equation, set the `inline` option to `true`. ```javascript var eqn = 'y = mx + b'; @@ -90,7 +89,7 @@ function clbk( error, svg ) { #### tex2svg.factory( options ) -Creates a reusable `function`. +Creates a reusable function. ```javascript function clbk( error, svg ) { @@ -112,7 +111,7 @@ convert( 'w = \\sum_{i=0}^{n} x_i', clbk ); // ... ``` -The factory method accepts the same `options` as [`tex2svg()`](#tex2svg). +The factory method accepts the same options as [`tex2svg()`](#tex2svg). @@ -144,6 +143,8 @@ The factory method accepts the same `options` as [`tex2svg()`](#tex2svg). ## Examples + + ```javascript @@ -186,9 +187,8 @@ Options: -h, --help Print this message. -V, --version Print the package version. --width width Container width in ex. Default: 100. - --ex ex ex size in pixels. Default: 6. + --ex ex ex size in pixels. Default: 8. --inline Format input equation as inline TeX. - --no-linebreaks Disable linebreaking. ``` diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/bin/cli b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/bin/cli index 15a357402308..318fb2a07860 100755 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/bin/cli +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/bin/cli @@ -69,9 +69,6 @@ function main() { if ( flags.inline ) { opts.inline = flags.inline; } - if ( flags.linebreaks === false ) { - opts.linebreaks = false; - } tex2svg( args[ 0 ], opts, clbk ); /** diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/docs/usage.txt b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/docs/usage.txt index a442022f7a35..68841e8afec0 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/docs/usage.txt +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/docs/usage.txt @@ -3,9 +3,8 @@ Usage: tex2svg [options] Options: - -h, --help Print this message. - -V, --version Print the package version. - --width width Container width in ex. Default: 100. - --ex ex ex size in pixels. Default: 6. - --inline Format input equation as inline TeX. - --no-linebreaks Disable linebreaking. + -h, --help Print this message. + -V, --version Print the package version. + --width width Container width in ex. Default: 100. + --ex ex ex size in pixels. Default: 8. + --inline Format input equation as inline TeX. diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/etc/cli_opts.json b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/etc/cli_opts.json index 08dba07d9261..01eddaf54cfa 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/etc/cli_opts.json +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/etc/cli_opts.json @@ -6,8 +6,7 @@ "boolean": [ "help", "version", - "inline", - "no-linebreaks" + "inline" ], "alias": { "help": [ diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/defaults.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/defaults.js new file mode 100644 index 000000000000..fbc0f9a09062 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/defaults.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns default options. +* +* @private +* @returns {Object} default options +*/ +function defaults() { + return { + 'svg': { + 'display': true, + 'containerWidth': 100, + 'em': 16, + 'ex': 8, + 'scale': 1 + }, + 'stripAttributes': true + }; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/defaults.json b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/defaults.json deleted file mode 100644 index b572a80c4013..000000000000 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/defaults.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "svg": true, - "inline": false, - "format": "TeX", - "width": 100, - "ex": 6, - "linebreaks": true, - "speakText": true, - "speakRuleset": "mathspeak", - "speakStyle": "default" -} diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/factory.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/factory.js index f0e94f2bbec7..25420b565dc0 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/factory.js +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/factory.js @@ -20,13 +20,12 @@ // MODULES // -var mathjax = require( 'mathjax-node-sre' ); var isFunction = require( '@stdlib/assert/is-function' ); var isString = require( '@stdlib/assert/is-string' ).isPrimitive; var format = require( '@stdlib/string/format' ); -var copy = require( '@stdlib/utils/copy' ); -var defaults = require( './defaults.json' ); +var defaults = require( './defaults.js' ); var validate = require( './validate.js' ); +var MathJax = require( './mathjax' ); // MAIN // @@ -38,7 +37,6 @@ var validate = require( './validate.js' ); * @param {PositiveInteger} [options.width=100] - container width in `ex` * @param {PositiveInteger} [options.ex=6] - `ex` size in pixels * @param {boolean} [options.inline=false] - specifies whether to format the input string as an inline equation -* @param {boolean} [options.linebreaks=true] - enable linebreaking * @throws {TypeError} options argument must be an object * @throws {TypeError} must provide valid options * @returns {Function} function to convert a string to an SVG @@ -60,16 +58,24 @@ var validate = require( './validate.js' ); * } */ function factory( options ) { + var sopts; var opts; var err; - opts = copy( defaults ); - err = validate( opts, options ); + + opts = defaults(); + + sopts = opts.svg; + err = validate( sopts, options ); if ( err ) { throw err; } - if ( opts.inline ) { - opts.format = 'inline-TeX'; - delete opts.inline; + if ( sopts.inline ) { + sopts.display = false; + delete sopts.inline; + } + if ( sopts.width ) { + sopts.containerWidth = sopts.width; + delete sopts.width; } return tex2svg; @@ -84,29 +90,15 @@ function factory( options ) { * @returns {void} */ function tex2svg( str, clbk ) { + var mathjax; if ( !isString( str ) ) { throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) ); } if ( !isFunction( clbk ) ) { throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); } - opts.math = str; - mathjax.typeset( opts, done ); - /** - * Callback invoked upon converting a string to SVG. - * - * @private - * @param {Object} data - output - * @returns {void} - */ - function done( data ) { - var err; - if ( data.errors ) { - err = new Error( data.errors[ 0 ] ); - return clbk( err ); - } - clbk( null, data.svg ); - } + mathjax = new MathJax(); + mathjax.tex2svg( str, sopts, clbk ); } } diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/main.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/main.js index 91c10df2da6e..a1608f75112f 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/main.js @@ -33,7 +33,6 @@ var factory = require( './factory.js' ); * @param {PositiveInteger} [options.width=100] - container width in `ex` * @param {PositiveInteger} [options.ex=6] - `ex` size in pixels * @param {boolean} [options.inline=false] - specifies whether to format the input string as an inline equation -* @param {boolean} [options.linebreaks=true] - enable linebreaking * @param {Callback} clbk - callback to invoke once finished * @throws {TypeError} first argument must be a string * @throws {TypeError} options argument must be an object diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/mathjax/index.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/mathjax/index.js new file mode 100644 index 000000000000..1b82a4cd4668 --- /dev/null +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/mathjax/index.js @@ -0,0 +1,418 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this, no-underscore-dangle */ + +'use strict'; + +// MODULES // + +var MathJax = require( 'mathjax' ); +var SRE = require( 'speech-rule-engine/cjs/common/system.js' ); +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var replace = require( '@stdlib/string/base/replace' ); +var format = require( '@stdlib/string/format' ); + + +// VARIABLES // + +var RE_DATA_ATTRIBUTES = /\sdata-[\w:-]+="[^"]*"/g; +var RE_ARIA_LEVEL_ATTRIBUTES = /\saria-level="[^"]*"/g; +var RE_EMPTY_GROUPS = /\s<\/g>/g; + +var INIT = false; + + +// FUNCTIONS // + +/** +* Returns MathJax options. +* +* @private +* @returns {Object} options +*/ +function mOptions() { + return { + 'loader': { + 'load': [ + 'input/tex', // process TeX input + 'output/svg', // generate SVG output + 'adaptors/liteDOM' // lightweight DOM for server use + ] + }, + 'options': { + 'compileError': onCompileError, // handler for trapping compilation errors + 'typesetError': onTypesetError // handler for trapping errors encountered during typesetting + }, + 'svg': { + 'fontCache': 'local' // make each SVG self-contained + }, + 'tex': { + 'formatError': onFormatError // handler for trapping errors during parsing + } + }; +} + +/** +* Returns SRE options. +* +* @private +* @param {string} modality - modality +* @returns {Object} options +*/ +function sOptions( modality ) { + return { + 'locale': 'en', + 'domain': 'mathspeak', + 'style': 'default', + 'modality': modality, + 'markup': 'none' + }; +} + +/** +* Callback invoked upon encountering a format error. +* +* ## Notes +* +* - This catches TeX expressions which do not parse properly. +* +* @private +* @param {Object} jax - TeX input jax +* @param {Error} error - error object +* @throws {Error} unexpected error +*/ +function onFormatError( jax, error ) { + throw new Error( format( 'invalid argument. Must provide a valid TeX or LaTeX string. %s. Value: `\'%s\'`.', error.message, jax.latex ) ); +} + +/** +* Callback invoked upon encountering a compile error. +* +* ## Notes +* +* - This catches TeX expressions which do not parse properly. +* +* @private +* @param {Object} document - math document object +* @param {Object} math - math item object +* @param {Error} error - error object +* @throws {Error} unexpected error +*/ +function onCompileError( document, math, error ) { + throw new Error( format( 'invalid argument. Must provide a valid TeX or LaTeX string. %s. Value: `\'%s\'`.', error.message, math.math ) ); +} + +/** +* Callback invoked upon encountering a typeset error. +* +* ## Notes +* +* - This catches TeX expressions which do not parse properly. +* +* @private +* @param {Object} document - math document object +* @param {Object} math - math item object +* @param {Error} error - error object +* @throws {Error} unexpected error +*/ +function onTypesetError( document, math, error ) { + throw new Error( format( 'invalid argument. Must provide a valid TeX or LaTeX string. %s. Value: `\'%s\'`.', error.message, math.math ) ); +} + + +// MAIN // + +/** +* Wrapper around MathJax. +* +* @private +* @constructor +* @returns {Wrapper} MathJax wrapper +*/ +function MathJaxWrapper() { + if ( !( this instanceof MathJaxWrapper ) ) { + return new MathJaxWrapper(); + } + return this; +} + +/** +* Converts a "raw" MML node to a SVG string. +* +* @private +* @name _serialize2svg +* @memberof MathJaxWrapper.prototype +* @type {Function} +* @param {Object} node - raw node +* @returns {string} SVG string +*/ +setReadOnly( MathJaxWrapper.prototype, '_serialize2svg', function serialize2svg( node ) { + var adaptor; + var braille; + var speech; + var svg; + var str; + + adaptor = MathJax.startup.adaptor; + speech = adaptor.getAttribute( node, 'data-semantic-speech-none' ) || ''; + braille = adaptor.getAttribute( node, 'data-semantic-braille' ) || ''; + + svg = adaptor.tags( node, 'svg' )[ 0 ]; + if ( speech ) { + adaptor.setAttribute( svg, 'aria-label', speech ); + } + if ( braille ) { + adaptor.setAttribute( svg, 'aria-braillelabel', braille ); + } + str = adaptor.serializeXML( svg ); + + str = replace( str, RE_DATA_ATTRIBUTES, '' ); + str = replace( str, RE_ARIA_LEVEL_ATTRIBUTES, '' ); + str = replace( str, RE_EMPTY_GROUPS, '' ); + + return str; +}); + +/** +* Initialize the SRE engine. +* +* @private +* @name _initSpeechEngine +* @memberof MathJaxWrapper.prototype +* @type {Function} +* @param {string} modality - modality +* @param {Callback} clbk - callback to invoke upon completion +*/ +setReadOnly( MathJaxWrapper.prototype, '_initSpeechEngine', function initSpeechEngine( modality, clbk ) { + var p = SRE.setupEngine( sOptions( modality ) ); + p.then( onSetup ).catch( onError ); + + /** + * Callback invoked upon setup. + * + * @private + */ + function onSetup() { + var p = SRE.engineReady(); + p.then( onReady ).catch( onError ); + } + + /** + * Callback invoked once the SRE engine is ready. + * + * @private + */ + function onReady() { + clbk(); + } + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + */ + function onError( error ) { + clbk( error ); + } +}); + +/** +* Converts a TeX string to MML. +* +* @name _tex2mml +* @memberof MathJaxWrapper.prototype +* @type {Function} +* @param {string} str - TeX string +* @param {Options} opts - options +* @param {Callback} clbk - callback to invoke upon completion +*/ +setReadOnly( MathJaxWrapper.prototype, '_tex2mml', function tex2mml( str, opts, clbk ) { + var p = MathJax.tex2mmlPromise( str, opts ); + p.then( onSVG ).catch( onError ); + + /** + * Callback invoked upon converting a TeX string to an SVG. + * + * @private + * @param {Object} node - output + */ + function onSVG( node ) { + clbk( null, node ); + } + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + * @returns {void} + */ + function onError( error ) { + clbk( error ); + } +}); + +/** +* Initializes MathJax. +* +* @private +* @name _init +* @memberof MathJaxWrapper.prototype +* @type {Function} +* @param {Callback} clbk - callback to invoke after completing initialization +* @returns {void} +*/ +setReadOnly( MathJaxWrapper.prototype, '_init', function onInit( clbk ) { + var p; + + if ( INIT ) { + return clbk(); + } + p = MathJax.init( mOptions() ); + p.then( onInit ).catch( onError ); + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + * @returns {void} + */ + function onError( error ) { + clbk( error ); + } + + /** + * Callback invoked upon successfully initializing MathJax. + * + * @private + */ + function onInit() { + INIT = true; + clbk(); + } +}); + +/** +* Converts a TeX string to an SVG. +* +* @name tex2svg +* @memberof MathJaxWrapper.prototype +* @type {Function} +* @param {string} str - TeX string +* @param {Options} opts - options +* @param {Callback} clbk - callback to invoke upon completion +*/ +setReadOnly( MathJaxWrapper.prototype, 'tex2svg', function tex2svg( str, opts, clbk ) { + var self; + var svg; + var mml; + + self = this; + if ( !INIT ) { + this._init( convert ); + return; + } + convert(); + + /** + * Converts a TeX string to an SVG. + * + * @private + * @param {Error} [error] - error object + * @returns {void} + */ + function convert( error ) { + var p; + if ( error ) { + return clbk( error ); + } + p = MathJax.tex2svgPromise( str, opts ); + p.then( onSVG ).catch( onError ); + } + + /** + * Callback invoked upon converting a TeX string to an SVG. + * + * @private + * @param {Object} node - output + */ + function onSVG( node ) { + svg = MathJax.startup.adaptor.tags( node, 'svg' )[ 0 ]; + self._tex2mml( str, opts, onMML ); + } + + /** + * Callback invoked upon converting a TeX string to MML. + * + * @private + * @param {(Error|null)} error - error object + * @param {Object} node - output + * @returns {void} + */ + function onMML( error, node ) { + if ( error ) { + return clbk( error ); + } + mml = node; + self._initSpeechEngine( 'speech', onInitSpeech ); + } + + /** + * Callback invoked upon initializing a speech engine. + * + * @private + */ + function onInitSpeech() { + var str = SRE.toSpeech( mml ); + MathJax.startup.adaptor.setAttribute( svg, 'aria-label', str ); + self._initSpeechEngine( 'braille', onInitBraille ); + } + + /** + * Callback invoked upon initializing a braille engine. + * + * @private + */ + function onInitBraille() { + // var str = SRE.toSpeech( mml ); // FIXME: uncomment once we can generate Braille + + // FIXME: generating Braille seems to be broken in the upstream library. Even basic examples fail to render properly. We should revisit once v5.0 is no longer in alpha/beta mode. + + // MathJax.startup.adaptor.setAttribute( svg, 'aria-braillelabel', str ); // FIXME: uncomment once we can generate Braille + clbk( null, self._serialize2svg( svg ) ); + } + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + * @returns {void} + */ + function onError( error ) { + clbk( error ); + } +}); + + +// EXPORTS // + +module.exports = MathJaxWrapper; diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/validate.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/validate.js index eab4ca6d6026..026bc1ec5d2c 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/validate.js +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/lib/validate.js @@ -38,7 +38,6 @@ var format = require( '@stdlib/string/format' ); * @param {PositiveInteger} [options.width] - container width in `ex` * @param {PositiveInteger} [options.ex] - `ex` size in pixels * @param {boolean} [options.inline] - specifies whether to format the input string as an inline equation -* @param {boolean} [options.linebreaks] - enable linebreaking * @returns {(Error|null)} error object or null * * @example @@ -73,12 +72,6 @@ function validate( opts, options ) { return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'inline', opts.inline ) ); } } - if ( hasOwnProp( options, 'linebreaks' ) ) { - opts.linebreaks = options.linebreaks; - if ( !isBoolean( opts.linebreaks ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'linebreaks', opts.linebreaks ) ); - } - } return null; } diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/1.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/1.js index 5d93823c7204..53bf40139768 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/1.js +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/1.js @@ -18,4 +18,4 @@ 'use strict'; -module.exports = '\ne r f left-parenthesis x right-parenthesis equals StartFraction 2 Over StartRoot pi EndRoot EndFraction integral Subscript 0 Superscript x Baseline e Superscript minus t squared Baseline normal d t period\n\n\n'; +module.exports = ''; diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/1.svg b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/1.svg index afdad49150a0..827d0e42a02d 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/1.svg +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/1.svg @@ -1,60 +1 @@ - -e r f left-parenthesis x right-parenthesis equals StartFraction 2 Over StartRoot pi EndRoot EndFraction integral Subscript 0 Superscript x Baseline e Superscript minus t squared Baseline normal d t period - - - + diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/2.svg b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/2.svg index db80943ea567..dbece7f398c5 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/2.svg +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/2.svg @@ -1,60 +1 @@ - -e r f left-parenthesis x right-parenthesis equals StartFraction 2 Over StartRoot pi EndRoot EndFraction integral Subscript 0 Superscript x Baseline e Superscript minus t squared Baseline normal d t period - - - + diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/3.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/3.js index 337497325d20..af9cbf902d05 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/3.js +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/3.js @@ -18,4 +18,4 @@ 'use strict'; -module.exports = '\ne r f left-parenthesis x right-parenthesis equals StartFraction 2 Over StartRoot pi EndRoot EndFraction integral Subscript 0 Superscript x Baseline e Superscript minus t squared Baseline normal d t period\n\n\n'; +module.exports = ''; diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/3.svg b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/3.svg index 223f76e56a71..7e49a42b88e4 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/3.svg +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/fixtures/3.svg @@ -1,60 +1 @@ - -e r f left-parenthesis x right-parenthesis equals StartFraction 2 Over StartRoot pi EndRoot EndFraction integral Subscript 0 Superscript x Baseline e Superscript minus t squared Baseline normal d t period - - - + diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.cli.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.cli.js index a7bdb3575741..ece81bf3fffa 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.cli.js +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.cli.js @@ -181,8 +181,7 @@ tape( 'the command-line interface converts a TeX or LaTeX string to an SVG (opti EXEC_PATH, fpath, '\'\\operatorname{erf}(x) = \\frac{2}{\\sqrt\\pi}\\int_0^x e^{-t^2}\\,\\mathrm dt.\'', - '--inline', - '--no-linebreaks' + '--inline' ]; expected = readFileSync( resolve( __dirname, 'fixtures', '2.svg' ), { 'encoding': 'utf8' diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.factory.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.factory.js index 78b7f50666d6..7d05daf7465d 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.factory.js +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.factory.js @@ -142,8 +142,8 @@ tape( 'the function returns a function which throws an error if provided a callb tape( 'the function returns a function which returns any errors to a provided callback', function test( t ) { var tex2svg = factory( {} ); - // Non-existent LaTeX command... - tex2svg( '\\infinity', clbk ); + // Invalid LaTeX command... + tex2svg( '\\mathrm', clbk ); function clbk( error ) { t.ok( error, 'returns expected value' ); @@ -174,8 +174,7 @@ tape( 'the function returns a function which converts an input string to an SVG opts = { 'width': 200, 'ex': 2, - 'inline': true, - 'linebreaks': false + 'inline': true }; tex2svg = factory( opts ); tex2svg( '\\operatorname{erf}(x) = \\frac{2}{\\sqrt\\pi}\\int_0^x e^{-t^2}\\,\\mathrm dt.', clbk ); diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.main.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.main.js index 49d7b8e7e7b2..b9c491001d96 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.main.js +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.main.js @@ -191,8 +191,8 @@ tape( 'the function throws an error if provided an invalid option', function tes }); tape( 'the function returns any errors to the provided callback', function test( t ) { - // Non-existent LaTeX command... - tex2svg( '\\infinity', clbk ); + // Invalid LaTeX command... + tex2svg( '\\mathrm', clbk ); function clbk( error ) { t.ok( error, 'returns expected value' ); @@ -219,8 +219,7 @@ tape( 'the function converts an input string to an SVG (options)', function test var opts = { 'width': 200, 'ex': 2, - 'inline': true, - 'linebreaks': false + 'inline': true }; tex2svg( '\\operatorname{erf}(x) = \\frac{2}{\\sqrt\\pi}\\int_0^x e^{-t^2}\\,\\mathrm dt.', opts, clbk ); diff --git a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.validate.js b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.validate.js index 6aecab9aad08..8c62afff8a7e 100644 --- a/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.validate.js +++ b/lib/node_modules/@stdlib/_tools/utils/tex-equation-to-svg/test/test.validate.js @@ -135,30 +135,6 @@ tape( 'if provided an `inline` option which is not a boolean primitive, the func t.end(); }); -tape( 'if provided a `linebreaks` option which is not a boolean primitive, the function returns a type error', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - void 0, - null, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'linebreaks': values[i] - }); - t.ok( err instanceof TypeError, 'returns a type error when provided '+values[i] ); - } - t.end(); -}); - tape( 'the function returns `null` if provided valid options', function test( t ) { var opts; var obj; @@ -167,8 +143,7 @@ tape( 'the function returns `null` if provided valid options', function test( t opts = { 'width': 200, 'ex': 2, - 'inline': true, - 'linebreaks': false + 'inline': true }; obj = {}; err = validate( obj, opts ); @@ -177,7 +152,6 @@ tape( 'the function returns `null` if provided valid options', function test( t t.strictEqual( obj.width, 200, 'sets width' ); t.strictEqual( obj.ex, 2, 'sets ex' ); t.strictEqual( obj.inline, true, 'sets inline' ); - t.strictEqual( obj.linebreaks, false, 'sets linebreaks' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/l.js b/lib/node_modules/@stdlib/namespace/lib/namespace/l.js index b4d96973f75a..a9c57c5c484b 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/l.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/l.js @@ -55,6 +55,14 @@ ns.push({ ] }); +ns.push({ + 'alias': 'LineChart', + 'path': '@stdlib/plot/charts/line/ctor', + 'value': require( '@stdlib/plot/charts/line/ctor' ), + 'type': 'Function', + 'related': [] +}); + ns.push({ 'alias': 'LinkedList', 'path': '@stdlib/dstructs/linked-list', diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/p.js b/lib/node_modules/@stdlib/namespace/lib/namespace/p.js index 96137568ae47..a10b21f932a4 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/p.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/p.js @@ -312,14 +312,14 @@ ns.push({ 'value': require( '@stdlib/plot' ), 'type': 'Function', 'related': [ - '@stdlib/plot/ctor' + '@stdlib/plot/2d' ] }); ns.push({ 'alias': 'Plot', - 'path': '@stdlib/plot/ctor', - 'value': require( '@stdlib/plot/ctor' ), + 'path': '@stdlib/plot/2d', + 'value': require( '@stdlib/plot/2d' ), 'type': 'Function', 'related': [ '@stdlib/plot' diff --git a/lib/node_modules/@stdlib/plot/2d/README.md b/lib/node_modules/@stdlib/plot/2d/README.md new file mode 100644 index 000000000000..dc2cb43b9c16 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/README.md @@ -0,0 +1,1465 @@ + + +# Plot + +> Create a 2-dimensional plot. + +
+ + + + + +
+ + + +
+ +## Usage + +```javascript +var Plot = require( '@stdlib/plot/2d' ); +``` + +#### Plot( \[x, y,] \[options] ) + +Returns a `plot` instance for creating 2-dimensional plots. + +```javascript +var plot = new Plot(); +// returns +``` + +To provide plot data at instantiation, provide `x` **and** `y` data as arguments. + +```javascript +var x = [[0.10, 0.20, 0.30]]; +var y = [[0.52, 0.79, 0.64]]; + +var plot = new Plot( x, y ); +// returns +``` + +The function accepts the following `options`: + +- [**autoRender**](#prop-auto-render): `boolean` indicating whether to re-render on a `change` event. Default: `false`. +- [**autoView**](#prop-auto-view): `boolean` indicating whether to generate an updated view on a `render` event. Default: `false`. +- [**colors**](#prop-colors): data color(s). Default: `category10`. +- [**description**](#prop-description): plot description. Default: `''`. +- [**engine**](#prop-engine): plot engine. Default: `svg`. +- [**height**](#prop-height): plot height. Default: `400` (pixels). +- [**labels**](#prop-labels): data labels. +- [**isDefined**](#prop-is-defined): accessor `function` indicating whether a datum is defined. +- [**lineStyle**](#prop-line-style): data line style(s). Default: `'-'`. +- [**lineOpacity**](#prop-line-opacity): data line opacity. Default: `0.9`. +- [**lineWidth**](#prop-line-width): data line width. Default: `2` (pixels). +- [**paddingBottom**](#prop-padding-bottom): bottom padding. Default: `80` (pixels). +- [**paddingLeft**](#prop-padding-left): left padding. Default: `90` (pixels). +- [**paddingRight**](#prop-padding-right): right padding. Default: `20` (pixels). +- [**paddingTop**](#prop-padding-top): top padding. Default: `80` (pixels). +- [**renderFormat**](#prop-render-format): render format. Default: `'vdom'`. +- [**symbols**](#prop-symbols): data symbols. Default: `'none'`. +- [**symbolsOpacity**](#prop-symbols-opacity): symbols opacity. Default: `0.9`. +- [**symbolsSize**](#prop-symbols-size): symbols size. Default: `6` (pixels). +- [**title**](#prop-title): plot title. Default: `''`. +- [**viewer**](#prop-viewer): plot viewer. Default: `'none'`. +- [**width**](#prop-width): plot width. Default: `400` (pixels). +- [**x**](#prop-x): `x` values. Default: `[]`. +- [**xAxisOrient**](#prop-x-axis-orient): `x`-axis orientation. Default: `'bottom'`. +- [**xLabel**](#prop-x-label): `x`-axis label. Default: `'x'`. +- [**xMax**](#prop-x-max): maximum value of the `x`-axis domain. Default: `null`. +- [**xMin**](#prop-x-min): minimum value of the `x`-axis domain. Default: `null`. +- [**xNumTicks**](#prop-x-num-ticks): number of `x`-axis tick marks. Default: `5`. +- [**xRug**](#prop-x-rug): `boolean` indicating whether to render a rug plot along an `x`-axis. +- [**xRugOrient**](#prop-x-rug-orient): `x`-axis rug orientation. Default: `'bottom'`. +- [**xRugOpacity**](#prop-x-rug-opacity): `x`-axis rug opacity. Default: `0.1`. +- [**xRugSize**](#prop-x-rug-size): `x`-axis rug tick (tassel) size. Default: `6` (pixels). +- [**xScale**](#prop-x-scale): `x`-axis scale. Default: `'linear'`. +- [**xTickFormat**](#prop-x-tick-format): `x`-axis tick format. Default: `null`. +- [**y**](#prop-y): `y` values. Default: `[]`. +- [**yAxisOrient**](#prop-y-axis-orient): `y`-axis orientation. Default: `'left'`. +- [**yLabel**](#prop-y-label): `y`-axis label. Default: `'y'`. +- [**yMax**](#prop-y-max): maximum value of the `y`-axis domain. Default: `null`. +- [**yMin**](#prop-y-min): minimum value of the `y`-axis domain. Default: `null`. +- [**yNumTicks**](#prop-y-num-ticks): number of `y`-axis tick marks. Default: `5`. +- [**yRug**](#prop-y-rug): `boolean` indicating whether to render a rug plot along an `y`-axis. +- [**yRugOrient**](#prop-y-rug-orient): `y`-axis rug orientation. Default: `'left'`. +- [**yRugOpacity**](#prop-y-rug-opacity): `y`-axis rug opacity. Default: `0.1`. +- [**yRugSize**](#prop-y-rug-size): `y`-axis rug tick (tassel) size. Default: `6` (pixels). +- [**yScale**](#prop-y-scale): `y`-axis scale. Default: `'linear'`. +- [**yTickFormat**](#prop-y-tick-format): `y`-axis tick format. Default: `null`. + +In addition to supporting `x` and `y` data as arguments, the constructor supports providing data via the `x` and `y` options. + +```javascript +var opts = { + 'x': [[0.10, 0.20, 0.30]], + 'y': [[0.52, 0.79, 0.64]] +}; + +var plot = new Plot( opts ); +// returns +``` + +Note that `x` and `y` arguments take precedence over `x` and `y` options. + +```javascript +var opts = { + 'x': [[0.10, 0.20, 0.30]], + 'y': [[0.52, 0.79, 0.64]] +}; + +var x = [[0.40, 0.50, 0.60]]; +var y = [[0.37, 0.51, 0.44]]; + +var plot = new Plot( x, y, opts ); + +var x1 = plot.x; +// returns [[0.40, 0.50, 0.60]] + +var y1 = plot.y; +// returns [[0.37, 0.51, 0.44]] +``` + +* * * + +### Methods + + + +#### Plot.prototype.render( \[format] ) + +Renders a plot. + +```javascript +var plot = new Plot(); +var vtree = plot.render(); +// returns +``` + +By default, the method renders a plot as a [virtual DOM tree][vdom]. To render to an alternative format, provide a `format` argument. + +```javascript +var plot = new Plot(); +var vtree = plot.render( 'html' ); +// returns +``` + + + +#### Plot.prototype.view( \[viewer] ) + +Generates a plot view. + +```javascript +var plot = new Plot(); +plot.view(); +``` + +To generate a particular plot view without updating the [`viewer`](#prop-viewer) property, provide a `viewer`. + +```javascript +var plot = new Plot(); +plot.view( 'stdout' ); +``` + +* * * + +### Writable Properties + + + +#### Plot.prototype.x + +`x` values. The `x` property value must be an `array`, where each element corresponds to a plotted dataset. + +```javascript +var plot = new Plot(); + +// Set: +plot.x = [ + [ 1417563950959, 1417563952959 ], // dataset 1 + [ 1417563950959, 1417563952959 ] // dataset 2 +]; + +// Get: +var x = plot.x; +// returns [ [ 1417563950959, 1417563952959 ], [ 1417563950959, 1417563952959 ] ] +``` + + + +#### Plot.prototype.y + +`y` values. The `y` property value must be an `array`, where each element corresponds to a plotted dataset. + +```javascript +var plot = new Plot(); + +// Set: +plot.y = [ + [ 0.25, 0.23 ], // dataset 1 + [ 0.72, 0.89 ] // dataset 2 +]; + +// Get: +var y = plot.y; +// returns [ [ 0.25, 0.23 ], [ 0.72, 0.89 ] ] +``` + + + +#### Plot.prototype.labels + +Data labels. During plot creation, each plotted dataset is assigned a `label`. If the number of `labels` is less than the number of plotted datasets, `labels` are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +// Set: +plot.labels = [ + 'beep', // assigned to datasets 0,2,4,... + 'boop' // assigned to datasets 1,3,5,... +]; + +// Get: +var labels = plot.labels; +// returns ['beep','boop'] +``` + + + +#### Plot.prototype.isDefined( d, i ) + +An accessor `function` which defines whether a datum is defined. This accessor is used to define how missing values are encoded. When invoked, the function is provided two arguments: + +- **d**: datum +- **i**: datum index + +```javascript +function isDefined( d ) { + return ( d !== null ); +} + +var plot = new Plot(); + +// Set: +plot.isDefined = isDefined; + +// Get: +var fcn = plot.isDefined; +// returns +``` + +The default behavior is to ignore values which are `NaN`. + + + +#### Plot.prototype.colors + +Data colors. To set the `color` for all plotted datasets, provide a `color` name. + +```javascript +var plot = new Plot(); + +// Set: +plot.colors = '#474747'; + +// Get: +var colors = plot.colors; +// returns ['#474747'] +``` + +To specify the colors for each dataset, provide an `array` of colors. During plot creation, each plotted dataset is assigned one of the provided colors. If the number of colors is less than the number of plotted datasets, colors are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.colors = [ + '#000', // assigned to datasets 0,3,6,9,... + 'rgb(100,100,100)', // assigned to datasets 1,4,7,10,... + 'red' // assigned to datasets 2,5,8,11,... +]; + +// Get: +var colors = plot.colors; +// returns ['#000','rgb(100,100,100)','red'] +``` + +A `plot` instance also supports providing the name of a predefined color scheme. The following schemes are supported: + +- **category10** +- **category20** +- **category20b** +- **category20c** + + + +```javascript +var plot = new Plot(); + +// Set: +plot.colors = 'category20'; + +// Get: +var colors = plot.colors; +// returns +``` + + + +#### Plot.prototype.lineStyle + +Data line style(s). The following line styles are supported: + +- `'-'`: solid line. +- `'--'`: dashed line. +- `':'`: dotted line. +- `'-.'`: alternating dashes and dots. +- `'none'`: no line. + +To set the line style for all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.lineStyle = '-'; // all solid lines + +// Get: +var lineStyle = plot.lineStyle; +// returns ['-'] +``` + +To specify the line style for each dataset, provide an `array` of line styles. During plot creation, each plotted dataset is assigned a `lineStyle`. If the number of line styles is less than the number of plotted datasets, line styles are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.lineStyle = [ + ':', // assigned to datasets 0,3,6,9,... + 'none', // assigned to datasets 1,4,7,10,... + '--' // assigned to datasets 2,5,8,11,... +]; +``` + + + +#### Plot.prototype.lineOpacity + +Data line opacity, where an opacity of `0.0` makes a line completely transparent and an opacity of `1.0` makes a line completely opaque. To set the opacity for all plotted lines, + +```javascript +var plot = new Plot(); + +// Set: +plot.lineOpacity = 0.9; + +// Get: +var opacity = plot.lineOpacity; +// returns [0.9] +``` + +To specify the line opacity for each dataset, provide an `array` of opacities. During plot creation, each plotted dataset is assigned an opacity. If the number of opacities is less than the number of plotted datasets, opacities are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.lineOpacity = [ + 0.7, // assigned to datasets 0,3,6,9,... + 0.2, // assigned to datasets 1,4,7,10,... + 1.0 // assigned to datasets 2,5,8,11,... +]; +``` + + + +#### Plot.prototype.lineWidth + +Data line width(s). To set the line widths for all plotted lines, + +```javascript +var plot = new Plot(); + +// Set: +plot.lineWidth = 1; + +// Get: +var width = plot.lineWidth; +// returns [1] +``` + +To specify the line width for each dataset, provide an `array` of widths. During plot creation, each plotted dataset is assigned a line width. If the number of line widths is less than the number of plotted datasets, line widths are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.lineWidth = [ + 1, // assigned to datasets 0,2,4,... + 3 // assigned to datasets 1,3,5,... +]; +``` + + + +#### Plot.prototype.symbols + +Data symbols. The following symbols are supported: + +- `'closed-circle'`: closed circles. +- `'open-circle'`: open circles. +- `'none'`: no symbols. + +To set the symbols for all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.symbols = 'closed-circle'; + +// Get: +var sym = plot.symbols; +// returns ['closed-circle'] +``` + +To specify the symbols used for each dataset, provide an `array` of symbols. During plot creation, each plotted dataset is assigned a symbol. If the number of symbols is less than the number of plotted datasets, symbols are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.symbols = [ + 'closed-circle', // assigned to datasets 0,3,6,9,... + 'none', // assigned to datasets 1,4,7,10,... + 'open-circle' // assigned to datasets 2,5,8,11,... +]; +``` + + + +#### Plot.prototype.symbolsSize + +Symbols size. To set the size of all symbols, + +```javascript +var plot = new Plot(); + +// Set: +plot.symbolsSize = 4; + +// Get: +var size = plot.symbolsSize; +// returns [4] +``` + +To specify the symbols size for each dataset, provide an `array` of sizes. During plot creation, each plotted dataset is assigned a symbols size. If the number of sizes is less than the number of plotted datasets, sizes are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.symbolsSize = [ + 4, // assigned to datasets 0,2,4,... + 6 // assigned to datasets 1,3,5,... +]; +``` + + + +#### Plot.prototype.symbolsOpacity + +Symbols opacity, where an opacity of `0.0` makes a symbol completely transparent and an opacity of `1.0` makes a symbol completely opaque. To set the opacity for all plotted symbols, + +```javascript +var plot = new Plot(); + +// Set: +plot.symbolsOpacity = 0.9; + +// Get: +var opacity = plot.symbolsOpacity; +// returns [0.9] +``` + +To specify the opacity for each dataset, provide an `array` of opacities. During plot creation, each plotted dataset is assigned an opacity. If the number of opacities is less than the number of plotted datasets, opacities are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.symbolsOpacity = [ + 0.7, // assigned to datasets 0,3,6,9,... + 0.2, // assigned to datasets 1,4,7,10,... + 1.0 // assigned to datasets 2,5,8,11,... +]; +``` + + + +#### Plot.prototype.width + +Plot width (in pixels). + +```javascript +var plot = new Plot(); + +// Set: +plot.width = 720; + +// Get: +var width = plot.width; +// returns 720 +``` + + + +#### Plot.prototype.height + +Plot height (in pixels). + +```javascript +var plot = new Plot(); + +// Set: +plot.height = 480; + +// Get: +var height = plot.height; +// returns 480 +``` + + + +#### Plot.prototype.paddingLeft + +Plot left padding (in pixels). Left padding is typically used to create space for a left-oriented `y`-axis. + +```javascript +var plot = new Plot(); + +// Set: +plot.paddingLeft = 120; + +// Get: +var padding = plot.paddingLeft; +// returns 120 +``` + + + +#### Plot.prototype.paddingRight + +Plot right padding (in pixels). Right padding is typically used to create space for a right-oriented `y`-axis. + +```javascript +var plot = new Plot(); + +// Set: +plot.paddingRight = 90; + +// Get: +var padding = plot.paddingRight; +// returns 90 +``` + + + +#### Plot.prototype.paddingTop + +Plot top padding (in pixels). Top padding is typically used to create space for a title or top-oriented `x`-axis. + +```javascript +var plot = new Plot(); + +// Set: +plot.paddingTop = 100; + +// Get: +var padding = plot.paddingTop; +// returns 100 +``` + + + +#### Plot.prototype.paddingBottom + +Plot bottom padding (in pixels). Bottom padding is typically used to create space for a bottom-oriented `x`-axis. + +```javascript +var plot = new Plot(); + +// Set: +plot.paddingBottom = 105; + +// Get: +var padding = plot.paddingBottom; +// returns 105 +``` + + + +#### Plot.prototype.xMin + +Minimum value of the `x`-axis domain. When retrieved, if the value has been set to `null`, the returned value is computed from the `x` data. + +```javascript +var plot = new Plot(); + +// Set: +plot.xMin = -1.0; + +// Get: +var xMin = plot.xMin; +// returns -1.0 +``` + + + +#### Plot.prototype.xMax + +Maximum value of the `x`-axis domain. When retrieved, if the value has been set to `null`, the returned value is computed from the `x` data. + +```javascript +var plot = new Plot(); + +// Set: +plot.xMax = 100.0; + +// Get: +var xMax = plot.xMax; +// returns 100.0 +``` + + + +#### Plot.prototype.yMin + +Minimum value of the `y`-axis domain. When retrieved, if the value has been set to `null`, the returned value is computed from the `y` data. + +```javascript +var plot = new Plot(); + +// Set: +plot.yMin = -50.0; + +// Get: +var yMin = plot.yMin; +// returns -50.0 +``` + + + +#### Plot.prototype.yMax + +Maximum value of the `y`-axis domain. When retrieved, if the value has been set to `null`, the returned value is computed from the `y` data. + +```javascript +var plot = new Plot(); + +// Set: +plot.yMax = 31.4; + +// Get: +var yMax = plot.yMax; +// returns 31.4 +``` + + + +#### Plot.prototype.xScale + +Scale function for mapping values to a coordinate along the `x`-axis. The following `scales` are supported: + +- `'linear'`: linear scale. +- `'time'`: time scale. + +To set the scale, + +```javascript +var plot = new Plot(); + +plot.xScale = 'time'; +``` + +When retrieved, the returned value is a scale `function`. + +```javascript +var plot = new Plot(); + +var xScale = plot.xScale; +// returns +``` + + + +#### Plot.prototype.yScale + +Scale function for mapping values to a coordinate along the `y`-axis. The following `scales` are supported: + +- `'linear'`: linear scale. +- `'time'`: time scale. + +To set the scale, + +```javascript +var plot = new Plot(); + +plot.yScale = 'linear'; +``` + +When retrieved, the returned value is a scale `function`. + +```javascript +var plot = new Plot(); + +var yScale = plot.yScale; +// returns +``` + + + +#### Plot.prototype.xTickFormat + +`x`-axis tick format. To set the tick format, + +```javascript +var plot = new Plot({ + 'xScale': 'time' +}); + +plot.xTickFormat = '%H:%M'; +``` + +When retrieved, if the value has not been set to `null`, the returned value is a formatting `function`. + +```javascript +var plot = new Plot({ + 'xScale': 'time', + 'xTickFormat': '%H:%M' +}); + +var fmt = plot.xTickFormat; +// returns +``` + + + +#### Plot.prototype.yTickFormat + +`y`-axis tick format. To set the tick format, + +```javascript +var plot = new Plot({ + 'yScale': 'linear' +}); + +plot.yTickFormat = '.0%'; +``` + +When retrieved, if the value has not been set to `null`, the returned value is a formatting `function`. + +```javascript +var plot = new Plot({ + 'yScale': 'linear', + 'yTickFormat': '.0%' +}); + +var fmt = plot.yTickFormat; +// returns +``` + + + +#### Plot.prototype.xNumTicks + +Number of `x`-axis tick marks. To set the number of tick marks, + +```javascript +var plot = new Plot(); + +// Set: +plot.xNumTicks = 10; + +// Get: +var numTicks = plot.xNumTicks; +// returns 10 +``` + +If the value is set to `null`, the number of tick marks is computed internally. + +```javascript +var plot = new Plot(); + +plot.xNumTicks = null; +``` + + + +#### Plot.prototype.yNumTicks + +Number of `y`-axis tick marks. To set the number of tick marks, + +```javascript +var plot = new Plot(); + +// Set: +plot.yNumTicks = 5; + +// Get: +var numTicks = plot.yNumTicks; +// returns 5 +``` + +If the value is set to `null`, the number of tick marks is computed internally. + +```javascript +var plot = new Plot(); + +plot.yNumTicks = null; +``` + + + +#### Plot.prototype.xAxisOrient + +`x`-axis orientation. The following orientations are supported: + +- `'bottom'` +- `'top'` + +To set the orientation, + +```javascript +var plot = new Plot(); + +// Set: +plot.xAxisOrient = 'top'; + +// Get: +var orient = plot.xAxisOrient; +// returns 'top' +``` + + + +#### Plot.prototype.yAxisOrient + +`y`-axis orientation. The following orientations are supported: + +- `'left'` +- `'right'` + +To set the orientation, + +```javascript +var plot = new Plot(); + +// Set: +plot.yAxisOrient = 'right'; + +// Get: +var orient = plot.yAxisOrient; +// returns 'right' +``` + + + +#### Plot.prototype.xRug + +Boolean flag(s) indicating whether to display a rug plot along the `x`-axis. To set the for flag all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.xRug = true; + +// Get: +var flgs = plot.xRug; +// returns [true] +``` + +To specify the flag for each dataset, provide an `array` of `booleans`. During plot creation, each plotted dataset is assigned a flag. If the number of flags is less than the number of plotted datasets, flags are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.xRug = [ + true, // assigned to datasets 0,2,4,... + false // assigned to datasets 1,3,5,... +]; +``` + + + +#### Plot.prototype.yRug + +Boolean flag(s) indicating whether to display a rug plot along the `y`-axis. To set the for flag all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.yRug = true; + +// Get: +var flgs = plot.yRug; +// returns [true] +``` + +To specify the flag for each dataset, provide an `array` of `booleans`. During plot creation, each plotted dataset is assigned a flag. If the number of flags is less than the number of plotted datasets, flags are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.yRug = [ + false, // assigned to datasets 0,2,4,... + true // assigned to datasets 1,3,5,... +]; +``` + + + +#### Plot.prototype.xRugOrient + +`x`-axis rug orientation. The following orientations are supported: + +- `'bottom'` +- `'top'` + +To set the orientation for all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.xRugOrient = 'top'; + +// Get: +var orient = plot.xRugOrient; +// returns ['top'] +``` + +To specify the `x`-axis rug orientation for each dataset, provide an `array` of orientations. During plot creation, each plotted dataset is assigned an orientation. If the number of orientations is less than the number of plotted datasets, orientations are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.xRugOrient = [ + 'bottom', // assigned to datasets 0,2,4,... + 'top' // assigned to datasets 1,3,5,... +]; +``` + + + +#### Plot.prototype.yRugOrient + +`y`-axis rug orientation. The following orientations are supported: + +- `'left'` +- `'right'` + +To set the orientation for all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.yRugOrient = 'right'; + +// Get: +var orient = plot.yRugOrient; +// returns ['right'] +``` + +To specify the `y`-axis rug orientation for each dataset, provide an `array` of orientations. During plot creation, each plotted dataset is assigned an orientation. If the number of orientations is less than the number of plotted datasets, orientations are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.yRugOrient = [ + 'left', // assigned to datasets 0,2,4,... + 'right' // assigned to datasets 1,3,5,... +]; +``` + + + +#### Plot.prototype.xRugOpacity + +`x`-axis rug opacity, where an opacity of `0.0` makes a rug completely transparent and an opacity of `1.0` makes a rug completely opaque. To set the opacity for all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.xRugOpacity = 0.2; + +// Get: +var opacity = plot.xRugOpacity; +// returns [0.2] +``` + +To specify the `x`-axis rug opacity for each dataset, provide an `array` of opacities. During plot creation, each plotted dataset is assigned an opacity. If the number of opacities is less than the number of plotted datasets, opacities are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.xRugOpacity = [ + 0.1, // assigned to datasets 0,2,4,... + 1.0 // assigned to datasets 1,3,5,... +]; +``` + + + +#### Plot.prototype.yRugOpacity + +`y`-axis rug opacity, where an opacity of `0.0` makes a rug completely transparent and an opacity of `1.0` makes a rug completely opaque. To set the opacity for all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.yRugOpacity = 0.4; + +// Get: +var opacity = plot.yRugOpacity; +// returns [0.4] +``` + +To specify the `y`-axis rug opacity for each dataset, provide an `array` of opacities. During plot creation, each plotted dataset is assigned an opacity. If the number of opacities is less than the number of plotted datasets, opacities are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.yRugOpacity = [ + 0.7, // assigned to datasets 0,2,4,... + 0.1 // assigned to datasets 1,3,5,... +]; +``` + + + +#### Plot.prototype.xRugSize + +`x`-axis rug tick (tassel) size. To set the tick size for all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.xRugSize = 4; + +// Get: +var size = plot.xRugSize; +// returns [4] +``` + +To specify the `x`-axis rug size for each dataset, provide an `array` of sizes. During plot creation, each plotted dataset is assigned a tick size. If the number of sizes is less than the number of plotted datasets, sizes are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.xRugSize = [ + 4, // assigned to datasets 0,3,6,... + 6, // assigned to datasets 1,4,7,... + 4 // assigned to datasets 2,5,8,... +]; +``` + + + +#### Plot.prototype.yRugSize + +`y`-axis rug tick (tassel) size. To set the tick size for all plotted datasets, + +```javascript +var plot = new Plot(); + +// Set: +plot.yRugSize = 4; + +// Get: +var size = plot.yRugSize; +// returns [4] +``` + +To specify the `y`-axis rug size for each dataset, provide an `array` of sizes. During plot creation, each plotted dataset is assigned a tick size. If the number of sizes is less than the number of plotted datasets, sizes are reused using modulo arithmetic. + +```javascript +var plot = new Plot(); + +plot.yRugSize = [ + 6, // assigned to datasets 0,3,6,... + 4, // assigned to datasets 1,4,7,... + 4 // assigned to datasets 2,5,8,... +]; +``` + + + +#### Plot.prototype.description + +Plot description. + +```javascript +var plot = new Plot(); + +// Set: +plot.description = 'A plot of `x` vs `y`.'; + +// Get: +var desc = plot.description; +// returns 'A plot of `x` vs `y`.' +``` + + + +#### Plot.prototype.title + +Plot title. + +```javascript +var plot = new Plot(); + +// Set: +plot.title = 'Time Series'; + +// Get: +var title = plot.title; +// returns 'Time Series' +``` + + + +#### Plot.prototype.xLabel + +`x`-axis label. + +```javascript +var plot = new Plot(); + +// Set: +plot.xLabel = 'time'; + +// Get: +var label = plot.xLabel; +// returns 'time' +``` + + + +#### Plot.prototype.yLabel + +`y`-axis label. + +```javascript +var plot = new Plot(); + +// Set: +plot.yLabel = 'value'; + +// Get: +var label = plot.yLabel; +// returns 'value' +``` + + + +#### Plot.prototype.renderFormat + +Plot render format. The following formats are supported: + +- `'vdom'` +- `'html'` + +```javascript +var plot = new Plot(); + +// Set: +plot.renderFormat = 'html'; + +// Get: +var fmt = plot.renderFormat; +// returns 'html' +``` + + + +#### Plot.prototype.autoRender + +Rendering mode. If `true`, an instance renders on each `'change'` event; otherwise, rendering must be triggered manually. + +```javascript +var plot = new Plot(); + +// Set: +plot.autoRender = false; + +// Get: +var mode = plot.autoRender; +// returns false +``` + + + +#### Plot.prototype.viewer + +Plot viewer. The following viewers are supported: + +- `'none'` +- `'stdout'` +- `'window'` +- `'browser'` + +```javascript +var plot = new Plot(); + +// Set: +plot.viewer = 'window'; + +// Get: +var viewer = plot.viewer; +// returns 'window' +``` + + + +#### Plot.prototype.autoView + +Viewer mode. If `true`, an instance generates an updated view on each `'render'` event; otherwise, generating a view must be triggered manually. + +```javascript +var plot = new Plot(); + +// Set: +plot.autoView = true; + +// Get: +var mode = plot.autoView; +// returns true +``` + +* * * + +### Computed Properties + + + +#### Plot.prototype.graphWidth + +Returns the expected graph width. + +```javascript +var plot = new Plot({ + 'width': 100, + 'paddingLeft': 20, + 'paddingRight': 10 +}); +var width = plot.graphWidth; +// returns 70 +``` + + + +#### Plot.prototype.graphHeight + +Returns the expected graph height. + +```javascript +var plot = new Plot({ + 'height': 500, + 'paddingTop': 10, + 'paddingBottom': 120 +}); +var height = plot.graphHeight; +// returns 370 +``` + + + +#### Plot.prototype.xDomain + +Returns the `x`-axis domain. + +```javascript +var plot = new Plot({ + 'xMin': -1.0, + 'xMax': 1.0 +}); +var domain = plot.xDomain; +// returns [-1.0,1.0] +``` + + + +#### Plot.prototype.yDomain + +Returns the `y`-axis domain. + +```javascript +var plot = new Plot({ + 'yMin': 0.0, + 'yMax': 100.0 +}); +var domain = plot.yDomain; +// returns [0.0,100.0] +``` + + + +#### Plot.prototype.xRange + +Returns the `x`-axis range. + +```javascript +var plot = new Plot({ + 'width': 100, + 'paddingLeft': 10, + 'paddingRight': 10 +}); +var range = plot.xRange; +// returns [0,80] +``` + + + +#### Plot.prototype.yRange + +Returns the `y`-axis range. + +```javascript +var plot = new Plot({ + 'height': 500, + 'paddingTop': 10, + 'paddingBottom': 120 +}); +var range = plot.yRange; +// returns [370,0] +``` + + + +#### Plot.prototype.xPos + +Returns a `function` to map values to `x`-axis coordinate values. + +```javascript +var plot = new Plot(); +var xPos = plot.xPos; +// returns +``` + + + +#### Plot.prototype.yPos + +Returns a `function` to map values to `y`-axis coordinate values. + +```javascript +var plot = new Plot(); +var yPos = plot.yPos; +// returns +``` + + + + + +
+ +* * * + +## Examples + + + +```javascript +var normal = require( '@stdlib/random/array/normal' ); +var linspace = require( '@stdlib/array/linspace' ); +var now = require( '@stdlib/time/now' ); +var plot = require( '@stdlib/plot/2d' ); + +// Create some data... +var opts = { + 'dtype': 'float64' +}; +var x = linspace( now()*1000, 100*360000, 100, opts ); +var y = normal( 100, 50.0, 10.0, opts ); + +// Create a new plot: +var plt = plot( [x], [y], { + 'width': 600, + 'height': 480, + 'xScale': 'time', + 'xTickFormat': '%H:%M', + 'renderFormat': 'svg', + 'autoRender': true +}); + +// Listen for 'render' events (e.g., when triggered due to changes in state): +h.on( 'render', onRender ); + +setTimeout( update, 1000 ); + +function update() { + h.width = 720; +} + +function onRender( svg ) { + console.log( svg ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/ctor/docs/repl.txt b/lib/node_modules/@stdlib/plot/2d/docs/repl.txt similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/docs/repl.txt rename to lib/node_modules/@stdlib/plot/2d/docs/repl.txt diff --git a/lib/node_modules/@stdlib/plot/2d/examples/index.js b/lib/node_modules/@stdlib/plot/2d/examples/index.js new file mode 100644 index 000000000000..72ae1dc8239a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/examples/index.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var normal = require( '@stdlib/random/array/normal' ); +var linspace = require( '@stdlib/array/linspace' ); +var Plot = require( './../lib' ); + +var opts = { + 'dtype': 'generic' +}; +var x = linspace( 1, 100, 100, opts ); +var y1 = normal( 100, 50.0, 10.0, opts ); +var y2 = normal( 100, 20.0, 10.0, opts ); + +var plot = new Plot( [ x ], [ y1, y2 ], { + 'width': 600, + 'height': 480, + 'xScale': 'linear', + 'title': 'Hello World!' +}); + +plot.render( onRender ); + +function onRender( error, result ) { + if ( error ) { + throw error; + } + console.log( result ); +} diff --git a/lib/node_modules/@stdlib/plot/ctor/examples/linescatter b/lib/node_modules/@stdlib/plot/2d/examples/linescatter similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/examples/linescatter rename to lib/node_modules/@stdlib/plot/2d/examples/linescatter diff --git a/lib/node_modules/@stdlib/plot/ctor/examples/linestyles b/lib/node_modules/@stdlib/plot/2d/examples/linestyles similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/examples/linestyles rename to lib/node_modules/@stdlib/plot/2d/examples/linestyles diff --git a/lib/node_modules/@stdlib/plot/ctor/examples/multiline b/lib/node_modules/@stdlib/plot/2d/examples/multiline similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/examples/multiline rename to lib/node_modules/@stdlib/plot/2d/examples/multiline diff --git a/lib/node_modules/@stdlib/plot/ctor/examples/scatter b/lib/node_modules/@stdlib/plot/2d/examples/scatter similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/examples/scatter rename to lib/node_modules/@stdlib/plot/2d/examples/scatter diff --git a/lib/node_modules/@stdlib/plot/ctor/examples/scatterrug b/lib/node_modules/@stdlib/plot/2d/examples/scatterrug similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/examples/scatterrug rename to lib/node_modules/@stdlib/plot/2d/examples/scatterrug diff --git a/lib/node_modules/@stdlib/plot/ctor/examples/timeseries b/lib/node_modules/@stdlib/plot/2d/examples/timeseries similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/examples/timeseries rename to lib/node_modules/@stdlib/plot/2d/examples/timeseries diff --git a/lib/node_modules/@stdlib/plot/2d/lib/defaults.js b/lib/node_modules/@stdlib/plot/2d/lib/defaults.js new file mode 100644 index 000000000000..c66d30d20828 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/defaults.js @@ -0,0 +1,184 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isNodeREPL = require( '@stdlib/assert/is-node-repl' ); + + +// MAIN // + +/** +* Returns default options. +* +* @private +* @returns {Object} default options +*/ +function defaults() { + var isREPL; + var o; + + isREPL = isNodeREPL(); + o = {}; + + // Boolean indicating whether to re-render on a change event: + o.autoRender = false; + + // Boolean indicating whether to generate an updated view on a render event: + o.autoView = false; + + // Data colors: + o.colors = 'category10'; + + // Plot description: + o.description = ''; + + // Plot height: + o.height = 400; // px + + // Data labels: + o.labels = []; + + // Data line opacity: + o.lineOpacity = 0.9; // [0,1] + + // Data line style(s): + o.lineStyle = '-'; + + // Data line width(s): + o.lineWidth = 2; // px + + // FIXME: padding props depend on orientation (may require using `null` to flag) + + // Bottom padding: + o.paddingBottom = 80; // px + + // Left padding: + o.paddingLeft = 90; // px + + // Right padding: + o.paddingRight = 20; // px + + // Top padding: + o.paddingTop = 80; // px + + // Render format: + o.renderFormat = 'svg'; + + // Data symbols: + o.symbols = 'none'; + + // Symbols opacity: + o.symbolsOpacity = 0.9; // [0,1] + + // Symbols size: + o.symbolsSize = 6; // px + + // Plot title: + o.title = ''; + + // Plot viewer: + if ( isREPL ) { + o.viewer = 'window'; + } else { + o.viewer = 'stdout'; + } + // Plot width: + o.width = 400; // px + + // x-values: + o.x = []; + + // x-axis orientation: + o.xAxisOrient = 'bottom'; + + // x-axis label: + o.xLabel = 'x'; + + // Maximum value of x-axis domain: + o.xMax = null; + + // Minimum value of x-axis domain: + o.xMin = null; + + // Number of x-axis tick marks: + o.xNumTicks = 5; + + // Boolean indicating whether to render a rug plot along the x-axis: + o.xRug = false; + + // x-axis rug orientation: + o.xRugOrient = 'bottom'; + + // x-axis rug opacity: + o.xRugOpacity = 0.1; // [0,1] + + // x-axis rug tick (tassel) size: + o.xRugSize = 6; // px + + // x-axis scale: + o.xScale = 'linear'; + + // x-axis tick format: + o.xTickFormat = null; + + // y-values: + o.y = []; + + // y-axis orientation: + o.yAxisOrient = 'left'; + + // y-axis label: + o.yLabel = 'y'; + + // Maximum value of y-axis domain: + o.yMax = null; + + // Minimum value of y-axis domain: + o.yMin = null; + + // Number of y-axis tick marks: + o.yNumTicks = 5; + + // Boolean indicating whether to render a rug plot along the y-axis: + o.yRug = false; + + // y-axis rug orientation: + o.yRugOrient = 'left'; + + // y-axis rug opacity: + o.yRugOpacity = 0.1; // [0,1] + + // y-axis rug tick (tassel) size: + o.yRugSize = 6; // px + + // y-axis scale: + o.yScale = 'linear'; + + // y-axis tick format: + o.yTickFormat = null; + + return o; +} + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/factory.js b/lib/node_modules/@stdlib/plot/2d/lib/factory.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/factory.js rename to lib/node_modules/@stdlib/plot/2d/lib/factory.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/index.js b/lib/node_modules/@stdlib/plot/2d/lib/index.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/index.js rename to lib/node_modules/@stdlib/plot/2d/lib/index.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/main.js b/lib/node_modules/@stdlib/plot/2d/lib/main.js new file mode 100644 index 000000000000..ce81784ad451 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/main.js @@ -0,0 +1,1579 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var EventEmitter = require( 'events' ).EventEmitter; +var logger = require( 'debug' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var defineProperty = require( '@stdlib/utils/define-property' ); +var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); +var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); +var setReadOnlyAccessor = require( '@stdlib/utils/define-read-only-accessor' ); +var isObject = require( '@stdlib/assert/is-plain-object' ); +var copy = require( '@stdlib/utils/copy' ); +var inherit = require( '@stdlib/utils/inherit' ); +var mergeFcn = require( '@stdlib/utils/merge' ).factory; +var format = require( '@stdlib/string/format' ); +var view = require( '@stdlib/plot/base/view' ); +var defaults = require( './defaults.js' ); +var setX = require( './props/x/set.js' ); +var getX = require( './props/x/get.js' ); +var setY = require( './props/y/set.js' ); +var getY = require( './props/y/get.js' ); +var setLabels = require( './props/labels/set.js' ); +var getLabels = require( './props/labels/get.js' ); +var setColors = require( './props/colors/set.js' ); +var getColors = require( './props/colors/get.js' ); +var setLineStyle = require( './props/line-style/set.js' ); +var getLineStyle = require( './props/line-style/get.js' ); +var setLineOpacity = require( './props/line-opacity/set.js' ); +var getLineOpacity = require( './props/line-opacity/get.js' ); +var setLineWidth = require( './props/line-width/set.js' ); +var getLineWidth = require( './props/line-width/get.js' ); +var setSymbols = require( './props/symbols/set.js' ); +var getSymbols = require( './props/symbols/get.js' ); +var setSymbolsSize = require( './props/symbols-size/set.js' ); +var getSymbolsSize = require( './props/symbols-size/get.js' ); +var setSymbolsOpacity = require( './props/symbols-opacity/set.js' ); +var getSymbolsOpacity = require( './props/symbols-opacity/get.js' ); +var setWidth = require( './props/width/set.js' ); +var getWidth = require( './props/width/get.js' ); +var setHeight = require( './props/height/set.js' ); +var getHeight = require( './props/height/get.js' ); +var setPaddingLeft = require( './props/padding-left/set.js' ); +var getPaddingLeft = require( './props/padding-left/get.js' ); +var setPaddingRight = require( './props/padding-right/set.js' ); +var getPaddingRight = require( './props/padding-right/get.js' ); +var setPaddingTop = require( './props/padding-top/set.js' ); +var getPaddingTop = require( './props/padding-top/get.js' ); +var setPaddingBottom = require( './props/padding-bottom/set.js' ); +var getPaddingBottom = require( './props/padding-bottom/get.js' ); +var setXMin = require( './props/x-min/set.js' ); +var getXMin = require( './props/x-min/get.js' ); +var setXMax = require( './props/x-max/set.js' ); +var getXMax = require( './props/x-max/get.js' ); +var setYMin = require( './props/y-min/set.js' ); +var getYMin = require( './props/y-min/get.js' ); +var setYMax = require( './props/y-max/set.js' ); +var getYMax = require( './props/y-max/get.js' ); +var setXScale = require( './props/x-scale/set.js' ); +var getXScale = require( './props/x-scale/get.js' ); +var setYScale = require( './props/y-scale/set.js' ); +var getYScale = require( './props/y-scale/get.js' ); +var setXTickFormat = require( './props/x-tick-format/set.js' ); +var getXTickFormat = require( './props/x-tick-format/get.js' ); +var setYTickFormat = require( './props/y-tick-format/set.js' ); +var getYTickFormat = require( './props/y-tick-format/get.js' ); +var setXNumTicks = require( './props/x-num-ticks/set.js' ); +var getXNumTicks = require( './props/x-num-ticks/get.js' ); +var setYNumTicks = require( './props/y-num-ticks/set.js' ); +var getYNumTicks = require( './props/y-num-ticks/get.js' ); +var setXAxisOrient = require( './props/x-axis-orient/set.js' ); +var getXAxisOrient = require( './props/x-axis-orient/get.js' ); +var setYAxisOrient = require( './props/y-axis-orient/set.js' ); +var getYAxisOrient = require( './props/y-axis-orient/get.js' ); +var setXRug = require( './props/x-rug/set.js' ); +var getXRug = require( './props/x-rug/get.js' ); +var setYRug = require( './props/y-rug/set.js' ); +var getYRug = require( './props/y-rug/get.js' ); +var setXRugOrient = require( './props/x-rug-orient/set.js' ); +var getXRugOrient = require( './props/x-rug-orient/get.js' ); +var setYRugOrient = require( './props/y-rug-orient/set.js' ); +var getYRugOrient = require( './props/y-rug-orient/get.js' ); +var setXRugOpacity = require( './props/x-rug-opacity/set.js' ); +var getXRugOpacity = require( './props/x-rug-opacity/get.js' ); +var setYRugOpacity = require( './props/y-rug-opacity/set.js' ); +var getYRugOpacity = require( './props/y-rug-opacity/get.js' ); +var setXRugSize = require( './props/x-rug-size/set.js' ); +var getXRugSize = require( './props/x-rug-size/get.js' ); +var setYRugSize = require( './props/y-rug-size/set.js' ); +var getYRugSize = require( './props/y-rug-size/get.js' ); +var setDescription = require( './props/description/set.js' ); +var getDescription = require( './props/description/get.js' ); +var setTitle = require( './props/title/set.js' ); +var getTitle = require( './props/title/get.js' ); +var setXLabel = require( './props/x-label/set.js' ); +var getXLabel = require( './props/x-label/get.js' ); +var setYLabel = require( './props/y-label/set.js' ); +var getYLabel = require( './props/y-label/get.js' ); +var setAutoRender = require( './props/auto-render/set.js' ); +var getAutoRender = require( './props/auto-render/get.js' ); +var setRenderFormat = require( './props/render-format/set.js' ); +var getRenderFormat = require( './props/render-format/get.js' ); +var setViewer = require( './props/viewer/set.js' ); +var getViewer = require( './props/viewer/get.js' ); +var setAutoView = require( './props/auto-view/set.js' ); +var getAutoView = require( './props/auto-view/get.js' ); +var getGraphWidth = require( './props/graph-width/get.js' ); +var getGraphHeight = require( './props/graph-height/get.js' ); +var getXDomain = require( './props/x-domain/get.js' ); +var getYDomain = require( './props/y-domain/get.js' ); +var getXRange = require( './props/x-range/get.js' ); +var getYRange = require( './props/y-range/get.js' ); +var getXPos = require( './props/x-pos/get.js' ); +var getYPos = require( './props/y-pos/get.js' ); +var render = require( './render' ); +var toJSON = require( './to_json.js' ); +var viewMethod = require( './view.js' ); + + +// VARIABLES // + +var debug = logger( 'plot:main' ); +var PRIVATE_PROPS = [ + '_autoRender', + '_autoView', + '_colors', + '_description', + '_engine', + '_height', + '_isDefined', + '_labels', + '_lineOpacity', + '_lineStyle', + '_lineWidth', + '_paddingBottom', + '_paddingLeft', + '_paddingRight', + '_paddingTop', + '_renderFormat', + '_symbols', + '_symbolsOpacity', + '_symbolsSize', + '_title', + '_viewer', + '_width', + '_xAxisOrient', + '_xData', + '_xLabel', + '_xMax', + '_xMin', + '_xNumTicks', + '_xRug', + '_xRugOpacity', + '_xRugOrient', + '_xRugSize', + '_xScale', + '_xTickFormat', + '_yAxisOrient', + '_yData', + '_yLabel', + '_yMax', + '_yMin', + '_yNumTicks', + '_yRug', + '_yRugOpacity', + '_yRugOrient', + '_yRugSize', + '_yScale', + '_yTickFormat' +]; + + +// FUNCTIONS // + +var merge = mergeFcn({ + 'extend': false +}); + + +// MAIN // + +/** +* Plot constructor. +* +* @constructor +* @param {Array} [x] - x-values +* @param {Array} [y] - y-values +* @param {Options} [options] - constructor options +* @param {boolean} [options.autoRender=false] - indicates whether to re-render on a change event +* @param {boolean} [options.autoView=false] - indicates whether to generate an updated view on a render event +* @param {(string|StringArray)} [options.colors='category10'] - data colors +* @param {string} [options.description=''] - plot description +* @param {string} [options.engine='svg'] - plot engine +* @param {PositiveNumber} [options.height=400] - plot height +* @param {Function} [options.isDefined] - accessor indicating whether a datum is defined +* @param {(StringArray|EmptyArray)} [options.labels] - data labels +* @param {(number|NumberArray)} [options.lineOpacity=0.9] - data line opacity +* @param {(string|StringArray)} [options.lineStyle='-'] - data line style(s) +* @param {(NonNegativeInteger|Array)} [options.lineWidth=2] - data line width(s) +* @param {NonNegativeInteger} [options.paddingBottom=80] - bottom padding +* @param {NonNegativeInteger} [options.paddingLeft=90] - left padding +* @param {NonNegativeInteger} [options.paddingRight=20] - right padding +* @param {NonNegativeInteger} [options.paddingTop=80] - top padding +* @param {string} [options.renderFormat='vdom'] - plot render format +* @param {(string|StringArray)} [options.symbols='none'] - data symbols +* @param {(number|NumberArray)} [options.symbolsOpacity=0.9] - symbols opacity +* @param {(NonNegativeInteger|Array)} [options.symbolsSize=6] - symbols size +* @param {string} [options.title=''] - plot title +* @param {string} [options.viewer='none'] - plot viewer +* @param {PositiveNumber} [options.width=400] - plot width +* @param {Array} [options.x=[]] - x-values +* @param {string} [options.xAxisOrient='bottom'] - x-axis orientation +* @param {string} [options.xLabel='x'] - x-axis label +* @param {(Date|FiniteNumber|null)} [options.xMax=null] - maximum value of x-axis domain +* @param {(Date|FiniteNumber|null)} [options.xMin=null] - minimum value of x-axis domain +* @param {(NonNegativeInteger|null)} [options.xNumTicks=5] - number of x-axis tick marks +* @param {(boolean|BooleanArray)} [options.xRug=false] - indicates whether to render a rug plot along the x-axis +* @param {(string|StringArray)} [options.xRugOrient='bottom'] - x-axis rug orientation +* @param {(number|NumberArray)} [options.xRugOpacity=0.1] - x-axis rug opacity +* @param {(NonNegativeInteger|Array)} [options.xRugSize=6] - x-axis rug tick (tassel) size +* @param {string} [options.xScale='linear'] - x-axis scale +* @param {(string|null)} [options.xTickFormat=null] - x-axis tick format +* @param {Array} [options.y=[]] - y-values +* @param {string} [options.yAxisOrient='left'] - y-axis orientation +* @param {string} [options.yLabel='y'] - y-axis label +* @param {(FiniteNumber|null)} [options.yMax=null] - maximum value of y-axis domain +* @param {(FiniteNumber|null)} [options.yMin=null] - minimum value of y-axis domain +* @param {(NonNegativeInteger|null)} [options.yNumTicks=5] - number of y-axis tick marks +* @param {(boolean|BooleanArray)} [options.yRug=false] - indicates whether to render a rug plot along the y-axis +* @param {(string|StringArray)} [options.yRugOrient='left'] - y-axis rug orientation +* @param {(number|NumberArray)} [options.yRugOpacity=0.1] - y-axis rug opacity +* @param {(NonNegativeInteger|Array)} [options.yRugSize=6] - y-axis rug tick (tassel) size +* @param {string} [options.yScale='linear'] - y-axis scale +* @param {(string|null)} [options.yTickFormat=null] - y-axis tick format +* @throws {TypeError} must provide valid options +* @returns {Plot} Plot instance +* +* @example +* var plot = new Plot(); +*/ +function Plot() { + var options; + var nargs; + var keys; + var self; + var opts; + var key; + var i; + + nargs = arguments.length; + if ( !(this instanceof Plot) ) { + if ( nargs === 0 ) { + return new Plot(); + } + if ( nargs === 1 ) { + return new Plot( arguments[0] ); + } + if ( nargs === 2 ) { + return new Plot( arguments[0], arguments[1] ); + } + return new Plot( arguments[0], arguments[1], arguments[2] ); + } + self = this; + + opts = defaults(); + if ( nargs === 0 ) { + options = {}; + } else if ( nargs === 1 ) { + options = arguments[ 0 ]; + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } + } else if ( nargs === 2 ) { + options = { + 'x': arguments[ 0 ], + 'y': arguments[ 1 ] + }; + } else if ( nargs > 2 ) { + if ( !isObject( arguments[2] ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arguments[2] ) ); + } + options = copy( arguments[2] ); // avoid mutation + options.x = arguments[ 0 ]; + options.y = arguments[ 1 ]; + } + opts = merge( opts, options ); + + debug( 'Creating an instance with the following configuration: %s.', JSON.stringify( opts ) ); + EventEmitter.call( this ); + + for ( i = 0; i < PRIVATE_PROPS.length; i++ ) { + defineProperty( this, PRIVATE_PROPS[ i ], { + 'configurable': false, + 'enumerable': false, + 'writable': true, + 'value': null + }); + } + + // Set options... + 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 ); + + 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 {*} plot - rendered plot + */ + function onRender( plot ) { + /* eslint-disable no-underscore-dangle */ + debug( 'Received a render event.' ); + if ( self._autoView ) { + debug( 'Viewer: %s.', self._viewer ); + debug( 'Generating view...' ); + view( self, self._viewer, plot ); + } + } +} + +/* +* Inherit from the `EventEmitter` prototype. +*/ +inherit( Plot, EventEmitter ); + +/** +* `x` values. +* +* @name x +* @memberof Plot.prototype +* @type {Array} +* @throws {TypeError} must be an array +* @default [] +* +* @example +* var plot = new Plot(); +* plot.x = [ [ 1417563950959, 1417563952959 ] ]; +* +* @example +* var plot = new Plot({ +* 'x': [ [ 1417563950959, 1417563952959 ] ] +* }); +* var x = plot.x; +* // returns [ [ 1417563950959, 1417563952959 ] ] +*/ +setReadWriteAccessor( Plot.prototype, 'x', getX, setX ); + +/** +* `y` values. +* +* @name y +* @memberof Plot.prototype +* @type {Array} +* @throws {TypeError} must be an array +* @default [] +* +* @example +* var plot = new Plot(); +* plot.x = [ [ 1417563950959, 1417563952959 ] ]; +* plot.y = [ [ 0.25, 0.23 ] ]; +* +* @example +* var plot = new Plot({ +* 'x': [ [ 1417563950959, 1417563952959 ] ], +* 'y': [ [ 0.25, 0.23 ] ] +* }); +* var y = plot.y; +* // returns [ [ 0.25, 0.23 ] ] +*/ +setReadWriteAccessor( Plot.prototype, 'y', getY, setY ); + +/** +* Data labels. +* +* @name labels +* @memberof Plot.prototype +* @type {(StringArray|EmptyArray)} +* @throws {TypeError} must be either an array of strings or an empty array +* @default [] +* +* @example +* var plot = new Plot(); +* plot.labels = [ 'beep', 'boop' ]; +* +* @example +* var plot = new Plot({ +* 'labels': [ 'beep', 'boop' ] +* }); +* var labels = plot.labels; +* // returns [ 'beep', 'boop' ] +*/ +setReadWriteAccessor( Plot.prototype, 'labels', getLabels, setLabels ); + +/** +* Data colors. When retrieved, the returned value is always an `array`. +* +* @name colors +* @memberof Plot.prototype +* @type {(string|StringArray)} +* @throws {TypeError} must be either a string or an array of strings +* @default 'category10' +* +* @example +* var plot = new Plot(); +* plot.colors = 'category20'; +* +* @example +* var plot = new Plot({ +* 'colors': 'category20' +* }); +* var colors = plot.colors; +* // returns [...] +*/ +setReadWriteAccessor( Plot.prototype, 'colors', getColors, setColors ); + +/** +* Data line style(s). +* +* ## Notes +* +* - When retrieved, the returned value is always an `array`. +* +* @name lineStyle +* @memberof Plot.prototype +* @type {(string|StringArray)} +* @throws {TypeError} must be a string or string array +* @throws {Error} must be a supported line style +* @default '-' +* +* @example +* var plot = new Plot(); +* plot.lineStyle = [ '-', 'none' ]; +* +* @example +* var plot = new Plot({ +* 'lineStyle': 'none' +* }); +* var lineStyle = plot.lineStyle; +* // returns [ 'none' ] +*/ +setReadWriteAccessor( Plot.prototype, 'lineStyle', getLineStyle, setLineStyle ); + +/** +* Data line opacity. +* +* ## Notes +* +* - When retrieved, the returned value is always an `array`. +* +* @name lineOpacity +* @memberof Plot.prototype +* @type {(number|NumberArray)} +* @throws {TypeError} must be a number or number array +* @throws {RangeError} must be a number on the interval `[0,1]` +* @default '0.9' +* +* @example +* var plot = new Plot(); +* plot.lineOpacity = [ 1.0, 0.5 ]; +* +* @example +* var plot = new Plot({ +* 'lineOpacity': 0.5 +* }); +* var opacity = plot.lineOpacity; +* // returns [ 0.5 ] +*/ +setReadWriteAccessor( Plot.prototype, 'lineOpacity', getLineOpacity, setLineOpacity ); + +/** +* Data line width. +* +* ## Notes +* +* - When retrieved, the returned value is always an `array`. +* +* @name lineWidth +* @memberof Plot.prototype +* @type {(NonNegativeInteger|NonNegativeIntegerArray)} +* @throws {TypeError} must be a nonnegative integer or nonnegative integer array +* @default 2 +* +* @example +* var plot = new Plot(); +* plot.lineWidth = 1; +* +* @example +* var plot = new Plot({ +* 'lineWidth': [ 1, 3 ] +* }); +* var width = plot.lineWidth; +* // returns [ 1, 3 ] +*/ +setReadWriteAccessor( Plot.prototype, 'lineWidth', getLineWidth, setLineWidth ); + +/** +* Data symbols. When retrieved, the returned value is always an `array`. +* +* @name symbols +* @memberof Plot.prototype +* @type {(string|StringArray)} +* @throws {TypeError} must be a string or string array +* @throws {Error} must be a supported symbol +* @default 'none' +* +* @example +* var plot = new Plot(); +* plot.symbols = [ 'open-circle', 'closed-circle' ]; +* +* @example +* var plot = new Plot({ +* 'symbols': 'closed-circle' +* }); +* var symbols = plot.symbols; +* // returns [ 'closed-circle' ] +*/ +setReadWriteAccessor( Plot.prototype, 'symbols', getSymbols, setSymbols ); + +/** +* Symbols size. When retrieved, the returned value is always an `array`. +* +* @name symbolsSize +* @memberof Plot.prototype +* @type {(NonNegativeInteger|NonNegativeIntegerArray)} +* @throws {TypeError} must be a nonnegative integer or nonnegative integer array +* @default 6 +* +* @example +* var plot = new Plot(); +* plot.symbolsSize = 4; +* +* @example +* var plot = new Plot({ +* 'symbolsSize': [ 4, 6 ] +* }); +* var size = plot.symbolsSize; +* // returns [ 4, 6 ] +*/ +setReadWriteAccessor( Plot.prototype, 'symbolsSize', getSymbolsSize, setSymbolsSize ); + +/** +* Symbols opacity. When retrieved, the returned value is always an `array`. +* +* @name symbolsOpacity +* @memberof Plot.prototype +* @type {(number|NumberArray)} +* @throws {TypeError} must be a number or number array +* @throws {RangeError} must be a number on the interval `[0,1]` +* @default 0.9 +* +* @example +* var plot = new Plot(); +* plot.symbolsOpacity = [ 0.2, 0.5 ]; +* +* @example +* var plot = new Plot({ +* 'symbolsOpacity': 0.2 +* }); +* var opacity = plot.symbolsOpacity; +* // returns [ 0.2 ] +*/ +setReadWriteAccessor( Plot.prototype, 'symbolsOpacity', getSymbolsOpacity, setSymbolsOpacity ); + +/** +* Plot width. +* +* @name width +* @memberof Plot.prototype +* @type {PositiveNumber} +* @throws {TypeError} must be a positive number +* @default 400 (px) +* +* @example +* var plot = new Plot(); +* plot.width = 100; +* +* @example +* var plot = new Plot({ +* 'width': 480 +* }); +* var width = plot.width; +* // returns 480 +*/ +setReadWriteAccessor( Plot.prototype, 'width', getWidth, setWidth ); + +/** +* Plot height. +* +* @name height +* @memberof Plot.prototype +* @type {PositiveNumber} +* @throws {TypeError} must be a positive number +* @default 400 (px) +* +* @example +* var plot = new Plot(); +* plot.height = 100; +* +* @example +* var plot = new Plot({ +* 'height': 360 +* }); +* var height = plot.height; +* // returns 360 +*/ +setReadWriteAccessor( Plot.prototype, 'height', getHeight, setHeight ); + +/** +* Plot left padding. +* +* ## Notes +* +* - Typically used to create space for a left-oriented y-axis. +* +* @name paddingLeft +* @memberof Plot.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be a nonnegative integer +* @default 90 (px) +* +* @example +* var plot = new Plot(); +* plot.paddingLeft = 100; +* +* @example +* var plot = new Plot({ +* 'paddingLeft': 100 +* }); +* var padding = plot.paddingLeft; +* // returns 100 +*/ +setReadWriteAccessor( Plot.prototype, 'paddingLeft', getPaddingLeft, setPaddingLeft ); + +/** +* Plot right padding. +* +* ## Notes +* +* - Typically used to create space for a right-oriented y-axis. +* +* @name paddingRight +* @memberof Plot.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be a nonnegative integer +* @default 20 (px) +* +* @example +* var plot = new Plot(); +* plot.paddingRight = 100; +* +* @example +* var plot = new Plot({ +* 'paddingRight': 100 +* }); +* var padding = plot.paddingRight; +* // returns 100 +*/ +setReadWriteAccessor( Plot.prototype, 'paddingRight', getPaddingRight, setPaddingRight ); + +/** +* Plot top padding. +* +* ## Notes +* +* - Typically used to create space for a title or top-oriented x-axis. +* +* @name paddingTop +* @memberof Plot.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be a nonnegative integer +* @default 80 (px) +* +* @example +* var plot = new Plot(); +* plot.paddingTop = 100; +* +* @example +* var plot = new Plot({ +* 'paddingTop': 100 +* }); +* var padding = plot.paddingTop; +* // returns 100 +*/ +setReadWriteAccessor( Plot.prototype, 'paddingTop', getPaddingTop, setPaddingTop ); + +/** +* Plot bottom padding. +* +* ## Notes +* +* - Typically used to create space for a bottom-oriented y-axis. +* +* @name paddingBottom +* @memberof Plot.prototype +* @type {NonNegativeInteger} +* @throws {TypeError} must be a nonnegative integer +* @default 80 (px) +* +* @example +* var plot = new Plot(); +* plot.paddingBottom = 100; +* +* @example +* var plot = new Plot({ +* 'paddingBottom': 100 +* }); +* var padding = plot.paddingBottom; +* // returns 100 +*/ +setReadWriteAccessor( Plot.prototype, 'paddingBottom', getPaddingBottom, setPaddingBottom ); + +/** +* Minimum value of the x-axis domain. +* +* ## Notes +* +* - When retrieved, if the value has been set to `null`, the returned value is computed from the `x` data. +* +* @name xMin +* @memberof Plot.prototype +* @type {(FiniteNumber|null)} +* @throws {TypeError} must be a finite number or null +* @default null +* +* @example +* var plot = new Plot(); +* plot.xMin = -1.0; +* +* @example +* var plot = new Plot({ +* 'xMin': -10.0 +* }); +* var xmin = plot.xMin; +* // returns -10.0 +*/ +setReadWriteAccessor( Plot.prototype, 'xMin', getXMin, setXMin ); + +/** +* Maximum value of the x-axis domain. +* +* ## Notes +* +* - When retrieved, if the value has been set to `null`, the returned value is computed from the `x` data. +* +* @name xMax +* @memberof Plot.prototype +* @type {(FiniteNumber|null)} +* @throws {TypeError} must be a finite number or null +* @default null +* +* @example +* var plot = new Plot(); +* plot.xMax = 100.0; +* +* @example +* var plot = new Plot({ +* 'xMax': 10.0 +* }); +* var xmax = plot.xMax; +* // returns 10.0 +*/ +setReadWriteAccessor( Plot.prototype, 'xMax', getXMax, setXMax ); + +/** +* Minimum value of the y-axis domain. +* +* ## Notes +* +* - When retrieved, if the value has been set to `null`, the returned value is computed from the `y` data. +* +* @name yMin +* @memberof Plot.prototype +* @type {(FiniteNumber|null)} +* @throws {TypeError} must be a finite number or null +* @default null +* +* @example +* var plot = new Plot(); +* plot.yMin = -100.0; +* +* @example +* var plot = new Plot({ +* 'yMin': 3.14 +* }); +* var ymin = plot.yMin; +* // returns 3.14 +*/ +setReadWriteAccessor( Plot.prototype, 'yMin', getYMin, setYMin ); + +/** +* Maximum value of the y-axis domain. +* +* ## Notes +* +* - When retrieved, if the value has been set to `null`, the returned value is computed from the `y` data. +* +* @name yMax +* @memberof Plot.prototype +* @type {(FiniteNumber|null)} +* @throws {TypeError} must be a finite number or null +* @default null +* +* @example +* var plot = new Plot(); +* plot.yMax = 100.0; +* +* @example +* var plot = new Plot({ +* 'yMax': 31.4 +* }); +* var ymax = plot.yMax; +* // returns 31.4 +*/ +setReadWriteAccessor( Plot.prototype, 'yMax', getYMax, setYMax ); + +/** +* Scale function for mapping values to a coordinate along the x-axis. When retrieved, the returned value is a scale function. +* +* @name xScale +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be a string +* @default 'linear' +* +* @example +* var plot = new Plot(); +* plot.xScale = 'time'; +* +* @example +* var plot = new Plot({ +* 'xScale': 'time' +* }); +* var scale = plot.xScale; +* // returns +*/ +setReadWriteAccessor( Plot.prototype, 'xScale', getXScale, setXScale ); + +/** +* Scale function for mapping values to a coordinate along the y-axis. When retrieved, the returned value is a scale function. +* +* @name yScale +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be a string +* @default 'linear' +* +* @example +* var plot = new Plot(); +* plot.yScale = 'linear'; +* +* @example +* var plot = new Plot({ +* 'yScale': 'linear' +* }); +* var scale = plot.yScale; +* // returns +*/ +setReadWriteAccessor( Plot.prototype, 'yScale', getYScale, setYScale ); + +/** +* x-axis tick format. +* +* ## Notes +* +* - When retrieved, if the value is not `null`, the returned value is a formatting function. +* +* @name xTickFormat +* @memberof Plot.prototype +* @type {(string|null)} +* @throws {TypeError} must be a string or null +* @default null +* +* @example +* var plot = new Plot(); +* plot.xScale = 'time'; +* plot.xTickFormat = '%H:%M'; +* +* @example +* var plot = new Plot({ +* 'xScale': 'time', +* 'xTickFormat': '%H:%M' +* }); +* var fmt = plot.xTickFormat; +* // returns +*/ +setReadWriteAccessor( Plot.prototype, 'xTickFormat', getXTickFormat, setXTickFormat ); + +/** +* y-axis tick format. +* +* ## Notes +* +* - If the value is not `null`, when retrieved, the returned value is a formatting function. +* +* @name yTickFormat +* @memberof Plot.prototype +* @type {(string|null)} +* @throws {TypeError} must be a string or null +* @default null +* +* @example +* var plot = new Plot(); +* plot.yTickFormat = '.0%'; +* +* @example +* var plot = new Plot({ +* 'yTickFormat': '.0%' +* }); +* var fmt = plot.yTickFormat; +* // returns +*/ +setReadWriteAccessor( Plot.prototype, 'yTickFormat', getYTickFormat, setYTickFormat ); + +/** +* Number of x-axis tick marks. +* +* @name xNumTicks +* @memberof Plot.prototype +* @type {(NonNegativeInteger|null)} +* @throws {TypeError} must be a nonnegative integer or null +* @default 5 +* +* @example +* var plot = new Plot(); +* plot.xNumTicks = 10; +* +* @example +* var plot = new Plot({ +* 'xNumTicks': 10 +* }); +* var ticks = plot.xNumTicks; +* // returns 10 +*/ +setReadWriteAccessor( Plot.prototype, 'xNumTicks', getXNumTicks, setXNumTicks ); + +/** +* Number of y-axis tick marks. +* +* @name yNumTicks +* @memberof Plot.prototype +* @type {(NonNegativeInteger|null)} +* @throws {TypeError} must be a nonnegative integer or null +* @default 5 +* +* @example +* var plot = new Plot(); +* plot.yNumTicks = 10; +* +* @example +* var plot = new Plot({ +* 'yNumTicks': 10 +* }); +* var ticks = plot.yNumTicks; +* // returns 10 +*/ +setReadWriteAccessor( Plot.prototype, 'yNumTicks', getYNumTicks, setYNumTicks ); + +/** +* x-axis orientation. +* +* @name xAxisOrient +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be either `'top'` or `'bottom'` +* @default 'bottom' +* +* @example +* var plot = new Plot(); +* plot.xAxisOrient = 'bottom'; +* +* @example +* var plot = new Plot({ +* 'xAxisOrient': 'bottom' +* }); +* var orientation = plot.xAxisOrient; +* // returns 'bottom' +*/ +setReadWriteAccessor( Plot.prototype, 'xAxisOrient', getXAxisOrient, setXAxisOrient ); + +/** +* y-axis orientation. +* +* @name yAxisOrient +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be either `'left'` or `'right'` +* @default 'left' +* +* @example +* var plot = new Plot(); +* plot.yAxisOrient = 'left'; +* +* @example +* var plot = new Plot({ +* 'yAxisOrient': 'left' +* }); +* var orientation = plot.yAxisOrient; +* // returns 'left' +*/ +setReadWriteAccessor( Plot.prototype, 'yAxisOrient', getYAxisOrient, setYAxisOrient ); + +/** +* Boolean flag(s) indicating whether to display a rug plot along the x-axis. When retrieved, the returned value is always an `array`. +* +* @name xRug +* @memberof Plot.prototype +* @type {(boolean|BooleanArray)} +* @throws {TypeError} must be a boolean or boolean array +* @default false +* +* @example +* var plot = new Plot({ +* 'xRug': true +* }); +* +* var bool = plot.xRug; +* // returns [ true ] +*/ +setReadWriteAccessor( Plot.prototype, 'xRug', getXRug, setXRug ); + +/** +* Boolean flag(s) indicating whether to display a rug plot along the y-axis. When retrieved, the returned value is always an `array`. +* +* @name yRug +* @memberof Plot.prototype +* @type {(boolean|BooleanArray)} +* @throws {TypeError} must be a boolean or boolean array +* @default false +* +* @example +* var plot = new Plot({ +* 'yRug': true +* }); +* +* var bool = plot.yRug; +* // returns [ true ] +*/ +setReadWriteAccessor( Plot.prototype, 'yRug', getYRug, setYRug ); + +/** +* x-axis rug orientation. When retrieved, the returned value is always an `array`. +* +* @name xRugOrient +* @memberof Plot.prototype +* @type {(string|StringArray)} +* @throws {TypeError} must be a string or string array +* @throws {TypeError} must be either `'top'` or `'bottom'` +* @default 'bottom' +* +* @example +* var plot = new Plot(); +* plot.xRugOrient = [ 'bottom', 'top' ]; +* +* @example +* var plot = new Plot({ +* 'xRugOrient': 'bottom' +* }); +* var orientation = plot.xRugOrient; +* // returns [ 'bottom' ] +*/ +setReadWriteAccessor( Plot.prototype, 'xRugOrient', getXRugOrient, setXRugOrient ); + +/** +* y-axis rug orientation. When retrieved, the returned value is always an `array`. +* +* @name yRugOrient +* @memberof Plot.prototype +* @type {(string|StringArray)} +* @throws {TypeError} must be a string or string array +* @throws {TypeError} must be either `'left'` or `'right'` +* @default 'left' +* +* @example +* var plot = new Plot(); +* plot.yRugOrient = [ 'right', 'left' ]; +* +* @example +* var plot = new Plot({ +* 'yRugOrient': 'left' +* }); +* var orientation = plot.yRugOrient; +* // returns [ 'left' ] +*/ +setReadWriteAccessor( Plot.prototype, 'yRugOrient', getYRugOrient, setYRugOrient ); + +/** +* x-axis rug opacity. When retrieved, the returned value is always an `array`. +* +* @name xRugOpacity +* @memberof Plot.prototype +* @type {(number|NumberArray)} +* @throws {TypeError} must be a number or number array +* @throws {RangeError} must be a number on the interval `[0,1]` +* @default 0.1 +* +* @example +* var plot = new Plot(); +* plot.xRugOpacity = [ 0.1, 0.5 ]; +* +* @example +* var plot = new Plot({ +* 'xRugOpacity': 0.1 +* }); +* var opacity = plot.xRugOpacity; +* // returns [ 0.1 ] +*/ +setReadWriteAccessor( Plot.prototype, 'xRugOpacity', getXRugOpacity, setXRugOpacity ); + +/** +* y-axis rug opacity. When retrieved, the returned value is always an `array`. +* +* @name yRugOpacity +* @memberof Plot.prototype +* @type {(number|NumberArray)} +* @throws {TypeError} must be a number or number array +* @throws {RangeError} must be a number on the interval `[0,1]` +* @default 0.1 +* +* @example +* var plot = new Plot(); +* plot.yRugOpacity = [ 0.1, 0.5 ]; +* +* @example +* var plot = new Plot({ +* 'yRugOpacity': 0.1 +* }); +* var opacity = plot.yRugOpacity; +* // returns [ 0.1 ] +*/ +setReadWriteAccessor( Plot.prototype, 'yRugOpacity', getYRugOpacity, setYRugOpacity ); + +/** +* x-axis rug tick (tassel) size. When retrieved, the returned value is always an `array`. +* +* @name xRugSize +* @memberof Plot.prototype +* @type {(NonNegativeInteger|Array)} +* @throws {TypeError} must be a nonnegative integer or nonnegative integer array +* @default 6 +* +* @example +* var plot = new Plot(); +* plot.xRugSize = [ 4, 6 ]; +* +* @example +* var plot = new Plot({ +* 'xRugSize': 4 +* }); +* var size = plot.xRugSize; +* // returns [ 4 ] +*/ +setReadWriteAccessor( Plot.prototype, 'xRugSize', getXRugSize, setXRugSize ); + +/** +* y-axis rug tick (tassel) size. When retrieved, the returned value is always an `array`. +* +* @name yRugSize +* @memberof Plot.prototype +* @type {(NonNegativeInteger|Array)} +* @throws {TypeError} must be a nonnegative integer or nonnegative integer array +* @default 6 +* +* @example +* var plot = new Plot(); +* plot.yRugSize = [ 4, 6 ]; +* +* @example +* var plot = new Plot({ +* 'yRugSize': 4 +* }); +* var size = plot.yRugSize; +* // returns [ 4 ] +*/ +setReadWriteAccessor( Plot.prototype, 'yRugSize', getYRugSize, setYRugSize ); + +/** +* Plot description. +* +* @name description +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be a string +* @default '' +* +* @example +* var plot = new Plot(); +* plot.description = 'Average stock market index covering the last 100 years.'; +* +* @example +* var plot = new Plot({ +* 'description': 'A plot description.' +* }); +* var desc = plot.description; +* // returns 'A plot description.' +*/ +setReadWriteAccessor( Plot.prototype, 'description', getDescription, setDescription ); + +/** +* Plot title. +* +* @name title +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be a string +* @default '' +* +* @example +* var plot = new Plot(); +* plot.title = 'Time Series'; +* +* @example +* var plot = new Plot({ +* 'title': 'Time Series' +* }); +* var t = plot.title; +* // returns 'Time Series' +*/ +setReadWriteAccessor( Plot.prototype, 'title', getTitle, setTitle ); + +/** +* x-axis label. +* +* @name xLabel +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be a string +* @default 'x' +* +* @example +* var plot = new Plot(); +* plot.xLabel = 'time'; +* +* @example +* var plot = new Plot({ +* 'xLabel': 'time' +* }); +* var xLabel = plot.xLabel; +* // returns 'time' +*/ +setReadWriteAccessor( Plot.prototype, 'xLabel', getXLabel, setXLabel ); + +/** +* y-axis label. +* +* @name yLabel +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be a string +* @default 'y' +* +* @example +* var plot = new Plot(); +* plot.yLabel = 'value'; +* +* @example +* var plot = new Plot({ +* 'yLabel': 'value' +* }); +* var yLabel = plot.yLabel; +* // returns 'value' +*/ +setReadWriteAccessor( Plot.prototype, 'yLabel', getYLabel, setYLabel ); + +/** +* Rendering mode. +* +* ## Notes +* +* - If `true`, an instance re-renders on each change event. +* +* @name autoRender +* @memberof Plot.prototype +* @type {boolean} +* @throws {TypeError} must be a boolean +* @default false +* +* @example +* var plot = new Plot({ +* 'autoRender': true +* }); +* +* var mode = plot.autoRender; +* // returns true +*/ +setReadWriteAccessor( Plot.prototype, 'autoRender', getAutoRender, setAutoRender ); + +/** +* Plot render format. +* +* @name renderFormat +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be a recognized format +* @default 'vdom' +* +* @example +* var plot = new Plot(); +* plot.renderFormat = 'vdom'; +* +* @example +* var plot = new Plot({ +* 'renderFormat': 'html' +* }); +* var fmt = plot.renderFormat; +* // returns 'html' +*/ +setReadWriteAccessor( Plot.prototype, 'renderFormat', getRenderFormat, setRenderFormat ); + +/** +* Plot viewer. +* +* @name viewer +* @memberof Plot.prototype +* @type {string} +* @throws {TypeError} must be a recognized viewer +* @default 'none' +* +* @example +* var plot = new Plot(); +* plot.viewer = 'none'; +* +* @example +* var plot = new Plot({ +* 'viewer': 'none' +* }); +* var viewer = plot.viewer; +* // returns 'none' +*/ +setReadWriteAccessor( Plot.prototype, 'viewer', getViewer, setViewer ); + +/** +* Viewer mode. If `true`, an instance generates an updated view on each render event. +* +* @name autoView +* @memberof Plot.prototype +* @type {boolean} +* @throws {TypeError} must be a boolean +* @default false +* +* @example +* var plot = new Plot({ +* 'autoView': false +* }); +* +* var mode = plot.autoView; +* // returns false +*/ +setReadWriteAccessor( Plot.prototype, 'autoView', getAutoView, setAutoView ); + +/** +* Expected graph width. +* +* @name graphWidth +* @memberof Plot.prototype +* @type {number} +* +* @example +* var plot = new Plot({ +* 'width': 100, +* 'paddingLeft': 10, +* 'paddingRight': 10 +* }); +* var width = plot.graphWidth; +* // returns 80 +*/ +setReadOnlyAccessor( Plot.prototype, 'graphWidth', getGraphWidth ); + +/** +* Expected graph height. +* +* @name graphHeight +* @memberof Plot.prototype +* @type {number} +* +* @example +* var plot = new Plot({ +* 'height': 100, +* 'paddingTop': 10, +* 'paddingBottom': 20 +* }); +* var height = plot.graphHeight; +* // returns 70 +*/ +setReadOnlyAccessor( Plot.prototype, 'graphHeight', getGraphHeight ); + +/** +* x-axis domain. +* +* @name xDomain +* @memberof Plot.prototype +* @type {Array} +* +* @example +* var plot = new Plot({ +* 'xMin': 0, +* 'xMax': 100 +* }); +* var domain = plot.xDomain; +* // returns [ 0, 100 ] +*/ +setReadOnlyAccessor( Plot.prototype, 'xDomain', getXDomain ); + +/** +* y-axis domain. +* +* @name yDomain +* @memberof Plot.prototype +* @type {NumberArray} +* +* @example +* var plot = new Plot({ +* 'yMin': 0, +* 'yMax': 100 +* }); +* var domain = plot.yDomain; +* // returns [ 0, 100 ] +*/ +setReadOnlyAccessor( Plot.prototype, 'yDomain', getYDomain ); + +/** +* x-axis range. +* +* @name xRange +* @memberof Plot.prototype +* @type {NumberArray} +* +* @example +* var plot = new Plot({ +* 'width': 100, +* 'paddingLeft': 10, +* 'paddingRight': 10 +* }); +* var range = plot.xRange; +* // returns [ 0, 80 ] +*/ +setReadOnlyAccessor( Plot.prototype, 'xRange', getXRange ); + +/** +* y-axis range. +* +* @name yRange +* @memberof Plot.prototype +* @type {NumberArray} +* +* @example +* var plot = new Plot({ +* 'height': 100, +* 'paddingTop': 10, +* 'paddingBottom': 20 +* }); +* var range = plot.yRange; +* // returns [ 70, 0 ] +*/ +setReadOnlyAccessor( Plot.prototype, 'yRange', getYRange ); + +/** +* Function to map values to x-axis coordinate values. +* +* @name xPos +* @memberof Plot.prototype +* @type {Function} +* +* @example +* var plot = new Plot(); +* var xPos = plot.xPos; +* // returns +*/ +setReadOnlyAccessor( Plot.prototype, 'xPos', getXPos ); + +/** +* Function to map values to y-axis coordinate values. +* +* @name yPos +* @memberof Plot.prototype +* @type {Function} +* +* @example +* var plot = new Plot(); +* var yPos = plot.yPos; +* // returns +*/ +setReadOnlyAccessor( Plot.prototype, 'yPos', getYPos ); + +/** +* Renders a plot. +* +* @name render +* @memberof Plot.prototype +* @type {Function} +* @param {string} [format] - render format +* @throws {TypeError} must provide a recognized format +* @returns {(VTree|string)} virtual tree or string +* +* @example +* var plot = new Plot(); +* plot.x = [ [ 1, 2, 3 ] ]; +* plot.y = [ [ 1, 0, 1 ] ]; +* +* var out = plot.render(); +* +* @example +* var plot = new Plot(); +* plot.x = [ [ 1, 2, 3 ] ]; +* plot.y = [ [ 1, 0, 1 ] ]; +* +* var out = plot.render( 'html' ); +*/ +setReadOnly( Plot.prototype, 'render', render ); + +/** +* Serializes a plot to JSON. +* +* @name toJSON +* @memberof Plot.prototype +* @type {Function} +* @returns {Object} JSON object +*/ +setReadOnly( Plot.prototype, 'toJSON', toJSON ); + +/** +* Generates a plot view. +* +* @name view +* @memberof Plot.prototype +* @type {Function} +* @param {string} [viewer] +* @throws {TypeError} must provide a recognized viewer +* +* @example +* var plot = new Plot(); +* plot.x = [ [ 1, 2, 3 ] ]; +* plot.y = [ [ 1, 0, 1 ] ]; +* +* plot.view( 'stdout' ); +*/ +setReadOnly( Plot.prototype, 'view', viewMethod ); + + +// EXPORTS // + +module.exports = Plot; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-render/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/auto-render/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-render/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/auto-render/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/auto-render/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/auto-render/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/auto-render/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/auto-render/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-view/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/auto-view/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-view/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/auto-view/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/auto-view/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/auto-view/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/auto-view/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/auto-view/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/colors/colors.js b/lib/node_modules/@stdlib/plot/2d/lib/props/colors/colors.js new file mode 100644 index 000000000000..44e315999329 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/colors/colors.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var category10 = require( '@stdlib/plot/color-schemes/category10' ); +var category20 = require( '@stdlib/plot/color-schemes/category20' ); +var category20b = require( '@stdlib/plot/color-schemes/category20b' ); +var category20c = require( '@stdlib/plot/color-schemes/category20c' ); + + +// MAIN // + +var COLORS = { + 'category10': category10(), + 'category20': category20(), + 'category20b': category20b(), + 'category20c': category20c() +}; + + +// EXPORTS // + +module.exports = COLORS; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/colors/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/colors/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/colors/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/colors/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/colors/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/colors/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/colors/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/colors/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/description/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/description/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/description/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/description/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/description/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/description/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/description/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/description/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/graph-height/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/graph-height/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/graph-height/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/graph-height/get.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/graph-width/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/graph-width/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/graph-width/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/graph-width/get.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/height/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/height/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/height/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/height/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/height/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/height/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/height/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/height/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/labels/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/labels/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/labels/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/labels/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/labels/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/labels/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/labels/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/labels/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/line-opacity/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/line-opacity/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/line-opacity/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/line-opacity/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/line-opacity/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/line-opacity/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/line-opacity/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/line-opacity/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/line-style/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/line-style/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/line-style/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/line-style/get.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/line-style/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/line-style/set.js new file mode 100644 index 000000000000..43ed4dd97201 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/line-style/set.js @@ -0,0 +1,76 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var indexOf = require( '@stdlib/utils/index-of' ); +var lineStyles = require( '@stdlib/plot/base/line-styles' ); +var format = require( '@stdlib/string/format' ); + + +// VARIABLES // + +var debug = logger( 'plot:set:line-style' ); +var LINESTYLES = lineStyles(); + + +// MAIN // + +/** +* Sets the data line style(s). +* +* @private +* @param {(string|StringArray)} v - line style(s) +* @throws {TypeError} must be a string or string array +* @throws {Error} must be a supported line style +* @returns {void} +*/ +function set( v ) { + /* eslint-disable no-invalid-this */ + var isStr = isString( v ); + var i; + if ( !isStr && !isStringArray( v ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string or an array of strings. Value: `%s`.', 'lineStyle', v ) ); + } + if ( isStr ) { + v = [ v ]; + } else { + v = v.slice(); + } + for ( i = 0; i < v.length; i++ ) { + if ( indexOf( LINESTYLES, v[i] ) === -1 ) { + throw new Error( format( 'invalid assignment. Unsupported/unrecognized line style. Must be one of the following: "%s". Value: `%s`.', LINESTYLES.join( '", "' ), v[i] ) ); + } + } + debug( 'Current value: %s.', JSON.stringify( this._lineStyle ) ); + + this._lineStyle = v; + debug( 'New Value: %s.', JSON.stringify( this._lineStyle ) ); + + this.emit( 'change' ); +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/line-width/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/line-width/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/line-width/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/line-width/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/line-width/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/line-width/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/line-width/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/line-width/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-bottom/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/padding-bottom/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-bottom/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/padding-bottom/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/padding-bottom/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/padding-bottom/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/padding-bottom/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/padding-bottom/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-left/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/padding-left/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-left/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/padding-left/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/padding-left/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/padding-left/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/padding-left/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/padding-left/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-right/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/padding-right/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-right/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/padding-right/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/padding-right/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/padding-right/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/padding-right/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/padding-right/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-top/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/padding-top/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-top/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/padding-top/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/padding-top/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/padding-top/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/padding-top/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/padding-top/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/render-format/formats.json b/lib/node_modules/@stdlib/plot/2d/lib/props/render-format/formats.json new file mode 100644 index 000000000000..79653264fcda --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/render-format/formats.json @@ -0,0 +1,4 @@ +[ + "svg", + "png" +] diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/render-format/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/render-format/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/render-format/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/render-format/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/render-format/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/render-format/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/render-format/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/render-format/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/symbols-opacity/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/symbols-opacity/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/symbols-opacity/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/symbols-opacity/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/symbols-opacity/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/symbols-opacity/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/symbols-opacity/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/symbols-opacity/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/symbols-size/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/symbols-size/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/symbols-size/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/symbols-size/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/symbols-size/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/symbols-size/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/symbols-size/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/symbols-size/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/symbols/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/symbols/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/symbols/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/symbols/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/symbols/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/symbols/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/symbols/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/symbols/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/symbols/symbols.json b/lib/node_modules/@stdlib/plot/2d/lib/props/symbols/symbols.json similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/symbols/symbols.json rename to lib/node_modules/@stdlib/plot/2d/lib/props/symbols/symbols.json diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/title/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/title/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/title/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/title/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/title/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/title/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/title/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/title/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/viewer/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/viewer/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/viewer/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/viewer/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/viewer/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/viewer/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/viewer/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/viewer/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/viewer/viewers.json b/lib/node_modules/@stdlib/plot/2d/lib/props/viewer/viewers.json new file mode 100644 index 000000000000..e61dd46778ff --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/viewer/viewers.json @@ -0,0 +1,5 @@ +[ + "browser", + "stdout", + "window" +] diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/width/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/width/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/width/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/width/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/width/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/width/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/width/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/width/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-axis-orient/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-axis-orient/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-axis-orient/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-axis-orient/get.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-axis-orient/orientations.json b/lib/node_modules/@stdlib/plot/2d/lib/props/x-axis-orient/orientations.json similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-axis-orient/orientations.json rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-axis-orient/orientations.json diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-axis-orient/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-axis-orient/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-axis-orient/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-axis-orient/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-domain/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-domain/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-domain/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-domain/get.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-label/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-label/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-label/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-label/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-label/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-label/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-label/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-label/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/x-max/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-max/get.js new file mode 100644 index 000000000000..a144cb9e1ee6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/x-max/get.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isNull = require( '@stdlib/assert/is-null' ); +var max = require( '@stdlib/stats/array/max' ); + + +// FUNCTIONS // + +/** +* Computes a maximum value. +* +* @private +* @param {Array} arr - input array +* @returns {(number|null)} maximum value or null +*/ +function getMax( arr ) { + var tmp; + var i; + if ( arr.length === 0 ) { + return null; + } + tmp = []; + for ( i = 0; i < arr.length; i++ ) { + tmp.push( max( arr[ i ] ) ); + } + return max( tmp ); +} + + +// MAIN // + +/** +* Returns the maximum value of the x-axis domain. +* +* @private +* @returns {number} maximum value +*/ +function get() { + /* eslint-disable no-invalid-this */ + var max; + if ( isNull( this._xMax ) ) { + max = getMax( this._xData ); + return ( isNull( max ) ) ? 1.0 : max; + } + return this._xMax; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-max/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-max/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-max/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-max/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/x-min/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-min/get.js new file mode 100644 index 000000000000..57274c64fa7d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/x-min/get.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isNull = require( '@stdlib/assert/is-null' ); +var min = require( '@stdlib/stats/array/min' ); + + +// FUNCTIONS // + +/** +* Computes a minimum value. +* +* @private +* @param {Array} arr - input array +* @returns {(number|null)} minimum value or null +*/ +function getMin( arr ) { + var tmp; + var i; + if ( arr.length === 0 ) { + return null; + } + tmp = []; + for ( i = 0; i < arr.length; i++ ) { + tmp.push( min( arr[ i ] ) ); + } + return min( tmp ); +} + + +// MAIN // + +/** +* Returns the minimum value of the x-axis domain. +* +* @private +* @returns {number} minimum value +*/ +function get() { + /* eslint-disable no-invalid-this */ + var min; + if ( isNull( this._xMin ) ) { + min = getMin( this._xData ); + return ( isNull( min ) ) ? 0.0 : min; + } + return this._xMin; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-min/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-min/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-min/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-min/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-num-ticks/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-num-ticks/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-num-ticks/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-num-ticks/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-num-ticks/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-num-ticks/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-num-ticks/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-num-ticks/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-pos/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-pos/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-pos/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-pos/get.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-range/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-range/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-range/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-range/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-opacity/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-opacity/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-opacity/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-opacity/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-opacity/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-opacity/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-opacity/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-opacity/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-orient/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-orient/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-orient/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-orient/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-orient/orientations.json b/lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-orient/orientations.json similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-orient/orientations.json rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-orient/orientations.json diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-orient/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-orient/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-orient/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-orient/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-size/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-size/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-size/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-size/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-size/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-size/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug-size/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-rug-size/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-rug/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-rug/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-rug/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-rug/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-rug/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/x-scale/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-scale/get.js new file mode 100644 index 000000000000..1d3b8565b39b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/x-scale/get.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MAIN // + +/** +* Returns the scale type for mapping values to a coordinate along the x-axis. +* +* @private +* @returns {string} scale type +*/ +function get() { + return this._xScale; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-scale/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-scale/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-scale/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-scale/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-tick-format/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-tick-format/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-tick-format/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-tick-format/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x-tick-format/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x-tick-format/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x-tick-format/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x-tick-format/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/x/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/x/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/x/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/x/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-axis-orient/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-axis-orient/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-axis-orient/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-axis-orient/get.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-axis-orient/orientations.json b/lib/node_modules/@stdlib/plot/2d/lib/props/y-axis-orient/orientations.json similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-axis-orient/orientations.json rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-axis-orient/orientations.json diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-axis-orient/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-axis-orient/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-axis-orient/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-axis-orient/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-domain/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-domain/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-domain/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-domain/get.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-label/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-label/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-label/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-label/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-label/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-label/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-label/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-label/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/y-max/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-max/get.js new file mode 100644 index 000000000000..85c4f25914f1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/y-max/get.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isNull = require( '@stdlib/assert/is-null' ); +var max = require( '@stdlib/stats/array/max' ); + + +// FUNCTIONS // + +/** +* Computes a maximum value. +* +* @private +* @param {Array} arr - input array +* @returns {(number|null)} maximum value or null +*/ +function getMax( arr ) { + var tmp; + var i; + if ( arr.length === 0 ) { + return null; + } + tmp = []; + for ( i = 0; i < arr.length; i++ ) { + tmp.push( max( arr[ i ] ) ); + } + return max( tmp ); +} + + +// MAIN // + +/** +* Returns the maximum value of the y-axis domain. +* +* @private +* @returns {number} maximum value +*/ +function get() { + /* eslint-disable no-invalid-this */ + var max; + if ( isNull( this._yMax ) ) { + max = getMax( this._yData ); + return ( isNull( max ) ) ? 1.0 : max; + } + return this._yMax; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-max/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-max/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-max/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-max/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/y-min/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-min/get.js new file mode 100644 index 000000000000..c1874d0370d6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/y-min/get.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isNull = require( '@stdlib/assert/is-null' ); +var min = require( '@stdlib/stats/array/min' ); + + +// FUNCTIONS // + +/** +* Computes a minimum value. +* +* @private +* @param {Array} arr - input array +* @returns {(number|null)} minimum value or null +*/ +function getMin( arr ) { + var tmp; + var i; + if ( arr.length === 0 ) { + return null; + } + tmp = []; + for ( i = 0; i < arr.length; i++ ) { + tmp.push( min( arr[ i ] ) ); + } + return min( tmp ); +} + + +// MAIN // + +/** +* Returns the minimum value of the y-axis domain. +* +* @private +* @returns {number} minimum value +*/ +function get() { + /* eslint-disable no-invalid-this */ + var min; + if ( isNull( this._yMin ) ) { + min = getMin( this._yData ); + return ( isNull( min ) ) ? 0.0 : min; + } + return this._yMin; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-min/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-min/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-min/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-min/set.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-num-ticks/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-num-ticks/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-num-ticks/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-num-ticks/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-num-ticks/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-num-ticks/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-num-ticks/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-num-ticks/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-pos/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-pos/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-pos/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-pos/get.js diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-range/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-range/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-range/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-range/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-opacity/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-opacity/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-opacity/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-opacity/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-opacity/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-opacity/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-opacity/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-opacity/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-orient/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-orient/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-orient/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-orient/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-orient/orientations.json b/lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-orient/orientations.json similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-orient/orientations.json rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-orient/orientations.json diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-orient/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-orient/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-orient/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-orient/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-size/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-size/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-size/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-size/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-size/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-size/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug-size/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-rug-size/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-rug/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-rug/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-rug/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-rug/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-rug/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/props/y-scale/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-scale/get.js new file mode 100644 index 000000000000..d49e150300c7 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/props/y-scale/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MAIN // + +/** +* Returns the scale type for mapping values to a coordinate along the y-axis. +* +* @private +* @returns {string} scale type +*/ +function get() { + return this._yScale; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-scale/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-scale/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-scale/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-scale/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-tick-format/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-tick-format/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-tick-format/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-tick-format/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y-tick-format/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y-tick-format/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y-tick-format/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y-tick-format/set.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y/get.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y/get.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y/get.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y/get.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/props/y/set.js b/lib/node_modules/@stdlib/plot/2d/lib/props/y/set.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/props/y/set.js rename to lib/node_modules/@stdlib/plot/2d/lib/props/y/set.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/render/index.js b/lib/node_modules/@stdlib/plot/2d/lib/render/index.js new file mode 100644 index 000000000000..b4a0819f2a80 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/render/index.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var spec2svg = require( '@stdlib/plot/vega/base/spec2svg' ); + + +// MAIN // + +/** +* Generates a Vega specification. +* +* @private +* @param {Callback} clbk - callback to invoke with rendered visualization +* @returns {void} +*/ +function render( clbk ) { + spec2svg( this.toJSON(), clbk ); +} + + +// EXPORTS // + +module.exports = render; diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/index.js b/lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/index.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/index.js rename to lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/index.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/lines.js b/lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/lines.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/lines.js rename to lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/lines.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/symbols.js b/lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/symbols.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/symbols.js rename to lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/symbols.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/x_rug.js b/lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/x_rug.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/x_rug.js rename to lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/x_rug.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/y_rug.js b/lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/y_rug.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/render/svg/marks/y_rug.js rename to lib/node_modules/@stdlib/plot/2d/lib/render/svg/marks/y_rug.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/render/svg/utils/x_rug_transform.js b/lib/node_modules/@stdlib/plot/2d/lib/render/svg/utils/x_rug_transform.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/render/svg/utils/x_rug_transform.js rename to lib/node_modules/@stdlib/plot/2d/lib/render/svg/utils/x_rug_transform.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/render/svg/utils/y_rug_transform.js b/lib/node_modules/@stdlib/plot/2d/lib/render/svg/utils/y_rug_transform.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/render/svg/utils/y_rug_transform.js rename to lib/node_modules/@stdlib/plot/2d/lib/render/svg/utils/y_rug_transform.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/render/index.js b/lib/node_modules/@stdlib/plot/2d/lib/render/tmp.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/render/index.js rename to lib/node_modules/@stdlib/plot/2d/lib/render/tmp.js diff --git a/lib/node_modules/@stdlib/plot/ctor/lib/render/validate.js b/lib/node_modules/@stdlib/plot/2d/lib/render/validate.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/lib/render/validate.js rename to lib/node_modules/@stdlib/plot/2d/lib/render/validate.js diff --git a/lib/node_modules/@stdlib/plot/2d/lib/to_json.js b/lib/node_modules/@stdlib/plot/2d/lib/to_json.js new file mode 100644 index 000000000000..5f299ba9c4b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/to_json.js @@ -0,0 +1,188 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var Axis = require( '@stdlib/plot/vega/axis/ctor' ); +var Title = require( '@stdlib/plot/vega/title/ctor' ); +var LinearScale = require( '@stdlib/plot/vega/scale/linear' ); +var Autosize = require( '@stdlib/plot/vega/autosize/ctor' ); +var Padding = require( '@stdlib/plot/vega/padding/ctor' ); +var paired2tidy = require( '@stdlib/plot/vega/data/tidy/from-paired-arrays' ); + + +// MAIN // + +/** +* Serializes a plot to JSON. +* +* @private +* @returns {Object} JSON object +*/ +function toJSON() { + var autosize; + var padding; + var xScale; + var yScale; + var xAxis; + var yAxis; + var title; + var data; + var spec; + var i; + + title = new Title({ + 'text': this.title + }); + + autosize = new Autosize({ + 'type': 'none', + 'contains': 'padding' + }); + + padding = new Padding({ + 'bottom': this.paddingBottom, + 'left': this.paddingLeft, + 'right': this.paddingRight, + 'top': this.paddingTop + }); + + xScale = new LinearScale({ + 'name': 'xScale', + 'domain': this.xDomain, + 'range': this.xRange + }); + + yScale = new LinearScale({ + 'name': 'yScale', + 'domain': this.yDomain, + 'range': this.yRange + }); + + xAxis = new Axis({ + 'scale': xScale.name, + 'orient': this.xAxisOrient, + 'title': this.xLabel + }); + if ( this.xNumTicks ) { + xAxis.tickCount = this.xNumTicks; + } + + yAxis = new Axis({ + 'scale': yScale.name, + 'orient': this.yAxisOrient, + 'title': this.yLabel, + 'domain': false + }); + if ( this.yNumTicks ) { + yAxis.tickCount = this.yNumTicks; + } + data = paired2tidy( this.x, this.y, [ 'table1', 'table2' ], [ 'x', 'y' ] ); + for ( i = 0; i < data.length; i++ ) { + data[ i ] = data[ i ].toJSON(); + } + + spec = { + '$schema': 'https://vega.github.io/schema/vega/v6.json', + 'description': this.description, + 'title': title.toJSON(), + 'width': this.width, + 'height': this.height, + 'autosize': autosize.toJSON(), + 'padding': padding.toJSON(), + 'scales': [ + xScale.toJSON(), + yScale.toJSON() + ], + 'axes': [ + xAxis.toJSON(), + yAxis.toJSON() + ], + 'marks': [ + { + 'type': 'line', + 'from': { + 'data': 'table1' + }, + 'encode': { + 'enter': { + 'stroke': { + 'value': this.colors[ 0 ] + }, + 'x': { + 'scale': 'xScale', + 'field': 'x' + }, + 'y': { + 'scale': 'yScale', + 'field': 'y' + }, + 'defined': { + 'signal': 'isValid(datum.y)' + } + }, + 'update': { + 'strokeDash': { + 'value': [ 5, 1, 1, 1 ] + } + } + } + }, + { + 'type': 'line', + 'from': { + 'data': 'table2' + }, + 'encode': { + 'enter': { + 'stroke': { + 'value': this.colors[ 1 ] + }, + 'x': { + 'scale': 'xScale', + 'field': 'x' + }, + 'y': { + 'scale': 'yScale', + 'field': 'y' + }, + 'defined': { + 'signal': 'isValid(datum.y)' + } + }, + 'update': { + 'strokeDash': { + 'value': [] + } + } + } + } + ], + 'data': data + }; + return spec; +} + + +// EXPORTS // + +module.exports = toJSON; diff --git a/lib/node_modules/@stdlib/plot/2d/lib/view.js b/lib/node_modules/@stdlib/plot/2d/lib/view.js new file mode 100644 index 000000000000..4ab1bedff8a6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/lib/view.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var View = require( '@stdlib/plot/base/view' ); + + +// VARIABLES // + +var debug = logger( 'plot:view' ); + + +// MAIN // + +/** +* Creates a plot view. +* +* @private +* @param {string} [viewer] - plot viewer +*/ +function view( viewer ) { + var view; + var v; + + if ( arguments.length ) { + v = viewer; + } else { + v = this.viewer; + } + debug( 'Viewer: %s', v ); + + view = new View( this ); + view.render( v ); +} + + +// EXPORTS // + +module.exports = view; diff --git a/lib/node_modules/@stdlib/plot/2d/package.json b/lib/node_modules/@stdlib/plot/2d/package.json new file mode 100644 index 000000000000..c5d3be967a18 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/2d/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/plot/2d", + "version": "0.0.0", + "description": "2-dimensional plot constructor.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": { + "./lib/view/view.js": "./lib/view/view.browser.js" + }, + "directories": { + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "constructor", + "ctor", + "figure", + "fig", + "graph", + "chart", + "diagram", + "2-dimensional", + "2d", + "data", + "visualize", + "visualization", + "dataviz", + "explore", + "exploratory", + "analysis" + ] +} diff --git a/lib/node_modules/@stdlib/plot/ctor/srv/scripts/fig_intro_plot.js b/lib/node_modules/@stdlib/plot/2d/srv/scripts/fig_intro_plot.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/srv/scripts/fig_intro_plot.js rename to lib/node_modules/@stdlib/plot/2d/srv/scripts/fig_intro_plot.js diff --git a/lib/node_modules/@stdlib/plot/ctor/test/test.js b/lib/node_modules/@stdlib/plot/2d/test/test.js similarity index 100% rename from lib/node_modules/@stdlib/plot/ctor/test/test.js rename to lib/node_modules/@stdlib/plot/2d/test/test.js diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/README.md b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/README.md new file mode 100644 index 000000000000..d4f6eeeae7e3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/README.md @@ -0,0 +1,119 @@ + + +# isLineStyle + +> Test if an input value is a supported [line style][@stdlib/plot/base/line-styles]. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var isLineStyle = require( '@stdlib/plot/base/assert/is-line-style' ); +``` + +#### isLineStyle( value ) + +Tests if an input value is a supported [line style][@stdlib/plot/base/line-styles]. + +```javascript +var bool = isLineStyle( '-' ); +// returns true + +bool = isLineStyle( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var isLineStyle = require( '@stdlib/plot/base/assert/is-line-style' ); + +var bool = isLineStyle( '-' ); +// returns true + +bool = isLineStyle( '--' ); +// returns true + +bool = isLineStyle( '' ); +// returns false + +bool = isLineStyle( 'foo' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/benchmark/benchmark.js new file mode 100644 index 000000000000..ba7c90c23f7c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/benchmark/benchmark.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isLineStyle = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var v; + var i; + + values = [ + '-', + '--', + + 'foo', + 'bar', + '', + 'beep', + 'boop' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = values[ i%values.length ]; + out = isLineStyle( v ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( out ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/docs/repl.txt b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/docs/repl.txt new file mode 100644 index 000000000000..dae3e0188fb8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/docs/repl.txt @@ -0,0 +1,28 @@ + +{{alias}}( value ) + Tests if an input value is a supported line style. + + Parameters + ---------- + value: any + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating if an input value is a supported line style. + + Examples + -------- + > var bool = {{alias}}( '-' ) + true + > bool = {{alias}}( '--' ) + true + > bool = {{alias}}( '' ) + false + > bool = {{alias}}( 'beep' ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/docs/types/index.d.ts new file mode 100644 index 000000000000..0160c368337d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/docs/types/index.d.ts @@ -0,0 +1,45 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests whether an input value is a supported line style. +* +* @param v - value to test +* @returns boolean indicating whether an input value is a supported line style +* +* @example +* var bool = isLineStyle( '-' ); +* // returns true +* +* bool = isLineStyle( '--' ); +* // returns true +* +* bool = isLineStyle( 'bar' ); +* // returns false +* +* bool = isLineStyle( 'foo' ); +* // returns false +*/ +declare function isLineStyle( v: any ): boolean; + + +// EXPORTS // + +export = isLineStyle; diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/docs/types/test.ts b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/docs/types/test.ts new file mode 100644 index 000000000000..efe707357b23 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/docs/types/test.ts @@ -0,0 +1,34 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import isLineStyle = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isLineStyle( '--' ); // $ExpectType boolean + isLineStyle( 'foo' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isLineStyle(); // $ExpectError + isLineStyle( undefined, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/examples/index.js b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/examples/index.js new file mode 100644 index 000000000000..09a8af515bb6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var isLineStyle = require( './../lib' ); + +var bool = isLineStyle( '-' ); +console.log( bool ); +// => true + +bool = isLineStyle( '--' ); +console.log( bool ); +// => true + +bool = isLineStyle( '' ); +console.log( bool ); +// => false + +bool = isLineStyle( 'foo' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/lib/index.js b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/lib/index.js new file mode 100644 index 000000000000..4547d259448a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/lib/index.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Test whether an input value is a supported line style. +* +* @module @stdlib/plot/base/assert/is-line-style +* +* @example +* var isLineStyle = require( '@stdlib/plot/base/assert/is-line-style' ); +* +* var bool = isLineStyle( '-' ); +* // returns true +* +* bool = isLineStyle( '--' ); +* // returns true +* +* bool = isLineStyle( 'bar' ); +* // returns false +* +* bool = isLineStyle( 'foo' ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/lib/main.js b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/lib/main.js new file mode 100644 index 000000000000..f383bdabc39b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/lib/main.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var lineStyles = require( '@stdlib/plot/base/line-styles' ); + + +// MAIN // + +/** +* Tests whether an input value is a supported line style. +* +* @name isLineStyle +* @type {Function} +* @param {*} v - value to test +* @returns {boolean} boolean indicating whether an input value is a supported line style +* +* @example +* var bool = isLineStyle( '-' ); +* // returns true +* +* bool = isLineStyle( '--' ); +* // returns true +* +* bool = isLineStyle( 'bar' ); +* // returns false +* +* bool = isLineStyle( 'foo' ); +* // returns false +*/ +var isLineStyle = contains( lineStyles() ); + + +// EXPORTS // + +module.exports = isLineStyle; diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/package.json b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/package.json new file mode 100644 index 000000000000..e48fc323b614 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/plot/base/assert/is-line-style", + "version": "0.0.0", + "description": "Test if an input value is a supported line style.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "base", + "linestyle", + "line-style", + "utilities", + "utility", + "utils", + "util", + "assert", + "test", + "check", + "is", + "valid", + "validate", + "validation", + "isvalid" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/base/assert/is-line-style/test/test.js b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/test/test.js new file mode 100644 index 000000000000..00477a146e76 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/assert/is-line-style/test/test.js @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isLineStyle = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isLineStyle, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a supported line style', function test( t ) { + var values; + var bool; + var i; + + values = [ + '-', + '--', + ':', + '-.' + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isLineStyle( values[ i ] ); + t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +}); + +tape( 'the function returns `false` if not provided a supported line style', function test( t ) { + var values; + var bool; + var i; + + values = [ + '', + 'beep', + 'boop', + 'foo', + 'bar', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + bool = isLineStyle( values[ i ] ); + t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/base/ctor/examples/index.js b/lib/node_modules/@stdlib/plot/base/ctor/examples/index.js deleted file mode 100644 index 2cc86a1a5e6d..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 Plot = require( './../lib' ); - -// Create a new plot: -var plot = new Plot({ - 'width': 600, - 'height': 480, - 'xScale': 'time', - 'xTickFormat': '%H:%M', - 'renderFormat': 'html' -}); - -console.log( plot.toString() ); diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/defaults.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/defaults.js deleted file mode 100644 index 4d0e929a11c3..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/defaults.js +++ /dev/null @@ -1,139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 isNodeREPL = require( '@stdlib/assert/is-node-repl' ); - - -// MAIN // - -/** -* Returns default options. -* -* @private -* @returns {Object} default options -*/ -function defaults() { - var isREPL; - var o; - - isREPL = isNodeREPL(); - o = {}; - - // Boolean indicating whether to re-render on a change event: - o.autoRender = false; - - // Boolean indicating whether to generate an updated view on a render event: - o.autoView = false; - - // Plot description: - o.description = ''; - - // Rendering engine: - o.engine = 'svg'; - - // Plot height: - o.height = 400; // px - - // Data labels: - o.labels = []; - - // Line opacity: - o.lineOpacity = 0.9; // [0,1] - - // Line style: - o.lineStyle = '-'; - - // Data line width(s): - o.lineWidth = 2; // px - - // FIXME: padding props depend on orientation (may require using `null` to flag) - - // Bottom padding: - o.paddingBottom = 80; // px - - // Left padding: - o.paddingLeft = 90; // px - - // Right padding: - o.paddingRight = 20; // px - - // Top padding: - o.paddingTop = 80; // px - - // Render format: - o.renderFormat = 'vdom'; - - // Plot title: - o.title = ''; - - // Plot viewer: - if ( isREPL ) { - o.viewer = 'window'; - } else { - o.viewer = 'none'; - } - // Plot width: - o.width = 400; // px - - // x-axis orientation: - o.xAxisOrient = 'bottom'; - - // x-axis label: - o.xLabel = 'x'; - - // Maximum value of x-axis domain: - o.xMax = null; - - // Minimum value of x-axis domain: - o.xMin = null; - - // Number of x-axis tick marks: - o.xNumTicks = 5; - - // x-axis tick format: - o.xTickFormat = null; - - // y-axis orientation: - o.yAxisOrient = 'left'; - - // y-axis label: - o.yLabel = 'y'; - - // Maximum value of y-axis domain: - o.yMax = null; - - // Minimum value of y-axis domain: - o.yMin = null; - - // Number of y-axis tick marks: - o.yNumTicks = 5; - - // y-axis tick format: - o.yTickFormat = null; - - return o; -} - - -// EXPORTS // - -module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/index.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/index.js deleted file mode 100644 index 3ca3c3fc3a9f..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 constructor for a 2-dimensional plot. -* -* @module @stdlib/plot/base/ctor -* -* @example -* var Plot = require( '@stdlib/plot/base/ctor' ); -* -* var plot = new Plot(); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/main.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/main.js deleted file mode 100644 index d06d83cb323c..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/main.js +++ /dev/null @@ -1,1251 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 EventEmitter = require( 'events' ).EventEmitter; -var logger = require( 'debug' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var inherit = require( '@stdlib/utils/inherit' ); -var copy = require( '@stdlib/utils/copy' ); -var mergeFcn = require( '@stdlib/utils/merge' ).factory; -var defineProperty = require( '@stdlib/utils/define-property' ); -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); -var isObject = require( '@stdlib/assert/is-plain-object' ); -var minstd = require( '@stdlib/random/base/minstd' ); -var format = require( '@stdlib/string/format' ); -var defaults = require( './defaults.js' ); -var view = require( './view' ); -var setAutoRender = require( './props/auto-render/set.js' ); -var getAutoRender = require( './props/auto-render/get.js' ); -var setAutoView = require( './props/auto-view/set.js' ); -var getAutoView = require( './props/auto-view/get.js' ); -var setDescription = require( './props/description/set.js' ); -var getDescription = require( './props/description/get.js' ); -var setEngine = require( './props/engine/set.js' ); -var getEngine = require( './props/engine/get.js' ); -var getGraphHeight = require( './props/graph-height/get.js' ); -var getGraphWidth = require( './props/graph-width/get.js' ); -var setHeight = require( './props/height/set.js' ); -var getHeight = require( './props/height/get.js' ); -var setLabels = require( './props/labels/set.js' ); -var getLabels = require( './props/labels/get.js' ); -var setLineOpacity = require( './props/line-opacity/set.js' ); -var getLineOpacity = require( './props/line-opacity/get.js' ); -var setLineStyle = require( './props/line-style/set.js' ); -var getLineStyle = require( './props/line-style/get.js' ); -var setLineWidth = require( './props/line-width/set.js' ); -var getLineWidth = require( './props/line-width/get.js' ); -var setPaddingBottom = require( './props/padding-bottom/set.js' ); -var getPaddingBottom = require( './props/padding-bottom/get.js' ); -var setPaddingLeft = require( './props/padding-left/set.js' ); -var getPaddingLeft = require( './props/padding-left/get.js' ); -var setPaddingRight = require( './props/padding-right/set.js' ); -var getPaddingRight = require( './props/padding-right/get.js' ); -var setPaddingTop = require( './props/padding-top/set.js' ); -var getPaddingTop = require( './props/padding-top/get.js' ); -var render = require( './render' ); -var stub = require( './render/stub.js' ); -var setRenderFormat = require( './props/render-format/set.js' ); -var getRenderFormat = require( './props/render-format/get.js' ); -var setTitle = require( './props/title/set.js' ); -var getTitle = require( './props/title/get.js' ); -var setViewer = require( './props/viewer/set.js' ); -var getViewer = require( './props/viewer/get.js' ); -var setWidth = require( './props/width/set.js' ); -var getWidth = require( './props/width/get.js' ); -var setXAxisOrient = require( './props/x-axis-orient/set.js' ); -var getXAxisOrient = require( './props/x-axis-orient/get.js' ); -var getXDomain = require( './props/x-domain/get.js' ); -var setXLabel = require( './props/x-label/set.js' ); -var getXLabel = require( './props/x-label/get.js' ); -var setXNumTicks = require( './props/x-num-ticks/set.js' ); -var getXNumTicks = require( './props/x-num-ticks/get.js' ); -var getXPos = require( './props/x-pos/get.js' ); -var getXRange = require( './props/x-range/get.js' ); -var setXTickFormat = require( './props/x-tick-format/set.js' ); -var getXTickFormat = require( './props/x-tick-format/get.js' ); -var setYAxisOrient = require( './props/y-axis-orient/set.js' ); -var getYAxisOrient = require( './props/y-axis-orient/get.js' ); -var getYDomain = require( './props/y-domain/get.js' ); -var setYLabel = require( './props/y-label/set.js' ); -var getYLabel = require( './props/y-label/get.js' ); -var setYNumTicks = require( './props/y-num-ticks/set.js' ); -var getYNumTicks = require( './props/y-num-ticks/get.js' ); -var getYPos = require( './props/y-pos/get.js' ); -var getYRange = require( './props/y-range/get.js' ); -var setYTickFormat = require( './props/y-tick-format/set.js' ); -var getYTickFormat = require( './props/y-tick-format/get.js' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:main' ); -var PRIVATE_PROPS = [ - '_autoRender', - '_autoView', - '_description', - '_engine', - '_height', - '_isDefined', - '_labels', - '_lineOpacity', - '_lineStyle', - '_lineWidth', - '_paddingBottom', - '_paddingLeft', - '_paddingRight', - '_paddingTop', - '_renderFormat', - '_title', - '_viewer', - '_width', - '_xAxisOrient', - '_xData', - '_xLabel', - '_xMax', - '_xMin', - '_xNumTicks', - '_xScale', - '_xTickFormat', - '_yAxisOrient', - '_yData', - '_yLabel', - '_yMax', - '_yMin', - '_yNumTicks', - '_yScale', - '_yTickFormat' -]; - - -// FUNCTIONS // - -var merge = mergeFcn({ - 'extend': false -}); - - -// MAIN // - -/** -* Base plot constructor. -* -* @constructor -* @param {Array} [x] - x values -* @param {Array} [y] - y values -* @param {Options} [options] - constructor options -* @param {boolean} [options.autoRender=false] - indicates whether to re-render on a change event -* @param {boolean} [options.autoView=false] - indicates whether to generate an updated view on a render event -* @param {string} [options.description=''] - description -* @param {string} [options.engine='svg'] - render engine -* @param {PositiveNumber} [options.height=400] - plot height -* @param {(StringArray|EmptyArray)} [options.labels] - data labels -* @param {(number|NumberArray)} [options.lineOpacity=0.9] - line opacity -* @param {(string|StringArray)} [options.lineStyle='-'] - line style(s) -* @param {(NonNegativeInteger|Array)} [options.lineWidth=2] - line width(s) -* @param {NonNegativeInteger} [options.paddingBottom=80] - bottom padding -* @param {NonNegativeInteger} [options.paddingLeft=90] - left padding -* @param {NonNegativeInteger} [options.paddingRight=20] - right padding -* @param {NonNegativeInteger} [options.paddingTop=80] - top padding -* @param {string} [options.renderFormat='vdom'] - render format -* @param {string} [options.title=''] - title -* @param {string} [options.viewer='none'] - viewer -* @param {PositiveNumber} [options.width=400] - plot width -* @param {string} [options.xAxisOrient='bottom'] - x-axis orientation -* @param {string} [options.xLabel='x'] - x-axis label -* @param {(Date|FiniteNumber|null)} [options.xMax=null] - maximum value of x-axis domain -* @param {(Date|FiniteNumber|null)} [options.xMin=null] - minimum value of x-axis domain -* @param {(NonNegativeInteger|null)} [options.xNumTicks=5] - number of x-axis tick marks -* @param {(string|null)} [options.xTickFormat=null] - x-axis tick format -* @param {string} [options.yAxisOrient='left'] - y-axis orientation -* @param {string} [options.yLabel='y'] - y-axis label -* @param {(FiniteNumber|null)} [options.yMax=null] - maximum value of y-axis domain -* @param {(FiniteNumber|null)} [options.yMin=null] - minimum value of y-axis domain -* @param {(NonNegativeInteger|null)} [options.yNumTicks=5] - number of y-axis tick marks -* @param {(string|null)} [options.yTickFormat=null] - y-axis tick format -* @throws {TypeError} must provide valid options -* @returns {Plot} Plot instance -* -* @example -* var plot = new Plot(); -*/ -function Plot() { - var options; - var nargs; - var keys; - var self; - var opts; - var key; - var i; - - nargs = arguments.length; - if ( !(this instanceof Plot) ) { - if ( nargs === 0 ) { - return new Plot(); - } - if ( nargs === 1 ) { - return new Plot( arguments[0] ); - } - if ( nargs === 2 ) { - return new Plot( arguments[0], arguments[1] ); - } - return new Plot( arguments[0], arguments[1], arguments[2] ); - } - self = this; - - opts = defaults(); - if ( nargs === 0 ) { - options = {}; - } else if ( nargs === 1 ) { - options = arguments[ 0 ]; - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - } else if ( nargs === 2 ) { - options = {}; - } else if ( nargs > 2 ) { - if ( !isObject( arguments[ 2 ] ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arguments[2] ) ); - } - options = copy( arguments[ 2 ] ); // avoid mutation - } - opts = merge( opts, options ); - - debug( 'Creating an instance with the following configuration: %s.', JSON.stringify( opts ) ); - EventEmitter.call( this ); - - for ( i = 0; i < PRIVATE_PROPS.length; i++ ) { - defineProperty( this, PRIVATE_PROPS[i], { - 'configurable': false, - 'enumerable': false, - 'writable': true, - 'value': null - }); - } - // Set a clipping path id: - defineProperty( this, '_clipPathId', { - 'configurable': false, - 'enumerable': false, - 'writable': false, - 'value': minstd().toString() // TODO: uuid - }); - - // Initialize an internal cache for renderers... - defineProperty( this, '$', { - 'configurable': false, - 'enumerable': false, - 'writable': false, - 'value': {} - }); - defineProperty( this.$, 'svg', { - 'configurable': false, - 'enumerable': false, - 'writable': false, - 'value': {} - }); - - // Set options... - 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 ); - - 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 {*} plot - rendered plot - */ - function onRender( plot ) { - /* eslint-disable no-underscore-dangle */ - debug( 'Received a render event.' ); - if ( self._autoView ) { - debug( 'Viewer: %s.', self._viewer ); - debug( 'Generating view...' ); - view( self, self._viewer, plot ); - } - } -} - -/* -* Inherit from the `EventEmitter` prototype. -*/ -inherit( Plot, EventEmitter ); - -/** -* Rendering mode. -* -* ## Notes -* -* - If `true`, an instance re-renders on each `'change'` event. -* -* @name autoRender -* @memberof Plot.prototype -* @type {boolean} -* @throws {TypeError} must be a boolean -* @default true -* -* @example -* var plot = new Plot({ -* 'autoRender': true -* }); -* -* var mode = plot.autoRender; -* // returns true -*/ -defineProperty( Plot.prototype, 'autoRender', { - 'configurable': false, - 'enumerable': true, - 'set': setAutoRender, - 'get': getAutoRender -}); - -/** -* Viewer mode. -* -* ## Notes -* -* - If `true`, an instance generates an updated view on each render event. -* -* @name autoView -* @memberof Plot.prototype -* @type {boolean} -* @throws {TypeError} must be a boolean -* @default false -* -* @example -* var plot = new Plot({ -* 'autoView': false -* }); -* -* var mode = plot.autoView; -* // returns false -*/ -defineProperty( Plot.prototype, 'autoView', { - 'configurable': false, - 'enumerable': true, - 'set': setAutoView, - 'get': getAutoView -}); - -/** -* Plot description. -* -* @name description -* @memberof Plot.prototype -* @type {string} -* @throws {TypeError} must be a string -* @default '' -* -* @example -* var plot = new Plot(); -* plot.description = 'A plot description.'; -* -* @example -* var plot = new Plot({ -* 'description': 'A plot description.' -* }); -* var desc = plot.description; -* // returns 'A plot description.' -*/ -defineProperty( Plot.prototype, 'description', { - 'configurable': false, - 'enumerable': true, - 'set': setDescription, - 'get': getDescription -}); - -/** -* Render engine. -* -* @name engine -* @memberof Plot.prototype -* @type {string} -* @throws {TypeError} must be a recognized engine -* @default 'svg' -* -* @example -* var plot = new Plot(); -* plot.engine = 'svg'; -* -* @example -* var plot = new Plot({ -* 'engine': 'svg' -* }); -* var engine = plot.engine; -* // returns 'svg' -*/ -defineProperty( Plot.prototype, 'engine', { - 'configurable': false, - 'enumerable': true, - 'set': setEngine, - 'get': getEngine -}); - -/** -* Expected graph height. -* -* @name graphHeight -* @memberof Plot.prototype -* @type {number} -* -* @example -* var plot = new Plot({ -* 'height': 100, -* 'paddingTop': 10, -* 'paddingBottom': 20 -* }); -* var height = plot.graphHeight; -* // returns 70 -*/ -defineProperty( Plot.prototype, 'graphHeight', { - 'configurable': false, - 'enumerable': true, - 'get': getGraphHeight -}); - -/** -* Expected graph width. -* -* @name graphWidth -* @memberof Plot.prototype -* @type {number} -* -* @example -* var plot = new Plot({ -* 'width': 100, -* 'paddingLeft': 10, -* 'paddingRight': 10 -* }); -* var width = plot.graphWidth; -* // returns 80 -*/ -defineProperty( Plot.prototype, 'graphWidth', { - 'configurable': false, - 'enumerable': true, - 'get': getGraphWidth -}); - -/** -* Plot height. -* -* @name height -* @memberof Plot.prototype -* @type {PositiveNumber} -* @throws {TypeError} must be a positive number -* @default 400 (px) -* -* @example -* var plot = new Plot(); -* plot.height = 100; -* -* @example -* var plot = new Plot({ -* 'height': 360 -* }); -* var height = plot.height; -* // returns 360 -*/ -defineProperty( Plot.prototype, 'height', { - 'configurable': false, - 'enumerable': true, - 'set': setHeight, - 'get': getHeight -}); - -/** -* Data labels. -* -* @name labels -* @memberof Plot.prototype -* @type {(StringArray|EmptyArray)} -* @throws {TypeError} must be either an array of strings or an empty array -* @default [] -* -* @example -* var plot = new Plot(); -* plot.labels = [ 'beep', 'boop' ]; -* -* @example -* var plot = new Plot({ -* 'labels': [ 'beep', 'boop' ] -* }); -* var labels = plot.labels; -* // returns [ 'beep', 'boop' ] -*/ -defineProperty( Plot.prototype, 'labels', { - 'configurable': false, - 'enumerable': true, - 'set': setLabels, - 'get': getLabels -}); - -/** -* Line opacity. -* -* ## Notes -* -* - When retrieved, the returned value is always an `array`. -* -* @name lineOpacity -* @memberof Plot.prototype -* @type {(number|NumberArray)} -* @throws {TypeError} must be a number or number array -* @throws {RangeError} must be a number on the interval `[0,1]` -* @default '0.9' -* -* @example -* var plot = new Plot(); -* plot.lineOpacity = [ 1.0, 0.5 ]; -* -* @example -* var plot = new Plot({ -* 'lineOpacity': 0.5 -* }); -* var opacity = plot.lineOpacity; -* // returns [ 0.5 ] -*/ -defineProperty( Plot.prototype, 'lineOpacity', { - 'configurable': false, - 'enumerable': true, - 'set': setLineOpacity, - 'get': getLineOpacity -}); - -/** -* Line style(s). -* -* ## Notes -* -* - When retrieved, the returned value is always an `array`. -* -* @name lineStyle -* @memberof Plot.prototype -* @type {(string|StringArray)} -* @throws {TypeError} must be a string or string array -* @throws {Error} must be a supported line style -* @default '-' -* -* @example -* var plot = new Plot(); -* plot.lineStyle = [ '-', 'none' ]; -* -* @example -* var plot = new Plot({ -* 'lineStyle': 'none' -* }); -* var lineStyle = plot.lineStyle; -* // returns [ 'none' ] -*/ -defineProperty( Plot.prototype, 'lineStyle', { - 'configurable': false, - 'enumerable': true, - 'set': setLineStyle, - 'get': getLineStyle -}); - -/** -* Line width. -* -* ## Notes -* -* - When retrieved, the returned value is always an `array`. -* -* @name lineWidth -* @memberof Plot.prototype -* @type {(NonNegativeInteger|NonNegativeIntegerArray)} -* @throws {TypeError} must be a nonnegative integer or nonnegative integer array -* @default 2 -* -* @example -* var plot = new Plot(); -* plot.lineWidth = 1; -* -* @example -* var plot = new Plot({ -* 'lineWidth': [ 1, 3 ] -* }); -* var width = plot.lineWidth; -* // returns [ 1, 3 ] -*/ -defineProperty( Plot.prototype, 'lineWidth', { - 'configurable': false, - 'enumerable': true, - 'set': setLineWidth, - 'get': getLineWidth -}); - -/** -* Plot bottom padding. -* -* ## Notes -* -* - Typically used to create space for a bottom-oriented y-axis. -* -* @name paddingBottom -* @memberof Plot.prototype -* @type {NonNegativeInteger} -* @throws {TypeError} must be a nonnegative integer -* @default 80 (px) -* -* @example -* var plot = new Plot(); -* plot.paddingBottom = 100; -* -* @example -* var plot = new Plot({ -* 'paddingBottom': 100 -* }); -* var padding = plot.paddingBottom; -* // returns 100 -*/ -defineProperty( Plot.prototype, 'paddingBottom', { - 'configurable': false, - 'enumerable': true, - 'set': setPaddingBottom, - 'get': getPaddingBottom -}); - -/** -* Plot left padding. -* -* ## Notes -* -* - Typically used to create space for a left-oriented y-axis. -* -* @name paddingLeft -* @memberof Plot.prototype -* @type {NonNegativeInteger} -* @throws {TypeError} must be a nonnegative integer -* @default 90 (px) -* -* @example -* var plot = new Plot(); -* plot.paddingLeft = 100; -* -* @example -* var plot = new Plot({ -* 'paddingLeft': 100 -* }); -* var padding = plot.paddingLeft; -* // returns 100 -*/ -defineProperty( Plot.prototype, 'paddingLeft', { - 'configurable': false, - 'enumerable': true, - 'set': setPaddingLeft, - 'get': getPaddingLeft -}); - -/** -* Plot right padding. -* -* ## Notes -* -* - Typically used to create space for a right-oriented y-axis. -* -* @name paddingRight -* @memberof Plot.prototype -* @type {NonNegativeInteger} -* @throws {TypeError} must be a nonnegative integer -* @default 20 (px) -* -* @example -* var plot = new Plot(); -* plot.paddingRight = 100; -* -* @example -* var plot = new Plot({ -* 'paddingRight': 100 -* }); -* var padding = plot.paddingRight; -* // returns 100 -*/ -defineProperty( Plot.prototype, 'paddingRight', { - 'configurable': false, - 'enumerable': true, - 'set': setPaddingRight, - 'get': getPaddingRight -}); - -/** -* Plot top padding. -* -* ## Notes -* -* - Typically used to create space for a title or top-oriented x-axis. -* -* @name paddingTop -* @memberof Plot.prototype -* @type {NonNegativeInteger} -* @throws {TypeError} must be a nonnegative integer -* @default 80 (px) -* -* @example -* var plot = new Plot(); -* plot.paddingTop = 100; -* -* @example -* var plot = new Plot({ -* 'paddingTop': 100 -* }); -* var padding = plot.paddingTop; -* // returns 100 -*/ -defineProperty( Plot.prototype, 'paddingTop', { - 'configurable': false, - 'enumerable': true, - 'set': setPaddingTop, - 'get': getPaddingTop -}); - -/** -* Renders a plot. -* -* @name render -* @memberof Plot.prototype -* @type {Function} -* @param {string} [format] - render format -* @throws {TypeError} must provide a recognized format -* @returns {(VTree|string)} virtual tree or string -* -* @example -* var plot = new Plot(); -* var out = plot.render(); -* -* @example -* var plot = new Plot(); -* var out = plot.render( 'html' ); -*/ -setReadOnly( Plot.prototype, 'render', render ); - -/** -* Renders a plot. -* -* ## Notes -* -* - This method **should** be implemented by descendants. -* -* @private -* @name _render -* @memberof Plot.prototype -* @type {Function} -* @param {string} format - render format -* @returns {(VTree|string)} rendered plot -*/ -setReadOnly( Plot.prototype, '_render', stub ); - -/** -* Render format. -* -* @name renderFormat -* @memberof Plot.prototype -* @type {string} -* @throws {TypeError} must be a recognized format -* @default 'vdom' -* -* @example -* var plot = new Plot(); -* plot.renderFormat = 'vdom'; -* -* @example -* var plot = new Plot({ -* 'renderFormat': 'html' -* }); -* var fmt = plot.renderFormat; -* // returns 'html' -*/ -defineProperty( Plot.prototype, 'renderFormat', { - 'configurable': false, - 'enumerable': true, - 'set': setRenderFormat, - 'get': getRenderFormat -}); - -/** -* Plot title. -* -* @name title -* @memberof Plot.prototype -* @type {string} -* @throws {TypeError} must be a string -* @default '' -* -* @example -* var plot = new Plot(); -* plot.title = 'Plot'; -* -* @example -* var plot = new Plot({ -* 'title': 'Plot' -* }); -* var t = plot.title; -* // returns 'Plot' -*/ -defineProperty( Plot.prototype, 'title', { - 'configurable': false, - 'enumerable': true, - 'set': setTitle, - 'get': getTitle -}); - -/** -* Plot viewer. -* -* @name viewer -* @memberof Plot.prototype -* @type {string} -* @throws {TypeError} must be a recognized viewer -* @default 'none' -* -* @example -* var plot = new Plot(); -* plot.viewer = 'none'; -* -* @example -* var plot = new Plot({ -* 'viewer': 'none' -* }); -* var viewer = plot.viewer; -* // returns 'none' -*/ -defineProperty( Plot.prototype, 'viewer', { - 'configurable': false, - 'enumerable': true, - 'set': setViewer, - 'get': getViewer -}); - -/** -* Plot width. -* -* @name width -* @memberof Plot.prototype -* @type {PositiveNumber} -* @throws {TypeError} must be a positive number -* @default 400 (px) -* -* @example -* var plot = new Plot(); -* plot.width = 100; -* -* @example -* var plot = new Plot({ -* 'width': 480 -* }); -* var width = plot.width; -* // returns 480 -*/ -defineProperty( Plot.prototype, 'width', { - 'configurable': false, - 'enumerable': true, - 'set': setWidth, - 'get': getWidth -}); - -/** -* x-axis orientation. -* -* @name xAxisOrient -* @memberof Plot.prototype -* @type {string} -* @throws {TypeError} must be either `'top'` or `'bottom'` -* @default 'bottom' -* -* @example -* var plot = new Plot(); -* plot.xAxisOrient = 'bottom'; -* -* @example -* var plot = new Plot({ -* 'xAxisOrient': 'bottom' -* }); -* var orientation = plot.xAxisOrient; -* // returns 'bottom' -*/ -defineProperty( Plot.prototype, 'xAxisOrient', { - 'configurable': false, - 'enumerable': true, - 'set': setXAxisOrient, - 'get': getXAxisOrient -}); - -/** -* x-axis domain. -* -* @name xDomain -* @memberof Plot.prototype -* @type {Array} -* -* @example -* var plot = new Plot({ -* 'xMin': 0, -* 'xMax': 100 -* }); -* var domain = plot.xDomain; -* // returns [ 0, 100 ] -*/ -defineProperty( Plot.prototype, 'xDomain', { - 'configurable': false, - 'enumerable': true, - 'get': getXDomain -}); - -/** -* x-axis label. -* -* @name xLabel -* @memberof Plot.prototype -* @type {string} -* @throws {TypeError} must be a string -* @default 'x' -* -* @example -* var plot = new Plot(); -* plot.xLabel = 'time'; -* -* @example -* var plot = new Plot({ -* 'xLabel': 'time' -* }); -* var xLabel = plot.xLabel; -* // returns 'time' -*/ -defineProperty( Plot.prototype, 'xLabel', { - 'configurable': false, - 'enumerable': true, - 'set': setXLabel, - 'get': getXLabel -}); - -/** -* Number of x-axis tick marks. -* -* @name xNumTicks -* @memberof Plot.prototype -* @type {(NonNegativeInteger|null)} -* @throws {TypeError} must be a nonnegative integer or null -* @default 5 -* -* @example -* var plot = new Plot(); -* plot.xNumTicks = 10; -* -* @example -* var plot = new Plot({ -* 'xNumTicks': 10 -* }); -* var ticks = plot.xNumTicks; -* // returns 10 -*/ -defineProperty( Plot.prototype, 'xNumTicks', { - 'configurable': false, - 'enumerable': true, - 'set': setXNumTicks, - 'get': getXNumTicks -}); - -/** -* Function to map values to x-axis coordinate values. -* -* @name xPos -* @memberof Plot.prototype -* @type {Function} -* -* @example -* var plot = new Plot(); -* var xPos = plot.xPos; -* // returns -*/ -defineProperty( Plot.prototype, 'xPos', { - 'configurable': false, - 'enumerable': true, - 'get': getXPos -}); - -/** -* x-axis range. -* -* @name xRange -* @memberof Plot.prototype -* @type {NumberArray} -* -* @example -* var plot = new Plot({ -* 'width': 100, -* 'paddingLeft': 10, -* 'paddingRight': 10 -* }); -* var range = plot.xRange; -* // returns [ 0, 80 ] -*/ -defineProperty( Plot.prototype, 'xRange', { - 'configurable': false, - 'enumerable': true, - 'get': getXRange -}); - -/** -* x-axis tick format. -* -* ## Notes -* -* - When retrieved, if the value is not `null`, the returned value is a formatting function. -* -* @name xTickFormat -* @memberof Plot.prototype -* @type {(string|null)} -* @throws {TypeError} must be a string or null -* @default null -* -* @example -* var plot = new Plot(); -* plot.xScale = 'time'; -* plot.xTickFormat = '%H:%M'; -* -* @example -* var plot = new Plot({ -* 'xScale': 'time', -* 'xTickFormat': '%H:%M' -* }); -* var fmt = plot.xTickFormat; -* // returns -*/ -defineProperty( Plot.prototype, 'xTickFormat', { - 'configurable': false, - 'enumerable': true, - 'set': setXTickFormat, - 'get': getXTickFormat -}); - -/** -* y-axis orientation. -* -* @name yAxisOrient -* @memberof Plot.prototype -* @type {string} -* @throws {TypeError} must be either `'left'` or `'right'` -* @default 'left' -* -* @example -* var plot = new Plot(); -* plot.yAxisOrient = 'left'; -* -* @example -* var plot = new Plot({ -* 'yAxisOrient': 'left' -* }); -* var orientation = plot.yAxisOrient; -* // returns 'left' -*/ -defineProperty( Plot.prototype, 'yAxisOrient', { - 'configurable': false, - 'enumerable': true, - 'set': setYAxisOrient, - 'get': getYAxisOrient -}); - -/** -* y-axis domain. -* -* @name yDomain -* @memberof Plot.prototype -* @type {Array} -* -* @example -* var plot = new Plot({ -* 'yMin': 0, -* 'yMax': 100 -* }); -* var domain = plot.yDomain; -* // returns [ 0, 100 ] -*/ -defineProperty( Plot.prototype, 'yDomain', { - 'configurable': false, - 'enumerable': true, - 'get': getYDomain -}); - -/** -* y-axis label. -* -* @name yLabel -* @memberof Plot.prototype -* @type {string} -* @throws {TypeError} must be a string -* @default 'y' -* -* @example -* var plot = new Plot(); -* plot.yLabel = 'value'; -* -* @example -* var plot = new Plot({ -* 'yLabel': 'value' -* }); -* var yLabel = plot.yLabel; -* // returns 'value' -*/ -defineProperty( Plot.prototype, 'yLabel', { - 'configurable': false, - 'enumerable': true, - 'set': setYLabel, - 'get': getYLabel -}); - -/** -* Number of y-axis tick marks. -* -* @name yNumTicks -* @memberof Plot.prototype -* @type {(NonNegativeInteger|null)} -* @throws {TypeError} must be a nonnegative integer or null -* @default 5 -* -* @example -* var plot = new Plot(); -* plot.yNumTicks = 10; -* -* @example -* var plot = new Plot({ -* 'yNumTicks': 10 -* }); -* var ticks = plot.yNumTicks; -* // returns 10 -*/ -defineProperty( Plot.prototype, 'yNumTicks', { - 'configurable': false, - 'enumerable': true, - 'set': setYNumTicks, - 'get': getYNumTicks -}); - -/** -* Function to map values to y-axis coordinate values. -* -* @name yPos -* @memberof Plot.prototype -* @type {Function} -* -* @example -* var plot = new Plot(); -* var yPos = plot.yPos; -* // returns -*/ -defineProperty( Plot.prototype, 'yPos', { - 'configurable': false, - 'enumerable': true, - 'get': getYPos -}); - -/** -* y-axis range. -* -* @name yRange -* @memberof Plot.prototype -* @type {NumberArray} -* -* @example -* var plot = new Plot({ -* 'height': 100, -* 'paddingTop': 10, -* 'paddingBottom': 20 -* }); -* var range = plot.yRange; -* // returns [ 70, 0 ] -*/ -defineProperty( Plot.prototype, 'yRange', { - 'configurable': false, - 'enumerable': true, - 'get': getYRange -}); - -/** -* y-axis tick format. -* -* ## Notes -* -* - If the value is not `null`, when retrieved, the returned value is a formatting function. -* -* @name yTickFormat -* @memberof Plot.prototype -* @type {(string|null)} -* @throws {TypeError} must be a string or null -* @default null -* -* @example -* var plot = new Plot(); -* plot.yTickFormat = '.0%'; -* -* @example -* var plot = new Plot({ -* 'yTickFormat': '.0%' -* }); -* var fmt = plot.yTickFormat; -* // returns -*/ -defineProperty( Plot.prototype, 'yTickFormat', { - 'configurable': false, - 'enumerable': true, - 'set': setYTickFormat, - 'get': getYTickFormat -}); - -/** -* Generates a plot view. -* -* @name view -* @memberof Plot.prototype -* @type {Function} -* @param {string} [viewer] - viewer -* @throws {TypeError} must provide a recognized viewer -* -* @example -* var plot = new Plot(); -* plot.x = [ [ 1, 2, 3 ] ]; -* plot.view( 'stdout' ); -*/ -setReadOnly( Plot.prototype, 'view', view ); - - -// EXPORTS // - -module.exports = Plot; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-render/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-render/set.js deleted file mode 100644 index de3b2bd4c002..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-render/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:auto-render' ); - - -// MAIN // - -/** -* Sets the rendering mode. -* -* @private -* @param {boolean} bool - boolean indicating whether to re-render on a change event -* @throws {TypeError} must be a boolean -*/ -function set( bool ) { - /* eslint-disable no-invalid-this */ - if ( !isBoolean( bool ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', 'autoRender', bool ) ); - } - if ( bool !== this._autoRender ) { - debug( 'Current value: %s.', this._autoRender ); - - this._autoRender = bool; - debug( 'New Value: %s.', this._autoRender ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-view/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-view/set.js deleted file mode 100644 index 3200d9164ffa..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/auto-view/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:auto-view' ); - - -// MAIN // - -/** -* Sets the viewing mode. -* -* @private -* @param {boolean} bool - boolean indicating whether to generate an updated view on a render event -* @throws {TypeError} must be a boolean -*/ -function set( bool ) { - /* eslint-disable no-invalid-this */ - if ( !isBoolean( bool ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a boolean. Value: `%s`.', 'autoView', bool ) ); - } - if ( bool !== this._autoView ) { - debug( 'Current value: %s.', this._autoView ); - - this._autoView = bool; - debug( 'New Value: %s.', this._autoView ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/description/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/description/set.js deleted file mode 100644 index 1f20f569d930..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/description/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:description' ); - - -// MAIN // - -/** -* Sets the description. -* -* @private -* @param {string} str - description -* @throws {TypeError} must be a string -*/ -function set( str ) { - /* eslint-disable no-invalid-this */ - if ( !isString( str ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'description', str ) ); - } - if ( str !== this._description ) { - debug( 'Current value: %s.', this._description ); - - this._description = str; - debug( 'New value: %s.', this._description ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/engines.json b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/engines.json deleted file mode 100644 index 00a90ebbc0fc..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/engines.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - "svg" -] diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/get.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/get.js deleted file mode 100644 index adcb427d9065..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/get.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 render engine. -* -* @private -* @returns {string} engine -*/ -function get() { - /* eslint-disable no-invalid-this */ - return this._engine; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/set.js deleted file mode 100644 index a830f484c6a5..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/engine/set.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var contains = require( '@stdlib/assert/contains' ); -var format = require( '@stdlib/string/format' ); -var ENGINES = require( './engines.json' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:engine' ); - - -// MAIN // - -/** -* Sets the engine. -* -* @private -* @param {string} engine - engine -* @throws {TypeError} must be a recognized engine -*/ -function set( engine ) { - /* eslint-disable no-invalid-this */ - if ( !contains( ENGINES, engine ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', 'engine', ENGINES.join( '", "' ), engine ) ); - } - if ( engine !== this._engine ) { - debug( 'Current value: %s.', this._engine ); - - this._engine = engine; - debug( 'New value: %s.', this._engine ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/height/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/height/set.js deleted file mode 100644 index d965f9dbd6c8..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/height/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:height' ); - - -// MAIN // - -/** -* Sets the height. -* -* @private -* @param {PositiveNumber} height - height -* @throws {TypeError} must be a positive number -*/ -function set( height ) { - /* eslint-disable no-invalid-this */ - if ( !isPositiveNumber( height ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a positive number. Value: `%s`.', 'height', height ) ); - } - if ( height !== this._height ) { - debug( 'Current value: %d.', this._height ); - - this._height = height; - debug( 'New Value: %d.', this._height ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/labels/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/labels/set.js deleted file mode 100644 index 6d680d56c97c..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/labels/set.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:labels' ); - - -// MAIN // - -/** -* Sets the data labels. -* -* @private -* @param {(StringArray|EmptyArray)} labels - data labels -* @throws {TypeError} must be either an array of strings or an empty array -*/ -function set( labels ) { - /* eslint-disable no-invalid-this */ - if ( !isEmptyArray( labels ) && !isStringArray( labels ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be an array of strings or an empty array. Value: `%s`.', 'labels', labels ) ); - } - debug( 'Current value: %s.', JSON.stringify( this._labels ) ); - - this._labels = labels.slice(); - debug( 'New Value: %s.', JSON.stringify( this._labels ) ); - - this.emit( 'change' ); -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-opacity/get.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-opacity/get.js deleted file mode 100644 index b6793668e589..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-opacity/get.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 line opacity. -* -* @private -* @returns {NumberArray} line opacity -*/ -function get() { - /* eslint-disable no-invalid-this */ - return this._lineOpacity.slice(); -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-opacity/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-opacity/set.js deleted file mode 100644 index 35abfb4677ad..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-opacity/set.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var isNumberArray = require( '@stdlib/assert/is-number-array' ).primitives; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:line-opacity' ); - - -// MAIN // - -/** -* Sets the line opacity. -* -* @private -* @param {(number|NumberArray)} v - opacity -* @throws {TypeError} must be a number or number array -* @throws {RangeError} must be a number on the interval `[0,1]` -*/ -function set( v ) { - /* eslint-disable no-invalid-this */ - var isNum = isNumber( v ); - var i; - if ( !isNum && !isNumberArray( v ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a number or an array of numbers. Value: `%s`.', 'lineOpacity', v ) ); - } - if ( isNum ) { - v = [ v ]; - } else { - v = v.slice(); - } - for ( i = 0; i < v.length; i++ ) { - if ( v[ i ] < 0.0 || v[ i ] > 1.0 ) { - throw new RangeError( format( 'invalid assignment. A `%s` must be a number on the interval: [0, 1]. Value: `%f`.', 'lineOpacity', v[i] ) ); - } - } - debug( 'Current value: %s.', JSON.stringify( this._lineOpacity ) ); - - this._lineOpacity = v; - debug( 'New Value: %s.', JSON.stringify( this._lineOpacity ) ); - - this.emit( 'change' ); -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/get.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/get.js deleted file mode 100644 index 61d078c0c175..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/get.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 line style(s). -* -* @private -* @returns {StringArray} line style(s) -*/ -function get() { - /* eslint-disable no-invalid-this */ - return this._lineStyle.slice(); -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/line_styles.json b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/line_styles.json deleted file mode 100644 index cf2ac738b711..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/line_styles.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "-", - "--", - ":", - "-.", - "none" -] diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/set.js deleted file mode 100644 index f539119d5af0..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-style/set.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var format = require( '@stdlib/string/format' ); -var indexOf = require( '@stdlib/utils/index-of' ); -var LINESTYLES = require( './line_styles.json' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:line-style' ); - - -// MAIN // - -/** -* Sets the line style(s). -* -* @private -* @param {(string|StringArray)} v - line style(s) -* @throws {TypeError} must be a string or string array -* @throws {Error} must be a supported line style -*/ -function set( v ) { - /* eslint-disable no-invalid-this */ - var isStr = isString( v ); - var i; - if ( !isStr && !isStringArray( v ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a string or an array of strings. Value: `%s`.', 'lineStyle', v ) ); - } - if ( isStr ) { - v = [ v ]; - } else { - v = v.slice(); - } - for ( i = 0; i < v.length; i++ ) { - if ( indexOf( LINESTYLES, v[i] ) === -1 ) { - throw new Error( format( 'invalid assignment. Unsupported/unrecognized line style. Must be one of the following: "%s". Value: `%s`.', LINESTYLES.join( '", "' ), v[i] ) ); - } - } - debug( 'Current value: %s.', JSON.stringify( this._lineStyle ) ); - - this._lineStyle = v; - debug( 'New Value: %s.', JSON.stringify( this._lineStyle ) ); - - this.emit( 'change' ); -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-width/get.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-width/get.js deleted file mode 100644 index 4a4469808504..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-width/get.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 line width. -* -* @private -* @returns {Array} line width(s) -*/ -function get() { - /* eslint-disable no-invalid-this */ - return this._lineWidth.slice(); -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-width/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-width/set.js deleted file mode 100644 index 54fbe80c7e13..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/line-width/set.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isNonNegativeIntegerArray = require( '@stdlib/assert/is-nonnegative-integer-array' ).primitives; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:line-width' ); - - -// MAIN // - -/** -* Sets the line width(s). -* -* @private -* @param {(NonNegativeInteger|Array)} v - width -* @throws {TypeError} must be a nonnegative integer or nonnegative integer array -*/ -function set( v ) { - /* eslint-disable no-invalid-this */ - var isInt = isNonNegativeInteger( v ); - if ( !isInt && !isNonNegativeIntegerArray( v ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative integer or an array of nonnegative integers. Value: `%s`.', 'lineWidth', v ) ); - } - if ( isInt ) { - v = [ v ]; - } else { - v = v.slice(); - } - debug( 'Current value: %s.', JSON.stringify( this._lineWidth ) ); - - this._lineWidth = v; - debug( 'New Value: %s.', JSON.stringify( this._lineWidth ) ); - - this.emit( 'change' ); -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-bottom/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-bottom/set.js deleted file mode 100644 index fa8027b39122..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-bottom/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:padding-bottom' ); - - -// MAIN // - -/** -* Sets the bottom padding. -* -* @private -* @param {NonNegativeInteger} padding - padding -* @throws {TypeError} must be a nonnegative integer -*/ -function set( padding ) { - /* eslint-disable no-invalid-this */ - if ( !isNonNegativeInteger( padding ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative integer. Value: `%s`.', 'paddingBottom', padding ) ); - } - if ( padding !== this._paddingBottom ) { - debug( 'Current value: %d.', this._paddingBottom ); - - this._paddingBottom = padding; - debug( 'New value: %d.', this._paddingBottom ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-left/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-left/set.js deleted file mode 100644 index 1de72a88c30d..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-left/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:padding-left' ); - - -// MAIN // - -/** -* Sets the left padding. -* -* @private -* @param {NonNegativeInteger} padding - padding -* @throws {TypeError} must be a nonnegative integer -*/ -function set( padding ) { - /* eslint-disable no-invalid-this */ - if ( !isNonNegativeInteger( padding ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative integer. Value: `%s`.', 'paddingLeft', padding ) ); - } - if ( padding !== this._paddingLeft ) { - debug( 'Current value: %d.', this._paddingLeft ); - - this._paddingLeft = padding; - debug( 'New value: %d.', this._paddingLeft ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-right/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-right/set.js deleted file mode 100644 index 82ae5a627ef7..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-right/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:padding-right' ); - - -// MAIN // - -/** -* Sets the right padding. -* -* @private -* @param {NonNegativeInteger} padding - padding -* @throws {TypeError} must be a nonnegative integer -*/ -function set( padding ) { - /* eslint-disable no-invalid-this */ - if ( !isNonNegativeInteger( padding ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative integer. Value: `%s`.', 'paddingRight', padding ) ); - } - if ( padding !== this._paddingRight ) { - debug( 'Current value: %d.', this._paddingRight ); - - this._paddingRight = padding; - debug( 'New value: %d.', this._paddingRight ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-top/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-top/set.js deleted file mode 100644 index c20f63e677cc..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/padding-top/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:padding-top' ); - - -// MAIN // - -/** -* Sets the top padding. -* -* @private -* @param {NonNegativeInteger} padding - padding -* @throws {TypeError} must be a nonnegative integer -*/ -function set( padding ) { - /* eslint-disable no-invalid-this */ - if ( !isNonNegativeInteger( padding ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative integer. Value: `%s`.', 'paddingTop', padding ) ); - } - if ( padding !== this._paddingTop ) { - debug( 'Current value: %d.', this._paddingTop ); - - this._paddingTop = padding; - debug( 'New value: %d.', this._paddingTop ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/render-format/formats.json b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/render-format/formats.json deleted file mode 100644 index 7479e772e50e..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/render-format/formats.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "vdom", - "html" -] diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/render-format/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/render-format/set.js deleted file mode 100644 index 9eb41a1fd6c5..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/render-format/set.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var indexOf = require( '@stdlib/utils/index-of' ); -var format = require( '@stdlib/string/format' ); -var FORMATS = require( './formats.json' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:render-format' ); - - -// MAIN // - -/** -* Sets the render format. -* -* @private -* @param {string} fmt - format -* @throws {TypeError} must be a recognized render format -*/ -function set( fmt ) { - /* eslint-disable no-invalid-this */ - if ( indexOf( FORMATS, fmt ) === -1 ) { - throw new TypeError( format( 'invalid assignment. Unrecognized/unsupported `%s`. Must be one of the following: "%s". Value: `%s`.', 'format', FORMATS.join( '", "' ), fmt ) ); - } - if ( fmt !== this._renderFormat ) { - debug( 'Current value: %s.', this._renderFormat ); - - this._renderFormat = fmt; - debug( 'New value: %s.', this._renderFormat ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/title/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/title/set.js deleted file mode 100644 index fcb285de8ecc..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/title/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:title' ); - - -// MAIN // - -/** -* Sets the title. -* -* @private -* @param {string} str - title -* @throws {TypeError} must be a string -*/ -function set( str ) { - /* eslint-disable no-invalid-this */ - if ( !isString( str ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'title', str ) ); - } - if ( str !== this._title ) { - debug( 'Current value: %s.', this._title ); - - this._title = str; - debug( 'New value: %s.', this._title ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/viewer/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/viewer/set.js deleted file mode 100644 index fd2fb24798c5..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/viewer/set.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var indexOf = require( '@stdlib/utils/index-of' ); -var format = require( '@stdlib/string/format' ); -var VIEWERS = require( './viewers.json' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:viewer' ); - - -// MAIN // - -/** -* Sets the viewer. -* -* @private -* @param {string} viewer - viewer -* @throws {TypeError} must be a recognized viewer -*/ -function set( viewer ) { - /* eslint-disable no-invalid-this */ - if ( indexOf( VIEWERS, viewer ) === -1 ) { - throw new TypeError( format( 'invalid assignment. Unrecognized/unsupported `%s`. Value: `%s`.', 'viewer', viewer ) ); - } - if ( viewer !== this._viewer ) { - debug( 'Current value: %s.', this._viewer ); - - this._viewer = viewer; - debug( 'New value: %s.', this._viewer ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/viewer/viewers.json b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/viewer/viewers.json deleted file mode 100644 index 93368048c131..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/viewer/viewers.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "none", - "browser", - "terminal", - "stdout", - "window" -] diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/width/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/width/set.js deleted file mode 100644 index 1368f5e1aa31..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/width/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:width' ); - - -// MAIN // - -/** -* Sets the width. -* -* @private -* @param {PositiveNumber} width - width -* @throws {TypeError} must be a positive number -*/ -function set( width ) { - /* eslint-disable no-invalid-this */ - if ( !isPositiveNumber( width ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a positive number. Value: `%s`.', 'width', width ) ); - } - if ( width !== this._width ) { - debug( 'Current value: %d.', this._width ); - - this._width = width; - debug( 'New value: %d.', this._width ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-axis-orient/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-axis-orient/set.js deleted file mode 100644 index 23cfa4f40195..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-axis-orient/set.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var indexOf = require( '@stdlib/utils/index-of' ); -var format = require( '@stdlib/string/format' ); -var ORIENTATIONS = require( './orientations.json' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:x-axis-orient' ); - - -// MAIN // - -/** -* Sets the x-axis orientation. -* -* @private -* @param {string} orientation - axis orientation -* @throws {TypeError} must be either `'bottom'` or `'top'` -*/ -function set( orientation ) { - /* eslint-disable no-invalid-this */ - if ( indexOf( ORIENTATIONS, orientation ) === -1 ) { - throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', 'xAxisOrient', ORIENTATIONS.join( '", "' ), orientation ) ); - } - if ( orientation !== this._xAxisOrient ) { - debug( 'Current value: %s.', this._xAxisOrient ); - - this._xAxisOrient = orientation; - debug( 'New value: %s.', this._xAxisOrient ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-label/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-label/set.js deleted file mode 100644 index 1774448ab5b6..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-label/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:x-label' ); - - -// MAIN // - -/** -* Sets the x-axis label. -* -* @private -* @param {string} label - axis label -* @throws {TypeError} must be a string -*/ -function set( label ) { - /* eslint-disable no-invalid-this */ - if ( !isString( label ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'xLabel', label ) ); - } - if ( label !== this._xLabel ) { - debug( 'Current value: %s.', this._xLabel ); - - this._xLabel = label; - debug( 'New value: %s.', this._xLabel ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-num-ticks/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-num-ticks/set.js deleted file mode 100644 index dffc6f437321..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-num-ticks/set.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNull = require( '@stdlib/assert/is-null' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:x-num-ticks' ); - - -// MAIN // - -/** -* Sets the number of x-axis tick marks. -* -* @private -* @param {(NonNegativeInteger|null)} ticks - number of ticks -* @throws {TypeError} must be a nonnegative integer or null -*/ -function set( ticks ) { - /* eslint-disable no-invalid-this */ - if ( !isNull( ticks ) && !isNonNegativeInteger( ticks ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative integer or null. Value: `%s`.', 'xNumTicks', ticks ) ); - } - if ( ticks !== this._xNumTicks ) { - debug( 'Current value: %d.', this._xNumTicks ); - - this._xNumTicks = ticks; - debug( 'New value: %d.', this._xNumTicks ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-pos/get.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-pos/get.js deleted file mode 100644 index f231fc5db30b..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-pos/get.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:x-pos' ); - - -// MAIN // - -/** -* Returns a function to map values to x-axis coordinate values. -* -* @private -* @returns {Function} map function -*/ -function get() { - /* eslint-disable no-invalid-this */ - var scale = this.xScale; - return xPos; - - /** - * Maps a value to a x-axis coordinate value. - * - * @private - * @param {number} d - datum - * @returns {number} pixel value - */ - function xPos( d ) { - var px = scale( d ); - debug( 'Value: %d => Pixel: %d.', d, px ); - return px; - } -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-tick-format/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-tick-format/set.js deleted file mode 100644 index 15106476fbec..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/x-tick-format/set.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNull = require( '@stdlib/assert/is-null' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:x-tick-format' ); - - -// MAIN // - -/** -* Sets the x-axis tick format. -* -* @private -* @param {(string|null)} fmt - axis tick format -* @throws {TypeError} must be a string -*/ -function set( fmt ) { - /* eslint-disable no-invalid-this */ - if ( !isNull( fmt ) && !isString( fmt ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a string or null. Value: `%s`.', 'xTickFormat', fmt ) ); - } - if ( fmt !== this._xTickFormat ) { - debug( 'Current value: %s.', this._xTickFormat ); - - this._xTickFormat = fmt; - debug( 'New value: %s.', this._xTickFormat ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-axis-orient/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-axis-orient/set.js deleted file mode 100644 index 7e2defe9c2b3..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-axis-orient/set.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var indexOf = require( '@stdlib/utils/index-of' ); -var format = require( '@stdlib/string/format' ); -var ORIENTATIONS = require( './orientations.json' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:y-axis-orient' ); - - -// MAIN // - -/** -* Sets the y-axis orientation. -* -* @private -* @param {string} orientation - axis orientation -* @throws {TypeError} must be either `'left'` or `'right'` -*/ -function set( orientation ) { - /* eslint-disable no-invalid-this */ - if ( indexOf( ORIENTATIONS, orientation ) === -1 ) { - throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', 'yAxisOrient', ORIENTATIONS.join( '", "' ), orientation ) ); - } - if ( orientation !== this._yAxisOrient ) { - debug( 'Current value: %s.', this._yAxisOrient ); - - this._yAxisOrient = orientation; - debug( 'New value: %s.', this._yAxisOrient ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-label/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-label/set.js deleted file mode 100644 index e8fdab47fbd4..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-label/set.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:y-label' ); - - -// MAIN // - -/** -* Sets the y-axis label. -* -* @private -* @param {string} label - axis label -* @throws {TypeError} must be a string -*/ -function set( label ) { - /* eslint-disable no-invalid-this */ - if ( !isString( label ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', 'yLabel', label ) ); - } - if ( label !== this._yLabel ) { - debug( 'Current value: %s.', this._yLabel ); - - this._yLabel = label; - debug( 'New value: %s.', this._yLabel ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-num-ticks/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-num-ticks/set.js deleted file mode 100644 index b8eb61522630..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-num-ticks/set.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNull = require( '@stdlib/assert/is-null' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:y-num-ticks' ); - - -// MAIN // - -/** -* Sets the number of y-axis tick marks. -* -* @private -* @param {(NonNegativeInteger|null)} ticks - number of ticks -* @throws {TypeError} must be a nonnegative integer or null -*/ -function set( ticks ) { - /* eslint-disable no-invalid-this */ - if ( !isNull( ticks ) && !isNonNegativeInteger( ticks ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative integer or null. Value: `%s`.', 'yNumTicks', ticks ) ); - } - if ( ticks !== this._yNumTicks ) { - debug( 'Current value: %d.', this._yNumTicks ); - - this._yNumTicks = ticks; - debug( 'New value: %d.', this._yNumTicks ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-pos/get.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-pos/get.js deleted file mode 100644 index 1a0ff92cbec2..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-pos/get.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:y-pos' ); - - -// MAIN // - -/** -* Returns a function to map values to y-axis coordinate values. -* -* @private -* @returns {Function} map function -*/ -function get() { - /* eslint-disable no-invalid-this */ - var scale = this.yScale; - return yPos; - - /** - * Maps a value to a y-axis coordinate value. - * - * @private - * @param {number} d - datum - * @returns {number} pixel value - */ - function yPos( d ) { - var px = scale( d ); - debug( 'Value: %d => Pixel: %d.', d, px ); - return px; - } -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-tick-format/get.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-tick-format/get.js deleted file mode 100644 index 2490f0a38d06..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-tick-format/get.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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( 'd3-format' ).format; // TODO: remove -var isNull = require( '@stdlib/assert/is-null' ); - - -// MAIN // - -/** -* Returns the y-axis tick format. -* -* @private -* @returns {(Function|null)} format function or null -*/ -function get() { - /* eslint-disable no-invalid-this */ - if ( isNull( this._yTickFormat ) ) { - return this._yTickFormat; - } - return format( this._yTickFormat ); -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-tick-format/set.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-tick-format/set.js deleted file mode 100644 index 85640da51fe3..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/props/y-tick-format/set.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var isNull = require( '@stdlib/assert/is-null' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:set:y-tick-format' ); - - -// MAIN // - -/** -* Sets the y-axis tick format. -* -* @private -* @param {(string|null)} fmt - axis tick format -* @throws {TypeError} must be a string or null -*/ -function set( fmt ) { - /* eslint-disable no-invalid-this */ - if ( !isNull( fmt ) && !isString( fmt ) ) { - throw new TypeError( format( 'invalid assignment. `%s` must be a string or null. Value: `%s`.', 'yTickFormat', fmt ) ); - } - if ( fmt !== this._yTickFormat ) { - debug( 'Current value: %s.', this._yTickFormat ); - - this._yTickFormat = fmt; - debug( 'New value: %s.', this._yTickFormat ); - - this.emit( 'change' ); - } -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/render/index.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/render/index.js deleted file mode 100644 index 66ed0ae82de2..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/render/index.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:render' ); - - -// MAIN // - -/** -* Renders a plot. -* -* @private -* @param {string} [format] - render format -* @returns {(VTree|string)} virtual tree or a string -*/ -function render( format ) { - /* eslint-disable no-invalid-this */ - var out; - var tmp; - var fmt; - - tmp = this.renderFormat; - if ( arguments.length ) { - // Temporarily set the render format: - this.renderFormat = format; - fmt = format; - } else { - fmt = tmp; - } - debug( 'Render format: %s.', this.renderFormat ); - - debug( 'Rendering...' ); - out = this._render( fmt ); - this.emit( 'render', out ); - - if ( arguments.length ) { - // Restore the render format: - this.renderFormat = tmp; - } - return out; -} - - -// EXPORTS // - -module.exports = render; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/render/stub.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/render/stub.js deleted file mode 100644 index d7046a7a6463..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/render/stub.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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'; - -/** -* Placeholder `render` function. -* -* @private -* @param {string} fmt - render format -* @throws {Error} must be implemented by descendant classes -*/ -function render() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = render; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/browser/index.html b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/browser/index.html deleted file mode 100644 index 79dc0c842de1..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/browser/index.html +++ /dev/null @@ -1,708 +0,0 @@ - - - - - - - - -   - - - - - -
{{plot}}
- - diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/browser/index.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/browser/index.js deleted file mode 100644 index f47b382bac42..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/browser/index.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 path = require( 'path' ); -var toHTML = require( 'vdom-to-html' ); -var readFileSync = require( '@stdlib/fs/read-file' ).sync; -var httpServer = require( '@stdlib/net/disposable-http-server' ); - - -// MAIN // - -/** -* Opens a plot in a browser window. -* -* @private -* @param {VTree} vtree - virtual DOM tree -*/ -function view( vtree ) { - var index; - var html; - - // Transform the virtual DOM tree to HTML: - html = toHTML( vtree ); - - // Inject the HTML: - index = path.join( __dirname, 'index.html' ); - index = readFileSync( index, { - 'encoding': 'utf8' - }); - - index = index.replace( /\{\{plot\}\}/, html ); - - // Create a disposable HTTP server: - httpServer({ - 'html': index, - 'open': true - }); -} - - -// EXPORTS // - -module.exports = view; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/css/colors.css b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/css/colors.css deleted file mode 100644 index 4aef35fbf55f..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/css/colors.css +++ /dev/null @@ -1,523 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2018 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. -*/ - -/* D3: Category10 */ -.category10-1, -[data-color="category10-1"] { - stroke: #1f77b4; -} -.category10-2, -[data-color="category10-2"] { - stroke: #ff7f0e; -} -.category10-3, -[data-color="category10-3"] { - stroke: #2ca02c; -} -.category10-4, -[data-color="category10-4"] { - stroke: #d62728; -} -.category10-5, -[data-color="category10-5"] { - stroke: #9467bd; -} -.category10-6, -[data-color="category10-6"] { - stroke: #8c564b; -} -.category10-7, -[data-color="category10-7"] { - stroke: #e377c2; -} -.category10-8, -[data-color="category10-8"] { - stroke: #7f7f7f; -} -.category10-9, -[data-color="category10-9"] { - stroke: #bcdb22; -} -.category10-10, -[data-color="category10-10"] { - stroke: #17becf; -} - -/* D3: category20 */ -.category20-1, -[data-color="category20-1"] { - stroke: #1f77b4; -} -.category20-2, -[data-color="category20-2"] { - stroke: #aec7e8; -} -.category20-3, -[data-color="category20-3"] { - stroke: #ff7f0e; -} -.category20-4, -[data-color="category20-4"] { - stroke: #ffbb78; -} -.category20-5, -[data-color="category20-5"] { - stroke: #2ca02c; -} -.category20-6, -[data-color="category20-6"] { - stroke: #98df8a; -} -.category20-7, -[data-color="category20-7"] { - stroke: #d62728; -} -.category20-8, -[data-color="category20-8"] { - stroke: #ff9896; -} -.category20-9, -[data-color="category20-9"] { - stroke: #9467bd; -} -.category20-10, -[data-color="category20-10"] { - stroke: #c5b0d5; -} -.category20-11, -[data-color="category20-11"] { - stroke: #8c564b; -} -.category20-12, -[data-color="category20-12"] { - stroke: #c49c94; -} -.category20-13, -[data-color="category20-13"] { - stroke: #e377c2; -} -.category20-14, -[data-color="category20-14"] { - stroke: #f7b6d2; -} -.category20-15, -[data-color="category20-15"] { - stroke: #7f7f7f; -} -.category20-16, -[data-color="category20-16"] { - stroke: #c7c7c7; -} -.category20-17, -[data-color="category20-17"] { - stroke: #bcbd22; -} -.category20-18, -[data-color="category20-18"] { - stroke: #dbdb8d; -} -.category20-19, -[data-color="category20-19"] { - stroke: #17becf; -} -.category20-20, -[data-color="category20-20"] { - stroke: #9edae5; -} - -/* D3: category20b */ -.category20b-1, -[data-color="category20b-1"] { - stroke: #393b79; -} -.category20b-2, -[data-color="category20b-2"] { - stroke: #5254a3; -} -.category20b-3, -[data-color="category20b-3"] { - stroke: #6b6ecf; -} -.category20b-4, -[data-color="category20b-4"] { - stroke: #9c9ede; -} -.category20b-5, -[data-color="category20b-5"] { - stroke: #637939; -} -.category20b-6, -[data-color="category20b-6"] { - stroke: #8ca252; -} -.category20b-7, -[data-color="category20b-7"] { - stroke: #b5cf6b; -} -.category20b-8, -[data-color="category20b-8"] { - stroke: #cedb9c; -} -.category20b-9, -[data-color="category20b-9"] { - stroke: #8c6d31; -} -.category20b-10, -[data-color="category20b-10"] { - stroke: #bd9e39; -} -.category20b-11, -[data-color="category20b-11"] { - stroke: #e7ba52; -} -.category20b-12, -[data-color="category20b-12"] { - stroke: #e7cb94; -} -.category20b-13, -[data-color="category20b-13"] { - stroke: #843c39; -} -.category20b-14, -[data-color="category20b-14"] { - stroke: #ad494a; -} -.category20b-15, -[data-color="category20b-15"] { - stroke: #d6616b; -} -.category20b-16, -[data-color="category20b-16"] { - stroke: #e7969c; -} -.category20b-17, -[data-color="category20b-17"] { - stroke: #7b4173; -} -.category20b-18, -[data-color="category20b-18"] { - stroke: #a55194; -} -.category20b-19, -[data-color="category20b-19"] { - stroke: #ce6dbd; -} -.category20b-20, -[data-color="category20b-20"] { - stroke: #de9ed6; -} - -/* D3: category20c */ -.category20c-1, -[data-color="category20c-1"] { - stroke: #3182bd; -} -.category20c-2, -[data-color="category20c-2"] { - stroke: #6baed6; -} -.category20c-3, -[data-color="category20c-3"] { - stroke: #9ecae1; -} -.category20c-4, -[data-color="category20c-4"] { - stroke: #c6dbef; -} -.category20c-5, -[data-color="category20c-5"] { - stroke: #e6550d; -} -.category20c-6, -[data-color="category20c-6"] { - stroke: #fd8d3c; -} -.category20c-7, -[data-color="category20c-7"] { - stroke: #fdae6b; -} -.category20c-8, -[data-color="category20c-8"] { - stroke: #fdd0a2; -} -.category20c-9, -[data-color="category20c-9"] { - stroke: #31a354; -} -.category20c-10, -[data-color="category20c-10"] { - stroke: #74c476; -} -.category20c-11, -[data-color="category20c-11"] { - stroke: #a1d99b; -} -.category20c-12, -[data-color="category20c-12"] { - stroke: #c7e9c0; -} -.category20c-13, -[data-color="category20c-13"] { - stroke: #756bb1; -} -.category20c-14, -[data-color="category20c-14"] { - stroke: #9e9ac8; -} -.category20c-15, -[data-color="category20c-15"] { - stroke: #bcbddc; -} -.category20c-16, -[data-color="category20c-16"] { - stroke: #dadaeb; -} -.category20c-17, -[data-color="category20c-17"] { - stroke: #636363; -} -.category20c-18, -[data-color="category20c-18"] { - stroke: #969696; -} -.category20c-19, -[data-color="category20c-19"] { - stroke: #bdbdbd; -} -.category20c-20, -[data-color="category20c-20"] { - stroke: #d9d9d9; -} - -/* D3: Category10 */ -.category10-1-span { - background-color: #1f77b4; -} -.category10-2-span { - background-color: #ff7f0e; -} -.category10-3-span { - background-color: #2ca02c; -} -.category10-4-span { - background-color: #d62728; -} -.category10-5-span { - background-color: #9467bd; -} -.category10-6-span { - background-color: #8c564b; -} -.category10-7-span { - background-color: #e377c2; -} -.category10-8-span { - background-color: #7f7f7f; -} -.category10-9-span { - background-color: #bcdb22; -} -.category10-10-span { - background-color: #17becf; -} - -/* D3: category20 */ -.category20-1-span { - background-color: #1f77b4; -} -.category20-2-span { - background-color: #aec7e8; -} -.category20-3-span { - background-color: #ff7f0e; -} -.category20-4-span { - background-color: #ffbb78; -} -.category20-5-span { - background-color: #2ca02c; -} -.category20-6-span { - background-color: #98df8a; -} -.category20-7-span { - background-color: #d62728; -} -.category20-8-span { - background-color: #ff9896; -} -.category20-9-span { - background-color: #9467bd; -} -.category20-10-span { - background-color: #c5b0d5; -} -.category20-11-span { - background-color: #8c564b; -} -.category20-12-span { - background-color: #c49c94; -} -.category20-13-span { - background-color: #e377c2; -} -.category20-14-span { - background-color: #f7b6d2; -} -.category20-15-span { - background-color: #7f7f7f; -} -.category20-16-span { - background-color: #c7c7c7; -} -.category20-17-span { - background-color: #bcbd22; -} -.category20-18-span { - background-color: #dbdb8d; -} -.category20-19-span { - background-color: #17becf; -} -.category20-20-span { - background-color: #9edae5; -} - -/* D3: category20b */ -.category20b-1-span { - background-color: #393b79; -} -.category20b-2-span { - background-color: #5254a3; -} -.category20b-3-span { - background-color: #6b6ecf; -} -.category20b-4-span { - background-color: #9c9ede; -} -.category20b-5-span { - background-color: #637939; -} -.category20b-6-span { - background-color: #8ca252; -} -.category20b-7-span { - background-color: #b5cf6b; -} -.category20b-8-span { - background-color: #cedb9c; -} -.category20b-9-span { - background-color: #8c6d31; -} -.category20b-10-span { - background-color: #bd9e39; -} -.category20b-11-span { - background-color: #e7ba52; -} -.category20b-12-span { - background-color: #e7cb94; -} -.category20b-13-span { - background-color: #843c39; -} -.category20b-14-span { - background-color: #ad494a; -} -.category20b-15-span { - background-color: #d6616b; -} -.category20b-16-span { - background-color: #e7969c; -} -.category20b-17-span { - background-color: #7b4173; -} -.category20b-18-span { - background-color: #a55194; -} -.category20b-19-span { - background-color: #ce6dbd; -} -.category20b-20-span { - background-color: #de9ed6; -} - -/* D3: category20c */ -.category20c-1-span { - background-color: #3182bd; -} -.category20c-2-span { - background-color: #6baed6; -} -.category20c-3-span { - background-color: #9ecae1; -} -.category20c-4-span { - background-color: #c6dbef; -} -.category20c-5-span { - background-color: #e6550d; -} -.category20c-6-span { - background-color: #fd8d3c; -} -.category20c-7-span { - background-color: #fdae6b; -} -.category20c-8-span { - background-color: #fdd0a2; -} -.category20c-9-span { - background-color: #31a354; -} -.category20c-10-span { - background-color: #74c476; -} -.category20c-11-span { - background-color: #a1d99b; -} -.category20c-12-span { - background-color: #c7e9c0; -} -.category20c-13-span { - background-color: #756bb1; -} -.category20c-14-span { - background-color: #9e9ac8; -} -.category20c-15-span { - background-color: #bcbddc; -} -.category20c-16-span { - background-color: #dadaeb; -} -.category20c-17-span { - background-color: #636363; -} -.category20c-18-span { - background-color: #969696; -} -.category20c-19-span { - background-color: #bdbdbd; -} -.category20c-20-span { - background-color: #d9d9d9; -} diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/css/reset.css b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/css/reset.css deleted file mode 100644 index 753131e3589b..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/css/reset.css +++ /dev/null @@ -1,66 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2018 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. -*/ - -/* http://meyerweb.com/eric/tools/css/reset/ - v2.0 | 20110126 - License: none (public domain) -*/ - -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -b, u, i, center, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, canvas, details, embed, -figure, figcaption, footer, header, hgroup, -menu, nav, output, ruby, section, summary, -time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} -/* HTML5 display-role reset for older browsers */ -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} -body { - line-height: 1; -} -ol, ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -blockquote:before, blockquote:after, -q:before, q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; -} diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/css/styles.css b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/css/styles.css deleted file mode 100644 index ed86f1a33289..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/css/styles.css +++ /dev/null @@ -1,135 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2018 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. -*/ - -.canvas { - display: block; - margin: 0 auto; -} - -.graph .hidden { - opacity: 0; -} - -/*.annotation .marker { - cursor: pointer; - opacity: 0.2; - fill: #ff0000; - stroke: none; -} - -.annotation .vline { - stroke: #000; - stroke-opacity: 0.2; -}*/ - -.annotations .title { - display: block; - /*font-size: 2em;*/ - line-height: 2em; - padding: 0 10px; - /*background-color: #474747;*/ - /*color: #ffffff;*/ - font-size: 1.5em; - color: #474747; -} - -.legend { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 60px; -} - -.legend .entry { - cursor: pointer; - margin-bottom: 10px; -} - -.legend .symbol { - display: inline-block; - height: 4px; - width: 10px; - line-height: 0.3em; -} - -.legend .label { - margin-left: 10px; -} - -.legend .hidden { - opacity: 0.25; -} - -.noselect { - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -/* http://css-tricks.com/guide-responsive-friendly-css-columns/ */ -.multicolumn-1 { - -webkit-column-count: 1; - -moz-column-count: 1; - -ms-column-count: 1; - column-count: 1; - - -webkit-column-width: 150px; - -moz-column-width: 150px; - -ms-column-width: 150px; - column-width: 150px; -} - -.multicolumn-2 { - -webkit-column-count: 2; - -moz-column-count: 2; - -ms-column-count: 2; - column-count: 2; - - -webkit-column-width: 150px; - -moz-column-width: 150px; - -ms-column-width: 150px; - column-width: 150px; -} - -.multicolumn-3 { - -webkit-column-count: 3; - -moz-column-count: 3; - -ms-column-count: 3; - column-count: 3; - - -webkit-column-width: 150px; - -moz-column-width: 150px; - -ms-column-width: 150px; - column-width: 150px; -} - -.multicolumn-4 { - -webkit-column-count: 4; - -moz-column-count: 4; - -ms-column-count: 4; - column-count: 4; - - -webkit-column-width: 150px; - -moz-column-width: 150px; - -ms-column-width: 150px; - column-width: 150px; -} diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/index.html b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/index.html deleted file mode 100644 index 76ba506589fb..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - -   - - - - - -
{{plot}}
- - - diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/index.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/index.js deleted file mode 100644 index 380ca2617ab0..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/index.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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'; - -// TODO: refactor. Remove disposable server. Create a server in the electron process and have it serve assets from local directories. Should be similar to SimpleServer. - -// MODULES // - -var spawn = require( 'child_process' ).spawn; -var path = require( 'path' ); -var logger = require( 'debug' ); -var toHTML = require( 'vdom-to-html' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var ENV = require( '@stdlib/process/env' ); -var copy = require( '@stdlib/utils/copy' ); -var merge = require( '@stdlib/utils/merge' ); -var readFileSync = require( '@stdlib/fs/read-file' ).sync; -var httpServer = require( '@stdlib/net/disposable-http-server' ); -var tryRequire = require( '@stdlib/utils/try-require' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:view:electron:main' ); -var electron = tryRequire( '@stdlib/electron' ); - - -// MAIN // - -/** -* Opens a plot in an electron window. -* -* @private -* @param {Plot} plot - plot context -* @param {VTree} vtree - virtual tree -* @throws {Error} Electron must be properly installed -*/ -function view( plot, vtree ) { - var index; - var html; - var opts; - var css; - - if ( instanceOf( electron, Error ) ) { - throw new Error( 'invalid operation. Unable to load Electron. Ensure Electron is installed and try again.' ); - } - debug( 'Transforming virtual DOM tree to HTML...' ); - html = toHTML( vtree ); - - // Define `fs` options: - opts = { - 'encoding': 'utf8' - }; - - debug( 'Injecting HTML into HTML template...' ); - index = path.join( __dirname, 'index.html' ); - index = readFileSync( index, opts ); - index = index.replace( /\{\{plot\}\}/, html ); - - debug( 'Injecting CSS into HTML template...' ); - css = path.join( __dirname, 'css', 'reset.css' ); - css = readFileSync( css, opts ); - index = index.replace( /\{\{reset\}\}/, css ); - - css = path.join( __dirname, 'css', 'colors.css' ); - css = readFileSync( css, opts ); - index = index.replace( /\{\{colors\}\}/, css ); - - css = path.join( __dirname, 'css', 'styles.css' ); - css = readFileSync( css, opts ); - index = index.replace( /\{\{styles\}\}/, css ); - - debug( 'Creating a disposable HTTP server...' ); - opts = { - 'html': index, - 'open': false - }; - httpServer( opts, onReady ); - - /** - * Callback invoked once a server is ready to receive requests. - * - * @private - * @param {(Error|null)} error - error object - * @param {Server} server - HTTP server - * @throws {Error} unexpected error - */ - function onReady( error, server ) { - var child; - var addr; - var opts; - var env; - if ( error ) { - throw error; - } - addr = server.address(); - debug( 'HTTP server initialized. Server is listening for requests on %s:%d.', addr.address, addr.port ); - - debug( 'Electron executable: %s.', electron ); - - // TODO: extract fixed env vars to config file and then won't need to pass via environment variables, but can simply require - env = { - 'SERVER_PORT': addr.port, - 'SERVER_ADDRESS': addr.address, - 'PLOT_WIDTH': plot.width, - 'PLOT_HEIGHT': plot.height, - 'PLOT_APP_PATH': __dirname, - 'PLOT_MIN_WIDTH': 100, - 'PLOT_MIN_HEIGHT': 100, - 'PLOT_TITLE': plot.title || 'stdlib' - }; - debug( 'Electron process environment variables: %s.', JSON.stringify( env ) ); - - opts = { - 'cwd': __dirname, - 'detached': true, - 'stdio': 'ignore' - }; - debug( 'Electron process options: %s.', JSON.stringify( opts ) ); - - // Merge the current process' environment variables: - opts.env = merge( {}, copy( ENV ), env ); - - debug( 'Spawning an electron process...' ); - child = spawn( electron, [ './main.js' ], opts ); - child.unref(); - } -} - - -// EXPORTS // - -module.exports = view; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/js/debug.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/js/debug.js deleted file mode 100644 index d736a98ef255..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/js/debug.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 ENV = require( '@stdlib/process/env' ); - - -// MAIN // - -var debug; - -// Setting the local storage variable must be done BEFORE loading `debug`: -localStorage.debug = ENV.DEBUG; - -// Load `debug`: -debug = require( 'debug/browser' ); // eslint-disable-line stdlib/require-order - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/js/script.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/js/script.js deleted file mode 100644 index 39a44c2a0b0b..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/js/script.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 path = require( 'path' ); -var readDir = require( '@stdlib/fs/read-dir' ); -var extname = require( '@stdlib/utils/extname' ); -var ENV = require( '@stdlib/process/env' ); -var logger = require( './debug.js' ); - - -// VARIABLES // - -var DIR = path.join( ENV.PLOT_APP_PATH, 'css' ); -var debug = logger( 'plot:base:view:electron:script' ); - - -// FUNCTIONS // - -/** -* Inserts stylesheets. -* -* @private -*/ -function stylesheets() { - var files; - var link; - var i; - - debug( 'Stylesheet directory: %s.', DIR ); - files = readDir.sync( DIR ); - for ( i = 0; i < files.length; i++ ) { - if ( extname( files[i] ) !== '.css' ) { - continue; - } - debug( 'Found a CSS file: %s.', files[i] ); - - debug( 'Generating link element...' ); - link = document.createElement( 'link' ); - link.setAttribute( 'rel', 'stylesheet' ); - link.setAttribute( 'href', path.join( DIR, files[i] ) ); - - debug( 'Appending link element to the document head...' ); - document.head.appendChild( link ); - } -} - - -// MAIN // - -/** -* Main script. -* -* @private -*/ -function main() { - debug( 'Injecting stylesheets into the document...' ); - stylesheets(); -} - -debug( 'Running main script...' ); -main(); diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/main.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/main.js deleted file mode 100644 index a7f113613389..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/electron/main.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var app = require( 'electron' ).app; -var BrowserWindow = require( 'electron' ).BrowserWindow; -var ENV = require( '@stdlib/process/env' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:view:electron:main-process' ); -var mainWindow = null; - - -// FUNCTIONS // - -/** -* Creates a browser window. -* -* @private -*/ -function createWindow() { - var opts; - var url; - - opts = { - 'width': parseInt( ENV.PLOT_WIDTH, 10 ) + 80, - 'height': parseInt( ENV.PLOT_HEIGHT, 10 ) + 20, - 'title': ENV.PLOT_TITLE, - - // 'minWidth': parseInt( ENV.PLOT_MIN_WIDTH, 10 ), // TODO: needed? - - // 'minHeight': parseInt( ENV.PLOT_MIN_HEIGHT, 10 ), // TODO: needed? - - // 'titleBarStyle': 'hidden-inset', // hide title bar on OS X - - 'useContentSize': true // specify web page size only considering the content - }; - debug( 'Creating a new browser window configured with the following options: %s.', JSON.stringify( opts ) ); - mainWindow = new BrowserWindow( opts ); - - mainWindow.on( 'close', onClose ); - - url = 'http://'+ENV.SERVER_ADDRESS+':'+ENV.SERVER_PORT+'/index.html'; - debug( 'Loading %s.', url ); - mainWindow.loadURL( url ); -} - -/** -* Callback invoked once a window closes. -* -* @private -*/ -function onClose() { - debug( 'Window closed. Dereferencing window object to allow for GC...' ); - mainWindow = null; -} - -/** -* Quits the application. -* -* @private -*/ -function quit() { - debug( 'Quitting application...' ); - app.quit(); -} - - -// MAIN // - -/** -* Runs the application. -* -* @private -*/ -function main() { - app.on( 'ready', createWindow ); - app.on( 'window-all-closed', quit ); -} - -debug( 'Running application...' ); -main(); diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/index.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/index.js deleted file mode 100644 index 36affde53c13..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 logger = require( 'debug' ); -var createView = require( './view.js' ); - - -// VARIABLES // - -var debug = logger( 'plot:base:view' ); - - -// MAIN // - -/** -* Generates a plot view. -* -* @private -* @param {string} viewer - plot viewer -*/ -function view( viewer ) { - /* eslint-disable no-invalid-this */ - var tmp = this.viewer; - if ( arguments.length ) { - // Temporarily set the viewer: - this.viewer = viewer; - } - debug( 'Viewer: %s.', this.viewer ); - debug( 'Generating view...' ); - createView( this, this.viewer, this.render() ); - if ( arguments.length ) { - // Restore the viewer: - this.viewer = tmp; - } -} - - -// EXPORTS // - -module.exports = view; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/stdout/index.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/stdout/index.js deleted file mode 100644 index be3992695bc2..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/stdout/index.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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'; - -/** -* Writes a plot (rendered as a virtual DOM tree) to `stdout`. -* -* @private -* @param {VTree} plot - virtual tree -*/ -function view( plot ) { - console.log( JSON.stringify( plot ) ); -} - - -// EXPORTS // - -module.exports = view; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/view.browser.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/view.browser.js deleted file mode 100644 index 91e2b3561cc4..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/view.browser.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 stdout = require( './stdout' ); - - -// MAIN // - -/** -* Generates a plot view. -* -* @private -* @param {Plot} plot - plot context -* @param {string} viewer - plot viewer -* @param {VTree} vtree - virtual tree -* @throws {Error} must specify a supported viewer -* @returns {void} -*/ -function view( plot, viewer, vtree ) { - if ( viewer === 'none' ) { - return; - } - if ( viewer === 'stdout' ) { - return stdout( vtree ); - } - if ( viewer === 'browser' ) { - throw new Error( format( 'invalid argument. Must provide a supported viewer. Value: `%s`.', viewer ) ); - } - if ( viewer === 'terminal' ) { - // TODO: ASCII - return; - } - throw new Error( format( 'invalid argument. Must provide a supported viewer. Value: `%s`.', viewer ) ); -} - - -// EXPORTS // - -module.exports = view; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/view.js b/lib/node_modules/@stdlib/plot/base/ctor/lib/view/view.js deleted file mode 100644 index 362970ed3e18..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/lib/view/view.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 stdout = require( './stdout' ); -var browser = require( './browser' ); -var electron = require( './electron' ); - - -// MAIN // - -/** -* Generates a plot view. -* -* @private -* @param {Plot} plot - plot context -* @param {string} viewer - plot viewer -* @param {VTree} vtree - virtual -* @returns {void} -*/ -function view( plot, viewer, vtree ) { - if ( viewer === 'none' ) { - return; - } - if ( viewer === 'stdout' ) { - return stdout( vtree ); - } - if ( viewer === 'browser' ) { - return browser( vtree ); - } - if ( viewer === 'terminal' ) { - // TODO: ASCII - return; - } - // viewer === 'window' - electron( plot, vtree ); -} - - -// EXPORTS // - -module.exports = view; diff --git a/lib/node_modules/@stdlib/plot/base/ctor/package.json b/lib/node_modules/@stdlib/plot/base/ctor/package.json deleted file mode 100644 index 00a2c390017c..000000000000 --- a/lib/node_modules/@stdlib/plot/base/ctor/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/plot/base/ctor", - "version": "0.0.0", - "description": "Base 2-dimensional plot constructor.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "browser": { - "./lib/view/view.js": "./lib/view/view.browser.js" - }, - "directories": { - "example": "./examples", - "lib": "./lib" - }, - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "plot", - "base", - "constructor", - "ctor", - "figure", - "fig", - "graph", - "chart", - "diagram", - "2-dimensional", - "2d", - "data", - "visualize", - "visualization", - "dataviz", - "explore", - "exploratory", - "analysis" - ] -} diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/README.md b/lib/node_modules/@stdlib/plot/base/line-styles/README.md new file mode 100644 index 000000000000..7d47b99b739c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/README.md @@ -0,0 +1,117 @@ + + +# lineStyles + +> List of supported line styles. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var lineStyles = require( '@stdlib/plot/base/line-styles' ); +``` + +#### lineStyles() + +Returns a list of line styles. + +```javascript +var out = lineStyles(); +// returns [ '-', '--', '-.', ':' ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var lineStyles = require( '@stdlib/plot/base/line-styles' ); + +var isLineStyle = contains( lineStyles() ); + +var bool = isLineStyle( '-' ); +// returns true + +bool = isLineStyle( ':' ); +// returns true + +bool = isLineStyle( '*' ); +// returns false + +bool = isLineStyle( '+' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/base/line-styles/benchmark/benchmark.js new file mode 100644 index 000000000000..6f5902b11213 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/benchmark/benchmark.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var pkg = require( './../package.json' ).name; +var lineStyles = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = lineStyles(); + if ( out.length < 2 ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isStringArray( out ) ) { + b.fail( 'should return an array of strings' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/docs/repl.txt b/lib/node_modules/@stdlib/plot/base/line-styles/docs/repl.txt new file mode 100644 index 000000000000..f7bbf08e295e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/docs/repl.txt @@ -0,0 +1,17 @@ + +{{alias}}() + Returns a list of line styles. + + Returns + ------- + out: Array + List of line styles. + + Examples + -------- + > var out = {{alias}}() + [ '-', '--', '-.', ':' ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/base/line-styles/docs/types/index.d.ts new file mode 100644 index 000000000000..561f019926bd --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/docs/types/index.d.ts @@ -0,0 +1,35 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns a list of line styles. +* +* @returns list of line styles +* +* @example +* var list = lineStyles(); +* // returns [ '-', '--', '-.', ':' ] +*/ +declare function lineStyles(): Array; + + +// EXPORTS // + +export = lineStyles; diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/docs/types/test.ts b/lib/node_modules/@stdlib/plot/base/line-styles/docs/types/test.ts new file mode 100644 index 000000000000..9d42703fa338 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/docs/types/test.ts @@ -0,0 +1,32 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import lineStyles = require( './index' ); + + +// TESTS // + +// The function returns an array of strings... +{ + lineStyles(); // $ExpectType string[] +} + +// The compiler throws an error if the function is provided any arguments... +{ + lineStyles( 9 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/examples/index.js b/lib/node_modules/@stdlib/plot/base/line-styles/examples/index.js new file mode 100644 index 000000000000..3c23566cc3f8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/examples/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var lineStyles = require( './../lib' ); + +var isLineStyle = contains( lineStyles() ); + +var bool = isLineStyle( '-' ); +console.log( bool ); +// => true + +bool = isLineStyle( ':' ); +console.log( bool ); +// => true + +bool = isLineStyle( '*' ); +console.log( bool ); +// => false + +bool = isLineStyle( '+' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/lib/data.json b/lib/node_modules/@stdlib/plot/base/line-styles/lib/data.json new file mode 100644 index 000000000000..5fb1c6b6621b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/lib/data.json @@ -0,0 +1,6 @@ +[ + "-", + "--", + "-.", + ":" +] diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/lib/index.js b/lib/node_modules/@stdlib/plot/base/line-styles/lib/index.js new file mode 100644 index 000000000000..e77feb6a93f8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/lib/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Return a list of line styles. +* +* @module @stdlib/plot/base/line-styles +* +* @example +* var lineStyles = require( '@stdlib/plot/base/line-styles' ); +* +* var out = lineStyles(); +* // returns [ '-', '--', '-.', ':' ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/lib/main.js b/lib/node_modules/@stdlib/plot/base/line-styles/lib/main.js new file mode 100644 index 000000000000..606d3f1c549e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/lib/main.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var DATA = require( './data.json' ); + + +// MAIN // + +/** +* Returns a list of line styles. +* +* @returns {StringArray} list of line styles +* +* @example +* var out = lineStyles(); +* // returns [ '-', '--', '-.', ':' ] +*/ +function lineStyles() { + return DATA.slice(); +} + + +// EXPORTS // + +module.exports = lineStyles; diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/package.json b/lib/node_modules/@stdlib/plot/base/line-styles/package.json new file mode 100644 index 000000000000..83a57d4ce0d0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/package.json @@ -0,0 +1,62 @@ +{ + "name": "@stdlib/plot/base/line-styles", + "version": "0.0.0", + "description": "List of supported line styles.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "line-style", + "linestyle", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/base/line-styles/test/test.js b/lib/node_modules/@stdlib/plot/base/line-styles/test/test.js new file mode 100644 index 000000000000..cb174dda71ad --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/line-styles/test/test.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var lineStyles = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof lineStyles, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a list of line styles', function test( t ) { + var expected; + var actual; + + expected = [ + '-', + '--', + '-.', + ':' + ]; + actual = lineStyles(); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/README.md b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/README.md new file mode 100644 index 000000000000..a9ab4529bdba --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/README.md @@ -0,0 +1,121 @@ + + +# linestyle2dasharray + +> Convert a [line style][@stdlib/plot/base/line-styles] string to a stroke dash array. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var linestyle2dasharray = require( '@stdlib/plot/base/linestyle2dasharray' ); +``` + +#### linestyle2dasharray( value ) + +Converts a [line style][@stdlib/plot/base/line-styles] string to a [`stroke-dasharray`][mdn-stroke-dasharray]. + +```javascript +var out = linestyle2dasharray( '--' ); +// returns [ 5, 1 ] +``` + +If unable to resolve a stroke dash array, the function returns `null`. + +```javascript +var out = linestyle2dasharray( '===' ); +// returns null +``` + +
+ + + + + +
+ +## Notes + +- A dash array consists of `[stroke, space, ...]` lengths for creating dashed or dotted lines. + +
+ + + + + +
+ +## Examples + + + +```javascript +var logEachMap = require( '@stdlib/console/log-each-map' ); +var lineStyles = require( '@stdlib/plot/base/line-styles' ); +var linestyle2dasharray = require( '@stdlib/plot/base/linestyle2dasharray' ); + +logEachMap( '%s => [%s]', lineStyles(), linestyle2dasharray ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/benchmark/benchmark.js new file mode 100644 index 000000000000..2a39b4cd9c48 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/benchmark/benchmark.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isArray = require( '@stdlib/assert/is-array' ); +var pkg = require( './../package.json' ).name; +var linestyle2dasharray = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var i; + + values = [ + '-', + ':', + '-.', + '--' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = linestyle2dasharray( values[ i%values.length ] ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an array' ); + } + } + b.toc(); + if ( !isArray( out ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/docs/repl.txt b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/docs/repl.txt new file mode 100644 index 000000000000..41fb3e56934a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/docs/repl.txt @@ -0,0 +1,24 @@ + +{{alias}}( value ) + Converts a line style string to a stroke dash array. + + If unable to resolve a stroke-dasharray, the function returns `null`. + + Parameters + ---------- + value: string + Line style string. + + Returns + ------- + out: Array|null + Dash array. + + Examples + -------- + > var out = {{alias}}( '--' ) + [ 5, 1 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/docs/types/index.d.ts new file mode 100644 index 000000000000..fe4b85e9889b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/docs/types/index.d.ts @@ -0,0 +1,49 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Converts a line style string to a [`stroke-dasharray`][1]. +* +* ## Notes +* +* - A dash array consists of `[stroke, space, ...]` lengths for creating dashed or dotted lines. +* - If unable to resolve a stroke dash array, the function returns `null`. +* +* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray +* +* @param value - line style string +* @returns stroke dash array +* +* @example +* var v = linestyle2dasharray( '-' ); +* // returns [] +* +* v = linestyle2dasharray( '--' ); +* // returns [ 5, 1 ] +* +* v = linestyle2dasharray( '=' ); +* // returns null +*/ +declare function linestyle2dasharray( value: string ): Array | null; + + +// EXPORTS // + +export = linestyle2dasharray; diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/docs/types/test.ts b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/docs/types/test.ts new file mode 100644 index 000000000000..855e6a4f6297 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/docs/types/test.ts @@ -0,0 +1,45 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import linestyle2dasharray = require( './index' ); + + +// TESTS // + +// The function returns an array or null... +{ + linestyle2dasharray( '-' ); // $ExpectType number[] | null +} + +// The compiler throws an error if the function is not provided a string... +{ + linestyle2dasharray( 1 ); // $ExpectError + linestyle2dasharray( true ); // $ExpectError + linestyle2dasharray( false ); // $ExpectError + linestyle2dasharray( null ); // $ExpectError + linestyle2dasharray( undefined ); // $ExpectError + linestyle2dasharray( [] ); // $ExpectError + linestyle2dasharray( {} ); // $ExpectError + linestyle2dasharray( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + linestyle2dasharray(); // $ExpectError + linestyle2dasharray( '-', {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/examples/index.js b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/examples/index.js new file mode 100644 index 000000000000..70fc7c7edfdc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/examples/index.js @@ -0,0 +1,25 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var logEachMap = require( '@stdlib/console/log-each-map' ); +var lineStyles = require( '@stdlib/plot/base/line-styles' ); +var linestyle2dasharray = require( './../lib' ); + +logEachMap( '%s => [%s]', lineStyles(), linestyle2dasharray ); diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/lib/index.js b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/lib/index.js new file mode 100644 index 000000000000..e25c11a70815 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/lib/index.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Convert a line style string to a stroke dash array. +* +* @module @stdlib/plot/base/linestyle2dasharray +* +* @example +* var linestyle2dasharray = require( '@stdlib/plot/base/linestyle2dasharray' ); +* +* var v = linestyle2dasharray( '-' ); +* // returns [] +* +* v = linestyle2dasharray( '--' ); +* // returns [ 5, 1 ] +* +* v = linestyle2dasharray( '=' ); +* // returns null +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/lib/main.js b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/lib/main.js new file mode 100644 index 000000000000..2bc76a3b4366 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/lib/main.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// VARIABLES // + +var STYLES = { + // Solid path: + '-': [], + + // Dashes: + '--': [ 5, 1 ], + + // Dotted path: + ':': [ 0.9 ], + + // Dash-dotted path: + '-.': [ 5, 1, 1, 1 ] +}; + + +// MAIN // + +/** +* Converts a line style string to a [`stroke-dasharray`][1]. +* +* ## Notes +* +* - A dash array consists of `[stroke, space, ...]` lengths for creating dashed or dotted lines. +* +* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray +* +* @param {string} value - line style +* @returns {(Array|null)} dash array or null +* +* @example +* var v = linestyle2dasharray( '-' ); +* // returns [] +* +* v = linestyle2dasharray( '--' ); +* // returns [ 5, 1 ] +* +* v = linestyle2dasharray( '=' ); +* // returns null +*/ +function linestyle2dasharray( value ) { + var v = STYLES[ value ]; + return ( v ) ? v.slice() : null; +} + + +// EXPORTS // + +module.exports = linestyle2dasharray; diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/package.json b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/package.json new file mode 100644 index 000000000000..ef0044bd17a6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/plot/base/linestyle2dasharray", + "version": "0.0.0", + "description": "Convert a line style string to a stroke dash array.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "linestyle", + "line-style", + "dasharray", + "stroke", + "stroke-dasharray", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/test/test.js b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/test/test.js new file mode 100644 index 000000000000..bf254d431bde --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/linestyle2dasharray/test/test.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isNumericArray = require( '@stdlib/assert/is-numeric-array' ); +var lineStyles = require( '@stdlib/plot/base/line-styles' ); +var linestyle2dasharray = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof linestyle2dasharray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function converts a line style string to a stroke dash array', function test( t ) { + var values; + var i; + + values = lineStyles(); + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isNumericArray( linestyle2dasharray( values[ i ] ) ), true, 'returns expected value for ' + values[ i ] ); + } + t.end(); +}); + +tape( 'if unable to resolve a stroke dash array, the function returns `null`', function test( t ) { + var expected; + var actual; + var values; + var i; + + values = [ + '==', + '^^', + '**', + '*' + ]; + expected = null; + for ( i = 0; i < values.length; i++ ) { + actual = linestyle2dasharray( values[ i ] ); + t.strictEqual( actual, expected, 'returns expected value for ' + values[ i ] ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/plot/base/server/lib/connections_store.js b/lib/node_modules/@stdlib/plot/base/server/lib/connections_store.js new file mode 100644 index 000000000000..c1d0f50b1d68 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/server/lib/connections_store.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Returns a new connections store. +* +* @private +* @returns {Object} store +*/ +function create() { + return {}; +} + + +// EXPORTS // + +module.exports = create; diff --git a/lib/node_modules/@stdlib/plot/base/server/lib/index.js b/lib/node_modules/@stdlib/plot/base/server/lib/index.js new file mode 100644 index 000000000000..1b7c374f2980 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/server/lib/index.js @@ -0,0 +1,50 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Plot server. +* +* @module @stdlib/plot/base/server +* +* @example +* var createServer = require( '@stdlib/plot/base/server' ); +* +* function router( req, res ) { +* res.end(); +* } +* +* function onReady( error, server ) { +* if ( error ) { +* throw error +* } +* server.close(); +* } +* +* createServer( router, onReady ); +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/base/server/lib/keys/localhost_cert.pem b/lib/node_modules/@stdlib/plot/base/server/lib/keys/localhost_cert.pem new file mode 100644 index 000000000000..b022ffdffc16 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/server/lib/keys/localhost_cert.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDGjCCAgKgAwIBAgIUY77Qg5UIMpE7/e3T9lfhA51jfdcwDQYJKoZIhvcNAQEL +BQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTI1MDgxNjA4NTU1MVoXDTI1MDkx +NTA4NTU1MVowFDESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEAolomYjGUgoRTbfkVZqcifglvr9d5K7mc280pbM5Zhbob +SVCc/BU52V8W7z18qq1jfaMwBbLKiIV5M8w50uGeE/mc51D2QohFQqWVby0fhJ57 +WW7w+Bn/bex1IG9mqtwfUxwgMCnyncWf8/0N9TY51EApOnmjZUil4u56dDUxb903 +UYt2evse7DmzHJBsNVdo14cf0ea91w5KMligts+UkyseBVeodKmWV5tea5tAif+Q +q3E2CFK+QkYhBm0JowdsbJfCNQv5dKrZwjtHR/YbFfWsuG8YJR36bEZcPEAqgcBu +RIlBBHSJlCwnWxhU8/U1A4yAhy7R4E4uabH2hCz5nQIDAQABo2QwYjAdBgNVHQ4E +FgQUfFkcV4D8H6oBGZgBED/1Oe9cOm0wHwYDVR0jBBgwFoAUfFkcV4D8H6oBGZgB +ED/1Oe9cOm0wDwYDVR0TAQH/BAUwAwEB/zAPBgNVHREECDAGhwR/AAABMA0GCSqG +SIb3DQEBCwUAA4IBAQByJA+NEziDO1JGSyzfzuog51khl0YGeA9i1wWuoiYe6VbJ +12BbFhb01bw+8kFQznWoJyNXh+yMP1/5FkbYjhWLEXoQsmetH2kxmug9kOZR/59C +EA7sNYNdLb8t6w7VfqfkMuC0dYskB0nRfawCIr+F9x3mM4A7z8O0DlvvbJtn7bq2 +gKANwfZOSnv5bJeNwd35LYXMyAHZey0HZA3Q/bblt4kbjBB5PRoTHorX5FGzub8k +ZM9XTixGfueivEc8tahTI+s8ncBBhMir+c8tCxfb/KEahextPkO6Y6pPJjZuqFGz +4vprylLQvT3zqX5VFQ/D+LWm0ySgprWxVbk8WnHy +-----END CERTIFICATE----- diff --git a/lib/node_modules/@stdlib/plot/base/server/lib/keys/localhost_privkey.pem b/lib/node_modules/@stdlib/plot/base/server/lib/keys/localhost_privkey.pem new file mode 100644 index 000000000000..d4e9ea378235 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/server/lib/keys/localhost_privkey.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCiWiZiMZSChFNt ++RVmpyJ+CW+v13kruZzbzSlszlmFuhtJUJz8FTnZXxbvPXyqrWN9ozAFssqIhXkz +zDnS4Z4T+ZznUPZCiEVCpZVvLR+EnntZbvD4Gf9t7HUgb2aq3B9THCAwKfKdxZ/z +/Q31NjnUQCk6eaNlSKXi7np0NTFv3TdRi3Z6+x7sObMckGw1V2jXhx/R5r3XDkoy +WKC2z5STKx4FV6h0qZZXm15rm0CJ/5CrcTYIUr5CRiEGbQmjB2xsl8I1C/l0qtnC +O0dH9hsV9ay4bxglHfpsRlw8QCqBwG5EiUEEdImULCdbGFTz9TUDjICHLtHgTi5p +sfaELPmdAgMBAAECggEAMMYFfv1nILixOboZWFAAuD2MfJauk9i8y3m8pq/tTBPn +i6R4rPCRgwCiqrfdoobZe06RqDyYxN/YVBvYCUb3jwevv/xeJwm6SPXmyVIUhGp6 +IxmFsftZdcQSQe7FuLHNhVHPR7jqZsSOs6WD0nV6dQ3bdPJDCLQFBgJf7lZmpjSk +B1RO5SITejFYZzhA88btRhN/Mo1Aq9tNRX5wSbgdsp9vGpnMhLSnh49lzNgMrlCt +5cRbFIp8nGNhEtdL602Iu3l/cnROsDkUpZ67Y4hCaD+ZLZzZiY6XcwLBkK/66yFJ ++Av3nMKNImFhmaBmFF9PP3uIThLCDU6uLB2nbOTS7wKBgQDUdnq1QIvP2brhzqZl +Miw/Uhn3vAI5afTj/t2L5fq8PlXqc0eEPePO/gDdzJz4sivn8nvOseATEy1rvVeb +bkBxgznIHVJz4BPJ1usALSUNXDoYo8g5kjLym0xRbFfji9+y4oBOFN2dqeuePHSn +zTihYvb7YnXKGDqlbD+1j6x+6wKBgQDDnu5SO6n2N1B2XtQSBm1jzGWoNi9er1jt +hwTq1B2lrviVuDa0kwXuGD9RTutUQyHBgzJIjjpTqmmY55YHSjtlzh4Jv5IipNb4 +orWI4zWdqCCTkHfJDlLCDMxyq6Lf+P1Abu2C9+INK3xJ92QrXqRy7bzCCGizARox +Ur675lUXlwKBgE7k8Av+O+yi3VKceg155BRfWGU1212Wiule6sXYUJM2UpEM3bGt +ibqDd67lHCT9hHBNCsxmIN70cBlh5fZBqox8PiihOszsmGyK8hjOqsObS7d6mg9G +ysRsBpr1sG0+s4KpuRtFhEXXozbPHEJzYmQLa8tNdI/nD1/+Imo5P8ShAoGAMZT/ +7OHog1qjz0zbzbHJWik9fvQ073fcP2Agk/CtjwgZQ8GMRBqbvyxwKAirxxC45pZ9 +UTyTdg9UcogIU9Kx2Wzz2h6vSI6lWiHLh2Wnek1Z7G0Kn3A886hQzaPJRaGTdxhm +pPJ1XkcuWoUU45U6c1Lkq/17pBtcazIA3BlWagMCgYBNaRXg01jVdAOM2Lfd2dgr +UKuucsQ2ZcfNqCPLoN0uq3W7zPrAl0dCLLssoMzXfvCTL9DDuurU9EHwzBm/84BG +cXKodXA+rC5axoj/BC4R0MkerjGuFxr0rh2o8yc6aTEer5Cvs4xkP2dAMgfXuc8B +3anarHhn0p3D/1YJppG3XQ== +-----END PRIVATE KEY----- diff --git a/lib/node_modules/@stdlib/plot/base/server/lib/main.js b/lib/node_modules/@stdlib/plot/base/server/lib/main.js new file mode 100644 index 000000000000..f1e84e3c5a4f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/server/lib/main.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var logger = require( 'debug' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var objectKeys = require( '@stdlib/utils/keys' ); +var readFileSync = require( '@stdlib/fs/read-file' ).sync; +var serverFactory = require( '@stdlib/net/http2-secure-server' ); +var format = require( '@stdlib/string/format' ); +var createStore = require( './connections_store.js' ); +var serverOpts = require( './opts.js' ); + + +// VARIABLES // + +var debug = logger( 'plot-server' ); +var KEYS_DIR = resolve( __dirname, 'keys' ); + + +// MAIN // + +/** +* Creates a plot server. +* +* @param {Function} router - request handler +* @param {Callback} clbk - callback to invoke upon creating a server +* @throws {TypeError} first argument must be a function +* @throws {TypeError} second argument must be a function +* @throws {Error} error encountered when starting server +* +* @example +* function router( req, res ) { +* res.end(); +* } +* +* function onReady( error, server ) { +* if ( error ) { +* throw error +* } +* server.close(); +* } +* +* createServer( router, onReady ); +*/ +function createServer( router, clbk ) { + var connections; + var server; + var sopts; + var boot; + + if ( !isFunction( router ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', router ) ); + } + if ( !isFunction( clbk ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + } + // Extract server options: + sopts = serverOpts( {} ); + + // Set required server options for SSL: + sopts.cert = readFileSync( resolve( KEYS_DIR, 'localhost_cert.pem' ) ); + sopts.key = readFileSync( resolve( KEYS_DIR, 'localhost_privkey.pem' ) ); + + // Create a function to boot a server... + boot = serverFactory( sopts, requestListener ); + + debug( 'Starting server...' ); + boot( onServer ); + + // Initialize a connections store: + connections = createStore(); + + /** + * Callback invoked upon creating a server. + * + * @private + * @param {(Error|null)} error - error object + * @param {Server} _server - server instance + * @throws {Error} error encountered when starting server + */ + function onServer( error, _server ) { + if ( error ) { + throw error; + } + debug( 'Server started.' ); + server = _server; + + // Track connections so that we can perform clean-up upon closing the server of any persistent TCP connections which are still hanging around: + server.on( 'connection', onConnection ); + + server.once( 'close', onClose ); + clbk( null, server ); + } + + /** + * Callback invoked upon receiving a socket connection. + * + * @private + * @param {Socket} socket - socket connection + */ + function onConnection( socket ) { + var key = socket.remoteAddress + ':' + socket.remotePort; + + debug( 'Received a socket connection: %s.', key ); + connections[ key ] = socket; + socket.on( 'close', onClose ); + + /** + * Callback invoked once a socket connection closes. + * + * @private + */ + function onClose() { + debug( 'Socket connection closed: %s.', key ); + delete connections[ key ]; + } + } + + /** + * Callback invoked upon receiving an HTTP request. + * + * @private + * @param {IncomingMessage} request - HTTP request object + * @param {ServerResponse} response - HTTP response object + * @returns {void} + */ + function requestListener( request, response ) { + debug( 'Received a request for %s', request.url ); + router( request, response ); + } + + /** + * Callback invoked once a server closes. + * + * @private + */ + function onClose() { + debug( 'Server closed.' ); + setTimeout( destroyConnections, 5000 ); + } + + /** + * Destroys all connections. + * + * @private + */ + function destroyConnections() { + var keys; + var i; + + debug( 'Destroying all connections...' ); + keys = objectKeys( connections ); + for ( i = 0; i < keys.length; i++ ) { + debug( 'Destroying connection %s...', keys[i] ); + connections[ keys[i] ].destroy(); + } + } +} + + +// EXPORTS // + +module.exports = createServer; diff --git a/lib/node_modules/@stdlib/plot/base/server/lib/opts.js b/lib/node_modules/@stdlib/plot/base/server/lib/opts.js new file mode 100644 index 000000000000..67a3c08d87b2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/server/lib/opts.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); + + +// MAIN // + +/** +* Extracts server options from input function options. +* +* @private +* @param {Options} options - function options +* @param {NonNegativeInteger} [options.port] - server port +* @param {NonNegativeInteger} [options.maxport] - max server port +* @param {string} [options.hostname] - server hostname +* @param {string} [options.address] - server address +* @returns {Options} server options +* +* @example +* var options = { +* 'port': 7331, +* 'address': '127.0.0.1' +* }; +* var out = opts( options ); +* // returns {'port': 7331, 'address': '127.0.0.1'} +*/ +function opts( options ) { + var out = {}; + if ( hasOwnProp( options, 'port' ) ) { + out.port = options.port; + } + if ( hasOwnProp( options, 'maxport' ) ) { + out.maxport = options.maxport; + } + if ( hasOwnProp( options, 'hostname' ) ) { + out.hostname = options.hostname; + } + if ( hasOwnProp( options, 'address' ) ) { + out.address = options.address; + } + return out; +} + + +// EXPORTS // + +module.exports = opts; diff --git a/lib/node_modules/@stdlib/plot/base/server/package.json b/lib/node_modules/@stdlib/plot/base/server/package.json new file mode 100644 index 000000000000..e405abff08fa --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/server/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/plot/base/server", + "version": "0.0.0", + "description": "Plot server.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "server", + "view", + "render", + "figure", + "fig", + "graph", + "chart", + "diagram", + "data", + "visualize", + "visualization", + "dataviz", + "explore", + "exploratory", + "analysis" + ] +} diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/app.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/app.js new file mode 100644 index 000000000000..b1857954006b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/app.js @@ -0,0 +1,170 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var parseJSON = require( '@stdlib/utils/parse-json' ); +var Schema = require( './schema' ); +var SSE = require( './sse' ); +var Visualization = require( './viz' ); +var Editor = require( './editor' ); +var series = require( './utils/series.js' ); +var state = require( './state.js' ); +var log = require( './log.js' ); + + +// FUNCTIONS // + +/** +* Initializes a visualization schema. +* +* @private +* @param {Callback} clbk - callback to invoke upon completion +*/ +function initSchema( clbk ) { + state.schema = new Schema( state ); + state.schema.resolve( clbk ); +} + +/** +* Creates an editor. +* +* @private +* @param {Callback} clbk - callback to invoke upon completion +*/ +function initEditor( clbk ) { + state.editor = new Editor( state ); + state.editor.init(); + state.editor.on( 'change', onEditorChange ); + clbk(); +} + +/** +* Establishes a long-lived connection with the server to receive periodic updates. +* +* @private +* @param {Callback} clbk - callback to invoke upon completion +*/ +function initSSE( clbk ) { + state.sse = new SSE( state ); + state.sse.on( 'refresh', onRefresh ); + state.sse.on( 'patch', onPatch ); + state.sse.on( 'data', onData ); + state.sse.connect( clbk ); +} + +/** +* Creates a visualization. +* +* @private +* @param {Callback} clbk - callback to invoke upon completion +*/ +function initVisualization( clbk ) { + state.view = new Visualization( state ); + state.view.init( clbk ); +} + +/** +* Callback invoked upon an editor "change" event. +* +* @private +* @param {Object} event - event object +*/ +function onEditorChange( event ) { + log( 'Updating rendered visualization...' ); + state.view.onSignal( event.path, event.value ); +} + +/** +* Callback invoked upon an SSE "refresh" event. +* +* @private +* @param {Object} event - event object +*/ +function onRefresh( event ) { + state.schema.raw = parseJSON( event.data ); + state.view.init(); + state.editor.refresh(); // FIXME: we may need to be more intelligent here, as the new schema could have new axes, marks, etc. Using `refresh` assumes that the general structure of the schema remains the same (i.e., we don't need to delete and/or remove folders, etc) +} + +/** +* Callback invoked upon an SSE "patch" event. +* +* @private +* @param {Object} event - event object +*/ +function onPatch() { + // FIXME: need to update editor + + // FIXME: depending on changes, we may need to re-initialize the editor + + // FIXME: perform JSON patch (currently, we're receiving the entire schema) + + // onRefresh( event ); // FIXME + + // rawSchema = parseJSON( event.data ); // FIXME +} + +/** +* Callback invoked upon an SSE "data" event. +* +* @private +* @param {Object} event - event object +*/ +function onData() { + // FIXME: create a Vega changeset, so we can avoid needing to re-initialize Vega +} + +/** +* Callback invoked upon completion. +* +* @private +* @param {Error} [error] - error object +*/ +function done( error ) { + if ( error ) { + console.error( error.message ); + return; + } + log( 'Successfully booted application.' ); +} + + +// MAIN // + +/** +* Creates an application. +* +* @private +*/ +function app() { + log( 'Booting application...' ); + series([ + initSchema, + initVisualization, + initSSE, + initEditor + ], done ); +} + + +// EXPORTS // + +module.exports = app; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/config.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/config.js new file mode 100644 index 000000000000..7914820e5f2c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/config.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var vega = require( './globals/vega.js' ); + + +// MAIN // + +/** +* Application configuration. +* +* @private +* @name config +* @type {Object} +*/ +var config = { + 'ack': { + 'interval': 600000 // 1000 * 60 * 10 milliseconds + }, + 'editor': { + 'width': 300 // px + }, + 'routes': { + 'ack': '/ack', + 'schema': '/schema', + 'sse': '/events', + 'config': '/config' + }, + 'verbose': true, + 'vega': { + 'container': '#main', + 'logLevel': vega.Warn, + 'renderer': 'svg' + } +}; + + +// EXPORTS // + +module.exports = config; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/axes.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/axes.js new file mode 100644 index 000000000000..bf5077bd35de --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/axes.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var axis = require( './axis.js' ); + + +// MAIN // + +/** +* Synchronizes a list of axis editor configurations with a provided schema. +* +* @private +* @param {Array} conf - list of axis configuration objects +* @param {Object} schema - visualization schema +* @returns {Array} mutated configuration objects +*/ +function config( conf, schema ) { + var list; + var M; + var N; + var i; + + list = schema.axes; + if ( !list ) { + return []; + } + M = list.length; + N = conf.length; + if ( N > M ) { + // WARNING: discarding extra configurations means that axis configuration objects become orphaned; thus, any editor controllers which still reference those objects will no longer sync with the greater editor configuration... + conf.length = M; + } else if ( N < M ) { + for ( i = N; i <= M; i++ ) { + conf.push( {} ); + } + } + for ( i = 0; i < M; i++ ) { + conf[ i ] = axis( conf[ i ], list[ i ] ); + } + return conf; +} + + +// EXPORTS // + +module.exports = config; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/axis.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/axis.js new file mode 100644 index 000000000000..00beb7c06a85 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/axis.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isArray = require( '@stdlib/assert/is-array' ); +var defaults = require( './../defaults.js' ); +var resolveValue = require( './resolve_value.js' ); +var resolveTextValue = require( './resolve_text_value.js' ); +var resolveSchemaValue = require( './resolve_schema_value.js' ); + + +// VARIABLES // + +var PROPS = [ + 'aria', + 'bandPosition', + 'description', + 'domain', + 'domainCap', + 'domainColor', + 'domainDashOffset', + 'domainOpacity', + 'domainWidth', + 'grid', + 'gridCap', + 'gridColor', + 'gridDashOffset', + 'gridOpacity', + 'labelAlign', + 'labelAngle', + 'labelBaseline', + 'labelBound', + 'labelColor', + 'labelFlush', + 'labelFlushOffset', + 'labelFont', + 'labelFontSize', + 'labelFontStyle', + 'labelFontWeight', + 'labelLimit', + 'labelLineHeight', + 'labelOffset', + 'labelOpacity', + 'labelOverlap', + 'labelPadding', + 'labels', + 'labelSeparation', + 'maxExtent', + 'minExtent', + 'offset', + 'orient', + 'position', + 'tickBand', + 'tickCap', + 'tickColor', + 'tickDashOffset', + 'tickMinStep', + 'tickOffset', + 'tickOpacity', + 'ticks', + 'tickSize', + 'tickWidth', + 'titleAlign', + 'titleAnchor', + 'titleAngle', + 'titleBaseline', + 'titleColor', + 'titleFont', + 'titleFontSize', + 'titleFontStyle', + 'titleFontWeight', + 'titleLimit', + 'titleLineHeight', + 'titleOpacity', + 'titlePadding', + 'titleX', + 'titleY', + 'zindex' +]; +var ARRAY_PROPS = [ + 'domainDash', + 'gridDash', + 'tickDash', + 'tickCount' +]; +var SCHEMA_PROPS = [ + 'gridScale', + 'scale' +]; +var TEXT_PROPS = [ + 'title' +]; + + +// MAIN // + +/** +* Synchronizes an axis editor configuration with a provided schema. +* +* @private +* @param {Object} conf - axis configuration object +* @param {Object} schema - axis schema +* @returns {Object} mutated configuration object +*/ +function config( conf, schema ) { + var def; + var i; + + def = defaults.axis; + + for ( i = 0; i < TEXT_PROPS.length; i++ ) { + resolveTextValue( schema, def, conf, TEXT_PROPS[ i ] ); + } + for ( i = 0; i < ARRAY_PROPS.length; i++ ) { + resolveValue( schema, def, conf, ARRAY_PROPS[ i ] ); + if ( isArray( conf[ ARRAY_PROPS[ i ] ] ) ) { + conf[ ARRAY_PROPS[ i ] ] = conf[ ARRAY_PROPS[ i ] ].join( ', ' ); + } + } + for ( i = 0; i < PROPS.length; i++ ) { + resolveValue( schema, def, conf, PROPS[ i ] ); + } + // Convert `labelBound` from a boolean to a string so that lil-gui renders a text input instead of a checkbox: + if ( conf.labelBound === false ) { + conf.labelBound = ''; + } + for ( i = 0; i < SCHEMA_PROPS.length; i++ ) { + resolveSchemaValue( schema, def, conf, SCHEMA_PROPS[ i ] ); + } + return conf; +} + + +// EXPORTS // + +module.exports = config; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/general.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/general.js new file mode 100644 index 000000000000..ea26fb35a0db --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/general.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var defaults = require( './../defaults.js' ); +var resolveValue = require( './resolve_value.js' ); + + +// VARIABLES // + +var PROPS = [ + 'background', + 'description', + 'height', + 'width' +]; + + +// MAIN // + +/** +* Synchronizes an editor configuration with a provided schema. +* +* @private +* @param {Object} conf - configuration object +* @param {Object} schema - visualization schema +* @returns {Object} mutated configuration object +*/ +function config( conf, schema ) { + var i; + for ( i = 0; i < PROPS.length; i++ ) { + resolveValue( schema, defaults, conf, PROPS[ i ] ); + } + // Account for possibility that the background is an empty string: + conf.background = conf.background || defaults.background.default; + return conf; +} + + +// EXPORTS // + +module.exports = config; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/padding.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/padding.js new file mode 100644 index 000000000000..2e2cc07401ec --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/padding.js @@ -0,0 +1,74 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var defaults = require( './../defaults.js' ); +var resolveValue = require( './resolve_value.js' ); + + +// VARIABLES // + +var PROPS = [ + 'bottom', + 'left', + 'right', + 'top' +]; + + +// MAIN // + +/** +* Synchronizes a padding editor configuration with a provided schema. +* +* @private +* @param {Object} conf - padding configuration object +* @param {Object} schema - visualization schema +* @returns {Object} mutated configuration object +*/ +function config( conf, schema ) { + var obj; + var def; + var i; + if ( isNumber( schema.padding ) ) { + conf.bottom = schema.padding; + conf.left = schema.padding; + conf.right = schema.padding; + conf.top = schema.padding; + return conf; + } + if ( isSignalReference( schema.padding ) || !schema.padding ) { + return conf; + } + obj = schema.padding; + def = defaults.padding; + for ( i = 0; i < PROPS.length; i++ ) { + resolveValue( obj, def, conf, PROPS[ i ] ); + } + return conf; +} + + +// EXPORTS // + +module.exports = config; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/resolve_schema_value.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/resolve_schema_value.js new file mode 100644 index 000000000000..9d39c425b189 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/resolve_schema_value.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); + + +// MAIN // + +/** +* Resolves a configuration value derived from a schema. +* +* @private +* @param {Object} src - source object +* @param {Object} defaults - defaults object +* @param {Object} dest - destination object +* @param {string} prop - property name +*/ +function resolveSchemaValue( src, defaults, dest, prop ) { + var v = src[ prop ]; + if ( !isSignalReference( v ) ) { + if ( isUndefined( v ) || v === '' ) { + if ( prop === 'gridScale' ) { + dest[ prop ] = src.scale; + } else { + dest[ prop ] = defaults[ prop ].default; + } + } else { + dest[ prop ] = v; + } + } +} + + +// EXPORTS // + +module.exports = resolveSchemaValue; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/resolve_text_value.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/resolve_text_value.js new file mode 100644 index 000000000000..9b2b8e37009f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/resolve_text_value.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var join = require( '@stdlib/array/base/join' ); + + +// MAIN // + +/** +* Resolves a text configuration value. +* +* @private +* @param {Object} src - source object +* @param {Object} defaults - defaults object +* @param {Object} dest - destination object +* @param {string} prop - property name +*/ +function resolveTextValue( src, defaults, dest, prop ) { + var v = src[ prop ]; + if ( !isSignalReference( v ) ) { + if ( isUndefined( v ) ) { + dest[ prop ] = defaults[ prop ].default; + } else if ( isString( v ) ) { + dest[ prop ] = v; + } else { + dest[ prop ] = join( v, '\n' ); + } + } +} + + +// EXPORTS // + +module.exports = resolveTextValue; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/resolve_value.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/resolve_value.js new file mode 100644 index 000000000000..72e5f88bdfe0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/resolve_value.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); + + +// MAIN // + +/** +* Resolves a configuration value. +* +* @private +* @param {Object} src - source object +* @param {Object} defaults - defaults object +* @param {Object} dest - destination object +* @param {string} prop - property name +*/ +function resolveValue( src, defaults, dest, prop ) { + var v = src[ prop ]; + if ( !isSignalReference( v ) ) { + dest[ prop ] = ( isUndefined( v ) ) ? defaults[ prop ].default : v; + } +} + + +// EXPORTS // + +module.exports = resolveValue; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/sync.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/sync.js new file mode 100644 index 000000000000..6c2f80fe9690 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/sync.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var general = require( './general.js' ); +var padding = require( './padding.js' ); +var title = require( './title.js' ); +var axes = require( './axes.js' ); + + +// MAIN // + +/** +* Synchronizes an editor configuration with a provided schema. +* +* @private +* @param {Object} conf - editor configuration +* @param {Object} schema - visualization schema +* @returns {Object} mutated editor configuration +*/ +function sync( conf, schema ) { + general( conf.general, schema ); + padding( conf.padding, schema ); + title( conf.title, schema ); + axes( conf.axes, schema ); + + // TODO: sync marks, legends, projections, scales, etc + + return conf; +} + + +// EXPORTS // + +module.exports = sync; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/title.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/title.js new file mode 100644 index 000000000000..434a72330bc3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/title.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var defaults = require( './../defaults.js' ); +var resolveValue = require( './resolve_value.js' ); +var resolveTextValue = require( './resolve_text_value.js' ); + + +// VARIABLES // + +var PROPS = [ + 'align', + 'anchor', + 'angle', + 'baseline', + 'color', + 'dx', + 'dy', + 'font', + 'fontSize', + 'fontStyle', + 'fontWeight', + 'frame', + 'limit', + 'lineHeight', + 'offset', + 'orient', + 'subtitleColor', + 'subtitleFont', + 'subtitleFontSize', + 'subtitleFontStyle', + 'subtitleFontWeight', + 'subtitleLineHeight', + 'subtitlePadding' +]; +var TEXT_PROPS = [ + 'text', + 'subtitle' +]; + + +// MAIN // + +/** +* Synchronizes a title editor configuration with a provided schema. +* +* @private +* @param {Object} conf - title configuration object +* @param {Object} schema - visualization schema +* @returns {Object} mutated configuration object +*/ +function config( conf, schema ) { + var obj; + var def; + var i; + + obj = schema.title; + if ( !obj ) { + return conf; + } + def = defaults.title; + for ( i = 0; i < TEXT_PROPS.length; i++ ) { + resolveTextValue( obj, def, conf, TEXT_PROPS[ i ] ); + } + for ( i = 0; i < PROPS.length; i++ ) { + resolveValue( obj, def, conf, PROPS[ i ] ); + } + return conf; +} + + +// EXPORTS // + +module.exports = config; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/defaults.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/defaults.js new file mode 100644 index 000000000000..7ecb3fbb1cb8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/defaults.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var config = require( '@stdlib/plot/vega/editor-config/visualization' ); + + +// MAIN // + +/** +* Defaults for visualization properties. +* +* @private +* @name defaults +* @type {Object} +*/ +var defaults = config(); + + +// EXPORTS // + +module.exports = defaults; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/index.js new file mode 100644 index 000000000000..9b6a2358105c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/index.js @@ -0,0 +1,304 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var EventEmitter = require( 'events' ).EventEmitter; +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var inherit = require( '@stdlib/utils/inherit' ); +var lil = require( './../globals/lil_gui.js' ); +var config = require( './../config.js' ); +var log = require( './../log.js' ); +var createGeneral = require( './menus/general.js' ); +var createPadding = require( './menus/padding.js' ); +var createTitle = require( './menus/title.js' ); +var createAxes = require( './menus/axes.js' ); +var sync = require( './config/sync.js' ); +var onChange = require( './on_change.js' ); +var defaults = require( './defaults.js' ); + + +// MAIN // + +/** +* Constructor for an editor manager. +* +* @private +* @constructor +* @param {Object} state - state object +* @returns {Editor} editor instance +*/ +function Editor( state ) { + if ( !( this instanceof Editor ) ) { + return new Editor( state ); + } + EventEmitter.call( this ); + + // Bound state object: + this._state = state; + + // GUI instance: + this._editor = null; + + // Editor toggle state: + this._toggle = false; + + // Controller configurations: + this._config = { + 'general': { + 'renderer': 'svg' + }, + 'axes': [], + 'legends': [], + 'marks': [], + 'padding': {}, + 'projections': [], + 'scales': [], + 'title': {} + }; + + // Editor tree: + this._tree = null; + this._initTree(); + + return this; +} + +/* +* Inherit from the `EventEmitter` prototype. +*/ +inherit( Editor, EventEmitter ); + +/** +* Callback upon editor change events. +* +* @private +* @name _onChange +* @memberof Editor.prototype +* @type {Function} +* @param {Object} event - event object +*/ +setReadOnly( Editor.prototype, '_onChange', onChange ); + +/** +* Initializes an editor tree. +* +* @private +* @name _initTree +* @memberof Editor.prototype +* @type {Function} +* @returns {Editor} editor instance +*/ +setReadOnly( Editor.prototype, '_initTree', function initTree() { + this._tree = { + 'general': null, + 'axes': null, + 'legends': null, + 'marks': null, + 'padding': null, + 'projections': null, + 'scales': null, + 'title': null + }; + return this; +}); + +/** +* Creates an editor. +* +* @name create +* @memberof Editor.prototype +* @type {Function} +* @returns {Editor} editor instance +*/ +setReadOnly( Editor.prototype, 'create', function create() { + var editor; + var conf; + var self; + var o; + + self = this; + + editor = new lil.GUI({ + 'width': config.editor.width + }); + + editor.title( 'Editor' ); + editor.close(); + + o = { + 'Toggle Menus': toggleFolders + }; + editor.add( o, 'Toggle Menus' ); + + conf = this._config; + this._tree.general = createGeneral( editor, conf.general ); + this._tree.padding = createPadding( editor, conf.padding ); + this._tree.title = createTitle( editor, conf.title ); + this._tree.axes = createAxes( editor, conf.axes, this._state.schema.raw ); + + editor.onFinishChange( onChange ); + + this._editor = editor; + return this; + + /** + * Toggles editor folders. + * + * @private + */ + function toggleFolders() { + self.toggleFolders(); + } + + /** + * Callback invoked upon an editor change event. + * + * @private + * @param {Object} event - event object + */ + function onChange( event ) { + self._onChange( event ); // eslint-disable-line no-underscore-dangle + } +}); + +/** +* Editor configuration defaults. +* +* @name defaults +* @memberof Editor.prototype +* @type {Object} +* @default {...} +*/ +setReadOnly( Editor.prototype, 'defaults', defaults ); + +/** +* Initializes an editor. +* +* @name init +* @memberof Editor.prototype +* @type {Function} +* @returns {Editor} editor instance +*/ +setReadOnly( Editor.prototype, 'init', function init() { + if ( this._editor ) { + // If there is an existing editor, go ahead and remove it... + this.remove(); + } + log( 'Initializing editor...' ); + sync( this._config, this._state.schema.raw ); + this.create(); + log( 'Editor initialized.' ); + return this; +}); + +/** +* Refreshes an editor. +* +* @name refresh +* @memberof Editor.prototype +* @type {Function} +* @returns {Editor} editor instance +*/ +setReadOnly( Editor.prototype, 'refresh', function refresh() { + log( 'Refreshing editor...' ); + sync( this._config, this._state.schema.raw ); + this.refreshControllers(); + log( 'Editor refreshed.' ); + return this; +}); + +/** +* Refreshes editor controllers. +* +* @name refreshControllers +* @memberof Editor.prototype +* @type {Function} +* @returns {Editor} editor instance +*/ +setReadOnly( Editor.prototype, 'refreshControllers', function refreshControllers() { + var controllers; + var i; + + log( 'Refreshing editor controllers...' ); + controllers = this._editor.controllersRecursive(); + for ( i = 0; i < controllers.length; i++ ) { + controllers[ i ].updateDisplay(); + } + log( 'Successfully refreshed editor controllers.' ); + return this; +}); + +/** +* Removes an editor. +* +* @name remove +* @memberof Editor.prototype +* @type {Function} +* @returns {Editor} editor instance +*/ +setReadOnly( Editor.prototype, 'remove', function remove() { + log( 'Removing editor...' ); + this._editor.destroy(); + this._initTree(); + log( 'Editor removed.' ); + return this; +}); + +/** +* Toggles editor folders. +* +* @name toggleFolders +* @memberof Editor.prototype +* @type {Function} +* @returns {Editor} editor instance +*/ +setReadOnly( Editor.prototype, 'toggleFolders', function toggleFolders() { + var folders; + var method; + var editor; + var flg; + var i; + + editor = this._editor; + if ( !editor ) { + return; + } + log( 'Toggling editor folders...' ); + + flg = this._toggle; + method = ( flg ) ? 'close' : 'open'; + + folders = editor.foldersRecursive(); + for ( i = 0; i < folders.length; i++ ) { + folders[ i ][ method ](); + } + this._toggle = !flg; + log( 'Toggled editor folders.' ); + + return this; +}); + + +// EXPORTS // + +module.exports = Editor; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/axes.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/axes.js new file mode 100644 index 000000000000..e6566a13942a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/axes.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var format = require( '@stdlib/string/format' ); +var axis = require( './axis.js' ); + + +// MAIN // + +/** +* Adds an axes menu to an editor. +* +* @private +* @param {Editor} editor - editor instance +* @param {Array} conf - list of editor axis configurations +* @param {Object} schema - visualization schema +* @returns {(Object|null)} menu tree +*/ +function addMenu( editor, conf, schema ) { + var children; + var folder; + var o; + var i; + + if ( conf.length === 0 ) { + return null; + } + folder = editor.addFolder( 'Axes' ); + folder.close(); + + children = []; + for ( i = 0; i < conf.length; i++ ) { + o = axis( folder, conf[ i ], schema, format( 'Axis %d', i+1 ) ); + if ( o ) { + children.push( o ); + } + } + return { + 'folder': folder, + 'children': children + }; +} + + +// EXPORTS // + +module.exports = addMenu; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/axis.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/axis.js new file mode 100644 index 000000000000..8b8a6f7fba18 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/axis.js @@ -0,0 +1,288 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-statements, max-lines-per-function */ + +'use strict'; + +// MODULES // + +var objectKeys = require( '@stdlib/utils/keys' ); +var format = require( '@stdlib/string/format' ); +var resolveSchemaValues = require( './resolve_schema_values.js' ); +var defaults = require( './../defaults.js' ); + + +// VARIABLES // + +var EMPTY_STRING = [ '' ]; + + +// MAIN // + +/** +* Adds an axis menu to a parent folder. +* +* @private +* @param {Editor} parent - parent folder instance +* @param {Object} conf - editor axis configuration +* @param {Object} schema - visualization schema +* @param {string} name - folder name +* @returns {(Object|null)} menu tree +*/ +function addMenu( parent, conf, schema, name ) { + var controllers; + var controller; + var folder; + var keys; + var def; + var d; + var i; + var k; + + keys = objectKeys( conf ); + if ( keys.length === 0 ) { + return null; + } + folder = parent.addFolder( name ); + folder.close(); + + def = defaults.axis; + + controllers = {}; + for ( i = 0; i < keys.length; i++ ) { + k = keys[ i ]; + d = def[ k ]; + if ( k === 'aria' ) { + controller = folder.add( conf, k ); + } else if ( k === 'bandPosition' ) { + controller = folder.add( conf, k ); + } else if ( k === 'description' ) { + controller = folder.add( conf, k ); + } else if ( k === 'domain' ) { + controller = folder.add( conf, k ); + } else if ( k === 'domainCap' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'domainColor' ) { + controller = folder.addColor( conf, k ); + } else if ( k === 'domainDash' ) { + controller = folder.add( conf, k ); + } else if ( k === 'domainDashOffset' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'domainOpacity' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .max( d.max ); + } else if ( k === 'domainWidth' ) { + controller = folder.add( conf, k ) + .min( d.min ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'grid' ) { + controller = folder.add( conf, k ); + } else if ( k === 'gridCap' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'gridColor' ) { + controller = folder.addColor( conf, k ); + } else if ( k === 'gridDash' ) { + controller = folder.add( conf, k ); + } else if ( k === 'gridDashOffset' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'gridOpacity' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .max( d.max ); + } else if ( k === 'gridScale' ) { + controller = folder.add( conf, k, resolveSchemaValues( schema, 'scales.*.name' ) ).disable(); + } else if ( k === 'gridWidth' ) { + controller = folder.add( conf, k ) + .min( d.min ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'labelAlign' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'labelAngle' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .max( d.max ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'labelBaseline' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'labelBound' ) { + controller = folder.add( conf, k ); + } else if ( k === 'labelColor' ) { + controller = folder.addColor( conf, k ); + } else if ( k === 'labelFlush' ) { + controller = folder.add( conf, k ); + } else if ( k === 'labelFlushOffset' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'labelFont' ) { + controller = folder.add( conf, k ); + } else if ( k === 'labelFontSize' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .step( d.step ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'labelFontStyle' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'labelFontWeight' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'labelLimit' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .step( d.step ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'labelLineHeight' ) { + controller = folder.add( conf, k ) + .min( d.min ); + } else if ( k === 'labelOffset' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'labelOpacity' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .max( d.max ); + } else if ( k === 'labelOverlap' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'labelPadding' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'labels' ) { + controller = folder.add( conf, k ); + } else if ( k === 'labelSeparation' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .step( d.step ); + } else if ( k === 'maxExtent' ) { + controller = folder.add( conf, k ) + .min( d.min ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'minExtent' ) { + controller = folder.add( conf, k ) + .min( d.min ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'offset' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'orient' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'position' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'scale' ) { + controller = folder.add( conf, k, resolveSchemaValues( schema, 'scales.*.name' ) ); + } else if ( k === 'tickBand' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'tickCap' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'tickColor' ) { + controller = folder.addColor( conf, k ); + } else if ( k === 'tickCount' ) { + controller = folder.add( conf, k ); + } else if ( k === 'tickDash' ) { + controller = folder.add( conf, k ); + } else if ( k === 'tickDashOffset' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'tickMinStep' ) { + controller = folder.add( conf, k ) + .min( d.min ); + } else if ( k === 'tickOffset' ) { + controller = folder.add( conf, k ) + .min( d.min ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'tickOpacity' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .max( d.max ); + } else if ( k === 'ticks' ) { + controller = folder.add( conf, k ); + } else if ( k === 'tickSize' ) { + controller = folder.add( conf, k ) + .min( d.min ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'tickWidth' ) { + controller = folder.add( conf, k ) + .min( d.min ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'title' ) { + controller = folder.add( conf, k ); + } else if ( k === 'titleAlign' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'titleAnchor' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'titleAngle' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .max( d.max ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'titleBaseline' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'titleColor' ) { + controller = folder.addColor( conf, k ); + } else if ( k === 'titleFont' ) { + controller = folder.add( conf, k ); + } else if ( k === 'titleFontSize' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .step( d.step ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'titleFontStyle' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'titleFontWeight' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'titleLimit' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .step( d.step ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'titleLineHeight' ) { + controller = folder.add( conf, k ) + .min( d.min ); + } else if ( k === 'titleOpacity' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .max( d.max ); + } else if ( k === 'titlePadding' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'titleX' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'titleY' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'zindex' ) { + controller = folder.add( conf, k ); + } else { + console.log( 'Unrecognized property in editor configuration. Key: %s.', k ); + continue; + } + controllers[ k ] = controller; + } + return { + 'folder': folder, + 'controllers': controllers + }; +} + + +// EXPORTS // + +module.exports = addMenu; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/general.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/general.js new file mode 100644 index 000000000000..17d456aba75c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/general.js @@ -0,0 +1,87 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var objectKeys = require( '@stdlib/utils/keys' ); +var format = require( '@stdlib/string/format' ); +var defaults = require( './../defaults.js' ); + + +// VARIABLES // + +var RENDERERS = [ 'svg', 'canvas' ]; + + +// MAIN // + +/** +* Adds a "general" menu to an editor. +* +* @private +* @param {Editor} editor - editor instance +* @param {Object} conf - editor configuration +* @returns {(Object|null)} menu tree +*/ +function addMenu( editor, conf ) { + var controllers; + var controller; + var folder; + var keys; + var def; + var k; + var i; + + keys = objectKeys( conf ); + if ( keys.length === 0 ) { + return null; + } + folder = editor.addFolder( 'General' ); + folder.close(); + + controllers = {}; + for ( i = 0; i < keys.length; i++ ) { + k = keys[ i ]; + if ( k === 'renderer' ) { + controller = folder.add( conf, k, RENDERERS ); + } else if ( k === 'background' ) { + controller = folder.addColor( conf, k ); + } else if ( k === 'description' ) { + controller = folder.add( conf, k ); + } else if ( k === 'width' || k === 'height' ) { + def = defaults[ k ]; + controller = folder.add( conf, k ).min( def.min ).step( def.step ); + controller.name( format( '%s (%s)', k, def.units ) ); + } else { + console.log( 'Unrecognized property in editor configuration. Key: %s.', k ); + continue; + } + controllers[ k ] = controller; + } + return { + 'folder': folder, + 'controllers': controllers + }; +} + + +// EXPORTS // + +module.exports = addMenu; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/padding.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/padding.js new file mode 100644 index 000000000000..7c38b1be441b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/padding.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var objectKeys = require( '@stdlib/utils/keys' ); +var format = require( '@stdlib/string/format' ); +var defaults = require( './../defaults.js' ); + + +// MAIN // + +/** +* Adds a padding menu to an editor. +* +* @private +* @param {Editor} editor - editor instance +* @param {Object} conf - editor padding configuration +* @returns {(Object|null)} menu tree +*/ +function addMenu( editor, conf ) { + var controllers; + var controller; + var folder; + var keys; + var def; + var d; + var i; + var k; + + keys = objectKeys( conf ); + if ( keys.length === 0 ) { + return null; + } + folder = editor.addFolder( 'Padding' ); + folder.close(); + + def = defaults.padding; + controllers = {}; + for ( i = 0; i < keys.length; i++ ) { + k = keys[ i ]; + d = def[ k ]; + controller = folder.add( conf, k ).step( d.step ); + controller.name( format( '%s (%s)', k, d.units ) ); + controllers[ k ] = controller; + } + return { + 'folder': folder, + 'controllers': controllers + }; +} + + +// EXPORTS // + +module.exports = addMenu; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/resolve_schema_values.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/resolve_schema_values.js new file mode 100644 index 000000000000..fbc3b34500b8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/resolve_schema_values.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Resolves configuration values from a visualization schema. +* +* @private +* @param {Object} schema - visualization schema +* @param {string} path - schema path pattern +* @returns {Array} resolved values +*/ +function resolveSchemaValues( schema, path ) { + var out; + var i; + if ( path === 'scales.*.name' ) { + out = []; + for ( i = 0; i < schema.scales.length; i++ ) { + out.push( schema.scales[ i ].name ); + } + } + return out; +} + + +// EXPORTS // + +module.exports = resolveSchemaValues; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/title.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/title.js new file mode 100644 index 000000000000..f16a3bc374e0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/title.js @@ -0,0 +1,150 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var objectKeys = require( '@stdlib/utils/keys' ); +var format = require( '@stdlib/string/format' ); +var defaults = require( './../defaults.js' ); + + +// VARIABLES // + +var EMPTY_STRING = [ '' ]; + + +// MAIN // + +/** +* Adds a title menu to an editor. +* +* @private +* @param {Editor} editor - editor instance +* @param {Object} conf - editor title configuration +* @returns {(Object|null)} menu tree +*/ +function addMenu( editor, conf ) { + var controllers; + var controller; + var folder; + var keys; + var def; + var d; + var k; + var i; + + keys = objectKeys( conf ); + if ( keys.length === 0 ) { + return null; + } + folder = editor.addFolder( 'Title' ); + folder.close(); + + def = defaults.title; + + // TODO: consider refactoring to a hash look-up table where the values are short(ish) functions + controllers = {}; + for ( i = 0; i < keys.length; i++ ) { + k = keys[ i ]; + d = def[ k ]; + if ( k === 'align' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'anchor' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'angle' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .max( d.max ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'baseline' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'color' ) { + controller = folder.addColor( conf, k ); + } else if ( k === 'dx' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'dy' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'font' ) { + controller = folder.add( conf, k ); + } else if ( k === 'fontSize' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .step( d.step ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'fontStyle' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'fontWeight' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'frame' ) { + controller = folder.add( conf, k, d.values ); + } else if ( k === 'limit' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .step( d.step ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'lineHeight' ) { + controller = folder.add( conf, k ) + .min( d.min ); + } else if ( k === 'offset' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'orient' ) { + controller = folder.add( conf, k, d.values ); + } else if ( k === 'subtitle' ) { + controller = folder.add( conf, k ); + } else if ( k === 'subtitleColor' ) { + controller = folder.addColor( conf, k ); + } else if ( k === 'subtitleFont' ) { + controller = folder.add( conf, k ); + } else if ( k === 'subtitleFontSize' ) { + controller = folder.add( conf, k ) + .min( d.min ) + .step( d.step ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'subtitleFontStyle' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'subtitleFontWeight' ) { + controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) ); + } else if ( k === 'subtitleLineHeight' ) { + controller = folder.add( conf, k ) + .min( d.min ); + } else if ( k === 'subtitlePadding' ) { + controller = folder.add( conf, k ); + controller.name( format( '%s (%s)', k, d.units ) ); + } else if ( k === 'text' ) { + controller = folder.add( conf, k ); + } else { + console.log( 'Unrecognized property in editor configuration. Key: %s.', k ); + continue; + } + controllers[ k ] = controller; + } + return { + 'folder': folder, + 'controllers': controllers + }; +} + + +// EXPORTS // + +module.exports = addMenu; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/on_change.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/on_change.js new file mode 100644 index 000000000000..6bc5bd664b3d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/on_change.js @@ -0,0 +1,186 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var parseJSON = require( '@stdlib/utils/parse-json' ); +var isJSON = require( '@stdlib/assert/is-json' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var trim = require( '@stdlib/string/base/trim' ); +var Number = require( '@stdlib/number/ctor' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var join = require( '@stdlib/array/base/join' ); +var log = require( './../log.js' ); +var config = require( './../config.js' ); + + +// VARIABLES // + +var URL_PREFIX = config.routes.config; + + +// FUNCTIONS // + +/** +* Returns request options. +* +* @private +* @param {string} body - request body +* @returns {Object} options object +*/ +function requestOptions( body ) { + return { + 'method': 'POST', + 'headers': { + 'Content-Type': 'text/plain' + }, + 'body': body, + 'credentials': 'same-origin' + }; +} + + +// MAIN // + +/** +* Callback invoked upon changing a value in the editor. +* +* @private +* @param {Event} event - event object +*/ +function onChange( event ) { + var self; + var conf; + var prop; + var path; + var url; + var tmp; + var val; + var obj; + var ns; + var i; + var n; + + self = this; + conf = this._config; + + // FIXME: other properties/objects + + obj = event.object; + if ( obj === conf.general ) { + ns = [ '' ]; + } else if ( obj === conf.padding ) { + ns = [ 'padding' ]; + } else if ( obj === conf.title ) { + ns = [ 'title' ]; + } else { + for ( i = 0; i < conf.axes.length; i++ ) { + if ( obj === conf.axes[ i ] ) { + ns = [ 'axes', i.toString() ]; + } + } + if ( ns === void 0 ) { + ns = [ '' ]; + } + } + + // Resolve the property name by removing any units: + prop = event.property.split( ' ' )[ 0 ]; + + // Convert namespace entries to a path: + path = join( ns, '/' ); + + val = event.value; + if ( isJSON( val ) ) { + tmp = parseJSON( val ); + if ( !( tmp instanceof Error ) ) { + val = tmp; + } + } else if ( isString( val ) ) { + tmp = trim( val ); + if ( prop === 'tickCount' ) { + n = Number( tmp ); + if ( tmp === '' ) { + val = void 0; + } else if ( !isnan( n ) ) { + val = n; + } else if ( tmp.indexOf( ',' ) !== -1 ) { + tmp = tmp.split( /\s*,\s*/ ); + val = { + 'interval': tmp[ 0 ], + 'step': parseInt( tmp[ 1 ], 10 ) + }; + } + } + } + + log( 'Editor changed: %s/%s', path, prop ); + this.emit( 'change', { + 'type': 'change', + 'source': 'editor', + 'property': event.property, + 'path': ns.concat( [ prop ] ), + 'value': val + }); + + log( 'Attempting to update configuration...' ); + url = URL_PREFIX+'/'+( ( path ) ? path+'/' : path )+prop; + fetch( url, requestOptions( event.value.toString() ) ) // eslint-disable-line n/no-unsupported-features/node-builtins + .then( onResponse ) + .catch( onError ); + + /** + * Callback invoked upon receiving an HTTP response. + * + * @private + * @param {Response} response - response object + * @returns {void} + */ + function onResponse( response ) { + if ( response.ok ) { + log( 'Successfully updated configuration.' ); + return; + } + console.error( 'Encountered an error when posting change. Status: %d.', response.status ); + + // If we failed, we need to roll back to displaying the value from the existing visualization schema: + self.refresh(); + } + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + */ + function onError( error ) { + console.error( 'Encountered an error when posting change. Error: %s.', error.message ); + + // If we failed, we need to roll back to displaying the value from the existing visualization schema: + self.refresh(); + } +} + + +// EXPORTS // + +module.exports = onChange; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/globals/lil_gui.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/globals/lil_gui.js new file mode 100644 index 000000000000..f27dfc8ab91f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/globals/lil_gui.js @@ -0,0 +1,25 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* global lil */ + +'use strict'; + +// EXPORTS // + +module.exports = lil; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/globals/vega.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/globals/vega.js new file mode 100644 index 000000000000..4ac039cb02ce --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/globals/vega.js @@ -0,0 +1,25 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* global vega */ + +'use strict'; + +// EXPORTS // + +module.exports = vega; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/index.js new file mode 100644 index 000000000000..5245bd3a6556 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/index.js @@ -0,0 +1,28 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var app = require( './app.js' ); + + +// MAIN // + +app(); diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/log.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/log.js new file mode 100644 index 000000000000..1ad8bcc41b2f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/log.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var logger = require( '@stdlib/console/log' ); +var config = require( './config.js' ); + + +// MAIN // + +/** +* Logs a message to the console. +* +* @private +* @param {string} msg - message to log +* @param {...*} [args] - additional arguments +* @returns {void} +*/ +function log() { + var args; + var i; + + if ( !config.verbose ) { + return; + } + args = []; + for ( i = 0; i < arguments.length; i++ ) { + args.push( arguments[ i ] ); + } + logger.apply( null, args ); +} + + +// EXPORTS // + +module.exports = log; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/index.js new file mode 100644 index 000000000000..8ea1bad4cf53 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/index.js @@ -0,0 +1,137 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var setReadWrite = require( '@stdlib/utils/define-nonenumerable-read-write-accessor' ); +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); +var config = require( './../config.js' ); +var log = require( './../log.js' ); +var getRaw = require( './raw/get.js' ); +var setRaw = require( './raw/set.js' ); +var getTransformed = require( './transformed/get.js' ); + + +// FUNCTIONS // + +/** +* Callback invoked upon receiving an HTTP response. +* +* @private +* @param {Response} response - response object +* @returns {Promise} promise which resolves upon converting response content to JSON +*/ +function onResponse( response ) { + return response.json(); +} + + +// MAIN // + +/** +* Constructor for a visualization schema manager. +* +* @private +* @constructor +* @param {Object} state - state object +* @returns {Schema} schema manager instance +*/ +function Schema( state ) { + if ( !( this instanceof Schema ) ) { + return new Schema( state ); + } + this._state = state; + this._raw = null; + this._transformed = null; + return this; +} + +/** +* Raw visualization schema. +* +* @name raw +* @memberof Schema.prototype +* @type {Object} +*/ +setReadWrite( Schema.prototype, 'raw', getRaw, setRaw ); + +/** +* Resolves a visualization schema. +* +* @name resolve +* @memberof Schema.prototype +* @type {Function} +* @param {Callback} [clbk] - callback to invoke upon completion +*/ +setReadOnly( Schema.prototype, 'resolve', function resolve( clbk ) { + var self = this; + + log( 'Resolving schema...' ); + fetch( config.routes.schema ) + .then( onResponse ) + .then( onJSON ) + .catch( onError ); + + /** + * Callback invoked upon resolving a schema. + * + * @private + * @param {Object} schema - schema + * @returns {void} + */ + function onJSON( schema ) { + log( 'Successfully resolved schema.' ); + self.raw = schema; + if ( clbk ) { + return clbk(); + } + } + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + * @returns {void} + */ + function onError( error ) { + console.error( 'Encountered an error when attempting to resolve a schema. Error: %s', error.message ); + if ( clbk ) { + return clbk( error ); + } + } +}); + +/** +* Transformed visualization schema. +* +* @name transformed +* @memberof Schema.prototype +* @type {Object} +*/ +setReadOnlyAccessor( Schema.prototype, 'transformed', getTransformed ); + + +// EXPORTS // + +module.exports = Schema; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/raw/get.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/raw/get.js new file mode 100644 index 000000000000..e7ab2997ed10 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/raw/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MAIN // + +/** +* Returns a "raw" visualization schema. +* +* @private +* @returns {Object} visualization schema +*/ +function get() { + return this._raw; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/raw/set.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/raw/set.js new file mode 100644 index 000000000000..1b3dd81f8763 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/raw/set.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var defaults = require( './../../editor/defaults.js' ); +var transform = require( './../transform.js' ); + + +// MAIN // + +/** +* Sets a "raw" visualization schema. +* +* @private +* @param {Object} schema - visualization schema +*/ +function set( schema ) { + var def = ( this._state.editor ) ? this._state.editor.defaults : defaults; + this._raw = schema; + this._transformed = transform( schema, def ); +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transform.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transform.js new file mode 100644 index 000000000000..d9c6bba1ff12 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transform.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var general = require( './transforms/general.js' ); +var title = require( './transforms/title.js' ); +var axes = require( './transforms/axes.js' ); + + +// MAIN // + +/** +* Returns a transformed visualization specification which replaces property values with signals for use in conjunction with UI components. +* +* @private +* @param {Object} schema - visualization specification +* @param {Object} defaults - UI defaults +* @returns {Object} transformed specification +*/ +function transform( schema, defaults ) { + var out; + + out = {}; + + // Vega defines built-in height, width, and padding signals, so we can simply copy over... + out.height = ( isUndefined( schema.height ) ) ? defaults.height : schema.height; + out.width = ( isUndefined( schema.width ) ) ? defaults.width : schema.width; + out.padding = ( isUndefined( schema.padding ) ) ? defaults.padding : schema.padding; + + // For the following properties, we simply copy them over, as no need to setup signals as they will not be associated with UI elements... + out.autosize = schema.autosize; + out.config = schema.config || {}; + out.data = schema.data || []; + out.encode = schema.encode || {}; + out.usermeta = schema.usermeta || {}; + + // Because we'll be adding to the list of signals, make a fresh (shallow) copy to avoid mutating the input schema: + out.signals = ( schema.signals ) ? schema.signals.slice() : []; + + // Initialize the background and description properties: + out.background = schema.background || void 0; + out.description = schema.description || void 0; + + // Perform schema transformations... + out = general( out, out.signals, defaults ); + if ( schema.title ) { + out.title = title( schema.title, out.signals, defaults.title ); + } + if ( schema.axes && schema.axes.length ) { + out.axes = axes( schema.axes, out.signals, defaults.axis ); + } + + // FIXME: the following properties in order of priority + out.scales = schema.scales; + out.marks = schema.marks; + out.legends = schema.legends; + out.projections = schema.projections; + + return out; +} + + +// EXPORTS // + +module.exports = transform; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transformed/get.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transformed/get.js new file mode 100644 index 000000000000..bd133369cc05 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transformed/get.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MAIN // + +/** +* Returns a transformed visualization schema. +* +* @private +* @returns {Object} visualization schema +*/ +function get() { + return this._transformed; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/axes.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/axes.js new file mode 100644 index 000000000000..db9578542d44 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/axes.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var copy = require( '@stdlib/array/base/copy' ); +var format = require( '@stdlib/string/format' ); +var axis = require( './axis.js' ); + + +// VARIABLES // + +var PREFIX = 'axes/'; + + +// MAIN // + +/** +* Returns a list of transformed axis schemas containing signals for use in conjunction with UI components. +* +* ## Notes +* +* - The function mutates the provided list of signals. +* +* @private +* @param {Array} schema - list of axis schemas +* @param {Array} signals - list of signals +* @param {Object} defaults - axis schema defaults +* @returns {Array} transformed schemas +*/ +function transform( schema, signals, defaults ) { + var out; + var i; + + out = copy( schema ); + for ( i = 0; i < out.length; i++ ) { + out[ i ] = axis( schema[ i ], signals, defaults, format( '%s%d/', PREFIX, i ) ); + } + return out; +} + + +// EXPORTS // + +module.exports = transform; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/axis.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/axis.js new file mode 100644 index 000000000000..118140791be1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/axis.js @@ -0,0 +1,242 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var copyJSON = require( './../../utils/copy_json.js' ); +var signalName = require( './../../utils/signal_name.js' ); + + +// VARIABLES // + +var PROPS = [ + 'bandPosition', + 'domain', + 'domainCap', + 'domainColor', + 'domainDash', + 'domainDashOffset', + 'domainOpacity', + 'domainWidth', + 'grid', + 'gridCap', + 'gridColor', + 'gridDash', + 'gridDashOffset', + 'gridOpacity', + 'gridWidth', + 'labelAlign', + 'labelAngle', + 'labelBaseline', + 'labelBound', + 'labelColor', + 'labelFlush', + 'labelFlushOffset', + 'labelFont', + 'labelFontSize', + 'labelFontStyle', + 'labelFontWeight', + 'labelLimit', + 'labelLineHeight', + 'labelOffset', + 'labelOpacity', + 'labelOverlap', + 'labelPadding', + 'labels', + 'labelSeparation', + 'maxExtent', + 'minExtent', + 'offset', + 'position', + 'tickBand', + 'tickCap', + 'tickColor', + 'tickCount', + 'tickDash', + 'tickDashOffset', + 'tickMinStep', + 'tickOffset', + 'tickOpacity', + 'ticks', + 'tickSize', + 'tickWidth', + 'title', + 'titleAlign', + 'titleAnchor', + 'titleAngle', + 'titleBaseline', + 'titleColor', + 'titleFont', + 'titleFontSize', + 'titleFontStyle', + 'titleFontWeight', + 'titleLimit', + 'titleLineHeight', + 'titleOpacity', + 'titlePadding', + 'titleX', + 'titleY', + 'zindex' +]; + +// Define a list of properties which need to be made explicitly "undefined" when set to falsy values: +var SPECIAL_PROPS = [ + 'labelAlign', + 'labelBaseline', + 'labelBound', + 'labelFlush', + 'labelOverlap', + 'titleAngle', + 'titleBaseline', + 'titleX', + 'titleY' +]; +var isSpecialProp = contains( SPECIAL_PROPS ); + +// FIXME: preferrably Vega would support signal updates here. For now, define a list of "structural" properties, as Vega does not currently support signal updates for toggling `domain`, `grid`, `labels`, and `ticks`. As a workaround, we keep them statically `true` and dynamically hide them by dropping their respective opacities to `0` when they are set to `false`. +var STRUCTURAL_PROPS = [ + 'domain', + 'grid', + 'labels', + 'ticks' +]; +var isStructuralProp = contains( STRUCTURAL_PROPS ); + +var OPACITY_PROPS = [ + 'domainOpacity', + 'gridOpacity', + 'labelOpacity', + 'tickOpacity' +]; +var isOpacityProp = contains( OPACITY_PROPS ); + +var OPACITY_TO_STRUCTURAL = { + 'domainOpacity': 'domain', + 'gridOpacity': 'grid', + 'labelOpacity': 'labels', + 'tickOpacity': 'ticks' +}; + + +// MAIN // + +/** +* Returns a transformed axis schema containing signals for use in conjunction with UI components. +* +* ## Notes +* +* - The function mutates the provided list of signals. +* +* @private +* @param {Object} schema - axis schema +* @param {Array} signals - list of signals +* @param {Object} defaults - axis schema defaults +* @param {string} prefix - signal prefix +* @returns {Object} transformed schema +*/ +function transform( schema, signals, defaults, prefix ) { + var value; + var name; + var out; + var k; + var v; + var i; + + out = copyJSON( schema ); + for ( i = 0; i < PROPS.length; i++ ) { + k = PROPS[ i ]; + v = schema[ k ]; + if ( !isSignalReference( v ) ) { + name = signalName( prefix+k ); + value = ( isUndefined( v ) ) ? defaults[ k ].default : v; + + if ( isSpecialProp( k ) ) { + if ( isUndefined( v ) || v === '' || v === false ) { + out[ k ] = void 0; + signals.push({ + 'name': name, + 'value': void 0 + }); + + // Skip further processing... + continue; + } + } + if ( k === 'tickCount' ) { + signals.push({ + 'name': name, + 'value': ( value === '' ) ? void 0 : value + }); + } else { + signals.push({ + 'name': name, + 'value': value + }); + } + if ( isStructuralProp( k ) ) { + out[ k ] = true; + } else if ( isOpacityProp( k ) ) { + out[ k ] = { + 'signal': signalName( prefix+OPACITY_TO_STRUCTURAL[ k ] ) + ' ? ' + name + ' : 0' + }; + } else if ( k === 'zindex' ) { + // FIXME: preferably Vega would support signal references for `zindex`. Currently, Vega's internal `definition()` function coerces `zindex` using `+spec.zindex || undefined`, which means a signal reference object (e.g., `{ signal: '...' }`) yields `NaN` and is discarded. As a workaround, keep `zindex` as a plain numeric value. + out[ k ] = value; + } else { + out[ k ] = { + 'signal': name + }; + } + } + } + + // FIXME: Currently, Vega's `ariaGuide` reads `description` from `item.description` (the child visual item), not from `mark.description` (the group definition). Since `buildAxisEncode` does not map `description`, the value is never populated on the item and the custom description is silently ignored. As a workaround, inject the description via a custom `encode.axis.enter` mapping so that Vega copies it onto the visual item during initialization. + if ( schema.description ) { + // TODO: consider replacing the following logic with a call to `utils/deep-set` once refactored + if ( !out.encode ) { + out.encode = {}; + } + if ( !out.encode.axis ) { + out.encode.axis = {}; + } + if ( !out.encode.axis.enter ) { + out.encode.axis.enter = {}; + } + out.encode.axis.enter.description = { + 'value': schema.description + }; + } else if ( + out.encode && + out.encode.axis && + out.encode.axis.enter + ) { + // TODO: determine whether it is possible to avoid using `delete` in order to avoid engine de-optimization + delete out.encode.axis.enter.description; + } + return out; +} + + +// EXPORTS // + +module.exports = transform; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/general.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/general.js new file mode 100644 index 000000000000..fa079f46708e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/general.js @@ -0,0 +1,78 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var signalName = require( './../../utils/signal_name.js' ); + + +// VARIABLES // + +var PROPS = [ + 'background' +]; + + +// MAIN // + +/** +* Returns a transformed schema containing signals for use in conjunction with UI components. +* +* ## Notes +* +* - The function mutates both the input schema and the provided list of signals. +* +* @private +* @param {Object} schema - schema +* @param {Array} signals - list of signals +* @param {Object} defaults - schema defaults +* @returns {Object} transformed schema +*/ +function transform( schema, signals, defaults ) { + var name; + var out; + var k; + var v; + var i; + + out = schema; + for ( i = 0; i < PROPS.length; i++ ) { + k = PROPS[ i ]; + v = schema[ k ]; + if ( !isSignalReference( v ) ) { + name = signalName( k ); + signals.push({ + 'name': name, + 'value': ( isUndefined( v ) ) ? defaults[ k ].default : v + }); + out[ k ] = { + 'signal': name + }; + } + } + return out; +} + + +// EXPORTS // + +module.exports = transform; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/title.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/title.js new file mode 100644 index 000000000000..c036fab5a7b2 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/title.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' ); +var isUndefined = require( '@stdlib/assert/is-undefined' ); +var copyJSON = require( './../../utils/copy_json.js' ); +var signalName = require( './../../utils/signal_name.js' ); + + +// VARIABLES // + +var PROPS = [ + 'align', + 'anchor', + 'angle', + 'baseline', + 'color', + 'dx', + 'dy', + 'font', + 'fontSize', + 'fontStyle', + 'fontWeight', + 'frame', + 'limit', + 'lineHeight', + 'offset', + 'orient', + 'subtitle', + 'subtitleColor', + 'subtitleFont', + 'subtitleFontSize', + 'subtitleFontStyle', + 'subtitleFontWeight', + 'subtitleLineHeight', + 'subtitlePadding', + 'text' +]; +var PREFIX = 'title/'; + + +// MAIN // + +/** +* Returns a transformed title schema containing signals for use in conjunction with UI components. +* +* ## Notes +* +* - The function mutates the provided list of signals. +* +* @private +* @param {Object} schema - title schema +* @param {Array} signals - list of signals +* @param {Object} defaults - title schema defaults +* @returns {Object} transformed schema +*/ +function transform( schema, signals, defaults ) { + var name; + var out; + var k; + var v; + var i; + + out = copyJSON( schema ); + for ( i = 0; i < PROPS.length; i++ ) { + k = PROPS[ i ]; + v = schema[ k ]; + if ( !isSignalReference( v ) ) { + name = signalName( PREFIX+k ); + signals.push({ + 'name': name, + 'value': ( isUndefined( v ) ) ? defaults[ k ].default : v + }); + out[ k ] = { + 'signal': name + }; + } + } + return out; +} + + +// EXPORTS // + +module.exports = transform; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/sse/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/sse/index.js new file mode 100644 index 000000000000..36df63e9c2bd --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/sse/index.js @@ -0,0 +1,223 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this, no-underscore-dangle */ + +'use strict'; + +// MODULES // + +var EventEmitter = require( 'events' ).EventEmitter; +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var inherit = require( '@stdlib/utils/inherit' ); +var log = require( './../log.js' ); +var config = require( './../config.js' ); + + +// MAIN // + +/** +* Server sent events manager. +* +* @private +* @constructor +* @param {Object} state - state object +* @returns {SSE} SSE instance +*/ +function SSE( state ) { + if ( !( this instanceof SSE ) ) { + return new SSE( state ); + } + EventEmitter.call( this ); + this._state = state; + this._source = null; + this._ack = null; + this._lastID = -1; + return this; +} + +/* +* Inherit from the `EventEmitter` prototype. +*/ +inherit( SSE, EventEmitter ); + +/** +* Sends an acknowledgment to the server regarding the last received event. +* +* @name ack +* @memberof SSE.prototype +* @type {Function} +*/ +setReadOnly( SSE.prototype, 'ack', function ack() { + var opts = { + 'method': 'POST', + 'body': this._lastID.toString(), + 'credentials': 'same-origin' + }; + log( 'Sending acknowledgement to server...' ); + fetch( config.routes.ack, opts ) + .then( onResponse ) + .catch( onError ); + + /** + * Callback invoked upon receiving an HTTP response. + * + * @private + * @param {Response} response - response object + * @returns {void} + */ + function onResponse( response ) { + if ( response.ok ) { + log( 'Successfully sent acknowledgment.' ); + return; + } + console.error( 'Encountered an error when sending acknowledgment. Status: %d.', response.status ); + } + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + */ + function onError( error ) { + console.error( 'Encountered an error when sending acknowledgment. Error: %s.', error.message ); + } +}); + +/** +* Establishes a server connection for listening to events. +* +* @name connect +* @memberof SSE.prototype +* @type {Function} +* @param {Callback} [clbk] - callback to invoke upon completion +*/ +setReadOnly( SSE.prototype, 'connect', function connect( clbk ) { + var self; + var src; + + self = this; + + src = new EventSource( config.routes.sse, { + 'withCredentials': true + }); + src.addEventListener( 'error', onError ); + src.addEventListener( 'open', onOpen ); + src.addEventListener( 'ping', onPing ); + + src.addEventListener( 'data', onData ); + src.addEventListener( 'patch', onPatch ); + src.addEventListener( 'refresh', onRefresh ); + + this._source = src; + + /** + * Callback invoked when unable to establish a server connection. + * + * @private + * @param {Event} event - event object + * @returns {void} + */ + function onError() { + var err = new Error( 'Failed to establish server connection.' ); + if ( self._ack ) { + clearInterval( self._ack ); + } + if ( clbk ) { + return clbk( err ); + } + } + + /** + * Callback invoked upon establishing a server connection. + * + * @private + * @param {Event} event - event object + * @returns {void} + */ + function onOpen() { + log( 'Established server connection.' ); + self._ack = setInterval( ack, config.ack.interval ); + if ( clbk ) { + return clbk(); + } + } + + /** + * Sends an acknowledge to the server regarding the last received event. + * + * @private + */ + function ack() { + self.ack(); + } + + /** + * Callback invoked upon receiving a "ping" (keep-alive) message. + * + * @private + */ + function onPing() { + log( 'Received a "ping" event.' ); + } + + /** + * Callback invoked upon a "refresh" event. + * + * @private + * @param {Event} event - event object + * @returns {void} + */ + function onRefresh( event ) { + log( 'Received a "refresh" event.' ); + self._lastID = event.id; + self.emit( 'refresh', event ); + } + + /** + * Callback invoked upon a "patch" event. + * + * @private + * @param {Event} event - event object + * @returns {void} + */ + function onPatch( event ) { + log( 'Received a "patch" event.' ); + self._lastID = event.id; + self.emit( 'patch', event ); + } + + /** + * Callback invoked upon a "data" event. + * + * @private + * @param {Event} event - event object + * @returns {void} + */ + function onData( event ) { + log( 'Received a "data" event.' ); + self._lastID = event.id; + self.emit( 'data', event ); + } +}); + + +// EXPORTS // + +module.exports = SSE; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/state.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/state.js new file mode 100644 index 000000000000..c0b46579d8b0 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/state.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Application state. +* +* @private +* @name state +* @type {Object} +*/ +var state = { + // Editor manager: + 'editor': null, + + // Visualization schema manager: + 'schema': null, + + // Server sent event manager: + 'sse': null, + + // Visualization manager: + 'viz': null +}; + + +// EXPORTS // + +module.exports = state; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/copy_json.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/copy_json.js new file mode 100644 index 000000000000..718e675dfaeb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/copy_json.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns a deep copy of a JSON object. +* +* @private +* @param {Object} obj - JSON object +* @returns {Object} deep copy +*/ +function copyJSON( obj ) { + return JSON.parse( JSON.stringify( obj ) ); +} + + +// EXPORTS // + +module.exports = copyJSON; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/series.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/series.js new file mode 100644 index 000000000000..3d97e358c3dc --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/series.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Executes a list of functions in series. +* +* @private +* @param {Array} fcns - list of functions to execute +* @param {Callback} clbk - callback to invoke upon completion +* @returns {void} +*/ +function series( fcns, clbk ) { + var idx = -1; + return next(); + + /** + * Executes the next function in the series. + * + * @private + * @param {(Error|null)} error - error object + * @returns {void} + */ + function next() { + // Check for an error... + if ( arguments[ 0 ] ) { + return clbk( arguments[ 0 ] ); + } + // Update the counter and check if we have run all functions... + idx += 1; + if ( idx >= fcns.length ) { + return clbk(); + } + // Invoke the next function: + fcns[ idx ]( next ); + } +} + + +// EXPORTS // + +module.exports = series; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/signal_name.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/signal_name.js new file mode 100644 index 000000000000..d8b965a43cf1 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/signal_name.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var replace = require( '@stdlib/string/base/replace' ); + + +// VARIABLES // + +// Define a list of built-in Vega signal names that shouldn't be overwritten... +var EXCLUDE = [ + 'width', + 'height', + 'padding', + 'autosize' +]; +var isExcluded = contains( EXCLUDE ); + +var PREFIX = '_config_'; +var RE_SLASH = /\//g; + + +// MAIN // + +/** +* Returns an editor-specific signal name. +* +* ## Notes +* +* - The intent of this function is to namespace editor signals to avoid potential naming collisions. +* +* @private +* @param {string} name - raw signal name +* @returns {string} signal name belonging to the editor signal namespace +*/ +function signalName( name ) { + if ( isExcluded( name ) ) { + return name; + } + return PREFIX + replace( name, RE_SLASH, '_' ); +} + + +// EXPORTS // + +module.exports = signalName; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/throttle.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/throttle.js new file mode 100644 index 000000000000..7379d7e7d12f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/utils/throttle.js @@ -0,0 +1,80 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns a function which should only be invoked at most once per a specified interval. +* +* @private +* @param {Function} fcn - function to wrap +* @param {NonNegativeInteger} interval - number of milliseconds before a function can be invoked again +* @returns {Function} wrapped function +*/ +function throttle( fcn, interval ) { // TODO: make more robust and comprehensive and move to `@stdlib/function/throttle` + var args; + var flg; + + flg = false; + return throttled; + + /** + * Returns a throttled function. + * + * @private + * @param {...*} [args] - arguments + * @returns {void} + */ + function throttled() { + var i; + + // Cache the latest list of arguments... + args = []; + for ( i = 0; i < arguments.length; i++ ) { + args.push( arguments[ i ] ); + } + // If the flag is already set, then we're paused... + if ( flg ) { + // Nothing left to do, but wait... + return; + } + flg = true; + + // Start the timer for when we can invoke the throttled function: + setTimeout( onTimeout, interval ); + } + + /** + * Callback invoked after a delay. + * + * @private + */ + function onTimeout() { + fcn.apply( null, args ); + + // Now that the function was invoked, we can reset the flag: + flg = false; + } +} + + +// EXPORTS // + +module.exports = throttle; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/viz/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/viz/index.js new file mode 100644 index 000000000000..d4758162e707 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/app/viz/index.js @@ -0,0 +1,176 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var join = require( '@stdlib/array/base/join' ); +var vega = require( './../globals/vega.js' ); +var signalName = require( './../utils/signal_name.js' ); +var log = require( './../log.js' ); +var config = require( './../config.js' ); + + +// MAIN // + +/** +* Constructor for a visualization manager. +* +* @private +* @constructor +* @param {Object} state - state object +* @returns {Visualization} visualization instance +*/ +function Visualization( state ) { + if ( !( this instanceof Visualization ) ) { + return new Visualization( state ); + } + this._state = state; + this._view = null; + this._renderer = config.vega.renderer; + return this; +} + +/** +* Initializes a visualization. +* +* @name init +* @memberof Visualization.prototype +* @type {Function} +* @param {Callback} [clbk] - callback to invoke upon completion +*/ +setReadOnly( Visualization.prototype, 'init', function init( clbk ) { + var runtime; + if ( this._view ) { + this._view.finalize(); + } + runtime = vega.parse( this._state.schema.transformed ); + this._view = new vega.View( runtime, { + 'logLevel': config.vega.logLevel, + 'renderer': this._renderer, + 'container': config.vega.container, + 'hover': true + }); + + log( 'Rendering visualization...' ); + this._view.runAsync() + .then( onRender ) + .catch( onError ); + + /** + * Callback invoked upon rendering a visualization. + * + * @private + * @returns {void} + */ + function onRender() { + log( 'Successfully rendered visualization.' ); + if ( clbk ) { + return clbk(); + } + } + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + * @returns {void} + */ + function onError( error ) { + console.error( 'Encountered an error when attempting to render visualization. Error: %s', error.message ); + if ( clbk ) { + return clbk( error ); + } + } +}); + +/** +* Callback invoked upon a new signal. +* +* @name onSignal +* @memberof Visualization.prototype +* @type {Function} +* @param {Array} path - signal path +* @param {*} value - signal value +* @param {Callback} [clbk] - callback to invoke upon completion +* @returns {void} +*/ +setReadOnly( Visualization.prototype, 'onSignal', function onSignal( path, value, clbk ) { + var ns = path[ 0 ]; + + // For height, width, padding, and certain axis property updates (e.g., aria, description, orient, and scale), we avoid propagating changes to the vega runtime, as these updates either require additional layout/scale modifications or full specification rebuilds and the logic for that resides on the server. Instead, these changes are pushed to the server, and the server will respond with a "refresh" event which will force the visualization to be re-rendered... + if ( + ns === 'width' || + ns === 'height' || + ns === 'padding' || + ( ns === 'axes' && ( path[ 2 ] === 'aria' || path[ 2 ] === 'description' || path[ 2 ] === 'orient' || path[ 2 ] === 'scale' ) ) + ) { + if ( clbk ) { + return clbk(); + } + return; + } + if ( ns === '' ) { + path = path.slice( 1 ); + } + try { + this._view.signal( signalName( join( path, '/' ) ), value ); + } catch ( err ) { + return onError( err ); + } + this._view.runAsync() + .then( onRender ) + .catch( onError ); + + /** + * Callback invoked upon rendering a visualization. + * + * @private + * @returns {void} + */ + function onRender() { + log( 'Successfully rendered visualization.' ); + if ( clbk ) { + return clbk(); + } + } + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + * @returns {void} + */ + function onError( error ) { + console.error( 'Encountered an error when attempting to render visualization. Error: %s', error.message ); + if ( clbk ) { + return clbk( error ); + } + } +}); + + +// EXPORTS // + +module.exports = Visualization; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/byte_length.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/byte_length.js new file mode 100644 index 000000000000..3027d7f2da46 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/byte_length.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var buffer2bytelength = require( '@stdlib/buffer/ctor' ).byteLength; +var NODE_VERSION = require( '@stdlib/process/node-version' ); + + +// VARIABLES // + +var SUPPORTS_BUFFER = ( parseInt( NODE_VERSION.split( '.' )[ 0 ], 10 ) < 6 ); + + +// MAIN // + +/** +* Returns the byte length of an encoded string. +* +* @private +* @param {(string|Buffer)} str - input string +* @returns {NonNegativeInteger} byte length +*/ +function byteLength( str ) { // TODO: consider making a robust utility in `@stdlib/buffer/byte-length` + if ( SUPPORTS_BUFFER ) { + return buffer2bytelength( str ); + } + // Earlier versions of Node.js do not support Buffers, ArrayBuffers, TypedArrays, DataViews, or SharedArrayBuffers, so we need to explicitly call `#.toString()`... + return buffer2bytelength( str.toString() ); +} + + +// EXPORTS // + +module.exports = byteLength; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/context.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/context.js new file mode 100644 index 000000000000..aba56340b8bf --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/context.js @@ -0,0 +1,102 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); // eslint-disable-line id-length +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' ); +var string2buffer = require( '@stdlib/buffer/from-string' ); + + +// MAIN // + +/** +* Context constructor. +* +* @private +* @constructor +* @param {Object} plot - plot instance +* @returns {Context} context instance +*/ +function Context( plot ) { + var self; + if ( !( this instanceof Context ) ) { + return new Context( plot ); + } + self = this; + + setNonEnumerableReadOnly( this, '_plot', plot ); + setNonEnumerable( this, '_spec', string2buffer( JSON.stringify( plot ) ) ); + setNonEnumerableReadOnly( this, '_events', [] ); + + plot.on( 'change', onChange ); + return this; + + /** + * Callback invoked upon a plot "change" event. + * + * @private + * @param {Object} event - event object + */ + function onChange() { + self._spec = string2buffer( JSON.stringify( plot ) ); // eslint-disable-line no-underscore-dangle + } +} + +/** +* Events database. +* +* @name events +* @memberof Context.prototype +* @type {Array} +*/ +setNonEnumerableReadOnlyAccessor( Context.prototype, 'events', function getEvents() { + return this._events; +}); + +/** +* Plot instance. +* +* @name plot +* @memberof Context.prototype +* @type {Object} +*/ +setNonEnumerableReadOnlyAccessor( Context.prototype, 'plot', function getPlot() { + return this._plot; +}); + +/** +* Serialized plot specification. +* +* @name spec +* @memberof Context.prototype +* @type {Buffer} +*/ +setNonEnumerableReadOnlyAccessor( Context.prototype, 'spec', function getSpec() { + return this._spec; +}); + + +// EXPORTS // + +module.exports = Context; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/index.js new file mode 100644 index 000000000000..4d8a2af60af5 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/index.js @@ -0,0 +1,123 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var openURL = require( '@stdlib/utils/open-url' ); +var createServer = require( '@stdlib/plot/base/server' ); +var routes = require( './routes' ); +var Router = require( './router.js' ); +var Context = require( './context.js' ); + + +// VARIABLES // + +var debug = logger( 'plot:view:browser' ); + + +// FUNCTIONS // + +/** +* Opens a plot in a web browser. +* +* @private +* @param {Object} plot - plot instance +*/ +function displayPlot( plot ) { + var addr = plot.server.address(); + openURL( 'https://'+addr.address+':'+addr.port ); +} + + +// MAIN // + +/** +* Opens a plot in a browser window. +* +* @private +* @param {Object} plot - plot instance +*/ +function view( plot ) { + var server; + var router; + var ctx; + + // Create a new request context: + ctx = new Context( plot ); + + // Initialize a new request router: + router = new Router(); + + // Register routes: + routes( router ); + + server = plot.server; + if ( !server || server.address() === null ) { // note: server.address() is `null` if a server has already been closed + debug( 'Creating a server...' ); + createServer( onRequest, onReady ); + } else { + displayPlot( plot ); + } + + /** + * Callback invoked once a server is ready to receive requests. + * + * @private + * @param {(Error|null)} error - error object + * @param {Server} server - server instance + * @throws {Error} unexpected error + */ + function onReady( error, server ) { + if ( error ) { + throw error; + } + // Bind the server to a plot instance: + plot.server = server; + + displayPlot( plot ); + } + + /** + * Request handler. + * + * @private + * @param {IncomingMessage} request - HTTP request object + * @param {ServerResponse} response - HTTP response object + * @returns {void} + */ + function onRequest( request, response ) { + var handler; + + // Resolve a route handler: + handler = router.resolve( request ); + + // Decorate each `request` object with a `locals` object for passing along intermediate results within middleware handlers: + request.locals = {}; + + // Invoke the route handler: + handler.call( ctx, request, response ); + } +} + + +// EXPORTS // + +module.exports = view; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/allow-credentials/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/allow-credentials/index.js new file mode 100644 index 000000000000..ef0dbff7a0ff --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/allow-credentials/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Middleware function to set a header for allowing credentials to be sent with a request. +* +* @private +* @param {Object} request - request object +* @param {Object} response - response object +* @param {Callback} next - callback to invoke upon completion +* @returns {void} +*/ +function allowCredentials( request, response, next ) { + response.setHeader( 'Access-Control-Allow-Credentials', true ); + next(); +} + + +// EXPORTS // + +module.exports = allowCredentials; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/body/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/body/index.js new file mode 100644 index 000000000000..f55f7b6d5def --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/body/index.js @@ -0,0 +1,129 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var Buffer = require( '@stdlib/buffer/ctor' ); + + +// VARIABLES // + +var debug = logger( 'plot:view:browser:middleware:body' ); + +// Define a limit for how large a request body can be: +var BODY_LIMIT = 10 * 1024 * 1024; // 10 MB + + +// MAIN // + +/** +* Middleware function to resolve a request body. +* +* @private +* @param {Object} request - request object +* @param {Object} response - response object +* @param {Callback} next - callback to invoke upon completion +* @returns {void} +*/ +function rawBody( request, response, next ) { + var chunks; + var size; + + chunks = []; + size = 0; + request.on( 'data', onData ); + request.on( 'aborted', onAborted ); + request.on( 'end', onEnd ); + request.on( 'error', onError ); + + /** + * Callback invoked upon receiving the next chunk of data. + * + * @private + * @param {string} chunk - chunk + * @returns {void} + */ + function onData( chunk ) { + size += chunk.length; + if ( size > BODY_LIMIT ) { + debug( 'Encountered an error when attempting to process a request body. Error: Request body is too large.' ); + return onEnd({ + 'statusCode': 413, + 'error': 'Bad Request', + 'message': 'Payload too large.' + }); + } + chunks.push( chunk ); + } + + /** + * Callback invoked upon encountering an error. + * + * @private + * @param {Error} error - error object + */ + function onError( error ) { + debug( 'Encountered an error when attempting to process a request body. Error: %s', error.message ); + onEnd({ + 'statusCode': 400, + 'error': 'Bad Request', + 'message': 'Unable to process request body' + }); + } + + /** + * Callback invoked upon a request being aborted. + * + * @private + */ + function onAborted() { + debug( 'Encountered an error when attempting to process a request body. Error: Request prematurely ended.' ); + onEnd({ + 'statusCode': 400, + 'error': 'Bad Request', + 'message': 'Request prematurely ended.' + }); + } + + /** + * Callback invoked upon receiving all chunks. + * + * @private + * @param {Object} [error] - error object + * @returns {void} + */ + function onEnd( error ) { + request.removeListener( 'data', onData ); + request.removeListener( 'end', onEnd ); + request.removeListener( 'error', onError ); + request.removeListener( 'aborted', onAborted ); + if ( error ) { + return next( error ); + } + request.body = Buffer.concat( chunks, size ).toString( 'utf8' ); + next(); + } +} + + +// EXPORTS // + +module.exports = rawBody; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/error/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/error/index.js new file mode 100644 index 000000000000..47a6d5d43115 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/error/index.js @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Callback invoked upon encountering an error. +* +* @private +* @param {Object} error - error object +* @param {Object} request - request object +* @param {Object} response - response object +* @param {Callback} next - callback to invoke upon completion +* @returns {void} +*/ +function onError( error, request, response ) { + response.statusCode = error.statusCode; + response.setHeader( 'Content-Type', 'application/json' ); + response.end( JSON.stringify( error ) ); +} + + +// EXPORTS // + +module.exports = onError; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/ok/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/ok/index.js new file mode 100644 index 000000000000..9362d571b4f3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/ok/index.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Middleware function to return an "ok" response. +* +* @private +* @param {Object} request - request object +* @param {Object} response - response object +* @param {Callback} next - callback to invoke upon completion +* @returns {void} +*/ +function ok( request, response ) { + response.statusCode = 200; + response.setHeader( 'Content-Type', 'text/plain' ); + response.end( 'OK' ); +} + + +// EXPORTS // + +module.exports = ok; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/plot-try-assign/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/plot-try-assign/index.js new file mode 100644 index 000000000000..cd7fc427583c --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware/plot-try-assign/index.js @@ -0,0 +1,138 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var isEmptyArrayLikeObject = require( '@stdlib/assert/is-empty-array-like-object' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var copy = require( '@stdlib/array/base/copy' ); +var format = require( '@stdlib/string/format' ); + + +// VARIABLES // + +var debug = logger( 'plot:view:browser:middleware:plot-try-assign' ); + + +// MAIN // + +/** +* Returns a middleware function for attempting to assign the body of an HTTP request to a nested property on a plot instance. +* +* ## Notes +* +* - A plot instance is assumed to be bound to a request's `this` context. +* +* @private +* @param {Array} path - nested object property path +* @param {string} prop - nested object property name +* @param {Function} [transform] - synchronous transform function to apply to request body before assignment +* @throws {TypeError} first argument must be an array of strings +* @throws {TypeError} second argument must be a string +* @throws {TypeError} third argument must be a function +* @returns {Function} middleware function +*/ +function factory( path, prop, transform ) { + if ( !isStringArray( path ) && !isEmptyArrayLikeObject( path ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an array of strings. Value: `%s`.', path ) ); + } + if ( !isString( prop ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a string. Value: `%s`.', prop ) ); + } + if ( arguments.length > 2 ) { + if ( !isFunction( transform ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`', transform ) ); + } + } + path = copy( path ); // note: copy to prevent external mutation + return tryAssign; + + /** + * Middleware function for attempting to assign the body of an HTTP request to a nested property on a plot instance. + * + * @private + * @param {Object} request - request object + * @param {Object} response - response object + * @param {Callback} next - callback to invoke upon completion + * @returns {void} + */ + function tryAssign( request, response, next ) { + var value; + var body; + var o; + var k; + var i; + + body = request.body; + debug( 'New value: %s', body ); + + if ( transform ) { + debug( 'Applying transform...' ); + try { + value = transform( body ); + } catch ( err ) { + debug( 'Encountered an error when attempting to transform request body. Error: %s', err.message ); + return next({ + 'statusCode': 400, + 'error': 'Bad Request', + 'message': format( 'Invalid value: %s. Error: %s', body, err.message ) + }); + } + debug( 'Successfully applied transform.' ); + } else { + value = body; + } + // Resolve the nested object to assign to... + o = this.plot; + for ( i = 0; i < path.length; i++ ) { + k = path[ i ]; + if ( k[ 0 ] === ':' ) { + k = request.params[ k.substring( 1 ) ]; + } + o = o[ k ]; + if ( o === void 0 ) { + break; + } + } + debug( 'Performing assignment...' ); + try { + o[ prop ] = value; + } catch ( err ) { + debug( 'Encountered an error when attempting to assign value. Error: %s', err.message ); + return next({ + 'statusCode': 400, + 'error': 'Bad Request', + 'message': format( 'Invalid value: %s. Error: %s', body, err.message ) + }); + } + debug( 'Successfully performed assignment.' ); + next(); + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware_sequence.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware_sequence.js new file mode 100644 index 000000000000..559f9a6c8b84 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/middleware_sequence.js @@ -0,0 +1,88 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isFunctionArray = require( '@stdlib/assert/is-function-array' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Returns a reusable middleware function. +* +* @param {FunctionArray} fcns - array of middleware functions +* @param {Callback} errback - callback to invoke upon encountering an error +* @throws {TypeError} first argument must be an array of functions +* @throws {TypeError} second argument must be a function +* @returns {Function} middleware function +*/ +function factory( fcns, errback ) { + if ( !isFunctionArray( fcns ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a function array. Value: `%s`.', fcns ) ); + } + if ( !isFunction( errback ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', errback ) ); + } + return middleware; + + /** + * Executes middleware functions in order. + * + * @private + * @param {Object} request - request object + * @param {Object} response - response object + * @param {Callback} [done] - callback to invoke upon completion + * @returns {void} + */ + function middleware( request, response, done ) { + var self = this; // eslint-disable-line no-invalid-this + var idx = -1; + return next(); + + /** + * Executes the next middleware function. + * + * @private + * @param {(Error|null)} error - error object + * @returns {void} + */ + function next() { + // Check for an error... + if ( arguments[ 0 ] ) { + return errback( arguments[ 0 ], request, response, next ); + } + // Update the counter and check if we have run all functions... + idx += 1; + if ( idx >= fcns.length ) { + return ( done ) ? done() : void 0; + } + // Call the next middleware function: + fcns[ idx ].call( self, request, response, next ); + } + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/router.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/router.js new file mode 100644 index 000000000000..e944b6087f16 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/router.js @@ -0,0 +1,201 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); + + +// VARIABLES // + +var debug = logger( 'plot:view:browser:router' ); +var RE_HAS_PARAMS = /:/; + + +// FUNCTIONS // + +/** +* Sends a 404 response. +* +* @private +* @param {IncomingMessage} request - HTTP request object +* @param {ServerResponse} response - HTTP response object +*/ +function notFound( request, response ) { + debug( 'Sending 404 response...' ); + response.statusCode = 404; + response.end(); +} + +/** +* Converts a parameterized URL to a route object. +* +* @private +* @param {string} url - input URL +* @returns {Object} route object +*/ +function parameterize( url ) { + var parts; + var names; + var re; + var p; + var i; + + // WARN: the following is a naive implementation which assumes simple parameterized URLs (e.g., `/foo/bar/:beep/:boop/biz`) + + parts = url.split( '/' ); + names = []; + for ( i = 0; i < parts.length; i++ ) { + p = parts[ i ]; + if ( p[ 0 ] === ':' ) { + names.push( p.substring( 1 ) ); + parts[ i ] = '([^/]+)'; + } + } + re = parts.join( '/' ); + if ( re[ 0 ] === '/' ) { + re = '\\' + re; + } + if ( re[ re.length-1 ] === '/' ) { + re = re.substring( re.length-1 ) + '\\/'; + } + re = '^' + re + '$'; + return { + 'regexp': new RegExp( re ), + 'names': names + }; +} + + +// MAIN // + +/** +* Router constructor. +* +* @private +* @constructor +* @returns {Router} router instance +*/ +function Router() { + if ( !( this instanceof Router ) ) { + return new Router(); + } + setNonEnumerableReadOnly( this, '_routes', { + 'GET': [], + 'POST': [] + }); + return this; +} + +/** +* Registers a route. +* +* @name route +* @memberof Router.prototype +* @type {Function} +* @param {Object} schema - route schema +* @returns {Router} router instance +*/ +setNonEnumerableReadOnly( Router.prototype, 'route', function route( schema ) { + var type; + var url; + + debug( 'Registering a new route: %s %s', schema.method, schema.url ); + if ( RE_HAS_PARAMS.test( schema.url ) ) { + type = 'params'; + url = parameterize( schema.url ); + } else { + type = 'path'; + url = schema.url; + } + this._routes[ schema.method ].push( [ type, url, schema.handler ] ); + return this; +}); + +/** +* Resolves a request handler. +* +* @name resolve +* @memberof Router.prototype +* @type {Function} +* @param {IncomingMessage} request - HTTP request object +* @returns {Function} request handler +*/ +setNonEnumerableReadOnly( Router.prototype, 'resolve', function resolve( request ) { + var method; + var names; + var match; + var table; + var entry; + var url; + var fcn; + var i; + var j; + + method = request.method; + url = request.url; + + // Initialize an object for storing route parameters: + request.params = {}; + + debug( 'Resolving request handler for %s %s', method, url ); + table = this._routes[ method ]; + if ( !table ) { + debug( 'Unable to resolve request handler.' ); + return notFound; + } + for ( i = 0; i < table.length; i++ ) { + entry = table[ i ]; + + // Case: URL matches an exact route path + if ( entry[ 0 ] === 'path' ) { + if ( url === entry[ 1 ] ) { + fcn = entry[ 2 ]; + break; + } + } + // Case: URL matches a parameterized route + else if ( entry[ 0 ] === 'params' ) { + match = url.match( entry[ 1 ].regexp ); + if ( match ) { + names = entry[ 1 ].names; + for ( j = 0; j < names.length; j++ ) { + request.params[ names[ j ] ] = match[ j+1 ]; + } + fcn = entry[ 2 ]; + break; + } + } + } + if ( !fcn ) { + debug( 'Unable to resolve request handler.' ); + return notFound; + } + debug( 'Successfully resolved request handler.' ); + return fcn; +}); + + +// EXPORTS // + +module.exports = Router; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/ack.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/ack.js new file mode 100644 index 000000000000..069c6b782a10 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/ack.js @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); + + +// VARIABLES // + +var debug = logger( 'plot:view:browser:routes:ack' ); + + +// MAIN // + +/** +* Callback invoked upon receiving an HTTP request. +* +* @private +* @param {Object} request - request object +* @param {Object} response - response object +* @param {Callback} next - callback to invoke upon completion +* @returns {void} +*/ +function handler( request, response, next ) { + var events; + var id; + var N; + var i; + var j; + + id = request.body; + debug( 'Received an ack for event identifier: %s.', id ); + + // Search for the acknowledged last event id... + events = this.events; + N = events.length; + for ( i = N-1; i >= 0; i-- ) { + if ( events[ i ].id === id ) { + break; + } + } + // If we found the identifier in our events database, we can safely remove all events up and including that event from our database... + if ( i >= 0 ) { + debug( 'Performing event database compaction...' ); + N -= i; + for ( j = 0; j <= i; j++ ) { + events[ j ] = events[ i ]; + i += 1; + } + events.length = N; + debug( 'Successfully compacted event database.' ); + } + next(); +} + + +// EXPORTS // + +module.exports = handler; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/index.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/index.js new file mode 100644 index 000000000000..151a0bc34938 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var schema = require( './schema.json' ); +var handler = require( './main.js' ); + + +// MAIN // + +/** +* Defines a route handler for receiving an acknowledgment regarding received events. +* +* @private +* @returns {Object} route declaration +*/ +function route() { + schema.handler = handler; + return schema; +} + + +// EXPORTS // + +module.exports = route; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/main.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/main.js new file mode 100644 index 000000000000..298221c463de --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/main.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var middleware = require( './../../middleware_sequence.js' ); +var allowCredentials = require( './../../middleware/allow-credentials' ); +var body = require( './../../middleware/body' ); +var ok = require( './../../middleware/ok' ); +var onError = require( './../../middleware/error' ); +var ack = require( './ack.js' ); + + +// VARIABLES // + +var steps = [ + allowCredentials, + body, + ack, + ok +]; + + +// MAIN // + +/** +* Request handler for receiving an acknowledgment regarding received events. +* +* @private +* @name handler +* @type {Function} +* @param {Object} request - request object +* @param {Object} response - response object +*/ +var handler = middleware( steps, onError ); + + +// EXPORTS // + +module.exports = handler; diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/schema.json b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/schema.json new file mode 100644 index 000000000000..6db0aeb08ceb --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/ack/schema.json @@ -0,0 +1,12 @@ +{ + "method": "POST", + "url": "/ack", + "schema": { + "response": { + "200": { + "type": "string" + } + } + }, + "handler": null +} diff --git a/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/app/bundle.js b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/app/bundle.js new file mode 100644 index 000000000000..b980e43691de --- /dev/null +++ b/lib/node_modules/@stdlib/plot/base/view/lib/browser/routes/app/bundle.js @@ -0,0 +1,6 @@ +/* @license Apache-2.0 */ + +/* eslint-disable */ + +/* editorconfig-checker-disable-file */ +!function(){R=function(e,t){var r=Object.prototype.toString;e.exports=function(e){var t=r.call(e);return"[object Arguments]"===t||"[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&0<=e.length&&"[object Function]"===r.call(e.callee)}};var R,C,M=function(e){return C||R(C={exports:{},parent:e},C.exports),C.exports},z="function"==typeof Object.defineProperty?Object.defineProperty:null;var U=function(){try{return z({},"x",{}),!0}catch(e){return!1}},D=Object.defineProperty;var N=function(e){return"number"==typeof e};function W(e){for(var t="",r=0;rn.maxWidth&&(n.arg=n.arg.substring(0,n.maxWidth)),n.padZeros?n.arg=$(n.arg,n.width||n.precision,n.padRight):n.width&&(n.arg=le(n.arg,n.width,n.padRight)),o+=n.arg||"",a+=1}return o},he=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;var ye=function(e){for(var t,r,n,i=[],o=0,a=he.exec(e);a;)(t=e.slice(o,he.lastIndex-a[0].length)).length&&i.push(t),"%"===a[6]?i.push("%"):i.push((n=void 0,n={mapping:(r=a)[1]?parseInt(r[1],10):void 0,flags:r[2],width:r[3],precision:r[5],specifier:r[6]},"."===r[4]&&void 0===r[5]&&(n.precision="1"),n)),o=he.lastIndex,a=he.exec(e);return(t=e.slice(o)).length&&i.push(t),i};var de=function(e){return"string"==typeof e};var h=function e(t){var r,n;if(!de(t))throw new TypeError(e("invalid argument. First argument must be a string. Value: `%s`.",t));for(r=[ye(t)],n=1;n=r.length?(l=!!(c=d(o,s)))&&"get"in c&&!("originalValue"in c.get)?c.get:o[s]:(l=Jt(o,s),o[s]),l&&!a&&(Qt[f]=o)}}return o},xr=$t([Er("%String.prototype.indexOf%")]),_r=ht(),Tr=er("Object.prototype.toString"),Sr=function(e){return!(_r&&e&&"object"==typeof e&&Symbol.toStringTag in e)&&"[object Arguments]"===Tr(e)},bt=function(){return Sr(arguments)}(),vt=(Sr.isLegacyArguments=tr,bt?Sr:tr),Ar=ht()?(rr=er("RegExp.prototype.exec"),nr={},ir={toString:wt=function(){throw nr},valueOf:wt},"symbol"==typeof Symbol.toPrimitive&&(ir[Symbol.toPrimitive]=wt),function(e){if(!e||"object"!=typeof e)return!1;var t=d(e,"lastIndex");if(!(t&&Jt(t,"value")))return!1;try{rr(e,ir)}catch(e){return e===nr}}):(or=er("Object.prototype.toString"),ar="[object RegExp]",function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&or(e)===ar}),Or=er("RegExp.prototype.exec"),jr=function(){if(void 0===ur)try{ur=Function("return function* () {}")().constructor}catch(e){ur=!1}return ur},kr=(t=>{if(Ar(t))return function(e){return null!==Or(t,e)};throw new p("`regex` must be a RegExp")})(/^\s*(?:function)?\*/),Fr=ht(),Pr=er("Object.prototype.toString"),Vr=er("Function.prototype.toString"),Lr=Function.prototype.toString,Ir="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof Ir&&"function"==typeof Object.defineProperty)try{lr=Object.defineProperty({},"length",{get:function(){throw sr}}),sr={},Ir(function(){throw 42},null,lr)}catch(e){e!==sr&&(Ir=null)}else Ir=null;function Br(e){try{return Cr(e)?!1:(Lr.call(e),!0)}catch(e){return!1}}var Rr=/^\s*class\b/,Cr=function(e){try{var t=Lr.call(e);return Rr.test(t)}catch(e){return!1}},Mr=Object.prototype.toString,zr="[object Object]",Ur="[object HTMLAllCollection]",Dr="[object HTML document.all class]",Nr="[object HTMLCollection]",Wr="function"==typeof Symbol&&!!Symbol.toStringTag,$r=!(0 in[,]),Gr=function(){return!1},Hr=("object"==typeof document&&Mr.call(document.all)===Mr.call(document.all)&&(Gr=function(e){if(($r||!e)&&(void 0===e||"object"==typeof e))try{var t=Mr.call(e);return(t===Ur||t===Dr||t===Nr||t===zr)&&null==e("")}catch(e){}return!1}),Ir?function(e){if(Gr(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{Ir(e,null,lr)}catch(e){if(e!==sr)return!1}return!Cr(e)&&Br(e)}:function(e){var t;return!!Gr(e)||!!e&&!("function"!=typeof e&&"object"!=typeof e||!Wr&&(Cr(e)||"[object Function]"!==(t=Mr.call(e))&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t)))&&Br(e)}),qr=Object.prototype.toString,Yr=Object.prototype.hasOwnProperty,Jr=function(e,t,r){for(var n=0,i=e.length;n{var r;return b(t)?e.stylize("undefined","undefined"):m(t)?(r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'",e.stylize(r,"string")):g(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):d(t)?e.stylize("null","null"):void 0})(t,r);if(e)return e;var i,e=Object.keys(r),o=(i={},e.forEach(function(e,t){i[e]=!0}),i);if(t.showHidden&&(e=Object.getOwnPropertyNames(r)),E(r)&&(0<=e.indexOf("message")||0<=e.indexOf("description")))return c(r);if(0===e.length){if(x(r))return a=r.name?": "+r.name:"",t.stylize("[Function"+a+"]","special");if(v(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(w(r))return t.stylize(Date.prototype.toString.call(r),"date");if(E(r))return c(r)}var a="",u=!1,l=["{","}"];if(h(r)&&(u=!0,l=["[","]"]),x(r)&&(a=" [Function"+(r.name?": "+r.name:"")+"]"),v(r)&&(a=" "+RegExp.prototype.toString.call(r)),w(r)&&(a=" "+Date.prototype.toUTCString.call(r)),E(r)&&(a=" "+c(r)),0===e.length&&(!u||0==r.length))return l[0]+a+l[1];if(n<0)return v(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special");t.seen.push(r),s=u?((t,r,n,i,e)=>{for(var o=[],a=0,u=r.length;a{if("undefined"!=typeof window)for(var e in window)try{if(!ai["$"+e]&&Qn.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{oi(window[e])}catch(e){return!0}}catch(e){return!0}return!1})(),li=function(e){if("undefined"==typeof window||!ui)return oi(e);try{return oi(e)}catch(e){return!1}},qo=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===ei.call(e),n=ti(e),i=t&&"[object String]"===ei.call(e),o=[];if(!t&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var a=ni&&r;if(i&&0{var r;return b(t)?e.stylize("undefined","undefined"):m(t)?(r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'",e.stylize(r,"string")):g(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):d(t)?e.stylize("null","null"):void 0})(t,r);if(e)return e;var i,e=Object.keys(r),o=(i={},e.forEach(function(e,t){i[e]=!0}),i);if(t.showHidden&&(e=Object.getOwnPropertyNames(r)),E(r)&&(0<=e.indexOf("message")||0<=e.indexOf("description")))return c(r);if(0===e.length){if(x(r))return a=r.name?": "+r.name:"",t.stylize("[Function"+a+"]","special");if(v(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(w(r))return t.stylize(Date.prototype.toString.call(r),"date");if(E(r))return c(r)}var a="",u=!1,l=["{","}"];if(h(r)&&(u=!0,l=["[","]"]),x(r)&&(a=" [Function"+(r.name?": "+r.name:"")+"]"),v(r)&&(a=" "+RegExp.prototype.toString.call(r)),w(r)&&(a=" "+Date.prototype.toUTCString.call(r)),E(r)&&(a=" "+c(r)),0===e.length&&(!u||0==r.length))return l[0]+a+l[1];if(n<0)return v(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special");t.seen.push(r),s=u?((t,r,n,i,e)=>{for(var o=[],a=0,u=r.length;a{var t;try{e()}catch(e){t=e}return t})(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!t&&l(t,r,"Missing expected exception"+n);var i="string"==typeof n,o=!e&&t&&!r;if((!e&&A.isError(t)&&i&&f(t,r)||o)&&l(t,r,"Got unwanted exception"+n),e&&t&&r&&!f(t,r)||!e&&t)throw t}o.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=a(u((r=this).actual),128)+" "+r.operator+" "+a(u(r.expected),128),this.generatedMessage=!0);var t,r=e.stackStartFunction||l;Error.captureStackTrace?Error.captureStackTrace(this,r):(e=new Error).stack&&(e=e.stack,t=i(r),0<=(t=e.indexOf("\n"+t))&&(t=e.indexOf("\n",t+1),e=e.substring(t+1)),this.stack=e)},A.inherits(o.AssertionError,Error),o.fail=l,o.ok=s,o.equal=function(e,t,r){e!=t&&l(e,t,r,"==",o.equal)},o.notEqual=function(e,t,r){e==t&&l(e,t,r,"!=",o.notEqual)},o.deepEqual=function(e,t,r){b(e,t,!1)||l(e,t,r,"deepEqual",o.deepEqual)},o.deepStrictEqual=function(e,t,r){b(e,t,!0)||l(e,t,r,"deepStrictEqual",o.deepStrictEqual)},o.notDeepEqual=function(e,t,r){b(e,t,!1)&&l(e,t,r,"notDeepEqual",o.notDeepEqual)},o.notDeepStrictEqual=function e(t,r,n){b(t,r,!0)&&l(t,r,n,"notDeepStrictEqual",e)},o.strictEqual=function(e,t,r){e!==t&&l(e,t,r,"===",o.strictEqual)},o.notStrictEqual=function(e,t,r){e===t&&l(e,t,r,"!==",o.notStrictEqual)},o.throws=function(e,t,r){c(!0,e,t,r)},o.doesNotThrow=function(e,t,r){c(!1,e,t,r)},o.ifError=function(e){if(e)throw e},o.strict=e(function e(t,r){t||l(t,!0,r,"==",e)},o,{equal:o.strictEqual,deepEqual:o.deepStrictEqual,notEqual:o.notStrictEqual,notDeepEqual:o.notDeepStrictEqual}),o.strict.strict=o.strict;var w=Object.keys||function(e){var t,r=[];for(t in e)n.call(e,t)&&r.push(t);return r}}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),{}),Si=(!function(l){!function(){function r(){return(new Date).getTime()}for(var t=Array.prototype.slice,n={},i=void 0!==l&&l.console?l.console:"undefined"!=typeof window&&window.console?window.console:{},e=[[function(){},"log"],[function(){i.log.apply(i,arguments)},"info"],[function(){i.log.apply(i,arguments)},"warn"],[function(){i.warn.apply(i,arguments)},"error"],[function(e){n[e]=r()},"time"],[function(e){var t=n[e];if(!t)throw new Error("No such label: "+e);delete n[e];t=r()-t;i.log(e+": "+t+"ms")},"timeEnd"],[function(){var e=new Error;e.name="Trace",e.message=k.format.apply(null,arguments),i.error(e.stack)},"trace"],[function(e){i.log(k.inspect(e)+"\n")},"dir"],[function(e){e||(e=t.call(arguments,1),_i.ok(!1,k.format.apply(null,e)))},"assert"]],o=0;o