Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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 @@ -20,6 +20,7 @@

// MODULES //

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' );
Expand All @@ -28,10 +29,19 @@ var resolveTextValue = require( './resolve_text_value.js' );
// VARIABLES //

var PROPS = [
'domain',
'domainCap',
'domainColor',
'domainDashOffset',
'domainOpacity',
'domainWidth',
'titleColor',
'titleFont',
'titleOpacity'
];
var ARRAY_PROPS = [
'domainDash'
];
var TEXT_PROPS = [
'title'
];
Expand All @@ -56,6 +66,12 @@ function config( conf, schema ) {
for ( i = 0; i < TEXT_PROPS.length; i++ ) {
resolveTextValue( schema, def, conf, TEXT_PROPS[ i ] );
}
for ( i = 0; i < ARRAY_PROPS.length; i++ ) {
resolveValue( schema, def, conf, ARRAY_PROPS[ i ] );
if ( isArray( conf[ ARRAY_PROPS[ i ] ] ) ) {
conf[ ARRAY_PROPS[ i ] ] = conf[ ARRAY_PROPS[ i ] ].join( ', ' );
}
}
for ( i = 0; i < PROPS.length; i++ ) {
resolveValue( schema, def, conf, PROPS[ i ] );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,26 @@
for ( i = 0; i < keys.length; i++ ) {
k = keys[ i ];
d = def[ k ];
if ( k === 'title' ) {
if ( k === 'domain' ) {
controller = folder.add( conf, k );
} else if ( k === 'domainCap' ) {
controller = folder.add( conf, k, EMPTY_STRING.concat( d.values ) );
} else if ( k === 'domainColor' ) {
controller = folder.addColor( conf, k );
} else if ( k === 'domainDash' ) {
controller = folder.add( conf, k );
} else if ( k === 'domainDashOffset' ) {
controller = folder.add( conf, k );
controller.name( format( '%s (%s)', k, d.units ) );
} else if ( k === 'domainOpacity' ) {
controller = folder.add( conf, k )
.min( d.min )
.max( d.max );
} else if ( k === 'domainWidth' ) {
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' ) {
controller = folder.addColor( conf, k );
Expand All @@ -87,7 +106,7 @@
.min( d.min )
.max( d.max );
} else {
console.log( 'Unrecognized property in editor configuration. Key: %s.', k );

Check warning on line 109 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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var tryAssign = require( './../../../../middleware/plot-try-assign' );
var body = require( './../../../../middleware/body' );
var ok = require( './../../../../middleware/ok' );
var onError = require( './../../../../middleware/error' );
var transform = require( './../../transforms.js' ).toJSON;
var transform = require( './../../transforms.js' ).toNumberArray;
Comment thread
kgryte marked this conversation as resolved.
Outdated


// VARIABLES //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,36 @@ function toNumber( value ) {
return v;
}

/**
* Transforms a request body containing comma-separated values to an array of integers.
*
* @private
* @param {string} value - raw request body
* @throws {TypeError} must provide a comma-separated list of integers
* @returns {Array<integer>} transformed value
*/
function toNumberArray( value ) {
Comment thread
kgryte marked this conversation as resolved.
Outdated
Comment thread
kgryte marked this conversation as resolved.
Outdated
var out;
var tmp;
var v;
var i;

v = trim( value );
if ( v === '' ) {
return [];
}
tmp = v.split( /\s*,\s*/ );
out = [];
for ( i = 0; i < tmp.length; i++ ) {
v = parseInt( tmp[ i ], 10 );
if ( isnan( v ) ) {
throw new TypeError( format( 'invalid argument. Must provide a comma-separated list of integers. Value: `%s`.', value ) );
}
out.push( v );
}
return out;
}

/**
* Transforms a request body to either a string or `undefined`.
*
Expand All @@ -122,6 +152,7 @@ var transforms = { // eslint-disable-line vars-on-top
'toInteger': toInteger,
'toJSON': toJSON,
'toNumber': toNumber,
'toNumberArray': toNumberArray,
Comment thread
kgryte marked this conversation as resolved.
Outdated
'empty2undefined': empty2undefined
};

Expand Down
57 changes: 57 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/editor-config/axis/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

'use strict';

// MODULES //

var strokeCaps = require( '@stdlib/plot/vega/base/stroke-caps' );


// MAIN //

/**
Expand All @@ -31,6 +36,58 @@
*/
function config() {
return {
'domain': {
'description': 'whether to include an axis baseline as part of an axis',
'property': 'domain',
'default': true,
'type': 'boolean'
},
'domainCap': {
'description': 'stroke cap for the axis domain line',
'property': 'domainCap',
'default': 'butt',
'type': 'oneOf',
'values': strokeCaps()
},
'domainColor': {
'description': 'color of the axis domain line',
'property': 'domainColor',
'default': '#000',
'type': 'string'
Comment thread
kgryte marked this conversation as resolved.
Outdated
},
'domainDash': {
'description': 'stroke dash of the axis domain line',
'property': 'domainDash',
'default': [],
'type': 'array',
'items': {
'type': 'number'
},
'minItems': 0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a valid lil gui configuration?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe stated differently, is this the first instance of us adding a configuration like this?

Copy link
Copy Markdown
Member

@kgryte kgryte May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a look through the code; I believe this is a first. I am guessing you are basing this off of JSON schema?

I am curious what is the larger context and how are you envisioning this will be used, as the "type", "items", and "minItems" fields are not immediately applicable to, e.g., lilgui.

Copy link
Copy Markdown
Member

@kgryte kgryte May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice how, for the other configurations, such as domainOpacity, the default value, along with min and max are directly applicable to a "slider" UI element.

In this case, I am not sure how the items and minItems fields have direct application to UI elements, but maybe you have a larger vision.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, they were placed from POV of JSON schema. They can be removed.

},
'domainDashOffset': {
'description': 'pixel offset at which to start an axis domain line stroke dash',
'property': 'domainDashOffset',
'default': 0,
'type': 'number',
'units': 'px'
},
'domainOpacity': {
'description': 'opacity of the axis domain line',
'property': 'domainOpacity',
'default': 1,
'type': 'number',
'min': 0,
'max': 1
},
'domainWidth': {
'description': 'stroke width of the axis domain line',
'property': 'domainWidth',
'default': 1,
'type': 'number',
'min': 0,
'units': 'px'
},
'title': {
'description': 'title text',
'property': 'title',
Expand Down
Loading