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,27 @@
/**
* @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 LabelTransform = require( './../lib' );

var transform = new LabelTransform({
'size': [ 500, 300 ]
});

console.log( transform.toJSON() );
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @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 no-invalid-this */

'use strict';

// MODULES //

var copy = require( '@stdlib/array/base/copy' );
var prop = require( './properties.js' );


// MAIN //

/**
* Returns the list of anchor directions to test for each label.
*
* @private
* @returns {StringArray} anchor directions
*/
function get() {
return copy( this[ prop.private ] );
}


// EXPORTS //

module.exports = get;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @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 property2object = require( '@stdlib/plot/vega/base/property2object' );


// MAIN //

var obj = property2object( 'anchor' );


// EXPORTS //

module.exports = obj;
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* @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 no-invalid-this */

'use strict';

// MODULES //

var logger = require( 'debug' );
var arraylikefcn = require( '@stdlib/assert/tools/array-like-function' );
var isLabelTransformAnchorDirection = require( '@stdlib/plot/vega/base/assert/is-label-transform-anchor-direction' );

Check warning on line 27 in lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/set.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Identifier name 'isLabelTransformAnchorDirection' is too long (> 25)
var anchorDirections = require( '@stdlib/plot/vega/transform/label/anchor-directions' );
var join = require( '@stdlib/array/base/join' );
var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' );
var copy = require( '@stdlib/array/base/copy' );
var format = require( '@stdlib/string/format' );
var changeEvent = require( './../change_event.js' );
var prop = require( './properties.js' );


// VARIABLES //

var debug = logger( 'vega:label-transform:set:'+prop.name );

// Function to test whether a value is an array of supported anchor directions:
var isLabelTransformAnchorDirectionArray = arraylikefcn( isLabelTransformAnchorDirection );

Check warning on line 42 in lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/set.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Identifier name 'isLabelTransformAnchorDirectionArray' is too long (> 25)

Check warning on line 42 in lib/node_modules/@stdlib/plot/vega/transform/label/ctor/lib/anchor/set.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 91. Maximum allowed is 80


// MAIN //

/**
* Sets the list of anchor directions to test for each label.
*
* @private
* @param {(string|StringArray)} value - input value
* @throws {TypeError} must be an anchor direction or an array of anchor directions
* @returns {void}
*/
function set( value ) {
var isDirection = isLabelTransformAnchorDirection( value );
if ( !isDirection && !isLabelTransformAnchorDirectionArray( value ) ) {
throw new TypeError( format( 'invalid assignment. `%s` must be an anchor direction or an array of anchor directions, where each direction is one of the following: "%s". Value: `%s`.', prop.name, join( anchorDirections(), '", "' ), value ) );
}
if ( isDirection ) {
value = [ value ];
} else {
value = copy( value );
}
if ( !hasEqualValues( value, this[ prop.private ] ) ) {
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
this[ prop.private ] = value;
this.emit( 'change', changeEvent( prop.name ) );
}
}


// EXPORTS //

module.exports = set;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @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 no-invalid-this */

'use strict';

// MODULES //

var copy = require( '@stdlib/array/base/copy-indexed' );
var prop = require( './properties.js' );


// MAIN //

/**
* Returns the output fields written by the transform.
*
* @private
* @returns {StringArray} output fields
*/
function get() {
return copy( this[ prop.private ] );
}


// EXPORTS //

module.exports = get;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @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 property2object = require( '@stdlib/plot/vega/base/property2object' );


// MAIN //

var obj = property2object( 'as' );


// EXPORTS //

module.exports = obj;
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* @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 no-invalid-this */

'use strict';

// MODULES //

var logger = require( 'debug' );
var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives;
var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' );
var copy = require( '@stdlib/array/base/copy' );
var format = require( '@stdlib/string/format' );
var changeEvent = require( './../change_event.js' );
var prop = require( './properties.js' );


// VARIABLES //

var debug = logger( 'vega:label-transform:set:'+prop.name );


// MAIN //

/**
* Sets the output fields written by the transform.
*
* @private
* @param {StringArray} value - input value
* @throws {TypeError} must be an array of strings
* @returns {void}
*/
function set( value ) {
if ( !isStringArray( value ) ) {
throw new TypeError( format( 'invalid assignment. `%s` must be an array of strings. Value: `%s`.', prop.name, value ) );
}
if ( !hasEqualValues( value, this[ prop.private ] ) ) {
debug( 'Current value: %s. New value: %s.', JSON.stringify( this[ prop.private ] ), JSON.stringify( value ) );
this[ prop.private ] = copy( value );
this.emit( 'change', changeEvent( prop.name ) );
}
}


// EXPORTS //

module.exports = set;
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.
*/

/* eslint-disable no-invalid-this */

'use strict';

// MODULES //

var prop = require( './properties.js' );


// MAIN //

/**
* Returns a boolean flag specifying whether labels should not overlap the base mark.
*
* @private
* @returns {boolean} boolean flag
*/
function get() {
return this[ prop.private ];
}


// EXPORTS //

module.exports = get;
Loading
Loading