Skip to content

Commit f2ab222

Browse files
committed
chore: cleanup and fix bugs
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_license_headers status: passed ---
1 parent 8ed18f1 commit f2ab222

32 files changed

Lines changed: 84 additions & 102 deletions

File tree

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/defaults.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,20 @@
2424
* Returns defaults.
2525
*
2626
* @private
27+
* @param {string} direction - legend direction
2728
* @returns {Object} default options
2829
*
2930
* @example
30-
* var o = defaults();
31+
* var o = defaults( 'vertical' );
3132
* // returns {...}
3233
*/
33-
function defaults() {
34+
function defaults( direction ) {
3435
return {
3536
// Boolean indicating whether to include ARIA attributes in SVG output:
3637
'aria': true,
3738

3839
// Number of columns in which to arrange symbol legend entries:
39-
'columns': 1,
40+
'columns': ( direction === 'horizontal' ) ? 0 : 1,
4041

4142
// Direction of the legend:
4243
'direction': 'vertical',
@@ -56,6 +57,9 @@ function defaults() {
5657
// Legend orientation:
5758
'orient': 'right',
5859

60+
// Stroke dash for legend symbols:
61+
'symbolDash': [],
62+
5963
// Legend title:
6064
'title': [ '' ],
6165

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/format-type/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var prop = require( './properties.js' );
2828
// MAIN //
2929

3030
/**
31-
* Returns the format type.
31+
* Returns the format to use for legend scales which do not have a strict domain data type.
3232
*
3333
* @private
3434
* @returns {(string|void)} format type

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/format-type/set.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var debug = logger( 'vega:legend:set:'+prop.name );
4040
// MAIN //
4141

4242
/**
43-
* Sets the format type.
43+
* Sets the format to use for legend scales which do not have a strict domain data type.
4444
*
4545
* ## Notes
4646
*

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/format/get.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
// MODULES //
2424

25+
var isObject = require( '@stdlib/assert/is-object' );
26+
var objectAssignIn = require( '@stdlib/object/assign-in' );
2527
var prop = require( './properties.js' );
2628

2729

@@ -34,7 +36,8 @@ var prop = require( './properties.js' );
3436
* @returns {(string|Object|void)} format
3537
*/
3638
function get() {
37-
return this[ prop.private ];
39+
var v = this[ prop.private ];
40+
return ( isObject( v ) ) ? objectAssignIn( {}, v ) : v;
3841
}
3942

4043

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/format/set.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var logger = require( 'debug' );
2626
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2727
var isObject = require( '@stdlib/assert/is-object' );
2828
var isUndefined = require( '@stdlib/assert/is-undefined' );
29+
var objectAssignIn = require( '@stdlib/object/assign-in' );
2930
var format = require( '@stdlib/string/format' );
3031
var changeEvent = require( './../change_event.js' );
3132
var prop = require( './properties.js' );
@@ -51,12 +52,19 @@ var debug = logger( 'vega:legend:set:'+prop.name );
5152
* @returns {void}
5253
*/
5354
function set( value ) {
54-
if ( !isString( value ) && !isObject( value ) && !isUndefined( value ) ) {
55-
throw new TypeError( format( 'invalid assignment. `%s` must be a string or object. Value: `%s`.', prop.name, value ) );
55+
var isObj = isObject( value );
56+
57+
// FIXME: validate that an object is a valid TimeMultiFormat object
58+
59+
if ( !isString( value ) && !isObj && !isUndefined( value ) ) {
60+
throw new TypeError( format( 'invalid assignment. `%s` must be a string or a valid format object. Value: `%s`.', prop.name, value ) );
5661
}
62+
63+
// TODO: consider a deep equality check for format objects in order to avoid false positive change events
64+
5765
if ( value !== this[ prop.private ] ) {
58-
debug( 'Current value: %s. New value: %s.', this[ prop.private ], value );
59-
this[ prop.private ] = value;
66+
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
67+
this[ prop.private ] = ( isObj ) ? objectAssignIn( {}, value ) : value;
6068
this.emit( 'change', changeEvent( prop.name ) );
6169
}
6270
}

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/gradient-length/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var prop = require( './properties.js' );
2828
// MAIN //
2929

3030
/**
31-
* Returns the length (in pixels) of the color ramp in a gradient legend.
31+
* Returns the length (in pixels) of the primary axis of a color gradient.
3232
*
3333
* @private
3434
* @returns {(number|void)} gradient length

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/gradient-length/set.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var debug = logger( 'vega:legend:set:'+prop.name );
3838
// MAIN //
3939

4040
/**
41-
* Sets the length (in pixels) of the color ramp in a gradient legend.
41+
* Sets the length (in pixels) of the primary axis of a color gradient.
4242
*
4343
* ## Notes
4444
*

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/gradient-stroke-color/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var prop = require( './properties.js' );
2828
// MAIN //
2929

3030
/**
31-
* Returns the stroke color of the color ramp border.
31+
* Returns the stroke color of the color gradient border.
3232
*
3333
* @private
3434
* @returns {(string|void)} gradient stroke color

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/gradient-stroke-color/set.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var debug = logger( 'vega:legend:set:'+prop.name );
3838
// MAIN //
3939

4040
/**
41-
* Sets the stroke color of the color ramp border.
41+
* Sets the stroke color of the color gradient border.
4242
*
4343
* ## Notes
4444
*

lib/node_modules/@stdlib/plot/vega/legend/ctor/lib/gradient-stroke-width/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var prop = require( './properties.js' );
2828
// MAIN //
2929

3030
/**
31-
* Returns the stroke width of the color ramp border.
31+
* Returns the stroke width of the color gradient border.
3232
*
3333
* @private
3434
* @returns {(number|void)} gradient stroke width

0 commit comments

Comments
 (0)