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,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';

var uniform = require( '@stdlib/random/uniform' );
var Float64Vector = require( '@stdlib/ndarray/vector/float64' );
var Scatterplot = require( './../lib' );

var a = new Float64Vector( [ 10.0, 20.0, 30.0, 40.0, 50.0 ] );
var b = new Float64Vector( [ 20.0, 30.0, 40.0, 50.0, 60.0 ] );

var y = uniform( [ 100, 5 ], a, b );

var chart = new Scatterplot( y, {
'symbols': [ 'o', 'square' ],
'symbolOpacity': [ 1.0, 0.4 ],
'symbolSize': [ 100, 50 ],
'edgeColors': [ '#000' ],
'edgeWidth': [ 1 ],
'legend': true
});
console.log( chart.toJSON() );

// Render "hollow" symbols by "unsetting" the symbol colors:
chart.colors = void 0;
console.log( chart.toJSON() );
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': 'visualization',
'property': property
};
}


// EXPORTS //

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

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

'use strict';

// MODULES //

var copy = require( '@stdlib/array/base/copy' );
var prop = require( './properties.js' );

Check warning on line 26 in lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/get.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

only the `private` property of the required module is used; require the property directly


// MAIN //

/**
* Returns the symbol colors.
*
* ## Notes
*
* - If symbol colors are "unset", the function returns `undefined`.
*
* @private
* @returns {(Array<string>|void)} colors
*/
function get() {
var v = this[ prop.private ];
if ( v === void 0 ) {
return v;
}
return copy( v );
}


// 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( 'colors' );


// EXPORTS //

module.exports = obj;
101 changes: 101 additions & 0 deletions lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* @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 isString = require( '@stdlib/assert/is-string' ).isPrimitive;
var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' );
var copy = require( '@stdlib/array/base/copy' );
var join = require( '@stdlib/array/base/join' );
var format = require( '@stdlib/string/format' );
var prop = require( './properties.js' );


// VARIABLES //

var debug = logger( 'scatterplot:set:'+prop.name );


// MAIN //

/**
* Sets symbol colors.
*
* ## Notes
*
* - Providing `undefined` "unsets" symbol colors, in which case symbols are rendered without a fill (i.e., as "hollow" symbols).

Check warning on line 47 in lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/colors/set.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unknown word: "unsets"
*
* @private
* @param {(Array<string>|string|void)} value - input value
* @throws {TypeError} must be a string, an array of strings, or undefined
* @returns {void}
*/
function set( value ) {
var isStr;
var curr;

curr = this[ prop.private ];

// Case: unset the symbol colors...
if ( value === void 0 ) {
if ( curr === void 0 ) {
return;
}
debug( 'Current value: [%s]. New value: undefined.', join( curr, ', ' ) );

// Cache the value before updating the scale to ensure consistent state:
this[ prop.private ] = value;

// Clear the edge color range, as the scale should no longer resolve values:
this.colorScale.range = [];
return;
}
isStr = isString( value );
if ( !isStr && !isStringArray( value ) ) {
throw new TypeError( format( 'invalid assignment. `%s` must be a string, an array of strings, or undefined. Value: `%s`.', prop.name, value ) );
}
if ( isStr ) {
value = [ value ];
}
if ( curr === void 0 ) {
debug( 'Current value: undefined. New value: [%s].', join( value, ', ' ) );
} else if ( hasEqualValues( value, curr ) ) {
return;
} else {
debug( 'Current value: [%s]. New value: [%s].', join( curr, ', ' ), join( value, ', ' ) );
}
// Perform a defensive copy as we will be caching the specified symbol colors:
value = copy( value );

// Cache the value before updating the scale to ensure consistent state:
this[ prop.private ] = value;

// Update the edge color range:
this.colorScale.range = value;
}


// EXPORTS //

module.exports = set;
69 changes: 69 additions & 0 deletions lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* @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' );


// MAIN //

/**
* Returns defaults.
*
* @private
* @returns {Object} defaults
*
* @example
* var obj = defaults();
* // returns {...}
*/
function defaults() {
return {
// Symbol colors (note: `undefined` indicates that symbols should not have a fill):
'colors': category10(),

// Symbol edge colors (note: `undefined` indicates that symbols should not have edges):
'edgeColors': void 0,

// Symbol edge opacity (note: `undefined` indicates that symbol edges should inherit the symbol opacity):
'edgeOpacity': void 0,

// Symbol edge width(s) (in pixels) (note: `undefined` indicates that symbol edges should use the default edge width):
'edgeWidth': void 0,

// Boolean indicating whether to display a legend:
'legend': false,

// Symbol(s):
'symbols': [ 'circle' ],

// Symbol opacity (note: default to semi-transparent symbols in order to convey whether data points lie beneath a given point, while remaining sufficiently opaque to avoid accessibility concerns):
'symbolOpacity': [ 0.6 ],

// Symbol size(s) (in pixels squared):
'symbolSize': [ 100 ]
};
}


// EXPORTS //

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

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

'use strict';

// MODULES //

var copy = require( '@stdlib/array/base/copy' );
var prop = require( './properties.js' );

Check warning on line 26 in lib/node_modules/@stdlib/plot/charts/scatter/ctor/lib/edge-colors/get.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

only the `private` property of the required module is used; require the property directly


// MAIN //

/**
* Returns the symbol edge colors.
*
* ## Notes
*
* - If symbol edges are "unset", the function returns `undefined`.
*
* @private
* @returns {(Array<string>|void)} colors
*/
function get() {
var v = this[ prop.private ];
if ( v === void 0 ) {
return v;
}
return copy( v );
}


// EXPORTS //

module.exports = get;
Loading
Loading