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 @@ -41,14 +41,25 @@ var PROPS = [
'gridColor',
'gridDashOffset',
'gridOpacity',
'gridWidth',
'tickBand',
'tickCap',
'tickColor',
'tickDashOffset',
'tickMinStep',
'tickOffset',
'tickOpacity',
'ticks',
'tickSize',
'tickWidth',
'titleColor',
'titleFont',
'titleOpacity'
];
var ARRAY_PROPS = [
'domainDash',
'gridDash'
'gridDash',
'tickDash',
'tickCount'
];
var SCHEMA_PROPS = [
'gridScale'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,40 @@
controller = folder.add( conf, k )
.min( d.min );
controller.name( format( '%s (%s)', k, d.units ) );
} else if ( k === 'tickBand' ) {
controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) );
} else if ( k === 'tickCap' ) {
controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) );
} else if ( k === 'tickColor' ) {
controller = folder.addColor( conf, k );
} else if ( k === 'tickCount' ) {
controller = folder.add( conf, k );
} else if ( k === 'tickDash' ) {
controller = folder.add( conf, k );
} else if ( k === 'tickDashOffset' ) {
controller = folder.add( conf, k );
controller.name( format( '%s (%s)', k, d.units ) );
} else if ( k === 'tickMinStep' ) {
controller = folder.add( conf, k )
.min( d.min );
} else if ( k === 'tickOffset' ) {
controller = folder.add( conf, k )
.min( d.min );
controller.name( format( '%s (%s)', k, d.units ) );
} else if ( k === 'tickOpacity' ) {
controller = folder.add( conf, k )
.min( d.min )
.max( d.max );
} else if ( k === 'ticks' ) {
controller = folder.add( conf, k );
} else if ( k === 'tickSize' ) {
controller = folder.add( conf, k )
.min( d.min );
controller.name( format( '%s (%s)', k, d.units ) );
} else if ( k === 'tickWidth' ) {
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 @@ -129,7 +163,7 @@
.min( d.min )
.max( d.max );
} else {
console.log( 'Unrecognized property in editor configuration. Key: %s.', k );

Check warning on line 166 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
Expand Up @@ -24,6 +24,10 @@

var parseJSON = require( '@stdlib/utils/parse-json' );
var isJSON = require( '@stdlib/assert/is-json' );
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
var trim = require( '@stdlib/string/base/trim' );
var Number = require( '@stdlib/number/ctor' );
Comment thread
kgryte marked this conversation as resolved.
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var join = require( '@stdlib/array/base/join' );
var log = require( './../log.js' );
var config = require( './../config.js' );
Expand Down Expand Up @@ -74,11 +78,12 @@
var obj;
var ns;
var i;
var n;

self = this;
conf = this._config;

// FIXME: other properties/objects

Check warning on line 86 in lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/on_change.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'fixme' comment: 'FIXME: other properties/objects'

obj = event.object;
if ( obj === conf.general ) {
Expand Down Expand Up @@ -110,6 +115,22 @@
if ( !( tmp instanceof Error ) ) {
val = tmp;
}
} else if ( isString( val ) ) {
tmp = trim( val );
if ( prop === 'tickCount' ) {
n = Number( tmp );
if ( tmp === '' ) {
val = void 0;
} else if ( !isnan( n ) ) {
val = n;
} else if ( tmp.indexOf( ',' ) !== -1 ) {
tmp = tmp.split( /\s*,\s*/ );
val = {
'interval': tmp[ 0 ],
'step': parseInt( tmp[ 1 ], 10 )
};
}
Comment thread
kgryte marked this conversation as resolved.
}
}

log( 'Editor changed: %s/%s', path, prop );
Expand All @@ -123,7 +144,7 @@

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

Expand All @@ -139,7 +160,7 @@
log( 'Successfully updated configuration.' );
return;
}
console.error( 'Encountered an error when posting change. Status: %d.', response.status );

Check warning on line 163 in lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/on_change.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected console statement

// If we failed, we need to roll back to displaying the value from the existing visualization schema:
self.refresh();
Expand All @@ -152,7 +173,7 @@
* @param {Error} error - error object
*/
function onError( error ) {
console.error( 'Encountered an error when posting change. Error: %s.', error.message );

Check warning on line 176 in lib/node_modules/@stdlib/plot/base/view/lib/browser/app/editor/on_change.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected console statement

// If we failed, we need to roll back to displaying the value from the existing visualization schema:
self.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@
'gridDashOffset',
'gridOpacity',
'gridWidth',
'tickBand',
'tickCap',
'tickColor',
'tickCount',
'tickDash',
'tickDashOffset',
'tickMinStep',
'tickOffset',
'tickOpacity',
'ticks',
'tickSize',
'tickWidth',
'title',
'titleColor',
'titleFont',
Expand All @@ -67,6 +79,7 @@
* @returns {Object} transformed schema
*/
function transform( schema, signals, defaults, prefix ) {
var value;
var name;
var out;
var k;
Expand All @@ -79,12 +92,21 @@
v = schema[ k ];
if ( !isSignalReference( v ) ) {
name = signalName( prefix+k );
signals.push({
'name': name,
'value': ( isUndefined( v ) ) ? defaults[ k ].default : v
});
value = ( isUndefined( v ) ) ? defaults[ k ].default : v;

// 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.
if ( k === 'tickCount' ) {
signals.push({
'name': name,
'value': ( value === '' ) ? void 0 : value
});
} else {
signals.push({
'name': name,
'value': value
});
}

// 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.

Check warning on line 109 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' ) {
Expand All @@ -97,6 +119,12 @@
out[ k ] = {
'signal': signalName( prefix+'grid' ) + ' ? ' + name + ' : 0'
};
} else if ( k === 'ticks' ) {
out[ k ] = true;
} else if ( k === 'tickOpacity' ) {
out[ k ] = {
'signal': signalName( prefix+'ticks' ) + ' ? ' + 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' ], 'tickBand' ),
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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"method": "POST",
"url": "/config/axes/:axis/tickBand",
"schema": {
"response": {
"200": {
"type": "string"
},
"400": {
"type": "object",
"properties": {
"statusCode": {
"type": "integer"
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"413": {
"type": "object",
"properties": {
"statusCode": {
"type": "integer"
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
},
"handler": null
}
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;
Loading
Loading