Skip to content

Commit 621d6bc

Browse files
authored
Merge branch 'refactor/plot' into assert-is-grid-align
2 parents 662256b + 8055618 commit 621d6bc

298 files changed

Lines changed: 25462 additions & 13 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/config/axis.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isArray = require( '@stdlib/assert/is-array' );
2424
var defaults = require( './../defaults.js' );
2525
var resolveValue = require( './resolve_value.js' );
2626
var resolveTextValue = require( './resolve_text_value.js' );
27+
var resolveSchemaValue = require( './resolve_schema_value.js' );
2728

2829

2930
// VARIABLES //
@@ -35,12 +36,33 @@ var PROPS = [
3536
'domainDashOffset',
3637
'domainOpacity',
3738
'domainWidth',
39+
'grid',
40+
'gridCap',
41+
'gridColor',
42+
'gridDashOffset',
43+
'gridOpacity',
44+
'tickBand',
45+
'tickCap',
46+
'tickColor',
47+
'tickDashOffset',
48+
'tickMinStep',
49+
'tickOffset',
50+
'tickOpacity',
51+
'ticks',
52+
'tickSize',
53+
'tickWidth',
3854
'titleColor',
3955
'titleFont',
4056
'titleOpacity'
4157
];
4258
var ARRAY_PROPS = [
43-
'domainDash'
59+
'domainDash',
60+
'gridDash',
61+
'tickDash',
62+
'tickCount'
63+
];
64+
var SCHEMA_PROPS = [
65+
'gridScale'
4466
];
4567
var TEXT_PROPS = [
4668
'title'
@@ -75,6 +97,9 @@ function config( conf, schema ) {
7597
for ( i = 0; i < PROPS.length; i++ ) {
7698
resolveValue( schema, def, conf, PROPS[ i ] );
7799
}
100+
for ( i = 0; i < SCHEMA_PROPS.length; i++ ) {
101+
resolveSchemaValue( schema, def, conf, SCHEMA_PROPS[ i ] );
102+
}
78103
return conf;
79104
}
80105

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' );
24+
var isUndefined = require( '@stdlib/assert/is-undefined' );
25+
26+
27+
// MAIN //
28+
29+
/**
30+
* Resolves a configuration value derived from a schema.
31+
*
32+
* @private
33+
* @param {Object} src - source object
34+
* @param {Object} defaults - defaults object
35+
* @param {Object} dest - destination object
36+
* @param {string} prop - property name
37+
*/
38+
function resolveSchemaValue( src, defaults, dest, prop ) {
39+
var v = src[ prop ];
40+
if ( !isSignalReference( v ) ) {
41+
if ( isUndefined( v ) || v === '' ) {
42+
if ( prop === 'gridScale' ) {
43+
dest[ prop ] = src.scale;
44+
} else {
45+
dest[ prop ] = defaults[ prop ].default;
46+
}
47+
} else {
48+
dest[ prop ] = v;
49+
}
50+
}
51+
}
52+
53+
54+
// EXPORTS //
55+
56+
module.exports = resolveSchemaValue;

lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ setReadOnly( Editor.prototype, 'create', function create() {
154154
this._tree.general = createGeneral( editor, conf.general );
155155
this._tree.padding = createPadding( editor, conf.padding );
156156
this._tree.title = createTitle( editor, conf.title );
157-
this._tree.axes = createAxes( editor, conf.axes );
157+
this._tree.axes = createAxes( editor, conf.axes, this._state.schema.raw );
158158

159159
editor.onFinishChange( onChange );
160160

lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/axes.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ var axis = require( './axis.js' );
3232
* @private
3333
* @param {Editor} editor - editor instance
3434
* @param {Array<Object>} conf - list of editor axis configurations
35+
* @param {Object} schema - visualization schema
3536
* @returns {(Object|null)} menu tree
3637
*/
37-
function addMenu( editor, conf ) {
38+
function addMenu( editor, conf, schema ) {
3839
var children;
3940
var folder;
4041
var o;
@@ -48,7 +49,7 @@ function addMenu( editor, conf ) {
4849

4950
children = [];
5051
for ( i = 0; i < conf.length; i++ ) {
51-
o = axis( folder, conf[ i ], format( 'Axis %d', i+1 ) );
52+
o = axis( folder, conf[ i ], schema, format( 'Axis %d', i+1 ) );
5253
if ( o ) {
5354
children.push( o );
5455
}

lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/axis.js

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

2323
var objectKeys = require( '@stdlib/utils/keys' );
2424
var format = require( '@stdlib/string/format' );
25+
var resolveSchemaValues = require( './resolve_schema_values.js' );
2526
var defaults = require( './../defaults.js' );
2627

2728

@@ -38,10 +39,11 @@ var EMPTY_STRING = [ '' ];
3839
* @private
3940
* @param {Editor} parent - parent folder instance
4041
* @param {Object} conf - editor axis configuration
42+
* @param {Object} schema - visualization schema
4143
* @param {string} name - folder name
4244
* @returns {(Object|null)} menu tree
4345
*/
44-
function addMenu( parent, conf, name ) {
46+
function addMenu( parent, conf, schema, name ) {
4547
var controllers;
4648
var controller;
4749
var folder;
@@ -83,6 +85,61 @@ function addMenu( parent, conf, name ) {
8385
controller = folder.add( conf, k )
8486
.min( d.min );
8587
controller.name( format( '%s (%s)', k, d.units ) );
88+
} else if ( k === 'grid' ) {
89+
controller = folder.add( conf, k );
90+
} else if ( k === 'gridCap' ) {
91+
controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) );
92+
} else if ( k === 'gridColor' ) {
93+
controller = folder.addColor( conf, k );
94+
} else if ( k === 'gridDash' ) {
95+
controller = folder.add( conf, k );
96+
} else if ( k === 'gridDashOffset' ) {
97+
controller = folder.add( conf, k );
98+
controller.name( format( '%s (%s)', k, d.units ) );
99+
} else if ( k === 'gridOpacity' ) {
100+
controller = folder.add( conf, k )
101+
.min( d.min )
102+
.max( d.max );
103+
} else if ( k === 'gridScale' ) {
104+
controller = folder.add( conf, k, resolveSchemaValues( schema, 'scales.*.name' ) ).disable();
105+
} else if ( k === 'gridWidth' ) {
106+
controller = folder.add( conf, k )
107+
.min( d.min );
108+
controller.name( format( '%s (%s)', k, d.units ) );
109+
} else if ( k === 'tickBand' ) {
110+
controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) );
111+
} else if ( k === 'tickCap' ) {
112+
controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) );
113+
} else if ( k === 'tickColor' ) {
114+
controller = folder.addColor( conf, k );
115+
} else if ( k === 'tickCount' ) {
116+
controller = folder.add( conf, k );
117+
} else if ( k === 'tickDash' ) {
118+
controller = folder.add( conf, k );
119+
} else if ( k === 'tickDashOffset' ) {
120+
controller = folder.add( conf, k );
121+
controller.name( format( '%s (%s)', k, d.units ) );
122+
} else if ( k === 'tickMinStep' ) {
123+
controller = folder.add( conf, k )
124+
.min( d.min );
125+
} else if ( k === 'tickOffset' ) {
126+
controller = folder.add( conf, k )
127+
.min( d.min );
128+
controller.name( format( '%s (%s)', k, d.units ) );
129+
} else if ( k === 'tickOpacity' ) {
130+
controller = folder.add( conf, k )
131+
.min( d.min )
132+
.max( d.max );
133+
} else if ( k === 'ticks' ) {
134+
controller = folder.add( conf, k );
135+
} else if ( k === 'tickSize' ) {
136+
controller = folder.add( conf, k )
137+
.min( d.min );
138+
controller.name( format( '%s (%s)', k, d.units ) );
139+
} else if ( k === 'tickWidth' ) {
140+
controller = folder.add( conf, k )
141+
.min( d.min );
142+
controller.name( format( '%s (%s)', k, d.units ) );
86143
} else if ( k === 'title' ) {
87144
controller = folder.add( conf, k );
88145
} else if ( k === 'titleColor' ) {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MAIN //
22+
23+
/**
24+
* Resolves configuration values from a visualization schema.
25+
*
26+
* @private
27+
* @param {Object} schema - visualization schema
28+
* @param {string} path - schema path pattern
29+
* @returns {Array} resolved values
30+
*/
31+
function resolveSchemaValues( schema, path ) {
32+
var out;
33+
var i;
34+
if ( path === 'scales.*.name' ) {
35+
out = [];
36+
for ( i = 0; i < schema.scales.length; i++ ) {
37+
out.push( schema.scales[ i ].name );
38+
}
39+
}
40+
return out;
41+
}
42+
43+
44+
// EXPORTS //
45+
46+
module.exports = resolveSchemaValues;

lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/on_change.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
var parseJSON = require( '@stdlib/utils/parse-json' );
2626
var isJSON = require( '@stdlib/assert/is-json' );
27+
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
28+
var trim = require( '@stdlib/string/base/trim' );
29+
var Number = require( '@stdlib/number/ctor' );
30+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2731
var join = require( '@stdlib/array/base/join' );
2832
var log = require( './../log.js' );
2933
var config = require( './../config.js' );
@@ -74,6 +78,7 @@ function onChange( event ) {
7478
var obj;
7579
var ns;
7680
var i;
81+
var n;
7782

7883
self = this;
7984
conf = this._config;
@@ -110,6 +115,22 @@ function onChange( event ) {
110115
if ( !( tmp instanceof Error ) ) {
111116
val = tmp;
112117
}
118+
} else if ( isString( val ) ) {
119+
tmp = trim( val );
120+
if ( prop === 'tickCount' ) {
121+
n = Number( tmp );
122+
if ( tmp === '' ) {
123+
val = void 0;
124+
} else if ( !isnan( n ) ) {
125+
val = n;
126+
} else if ( tmp.indexOf( ',' ) !== -1 ) {
127+
tmp = tmp.split( /\s*,\s*/ );
128+
val = {
129+
'interval': tmp[ 0 ],
130+
'step': parseInt( tmp[ 1 ], 10 )
131+
};
132+
}
133+
}
113134
}
114135

115136
log( 'Editor changed: %s/%s', path, prop );
@@ -123,7 +144,7 @@ function onChange( event ) {
123144

124145
log( 'Attempting to update configuration...' );
125146
url = URL_PREFIX+'/'+( ( path ) ? path+'/' : path )+prop;
126-
fetch( url, requestOptions( event.value.toString() ) )
147+
fetch( url, requestOptions( event.value.toString() ) ) // eslint-disable-line n/no-unsupported-features/node-builtins
127148
.then( onResponse )
128149
.catch( onError );
129150

lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/axis.js

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ var PROPS = [
3636
'domainDashOffset',
3737
'domainOpacity',
3838
'domainWidth',
39+
'grid',
40+
'gridCap',
41+
'gridColor',
42+
'gridDash',
43+
'gridDashOffset',
44+
'gridOpacity',
45+
'gridWidth',
46+
'tickBand',
47+
'tickCap',
48+
'tickColor',
49+
'tickCount',
50+
'tickDash',
51+
'tickDashOffset',
52+
'tickMinStep',
53+
'tickOffset',
54+
'tickOpacity',
55+
'ticks',
56+
'tickSize',
57+
'tickWidth',
3958
'title',
4059
'titleColor',
4160
'titleFont',
@@ -60,6 +79,7 @@ var PROPS = [
6079
* @returns {Object} transformed schema
6180
*/
6281
function transform( schema, signals, defaults, prefix ) {
82+
var value;
6383
var name;
6484
var out;
6585
var k;
@@ -72,18 +92,39 @@ function transform( schema, signals, defaults, prefix ) {
7292
v = schema[ k ];
7393
if ( !isSignalReference( v ) ) {
7494
name = signalName( prefix+k );
75-
signals.push({
76-
'name': name,
77-
'value': ( isUndefined( v ) ) ? defaults[ k ].default : v
78-
});
95+
value = ( isUndefined( v ) ) ? defaults[ k ].default : v;
7996

80-
// FIXME: Vega does not currently support signal updates for structural properties like `domain`. As a workaround, we keep `domain` statically `true` and dynamically hide it by dropping `domainOpacity` to 0 when unchecked.
97+
if ( k === 'tickCount' ) {
98+
signals.push({
99+
'name': name,
100+
'value': ( value === '' ) ? void 0 : value
101+
});
102+
} else {
103+
signals.push({
104+
'name': name,
105+
'value': value
106+
});
107+
}
108+
109+
// FIXME: Vega does not currently support signal updates for structural properties like `domain`, `grid` & `ticks`. As a workaround, we keep them statically `true` and dynamically hide them by dropping their respective opacities to 0 when unchecked.
81110
if ( k === 'domain' ) {
82111
out[ k ] = true;
83112
} else if ( k === 'domainOpacity' ) {
84113
out[ k ] = {
85114
'signal': signalName( prefix+'domain' ) + ' ? ' + name + ' : 0'
86115
};
116+
} else if ( k === 'grid' ) {
117+
out[ k ] = true;
118+
} else if ( k === 'gridOpacity' ) {
119+
out[ k ] = {
120+
'signal': signalName( prefix+'grid' ) + ' ? ' + name + ' : 0'
121+
};
122+
} else if ( k === 'ticks' ) {
123+
out[ k ] = true;
124+
} else if ( k === 'tickOpacity' ) {
125+
out[ k ] = {
126+
'signal': signalName( prefix+'ticks' ) + ' ? ' + name + ' : 0'
127+
};
87128
} else {
88129
out[ k ] = {
89130
'signal': name

0 commit comments

Comments
 (0)