Skip to content
Open
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
@@ -0,0 +1,34 @@
/**
* @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';

var Value = require( '@stdlib/plot/vega/value/ctor' );
var RuleEncodingSet = require( './../lib' );

var encoding = new RuleEncodingSet({
'x': new Value({
'field': 'x',
'scale': 'xScale'
}),
'y': new Value({
'field': 'y',
'scale': 'yScale'
})
});
console.log( encoding.toJSON() );
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @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 //

/**
* Returns a new change event object.
*
* @private
* @param {string} property - property name
* @returns {Object} event object
*/
function event( property ) { // eslint-disable-line stdlib/no-redeclare
return {
'type': 'update',
'source': 'mark',
'property': property
};
}


// EXPORTS //

module.exports = event;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @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';

/**
* Rule mark encoding set constructor.
*
* @module @stdlib/plot/vega/mark/rule/encoding-set
*
* @example
* var RuleEncodingSet = require( '@stdlib/plot/vega/mark/rule/encoding-set' );
*
* var encoding = new RuleEncodingSet();
* // returns <RuleEncodingSet>
*/

// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
243 changes: 243 additions & 0 deletions lib/node_modules/@stdlib/plot/vega/mark/rule/encoding-set/lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
/**
* @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.
*/

/* eslint-disable stdlib/no-empty-lines-between-requires */

'use strict';

// MODULES //

var logger = require( 'debug' );
var isObject = require( '@stdlib/assert/is-object' );
var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); // eslint-disable-line id-length
var setNonEnumerableReadOnlyProperty = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); // eslint-disable-line id-length
var hasProp = require( '@stdlib/assert/has-property' );
var inherit = require( '@stdlib/utils/inherit' );
var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' );
var EncodingSet = require( '@stdlib/plot/vega/mark/base/encoding-set' );
var format = require( '@stdlib/string/format' );
var properties = require( './properties.json' );

// Note: keep the following in alphabetical order according to the `require` path...
var getProperties = require( './properties/get.js' );


// VARIABLES //

var debug = logger( 'vega:mark:rule:encoding-set:main' );


// MAIN //

/**
* Rule mark encoding set constructor.
*
* @constructor
* @param {Options} options - constructor options
* @param {Value} [options.aria] - flag indicating whether to include ARIA attributes in SVG output
* @param {Value} [options.blend] - color blend mode
* @param {Value} [options.cursor] - mouse cursor used over a mark
* @param {Value} [options.description] - text description of a mark item for ARIA accessibility
* @param {Value} [options.fill] - fill color
* @param {Value} [options.fillOpacity] - fill opacity
* @param {Value} [options.href] - URL to load upon mouse click
* @param {Value} [options.opacity] - mark opacity
* @param {Value} [options.stroke] - stroke color
* @param {Value} [options.strokeCap] - stroke cap for line ending style
* @param {Value} [options.strokeDash] - stroke dash
* @param {Value} [options.strokeDashOffset] - pixel offset at which to start the dash array
* @param {Value} [options.strokeJoin] - stroke line join method
* @param {Value} [options.strokeMiterLimit] - miter limit at which to bevel a line join
* @param {Value} [options.strokeOpacity] - stroke opacity
* @param {Value} [options.strokeWidth] - stroke width
* @param {Value} [options.tooltip] - tooltip text to show upon mouse hover
* @param {Value} [options.x] - primary x-coordinate
* @param {Value} [options.x2] - secondary x-coordinate
* @param {Value} [options.y] - primary y-coordinate
* @param {Value} [options.y2] - secondary y-coordinate
* @param {Value} [options.zindex] - layering order of sibling mark items
* @throws {TypeError} options argument must be an object
* @throws {Error} must provide valid options
* @returns {RuleEncodingSet} encoding set instance
*
* @example
* var encoding = new RuleEncodingSet();
* // returns <RuleEncodingSet>
*/
function RuleEncodingSet( options ) {
var nargs;
var v;
var k;
var i;

nargs = arguments.length;
if ( !( this instanceof RuleEncodingSet ) ) {
if ( nargs === 0 ) {
return new RuleEncodingSet();
}
return new RuleEncodingSet( options );
}
EncodingSet.call( this );
if ( nargs ) {
if ( !isObject( options ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
}
// Validate provided options by attempting to assign option values to corresponding fields...
for ( i = 0; i < properties.length; i++ ) {
k = properties[ i ];
if ( !hasProp( options, k ) ) {
continue;
}
v = options[ k ];
try {
this[ k ] = v;
} catch ( err ) {
debug( 'Encountered an error. Error: %s', err.message );

// FIXME: retain thrown error type

Check warning on line 113 in lib/node_modules/@stdlib/plot/vega/mark/rule/encoding-set/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'fixme' comment: 'FIXME: retain thrown error type'
throw new Error( transformErrorMessage( err.message ) );
}
}
}
return this;
}

/*
* Inherit from the `EncodingSet` prototype.
*/
inherit( RuleEncodingSet, EncodingSet );

/**
* Constructor name.
*
* @private
* @name name
* @memberof RuleEncodingSet
* @readonly
* @type {string}
*/
setNonEnumerableReadOnly( RuleEncodingSet, 'name', 'RuleEncodingSet' );

/**
* Encoding specifying a mark height (in pixels).
*
* ## Notes
*
* - This property is inherited from the parent prototype and is not applicable to rule mark types.
*
* @name height
* @memberof RuleEncodingSet.prototype
* @readonly
* @type {void}
*
* @example
* var Value = require( '@stdlib/plot/vega/value/ctor' );
*
* var encoding = new RuleEncodingSet();
*
* var v = encoding.height;
* // returns undefined
*/
setNonEnumerableReadOnlyProperty( RuleEncodingSet.prototype, 'height', void 0 );

/**
* EncodingSet properties.
*
* @name properties
* @memberof RuleEncodingSet.prototype
* @type {Array<string>}
*
* @example
* var encoding = new RuleEncodingSet();
*
* var v = encoding.properties;
* // returns [...]
*/
setNonEnumerableReadOnlyAccessor( RuleEncodingSet.prototype, 'properties', getProperties );

/**
* Encoding specifying a mark width (in pixels).
*
* ## Notes
*
* - This property is inherited from the parent prototype and is not applicable to rule mark types.
*
* @name width
* @memberof RuleEncodingSet.prototype
* @readonly
* @type {void}
*
* @example
* var Value = require( '@stdlib/plot/vega/value/ctor' );
*
* var encoding = new RuleEncodingSet();
*
* var v = encoding.width;
* // returns undefined
*/
setNonEnumerableReadOnlyProperty( RuleEncodingSet.prototype, 'width', void 0 );

/**
* Encoding specifying a mark center x-coordinate (in pixels).
*
* ## Notes
*
* - This property is inherited from the parent prototype and is not applicable to rule mark types.
*
* @name xc
* @memberof RuleEncodingSet.prototype
* @readonly
* @type {void}
*
* @example
* var Value = require( '@stdlib/plot/vega/value/ctor' );
*
* var encoding = new RuleEncodingSet();
*
* var v = encoding.xc;
* // returns undefined
*/
setNonEnumerableReadOnlyProperty( RuleEncodingSet.prototype, 'xc', void 0 );

/**
* Encoding specifying a mark center y-coordinate (in pixels).
*
* ## Notes
*
* - This property is inherited from the parent prototype and is not applicable to rule mark types.
*
* @name yc
* @memberof RuleEncodingSet.prototype
* @readonly
* @type {void}
*
* @example
* var Value = require( '@stdlib/plot/vega/value/ctor' );
*
* var encoding = new RuleEncodingSet();
*
* var v = encoding.yc;
* // returns undefined
*/
setNonEnumerableReadOnlyProperty( RuleEncodingSet.prototype, 'yc', void 0 );


// EXPORTS //

module.exports = RuleEncodingSet;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
"aria",
"blend",
"cursor",
"description",
"fill",
"fillOpacity",
"href",
"opacity",
"stroke",
"strokeCap",
"strokeDash",
"strokeDashOffset",
"strokeJoin",
"strokeMiterLimit",
"strokeOpacity",
"strokeWidth",
"tooltip",
"x",
"x2",
"y",
"y2",
"zindex"
]
Loading
Loading