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 @@ -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' ).toIntegerArray;


// 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 toIntegerArray( value ) {
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,
'toIntegerArray': toIntegerArray,
'empty2undefined': empty2undefined
};

Expand Down
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,54 @@
*/
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': 'color'
},
'domainDash': {
'description': 'stroke dash of the axis domain line',
'property': 'domainDash',
'default': '',
'type': 'string'
},
'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 All @@ -41,7 +94,7 @@ function config() {
'description': 'color of the title',
'property': 'titleColor',
'default': '#000',
'type': 'string'
'type': 'color'
},
'titleFont': {
'description': 'font of the title',
Expand Down
Loading