Skip to content

Commit a80bf49

Browse files
committed
implement cartesian axis for parcoords and change parcoords tickformat default to be on par with cartesian axes
1 parent 9e73c27 commit a80bf49

12 files changed

+36
-27
lines changed

src/traces/parcoords/attributes.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,9 @@ module.exports = {
8181
'Sets the text displayed at the ticks position via `tickvals`.'
8282
].join(' ')
8383
}),
84-
tickformat: {
85-
valType: 'string',
86-
dflt: '3s',
87-
noBlank: true,
88-
role: 'style',
89-
editType: 'plot',
90-
description: [
91-
'Sets the tick label formatting rule using d3 formatting mini-language',
92-
'which is similar to those of Python. See',
93-
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
94-
].join(' ')
95-
},
84+
tickformat: extendFlat({}, axesAttrs.tickformat, {
85+
editType: 'plot'
86+
}),
9687
visible: {
9788
valType: 'boolean',
9889
dflt: true,

src/traces/parcoords/defaults.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ var hasColorscale = require('../../components/colorscale/helpers').hasColorscale
1313
var colorscaleDefaults = require('../../components/colorscale/defaults');
1414
var handleDomainDefaults = require('../../plots/domain').defaults;
1515
var handleArrayContainerDefaults = require('../../plots/array_container_defaults');
16+
var Axes = require('../../plots/cartesian/axes');
17+
var axesAttrs = require('../../plots/cartesian/layout_attributes');
1618

1719
var attributes = require('./attributes');
1820
var axisBrush = require('./axisbrush');
@@ -37,11 +39,15 @@ function handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
3739
return Infinity;
3840
}
3941

40-
function dimensionDefaults(dimensionIn, dimensionOut) {
42+
function dimensionDefaults(dimensionIn, dimensionOut, parentOut, opts) {
4143
function coerce(attr, dflt) {
4244
return Lib.coerce(dimensionIn, dimensionOut, attributes.dimensions, attr, dflt);
4345
}
4446

47+
function axCoerce(attr, dflt) {
48+
return Lib.coerce(dimensionIn, dimensionOut._ax, axesAttrs, attr, dflt);
49+
}
50+
4551
var values = coerce('values');
4652
var visible = coerce('visible');
4753
if(!(values && values.length)) {
@@ -53,7 +59,18 @@ function dimensionDefaults(dimensionIn, dimensionOut) {
5359
coerce('tickvals');
5460
coerce('ticktext');
5561
coerce('tickformat');
56-
coerce('range');
62+
63+
dimensionOut._ax = {
64+
_id: 'y',
65+
type: 'linear',
66+
showexponent: 'all',
67+
exponentformat: 'B'
68+
};
69+
70+
Axes.setConvert(dimensionOut._ax, opts.layout);
71+
72+
axCoerce('range');
73+
dimensionOut.range = dimensionOut._ax.range;
5774

5875
coerce('multiselect');
5976
var constraintRange = coerce('constraintrange');
@@ -76,6 +93,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
7693

7794
var dimensions = handleArrayContainerDefaults(traceIn, traceOut, {
7895
name: 'dimensions',
96+
layout: layout,
7997
handleItemDefaults: dimensionDefaults
8098
});
8199

src/traces/parcoords/parcoords.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -378,22 +378,22 @@ function updatePanelLayout(yAxis, vm) {
378378
}
379379
}
380380

381-
function attachAxesToCd(cd, fullLayout) {
381+
function calcAllTicks(cd) {
382382
for(var i = 0; i < cd.length; i++) {
383383
for(var j = 0; j < cd[i].length; j++) {
384384
var dimensions = cd[i][j].trace.dimensions;
385-
386385
for(var k = 0; k < dimensions.length; k++) {
387-
var dim = dimensions[k];
386+
var dim = dimensions[k]._ax;
388387

389-
dim._ax = {
390-
type: 'linear',
391-
showexponent: 'all',
392-
exponentformat: 'B',
393-
tickformat: dim.tickformat
394-
};
388+
if(dim) {
389+
if(!dim.range) dim.range = [0, 1];
390+
if(!dim.dtick) dim.dtick = 0.1;
391+
dim.tickformat = dimensions[k].tickformat;
392+
393+
Axes.calcTicks(dim);
395394

396-
Axes.setConvert(dim._ax, fullLayout);
395+
dim.cleanRange();
396+
}
397397
}
398398
}
399399
}
@@ -406,8 +406,6 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
406406
var svg = fullLayout._toppaper;
407407
var glContainer = fullLayout._glcontainer;
408408

409-
attachAxesToCd(cdModule, fullLayout);
410-
411409
function linearFormat(dim, v) {
412410
return Axes.tickText(dim._ax, v, false).text;
413411
}
@@ -420,6 +418,8 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
420418
return linearFormat(d.model.dimensions[d.visibleIndex], v);
421419
}
422420

421+
calcAllTicks(cdModule);
422+
423423
var vm = cdModule
424424
.filter(function(d) { return unwrap(d).trace.visible; })
425425
.map(model.bind(0, layout))
4.22 KB
Loading
Loading
-1019 Bytes
Loading
-495 Bytes
Loading
6.52 KB
Loading
Loading
-1019 Bytes
Loading
241 Bytes
Loading

test/jasmine/tests/parcoords_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ describe('parcoords initialization tests', function() {
165165
expect(fullTrace.dimensions).toEqual([jasmine.objectContaining({
166166
values: [1],
167167
visible: true,
168-
tickformat: '3s',
168+
tickformat: '',
169169
multiselect: true,
170170
_index: 0,
171171
_length: 1

0 commit comments

Comments
 (0)