Skip to content
Merged
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
Expand Up @@ -24,6 +24,7 @@ var isArray = require( '@stdlib/assert/is-array' );
var defaults = require( './../defaults.js' );
var resolveValue = require( './resolve_value.js' );
var resolveTextValue = require( './resolve_text_value.js' );
var resolveSchemaValue = require( './resolve_schema_value.js' );


// VARIABLES //
Expand All @@ -35,12 +36,22 @@ var PROPS = [
'domainDashOffset',
'domainOpacity',
'domainWidth',
'grid',
'gridCap',
'gridColor',
'gridDashOffset',
'gridOpacity',
'gridWidth',
'titleColor',
'titleFont',
'titleOpacity'
];
var ARRAY_PROPS = [
'domainDash'
'domainDash',
'gridDash'
];
var SCHEMA_PROPS = [
'gridScale'
];
var TEXT_PROPS = [
'title'
Expand Down Expand Up @@ -75,6 +86,9 @@ function config( conf, schema ) {
for ( i = 0; i < PROPS.length; i++ ) {
resolveValue( schema, def, conf, PROPS[ i ] );
}
for ( i = 0; i < SCHEMA_PROPS.length; i++ ) {
resolveSchemaValue( schema, def, conf, SCHEMA_PROPS[ i ] );
}
return conf;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @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 isSignalReference = require( '@stdlib/plot/vega/base/assert/is-signal-reference' );
var isUndefined = require( '@stdlib/assert/is-undefined' );


// MAIN //

/**
* Resolves a configuration value derived from a schema.
*
* @private
* @param {Object} src - source object
* @param {Object} defaults - defaults object
* @param {Object} dest - destination object
* @param {string} prop - property name
*/
function resolveSchemaValue( src, defaults, dest, prop ) {
var v = src[ prop ];
if ( !isSignalReference( v ) ) {
if ( isUndefined( v ) || v === '' ) {
if ( prop === 'gridScale' ) {
dest[ prop ] = src.scale;
} else {
dest[ prop ] = defaults[ prop ].default;
}
} else {
dest[ prop ] = v;
}
}
}


// EXPORTS //

module.exports = resolveSchemaValue;
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ setReadOnly( Editor.prototype, 'create', function create() {
this._tree.general = createGeneral( editor, conf.general );
this._tree.padding = createPadding( editor, conf.padding );
this._tree.title = createTitle( editor, conf.title );
this._tree.axes = createAxes( editor, conf.axes );
this._tree.axes = createAxes( editor, conf.axes, this._state.schema.raw );

editor.onFinishChange( onChange );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ var axis = require( './axis.js' );
* @private
* @param {Editor} editor - editor instance
* @param {Array<Object>} conf - list of editor axis configurations
* @param {Object} schema - visualization schema
* @returns {(Object|null)} menu tree
*/
function addMenu( editor, conf ) {
function addMenu( editor, conf, schema ) {
var children;
var folder;
var o;
Expand All @@ -48,7 +49,7 @@ function addMenu( editor, conf ) {

children = [];
for ( i = 0; i < conf.length; i++ ) {
o = axis( folder, conf[ i ], format( 'Axis %d', i+1 ) );
o = axis( folder, conf[ i ], schema, format( 'Axis %d', i+1 ) );
if ( o ) {
children.push( o );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

var objectKeys = require( '@stdlib/utils/keys' );
var format = require( '@stdlib/string/format' );
var resolveSchemaValues = require( './resolve_schema_values.js' );
var defaults = require( './../defaults.js' );


Expand All @@ -38,10 +39,11 @@
* @private
* @param {Editor} parent - parent folder instance
* @param {Object} conf - editor axis configuration
* @param {Object} schema - visualization schema
* @param {string} name - folder name
* @returns {(Object|null)} menu tree
*/
function addMenu( parent, conf, name ) {
function addMenu( parent, conf, schema, name ) {
var controllers;
var controller;
var folder;
Expand Down Expand Up @@ -83,6 +85,27 @@
controller = folder.add( conf, k )
.min( d.min );
controller.name( format( '%s (%s)', k, d.units ) );
} else if ( k === 'grid' ) {
controller = folder.add( conf, k );
} else if ( k === 'gridCap' ) {
controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) );
} else if ( k === 'gridColor' ) {
controller = folder.addColor( conf, k );
} else if ( k === 'gridDash' ) {
controller = folder.add( conf, k );
} else if ( k === 'gridDashOffset' ) {
controller = folder.add( conf, k );
controller.name( format( '%s (%s)', k, d.units ) );
} else if ( k === 'gridOpacity' ) {
controller = folder.add( conf, k )
.min( d.min )
.max( d.max );
} else if ( k === 'gridScale' ) {
controller = folder.add( conf, k, resolveSchemaValues( schema, 'scales.*.name' ) ).disable();
} else if ( k === 'gridWidth' ) {
controller = folder.add( conf, k )
.min( d.min );
controller.name( format( '%s (%s)', k, d.units ) );
} else if ( k === 'title' ) {
controller = folder.add( conf, k );
} else if ( k === 'titleColor' ) {
Expand All @@ -106,7 +129,7 @@
.min( d.min )
.max( d.max );
} else {
console.log( 'Unrecognized property in editor configuration. Key: %s.', k );

Check warning on line 132 in lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/menus/axis.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected console statement
continue;
}
controllers[ k ] = controller;
Expand Down
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';

// MAIN //

/**
* Resolves configuration values from a visualization schema.
*
* @private
* @param {Object} schema - visualization schema
* @param {string} path - schema path pattern
* @returns {Array} resolved values
*/
function resolveSchemaValues( schema, path ) {
var out;
var i;
if ( path === 'scales.*.name' ) {
out = [];
for ( i = 0; i < schema.scales.length; i++ ) {
out.push( schema.scales[ i ].name );
}
}
return out;
}


// EXPORTS //

module.exports = resolveSchemaValues;
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
'domainDashOffset',
'domainOpacity',
'domainWidth',
'grid',
'gridCap',
'gridColor',
'gridDash',
'gridDashOffset',
'gridOpacity',
'gridWidth',
'title',
'titleColor',
'titleFont',
Expand Down Expand Up @@ -77,13 +84,19 @@
'value': ( isUndefined( v ) ) ? defaults[ k ].default : v
});

// 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.
// FIXME: Vega does not currently support signal updates for structural properties like `domain` and `grid`. As a workaround, we keep them statically `true` and dynamically hide them by dropping their respective opacities to 0 when unchecked.

Check warning on line 87 in lib/node_modules/@stdlib/plot/base/view/lib/browser/app/schema/transforms/axis.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'fixme' comment: 'FIXME: Vega does not currently support...'
if ( k === 'domain' ) {
out[ k ] = true;
} else if ( k === 'domainOpacity' ) {
out[ k ] = {
'signal': signalName( prefix+'domain' ) + ' ? ' + name + ' : 0'
};
} else if ( k === 'grid' ) {
out[ k ] = true;
} else if ( k === 'gridOpacity' ) {
out[ k ] = {
'signal': signalName( prefix+'grid' ) + ' ? ' + name + ' : 0'
};
} else {
out[ k ] = {
'signal': name
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @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 schema = require( './schema.json' );
var handler = require( './main.js' );


// MAIN //

/**
* Defines a route handler for receiving updating a plot configuration.
*
* @private
* @returns {Object} route declaration
*/
function route() {
schema.handler = handler;
return schema;
}


// EXPORTS //

module.exports = route;
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @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 middleware = require( './../../../../middleware_sequence.js' );
var allowCredentials = require( './../../../../middleware/allow-credentials' );
var tryAssign = require( './../../../../middleware/plot-try-assign' );
var body = require( './../../../../middleware/body' );
var ok = require( './../../../../middleware/ok' );
var onError = require( './../../../../middleware/error' );


// VARIABLES //

var steps = [
allowCredentials,
body,
tryAssign( [ 'config', 'axes', ':axis' ], 'gridCap' ),
ok
];


// MAIN //

/**
* Request handler for updating a plot configuration.
*
* @private
* @name handler
* @type {Function}
* @param {Object} request - request object
* @param {Object} response - response object
*/
var handler = middleware( steps, onError );


// EXPORTS //

module.exports = handler;
Loading
Loading