-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add plot/vega/scale/quantile
#9775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gururaj1512
wants to merge
2
commits into
stdlib-js:refactor/plot
Choose a base branch
from
gururaj1512:refactor/plot-vega-scale-quantile
base: refactor/plot
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+352
−0
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
lib/node_modules/@stdlib/plot/vega/scale/quantile/examples/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| var DiscretizingScale = require( './../lib' ); | ||
|
|
||
| var scale = new DiscretizingScale({ | ||
| 'name': 'colorScale' | ||
| }); | ||
|
|
||
| console.log( scale.toJSON() ); |
42 changes: 42 additions & 0 deletions
42
lib/node_modules/@stdlib/plot/vega/scale/quantile/lib/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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'; | ||
|
|
||
| /** | ||
| * Quantile scale constructor. | ||
| * | ||
| * @module @stdlib/plot/vega/scale/quantile | ||
| * | ||
| * @example | ||
| * var QuantileScale = require( '@stdlib/plot/vega/scale/quantile' ); | ||
| * | ||
| * var scale = new QuantileScale({ | ||
| * 'name': 'colorScale' | ||
| * }); | ||
| * // returns <QuantileScale> | ||
| */ | ||
|
|
||
| // MODULES // | ||
|
|
||
| var main = require( './main.js' ); | ||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| module.exports = main; |
110 changes: 110 additions & 0 deletions
110
lib/node_modules/@stdlib/plot/vega/scale/quantile/lib/main.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /** | ||
| * @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 isObject = require( '@stdlib/assert/is-object' ); | ||
| var hasProp = require( '@stdlib/assert/has-property' ); | ||
| var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); | ||
| var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); | ||
| var inherit = require( '@stdlib/utils/inherit' ); | ||
| var DiscretizingScale = require( '@stdlib/plot/vega/scale/discretizing' ); | ||
| var format = require( '@stdlib/string/format' ); | ||
| var TYPE = require( './type/type.js' ); | ||
| var getType = require( './type/get.js' ); | ||
| var setType = require( './type/set.js' ); | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| /** | ||
| * Quantile scale constructor. | ||
| * | ||
| * @constructor | ||
| * @param {Options} options - constructor options | ||
| * @param {string} options.name - scale name | ||
| * @param {(Collection|Object|Signal)} [options.domain] - domain of associated data values | ||
| * @param {Collection} [options.domainRaw] - array of raw domain values which overrides the `domain` property | ||
| * @param {(string|Object)} [options.interpolate] - scale range interpolation method | ||
| * @param {(Collection|Object|Signal|string)} [options.range] - scale range | ||
| * @param {boolean} [options.reverse=false] - boolean indicating whether to reverse the order of the scale range | ||
| * @throws {TypeError} options argument must be an object | ||
| * @throws {Error} must provide valid options | ||
| * @returns {QuantileScale} scale instance | ||
| * | ||
| * @example | ||
| * var scale = new QuantileScale({ | ||
| * 'name': 'colorScale' | ||
| * }); | ||
| * // returns <QuantileScale> | ||
| */ | ||
| function QuantileScale( options ) { | ||
| if ( !( this instanceof QuantileScale ) ) { | ||
| return new QuantileScale( options ); | ||
| } | ||
| if ( !isObject( options ) ) { | ||
| throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); | ||
| } | ||
| if ( hasProp( options, 'type' ) && options.type !== TYPE ) { | ||
| throw new TypeError( format( 'invalid argument. `%s` option must be equal to "%s". Option: `%s`.', 'type', TYPE, options.type ) ); | ||
| } | ||
| DiscretizingScale.call( this, options ); | ||
| this._type = TYPE; | ||
| return this; | ||
| } | ||
|
|
||
| /* | ||
| * Inherit from a parent prototype. | ||
| */ | ||
| inherit( QuantileScale, DiscretizingScale ); | ||
|
|
||
| /** | ||
| * Constructor name. | ||
| * | ||
| * @private | ||
| * @name name | ||
| * @memberof QuantileScale | ||
| * @readonly | ||
| * @type {string} | ||
| */ | ||
| setReadOnly( QuantileScale, 'name', 'QuantileScale' ); | ||
|
|
||
| /** | ||
| * Scale type. | ||
| * | ||
| * @name type | ||
| * @memberof QuantileScale.prototype | ||
| * @type {string} | ||
| * @default 'quantile' | ||
| * | ||
| * @example | ||
| * var scale = new QuantileScale({ | ||
| * 'name': 'colorScale' | ||
| * }); | ||
| * | ||
| * var v = scale.type; | ||
| * // returns 'quantile' | ||
| */ | ||
| setReadWriteAccessor( QuantileScale.prototype, 'type', getType, setType ); | ||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| module.exports = QuantileScale; | ||
41 changes: 41 additions & 0 deletions
41
lib/node_modules/@stdlib/plot/vega/scale/quantile/lib/type/get.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 TYPE = require( './type.js' ); | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| /** | ||
| * Returns the scale type. | ||
| * | ||
| * @private | ||
| * @returns {string} scale type | ||
| */ | ||
| function get() { | ||
| return TYPE; | ||
| } | ||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| module.exports = get; |
46 changes: 46 additions & 0 deletions
46
lib/node_modules/@stdlib/plot/vega/scale/quantile/lib/type/set.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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'; | ||
|
|
||
| // MODULES // | ||
|
|
||
| var format = require( '@stdlib/string/format' ); | ||
| var TYPE = require( './type.js' ); | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| /** | ||
| * Sets the scale type. | ||
| * | ||
| * @private | ||
| * @param {string} value - input value | ||
| * @throws {TypeError} must be a valid scale | ||
| * @returns {void} | ||
| */ | ||
| function set( value ) { | ||
| if ( value !== TYPE ) { | ||
| throw new TypeError( format( 'invalid assignment. `%s` must be equal to "%s". Value: `%s`.', 'type', TYPE, value ) ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| module.exports = set; |
23 changes: 23 additions & 0 deletions
23
lib/node_modules/@stdlib/plot/vega/scale/quantile/lib/type/type.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * @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'; | ||
|
|
||
| // EXPORTS // | ||
|
|
||
| module.exports = 'quantile'; |
63 changes: 63 additions & 0 deletions
63
lib/node_modules/@stdlib/plot/vega/scale/quantile/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| { | ||
| "name": "@stdlib/plot/vega/scale/quantile", | ||
| "version": "0.0.0", | ||
| "description": "Quantile scale constructor.", | ||
| "license": "Apache-2.0", | ||
| "author": { | ||
| "name": "The Stdlib Authors", | ||
| "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" | ||
| }, | ||
| "contributors": [ | ||
| { | ||
| "name": "The Stdlib Authors", | ||
| "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" | ||
| } | ||
| ], | ||
| "main": "./lib", | ||
| "directories": { | ||
| "benchmark": "./benchmark", | ||
| "doc": "./docs", | ||
| "example": "./examples", | ||
| "lib": "./lib", | ||
| "test": "./test" | ||
| }, | ||
| "types": "./docs/types", | ||
| "scripts": {}, | ||
| "homepage": "https://github.com/stdlib-js/stdlib", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git://github.com/stdlib-js/stdlib.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/stdlib-js/stdlib/issues" | ||
| }, | ||
| "dependencies": {}, | ||
| "devDependencies": {}, | ||
| "engines": { | ||
| "node": ">=0.10.0", | ||
| "npm": ">2.7.0" | ||
| }, | ||
| "os": [ | ||
| "aix", | ||
| "darwin", | ||
| "freebsd", | ||
| "linux", | ||
| "macos", | ||
| "openbsd", | ||
| "sunos", | ||
| "win32", | ||
| "windows" | ||
| ], | ||
| "keywords": [ | ||
| "stdlib", | ||
| "plot", | ||
| "vega", | ||
| "scale", | ||
| "discrete", | ||
| "categorical", | ||
| "quantile", | ||
| "constructor", | ||
| "ctor" | ||
| ], | ||
| "__stdlib__": {} | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This properties here are same to the
ordinalscale. How to determine properties?There is nothing mentioned in the quantile scales documentation. Also why ordinal scale do not have all general properties of scales