Skip to content

Commit 3f9b1d5

Browse files
committed
expose the tickformat attribute
1 parent fd538ca commit 3f9b1d5

File tree

8 files changed

+22
-8
lines changed

8 files changed

+22
-8
lines changed

src/traces/parcoords/attributes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ module.exports = {
5656
},
5757
tickvals: axesAttrs.tickvals,
5858
ticktext: axesAttrs.ticktext,
59+
tickformat: {
60+
valType: 'string',
61+
dflt: '3s',
62+
role: 'style',
63+
description: [
64+
'Sets the tick label formatting rule using d3 formatting mini-language',
65+
'which is similar to those of Python. See',
66+
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
67+
].join(' ')
68+
},
5969
visible: {
6070
valType: 'boolean',
6171
dflt: true,

src/traces/parcoords/calc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = function calc(gd, trace) {
2323
constraintrange: inputDimensions[i].constraintrange,
2424
tickvals: inputDimensions[i].tickvals,
2525
ticktext: inputDimensions[i].ticktext,
26+
tickformat: inputDimensions[i].tickformat,
2627
visible: inputDimensions[i].visible,
2728
label: inputDimensions[i].label,
2829
values: inputDimensions[i].values

src/traces/parcoords/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = {
1515
legendWidth: 80,
1616
verticalPadding: 2, // otherwise, horizontal lines on top or bottom are of lower width
1717
tickDistance: 50,
18-
tickFormat: '3s',
1918
canvasPixelRatio: 1,
2019
blockLineCount: 5000,
2120
scatter: false,

src/traces/parcoords/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ function dimensionsDefaults(traceIn, traceOut) {
6161
coerce('label');
6262
coerce('tickvals');
6363
coerce('ticktext');
64+
coerce('tickformat');
6465
coerce('range');
6566
coerce('constraintrange');
6667
coerce('values');

src/traces/parcoords/parcoords.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ function viewModel(model) {
184184
return {
185185
key: key,
186186
label: dimension.label,
187-
tickvals: dimension.tickvals || false,
188-
ticktext: dimension.ticktext || false,
187+
tickFormat: dimension.tickformat,
188+
tickvals: dimension.tickvals,
189+
ticktext: dimension.ticktext,
189190
ordinal: !!dimension.tickvals,
190191
scatter: c.scatter || dimension.scatter,
191192
xIndex: i,
@@ -548,7 +549,7 @@ module.exports = function(root, svg, styledData, layout, callbacks) {
548549
.orient('left')
549550
.tickSize(4)
550551
.outerTickSize(2)
551-
.ticks(wantedTickCount, c.tickFormat) // works for continuous scales only...
552+
.ticks(wantedTickCount, d.tickFormat) // works for continuous scales only...
552553
.tickValues(d.ordinal ? // and this works for ordinal scales
553554
sdom.filter(function(d, i) {return !(i % Math.round((sdom.length / wantedTickCount)));})
554555
.map(function(d, i) {return texts && texts[i] || d;}) :
@@ -619,7 +620,7 @@ module.exports = function(root, svg, styledData, layout, callbacks) {
619620
.data(repeat, keyFun);
620621

621622
function formatExtreme(d) {
622-
return d.ordinal ? function() {return '';} : d3.format(c.tickFormat);
623+
return d.ordinal ? function() {return '';} : d3.format(d.tickFormat);
623624
}
624625

625626
axisExtentTopText.enter()
628 Bytes
Loading

test/image/mocks/gl2d_parcoords.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"id": "Block width",
3030
"label": "Block width",
3131
"range": [0, 700000],
32+
"tickformat": "",
3233
"values": [268630, 489543, 379086, 600000, 489543, 268630, 600000, 379086, 268630, 489543, 379086, 600000, 489543, 268630, 600000, 379086, 268630, 489543, 379086, 600000, 489543, 268630, 600000, 379086, 268630, 489543, 436900, 373600, 268630, 439000, 381800, 491200, 402800, 381400, 485600, 600000, 372200, 394700, 383800, 401100, 356500, 313200, 487100, 490700, 432299, 530300, 521500, 456700, 333800, 343200, 394000, 328200, 487700, 383600, 317700, 324600, 482900, 515100, 500100, 562700, 486000, 453400, 352900, 331300, 496200, 469099, 472500, 354700, 507700, 509000, 439300, 525300, 347600, 379000, 432800, 378800, 383200, 523800, 600000, 313600, 497700, 411300, 420000, 381100, 342800, 385900, 268630, 495800, 488000, 446400, 397900, 373300, 385700, 396500, 475700, 510600, 586800, 596000, 407600, 439200]
3334
},
3435
{

test/jasmine/tests/parcoords_test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('parcoords initialization tests', function() {
8282
alienProperty: 'Alpha Centauri'
8383
}]
8484
});
85-
expect(fullTrace.dimensions).toEqual([{values: [1], visible: true, _index: 0}]);
85+
expect(fullTrace.dimensions).toEqual([{values: [1], visible: true, tickformat: '3s', _index: 0}]);
8686
});
8787

8888
it('\'dimension.visible\' should be set to false, and other props just passed through if \'values\' is not provided', function() {
@@ -125,8 +125,8 @@ describe('parcoords initialization tests', function() {
125125
{values: [1, 2], visible: false} // shouldn't be truncated to as false
126126
]});
127127
expect(fullTrace.dimensions).toEqual([
128-
{values: [321, 534, 542], visible: true, _index: 0},
129-
{values: [562, 124, 942], visible: true, _index: 1},
128+
{values: [321, 534, 542], visible: true, tickformat: '3s', _index: 0},
129+
{values: [562, 124, 942], visible: true, tickformat: '3s', _index: 1},
130130
{values: [], visible: false},
131131
{values: [1, 2], visible: false}
132132
]);
@@ -587,6 +587,7 @@ describe('parcoords', function() {
587587
restyleDimension('label', 'new label')()
588588
.then(restyleDimension('tickvals', [[0, 0.1, 0.4, 1, 2]]))
589589
.then(restyleDimension('ticktext', [['alpha', 'gamma', 'beta', 'omega', 'epsilon']]))
590+
.then(restyleDimension('tickformat', '4s'))
590591
.then(restyleDimension('range', [[0, 2]]))
591592
.then(restyleDimension('constraintrange', [[0, 1]]))
592593
.then(restyleDimension('values', [[0, 0.1, 0.4, 1, 2, 0, 0.1, 0.4, 1, 2]]))

0 commit comments

Comments
 (0)