From 4c53886b099ee359f779543aa6a1c9e95e65d84e Mon Sep 17 00:00:00 2001 From: orthodox-64 Date: Sun, 17 May 2026 15:00:25 +0530 Subject: [PATCH] feat: add plot/vega/legend/orientations --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../plot/vega/legend/orientations/README.md | 117 ++++++++++++++++++ .../orientations/benchmark/benchmark.js | 48 +++++++ .../vega/legend/orientations/docs/repl.txt | 17 +++ .../legend/orientations/docs/types/index.d.ts | 35 ++++++ .../legend/orientations/docs/types/test.ts | 32 +++++ .../legend/orientations/examples/index.js | 40 ++++++ .../vega/legend/orientations/lib/data.json | 11 ++ .../vega/legend/orientations/lib/index.js | 40 ++++++ .../plot/vega/legend/orientations/lib/main.js | 44 +++++++ .../vega/legend/orientations/package.json | 64 ++++++++++ .../vega/legend/orientations/test/test.js | 54 ++++++++ 11 files changed, 502 insertions(+) create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/README.md create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/examples/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/data.json create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/index.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/main.js create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/package.json create mode 100644 lib/node_modules/@stdlib/plot/vega/legend/orientations/test/test.js diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/README.md b/lib/node_modules/@stdlib/plot/vega/legend/orientations/README.md new file mode 100644 index 000000000000..d284b96ef7d3 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/README.md @@ -0,0 +1,117 @@ + + +# legendOrientations + +> List of supported Vega legend orientations. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var legendOrientations = require( '@stdlib/plot/vega/legend/orientations' ); +``` + +#### legendOrientations() + +Returns a list of legend orientations. + +```javascript +var out = legendOrientations(); +// returns [ 'bottom', 'bottom-left', 'bottom-right', 'left', 'none', 'right', 'top', 'top-left', 'top-right' ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var contains = require( '@stdlib/array/base/assert/contains' ).factory; +var legendOrientations = require( '@stdlib/plot/vega/legend/orientations' ); + +var isLegendOrientation = contains( legendOrientations() ); + +var bool = isLegendOrientation( 'left' ); +// returns true + +bool = isLegendOrientation( 'top-right' ); +// returns true + +bool = isLegendOrientation( 'beep' ); +// returns false + +bool = isLegendOrientation( 'boop' ); +// returns false +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/benchmark/benchmark.js b/lib/node_modules/@stdlib/plot/vega/legend/orientations/benchmark/benchmark.js new file mode 100644 index 000000000000..541f7d51d62a --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/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 legendOrientations = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = legendOrientations(); + 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/vega/legend/orientations/docs/repl.txt b/lib/node_modules/@stdlib/plot/vega/legend/orientations/docs/repl.txt new file mode 100644 index 000000000000..3d585247b3b6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/docs/repl.txt @@ -0,0 +1,17 @@ + +{{alias}}() + Returns a list of legend orientations. + + Returns + ------- + out: Array + List of legend orientations. + + Examples + -------- + > var out = {{alias}}() + [ 'bottom', 'bottom-left', 'bottom-right', ... ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/docs/types/index.d.ts b/lib/node_modules/@stdlib/plot/vega/legend/orientations/docs/types/index.d.ts new file mode 100644 index 000000000000..5cbe9f0d40e8 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/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 legend orientations. +* +* @returns list of legend orientations +* +* @example +* var list = legendOrientations(); +* // returns [ 'bottom', 'bottom-left', 'bottom-right', 'left', 'none', 'right', 'top', 'top-left', 'top-right' ] +*/ +declare function legendOrientations(): Array; + + +// EXPORTS // + +export = legendOrientations; diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/docs/types/test.ts b/lib/node_modules/@stdlib/plot/vega/legend/orientations/docs/types/test.ts new file mode 100644 index 000000000000..6198358cc81b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/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 legendOrientations = require( './index' ); + + +// TESTS // + +// The function returns an array of strings... +{ + legendOrientations(); // $ExpectType string[] +} + +// The compiler throws an error if the function is provided any arguments... +{ + legendOrientations( 9 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/examples/index.js b/lib/node_modules/@stdlib/plot/vega/legend/orientations/examples/index.js new file mode 100644 index 000000000000..34566eb52fee --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/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 legendOrientations = require( './../lib' ); + +var isLegendOrientation = contains( legendOrientations() ); + +var bool = isLegendOrientation( 'left' ); +console.log( bool ); +// => true + +bool = isLegendOrientation( 'top-right' ); +console.log( bool ); +// => true + +bool = isLegendOrientation( 'beep' ); +console.log( bool ); +// => false + +bool = isLegendOrientation( 'boop' ); +console.log( bool ); +// => false diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/data.json b/lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/data.json new file mode 100644 index 000000000000..b87b112015ba --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/data.json @@ -0,0 +1,11 @@ +[ + "bottom", + "bottom-left", + "bottom-right", + "left", + "none", + "right", + "top", + "top-left", + "top-right" +] diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/index.js b/lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/index.js new file mode 100644 index 000000000000..620cd9e88982 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/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 legend orientations. +* +* @module @stdlib/plot/vega/legend/orientations +* +* @example +* var legendOrientations = require( '@stdlib/plot/vega/legend/orientations' ); +* +* var out = legendOrientations(); +* // returns [ 'bottom', 'bottom-left', 'bottom-right', 'left', 'none', 'right', 'top', 'top-left', 'top-right' ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/main.js b/lib/node_modules/@stdlib/plot/vega/legend/orientations/lib/main.js new file mode 100644 index 000000000000..e0378ec3206e --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/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 legend orientations. +* +* @returns {StringArray} list of legend orientations +* +* @example +* var out = legendOrientations(); +* // returns [ 'bottom', 'bottom-left', 'bottom-right', 'left', 'none', 'right', 'top', 'top-left', 'top-right' ] +*/ +function legendOrientations() { + return DATA.slice(); +} + + +// EXPORTS // + +module.exports = legendOrientations; diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/package.json b/lib/node_modules/@stdlib/plot/vega/legend/orientations/package.json new file mode 100644 index 000000000000..e93808345340 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/plot/vega/legend/orientations", + "version": "0.0.0", + "description": "List of supported Vega legend orientations.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "vega", + "legend", + "orientation", + "orientations", + "utilities", + "utility", + "utils", + "util" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/plot/vega/legend/orientations/test/test.js b/lib/node_modules/@stdlib/plot/vega/legend/orientations/test/test.js new file mode 100644 index 000000000000..4fa0246d122d --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/legend/orientations/test/test.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 tape = require( 'tape' ); +var legendOrientations = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof legendOrientations, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a list of legend orientations', function test( t ) { + var expected; + var actual; + + expected = [ + 'bottom', + 'bottom-left', + 'bottom-right', + 'left', + 'none', + 'right', + 'top', + 'top-left', + 'top-right' + ]; + actual = legendOrientations(); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +});