Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';

var BinOrdinalScale = require( './../lib' );

var scale = new BinOrdinalScale({
'name': 'color',
'bins': [0, 5, 10, 15, 20]
});

console.log( scale.toJSON() );
Original file line number Diff line number Diff line change
@@ -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 copy = require( '@stdlib/utils/copy' );
var prop = require( './properties.js' );


// MAIN //

/**
* Returns bin boundaries of the scale domain.
*
* @private
* @returns {(Array|Object|void)} bin boundaries
*/
function get() {
return copy( this[ prop.private ] ); // FIXME: can we avoid using `utils/copy` here?

Check warning on line 38 in lib/node_modules/@stdlib/plot/vega/scale/bin-ordinal/lib/bins/get.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'fixme' comment: 'FIXME: can we avoid using `utils/copy`...'
}


// EXPORTS //

module.exports = get;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @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 property2object = require( '@stdlib/plot/vega/base/property2object' );


// MAIN //

var obj = property2object( 'bins' );


// EXPORTS //

module.exports = obj;
Original file line number Diff line number Diff line change
@@ -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.
*/

/* eslint-disable no-invalid-this */

'use strict';

// MODULES //

var logger = require( 'debug' );
var isCollection = require( '@stdlib/assert/is-collection' );
var isUndefined = require( '@stdlib/assert/is-undefined' );
var isObject = require( '@stdlib/assert/is-object' );
var copyArray = require( '@stdlib/array/base/copy' );
var copy = require( '@stdlib/utils/copy' );
var format = require( '@stdlib/string/format' );
var changeEvent = require( './../change_event.js' );
var prop = require( './properties.js' );


// VARIABLES //

var debug = logger( 'vega:bin-ordinal-scale:set:'+prop.name );


// MAIN //

/**
* Sets bin boundaries over the scale domain.
*
* ## Notes
*
* - Providing `undefined` "unsets" the configured value.

Check warning on line 48 in lib/node_modules/@stdlib/plot/vega/scale/bin-ordinal/lib/bins/set.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "unsets"
*
* @private
* @param {(Collection|Object|Signal|void)} value - input value
* @throws {TypeError} must be either an array-like object or an object
* @returns {void}
*/
function set( value ) {
var isArr = isCollection( value );
if ( !isArr && !isObject( value ) && !isUndefined( value ) ) {
throw new TypeError( format( 'invalid assignment. `%s` must be either an array-like object or an object. Value: `%s`.', prop.name, value ) );
}

// FIXME: should we perform a deep equal check here in order to avoid a potential false positive change event?

Check warning on line 61 in lib/node_modules/@stdlib/plot/vega/scale/bin-ordinal/lib/bins/set.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'fixme' comment: 'FIXME: should we perform a deep equal...'

// FIXME: can we do further validation of objects (e.g., data reference or signal reference)?

Check warning on line 63 in lib/node_modules/@stdlib/plot/vega/scale/bin-ordinal/lib/bins/set.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'fixme' comment: 'FIXME: can we do further validation of...'

if ( isArr ) {
value = copyArray( value );
} else {
value = copy( value );
}
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
this[ prop.private ] = value;
this.emit( 'change', changeEvent( prop.name ) );
}


// EXPORTS //

module.exports = set;
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';

// MAIN //

/**
* Returns a new change event object.
*
* @private
* @param {string} property - property name
* @returns {Object} event object
*/
function event( property ) { // eslint-disable-line stdlib/no-redeclare
return {
'type': 'update',
'source': 'scale',
'property': property
};
}


// EXPORTS //

module.exports = event;
42 changes: 42 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/scale/bin-ordinal/lib/index.js
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';

/**
* Bin-Ordinal scale constructor.
*
* @module @stdlib/plot/vega/scale/bin-ordinal
*
* @example
* var BinOrdinalScale = require( '@stdlib/plot/vega/scale/bin-ordinal' );
*
* var scale = new BinOrdinalScale({
* 'name': 'color'
* });
* // returns <BinOrdinalScale>
*/

// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
Loading
Loading