Skip to content

Commit e966d85

Browse files
committed
feat: add maxExtent, minExtent, offset, and position property support
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 579ee4b commit e966d85

File tree

13 files changed

+653
-0
lines changed

13 files changed

+653
-0
lines changed

lib/node_modules/@stdlib/plot/vega/axis/ctor/lib/main.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,18 @@ var setLabelSeparation = require( './label-separation/set.js' );
118118
var getLabels = require( './labels/get.js' );
119119
var setLabels = require( './labels/set.js' );
120120

121+
var getMaxExtent = require( './max-extent/get.js' );
122+
var setMaxExtent = require( './max-extent/set.js' );
123+
var getMinExtent = require( './min-extent/get.js' );
124+
var setMinExtent = require( './min-extent/set.js' );
125+
126+
var getOffset = require( './offset/get.js' );
127+
var setOffset = require( './offset/set.js' );
121128
var getOrient = require( './orient/get.js' );
122129
var setOrient = require( './orient/set.js' );
123130

131+
var getPosition = require( './position/get.js' );
132+
var setPosition = require( './position/set.js' );
124133
var getProperties = require( './properties/get.js' );
125134

126135
var getScale = require( './scale/get.js' );
@@ -1021,6 +1030,63 @@ setReadWriteAccessor( Axis.prototype, 'labels', getLabels, setLabels );
10211030
*/
10221031
setReadWriteAccessor( Axis.prototype, 'labelSeparation', getLabelSeparation, setLabelSeparation );
10231032

1033+
/**
1034+
* Maximum extent (in pixels) that axis ticks and labels should use.
1035+
*
1036+
* @name maxExtent
1037+
* @memberof Axis.prototype
1038+
* @type {NonNegativeNumber}
1039+
*
1040+
* @example
1041+
* var axis = new Axis({
1042+
* 'scale': 'xScale',
1043+
* 'orient': 'bottom',
1044+
* 'maxExtent': 20
1045+
* });
1046+
*
1047+
* var v = axis.maxExtent;
1048+
* // returns 20
1049+
*/
1050+
setReadWriteAccessor( Axis.prototype, 'maxExtent', getMaxExtent, setMaxExtent );
1051+
1052+
/**
1053+
* Minimum extent (in pixels) that axis ticks and labels should use.
1054+
*
1055+
* @name minExtent
1056+
* @memberof Axis.prototype
1057+
* @type {NonNegativeNumber}
1058+
*
1059+
* @example
1060+
* var axis = new Axis({
1061+
* 'scale': 'xScale',
1062+
* 'orient': 'bottom',
1063+
* 'minExtent': 20
1064+
* });
1065+
*
1066+
* var v = axis.minExtent;
1067+
* // returns 20
1068+
*/
1069+
setReadWriteAccessor( Axis.prototype, 'minExtent', getMinExtent, setMinExtent );
1070+
1071+
/**
1072+
* Orthogonal offset (in pixels) by which to displace the axis from its position along the edge of a chart.
1073+
*
1074+
* @name offset
1075+
* @memberof Axis.prototype
1076+
* @type {number}
1077+
*
1078+
* @example
1079+
* var axis = new Axis({
1080+
* 'scale': 'xScale',
1081+
* 'orient': 'bottom',
1082+
* 'offset': 5
1083+
* });
1084+
*
1085+
* var v = axis.offset;
1086+
* // returns 5
1087+
*/
1088+
setReadWriteAccessor( Axis.prototype, 'offset', getOffset, setOffset );
1089+
10241090
/**
10251091
* Axis orientation.
10261092
*
@@ -1039,6 +1105,26 @@ setReadWriteAccessor( Axis.prototype, 'labelSeparation', getLabelSeparation, set
10391105
*/
10401106
setReadWriteAccessor( Axis.prototype, 'orient', getOrient, setOrient );
10411107

1108+
/**
1109+
* Anchor position of an axis (in pixels).
1110+
*
1111+
* @name position
1112+
* @memberof Axis.prototype
1113+
* @type {number}
1114+
* @default 0
1115+
*
1116+
* @example
1117+
* var axis = new Axis({
1118+
* 'scale': 'xScale',
1119+
* 'orient': 'bottom',
1120+
* 'position': 5
1121+
* });
1122+
*
1123+
* var v = axis.position;
1124+
* // returns 5
1125+
*/
1126+
setReadWriteAccessor( Axis.prototype, 'position', getPosition, setPosition );
1127+
10421128
/**
10431129
* Axis properties.
10441130
*
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* eslint-disable no-invalid-this */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var prop = require( './properties.js' );
26+
27+
28+
// MAIN //
29+
30+
/**
31+
* Returns the maximum extent (in pixels) that axis ticks and labels should use.
32+
*
33+
* @private
34+
* @returns {(void|NonNegativeNumber)} maximum extent
35+
*/
36+
function get() {
37+
return this[ prop.private ];
38+
}
39+
40+
41+
// EXPORTS //
42+
43+
module.exports = get;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var property2object = require( '@stdlib/plot/vega/base/property2object' );
24+
25+
26+
// MAIN //
27+
28+
var obj = property2object( 'maxExtent' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* eslint-disable no-invalid-this */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var logger = require( 'debug' );
26+
var isNonNegativeNumber = require( '@stdlib/assert/is-nonnegative-number' ).isPrimitive;
27+
var isUndefined = require( '@stdlib/assert/is-undefined' );
28+
var format = require( '@stdlib/string/format' );
29+
var changeEvent = require( './../change_event.js' );
30+
var prop = require( './properties.js' );
31+
32+
33+
// VARIABLES //
34+
35+
var debug = logger( 'vega:axis:set:'+prop.name );
36+
37+
38+
// MAIN //
39+
40+
/**
41+
* Sets the maximum extent (in pixels) that axis ticks and labels should use.
42+
*
43+
* ## Notes
44+
*
45+
* - Providing `undefined` "unsets" the configured value.
46+
*
47+
* @private
48+
* @param {(NonNegativeNumber|void)} value - input value
49+
* @throws {TypeError} must be a nonnegative number
50+
* @returns {void}
51+
*/
52+
function set( value ) {
53+
// FIXME: add "value" support
54+
if ( !isNonNegativeNumber( value ) && !isUndefined( value ) ) {
55+
throw new TypeError( format( 'invalid assignment. `%s` must be a nonnegative number. Value: `%s`.', prop.name, value ) );
56+
}
57+
if ( value !== this[ prop.private ] ) {
58+
debug( 'Current value: %s. New value: %s.', this[ prop.private ], value );
59+
this[ prop.private ] = value;
60+
this.emit( 'change', changeEvent( prop.name ) );
61+
}
62+
}
63+
64+
65+
// EXPORTS //
66+
67+
module.exports = set;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* eslint-disable no-invalid-this */
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var prop = require( './properties.js' );
26+
27+
28+
// MAIN //
29+
30+
/**
31+
* Returns the minimum extent (in pixels) that axis ticks and labels should use.
32+
*
33+
* @private
34+
* @returns {(void|NonNegativeNumber)} minimum extent
35+
*/
36+
function get() {
37+
return this[ prop.private ];
38+
}
39+
40+
41+
// EXPORTS //
42+
43+
module.exports = get;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var property2object = require( '@stdlib/plot/vega/base/property2object' );
24+
25+
26+
// MAIN //
27+
28+
var obj = property2object( 'minExtent' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

0 commit comments

Comments
 (0)