Skip to content

Commit 8841cb4

Browse files
committed
feat: add various tick properties
--- 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 e966d85 commit 8841cb4

File tree

22 files changed

+1149
-0
lines changed

22 files changed

+1149
-0
lines changed

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

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,21 @@ var getProperties = require( './properties/get.js' );
135135
var getScale = require( './scale/get.js' );
136136
var setScale = require( './scale/set.js' );
137137

138+
var getTickBand = require( './tick-band/get.js' );
139+
var setTickBand = require( './tick-band/set.js' );
140+
var getTickCap = require( './tick-cap/get.js' );
141+
var setTickCap = require( './tick-cap/set.js' );
142+
var getTickColor = require( './tick-color/get.js' );
143+
var setTickColor = require( './tick-color/set.js' );
144+
var getTickCount = require( './tick-count/get.js' );
145+
var setTickCount = require( './tick-count/set.js' );
146+
var getTickDash = require( './tick-dash/get.js' );
147+
var setTickDash = require( './tick-dash/set.js' );
148+
var getTickDashOffset = require( './tick-dash-offset/get.js' );
149+
var setTickDashOffset = require( './tick-dash-offset/set.js' );
150+
var getTicks = require( './ticks/get.js' );
151+
var setTicks = require( './ticks/set.js' );
152+
138153
var getTitle = require( './title/get.js' );
139154
var setTitle = require( './title/set.js' );
140155

@@ -1161,6 +1176,143 @@ setNonEnumerableReadOnlyAccessor( Axis.prototype, 'properties', getProperties );
11611176
*/
11621177
setReadWriteAccessor( Axis.prototype, 'scale', getScale, setScale );
11631178

1179+
/**
1180+
* Axis tick style to use in conjunction with band scales.
1181+
*
1182+
* @name tickBand
1183+
* @memberof Axis.prototype
1184+
* @type {string}
1185+
* @default 'center'
1186+
*
1187+
* @example
1188+
* var axis = new Axis({
1189+
* 'scale': 'xScale',
1190+
* 'orient': 'bottom',
1191+
* 'tickBand': 'extent'
1192+
* });
1193+
*
1194+
* var v = axis.tickBand;
1195+
* // returns 'extent'
1196+
*/
1197+
setReadWriteAccessor( Axis.prototype, 'tickBand', getTickBand, setTickBand );
1198+
1199+
/**
1200+
* Stroke cap for axis tick marks.
1201+
*
1202+
* @name tickCap
1203+
* @memberof Axis.prototype
1204+
* @type {string}
1205+
* @default 'butt'
1206+
*
1207+
* @example
1208+
* var axis = new Axis({
1209+
* 'scale': 'xScale',
1210+
* 'orient': 'bottom',
1211+
* 'tickCap': 'round'
1212+
* });
1213+
*
1214+
* var v = axis.tickCap;
1215+
* // returns 'round'
1216+
*/
1217+
setReadWriteAccessor( Axis.prototype, 'tickCap', getTickCap, setTickCap );
1218+
1219+
/**
1220+
* Color of axis tick marks.
1221+
*
1222+
* @name tickColor
1223+
* @memberof Axis.prototype
1224+
* @type {(string|void)}
1225+
*
1226+
* @example
1227+
* var axis = new Axis({
1228+
* 'scale': 'xScale',
1229+
* 'orient': 'bottom',
1230+
* 'tickColor': 'steelblue'
1231+
* });
1232+
*
1233+
* var v = axis.tickColor;
1234+
* // returns 'steelblue'
1235+
*/
1236+
setReadWriteAccessor( Axis.prototype, 'tickColor', getTickColor, setTickColor );
1237+
1238+
/**
1239+
* Desired number of axis tick marks for an axis visualizing a quantitative scale.
1240+
*
1241+
* @name tickCount
1242+
* @memberof Axis.prototype
1243+
* @type {(string|number|Object|void)}
1244+
*
1245+
* @example
1246+
* var axis = new Axis({
1247+
* 'scale': 'xScale',
1248+
* 'orient': 'bottom',
1249+
* 'tickCount': 10
1250+
* });
1251+
*
1252+
* var v = axis.tickCount;
1253+
* // returns 10
1254+
*/
1255+
setReadWriteAccessor( Axis.prototype, 'tickCount', getTickCount, setTickCount );
1256+
1257+
/**
1258+
* Stroke dash of axis tick marks.
1259+
*
1260+
* @name tickDash
1261+
* @memberof Axis.prototype
1262+
* @type {Array}
1263+
* @default []
1264+
*
1265+
* @example
1266+
* var axis = new Axis({
1267+
* 'scale': 'xScale',
1268+
* 'orient': 'bottom',
1269+
* 'tickDash': [ 5, 1, 1, 1 ]
1270+
* });
1271+
*
1272+
* var v = axis.tickDash;
1273+
* // returns [ 5, 1, 1, 1 ]
1274+
*/
1275+
setReadWriteAccessor( Axis.prototype, 'tickDash', getTickDash, setTickDash );
1276+
1277+
/**
1278+
* Pixel offset at which to start an axis tick mark dash array.
1279+
*
1280+
* @name tickDashOffset
1281+
* @memberof Axis.prototype
1282+
* @type {(void|number)}
1283+
*
1284+
* @example
1285+
* var axis = new Axis({
1286+
* 'scale': 'xScale',
1287+
* 'orient': 'bottom',
1288+
* 'tickDashOffset': 5
1289+
* });
1290+
*
1291+
* var v = axis.tickDashOffset;
1292+
* // returns 5
1293+
*/
1294+
setReadWriteAccessor( Axis.prototype, 'tickDashOffset', getTickDashOffset, setTickDashOffset );
1295+
1296+
/**
1297+
* Boolean indicating whether axis tick marks should be included as part of the axis.
1298+
*
1299+
* @name ticks
1300+
* @memberof Axis.prototype
1301+
* @type {boolean}
1302+
* @default true
1303+
*
1304+
* @example
1305+
* var axis = new Axis({
1306+
* 'scale': 'xScale',
1307+
* 'orient': 'bottom',
1308+
* 'ticks': false
1309+
* });
1310+
*
1311+
* var v = axis.ticks;
1312+
* // returns false
1313+
*/
1314+
setReadWriteAccessor( Axis.prototype, 'ticks', getTicks, setTicks );
1315+
11641316
/**
11651317
* Axis title.
11661318
*
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 axis tick style to use in conjunction with band scales.
32+
*
33+
* @private
34+
* @returns {string} value
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( 'tickBand' );
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 contains = require( '@stdlib/array/base/assert/contains' ).factory;
27+
var join = require( '@stdlib/array/base/join' );
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+
var STYLES = [
37+
'center',
38+
'extent'
39+
];
40+
var isStyle = contains( STYLES );
41+
42+
43+
// MAIN //
44+
45+
/**
46+
* Sets the axis tick style to use in conjunction with band scales.
47+
*
48+
* @private
49+
* @param {string} value - input value
50+
* @throws {TypeError} must be a supported tick style
51+
* @returns {void}
52+
*/
53+
function set( value ) {
54+
if ( !isStyle( value ) ) {
55+
throw new TypeError( format( 'invalid assignment. `%s` must be one of the following: "%s". Value: `%s`.', prop.name, join( STYLES, '", "' ), 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 stroke cap for axis tick marks.
32+
*
33+
* @private
34+
* @returns {string} stroke cap
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( 'tickCap' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = obj;

0 commit comments

Comments
 (0)