Skip to content

Commit

Permalink
Renamed parcats.marker -> parcats.line
Browse files Browse the repository at this point in the history
Renamed shape categories to `linear` and `hspline` and made `linear` the default.
  • Loading branch information
jonmmease committed Aug 7, 2018
1 parent 0c9c75f commit 7b75100
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
14 changes: 7 additions & 7 deletions src/traces/parcats/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ var extendFlat = require('../../lib/extend').extendFlat;
var colorAttributes = require('../../components/colorscale/attributes');

var scatterAttrs = require('../scatter/attributes');
var scatterMarkerAttrs = scatterAttrs.marker;
var scatterLineAttrs = scatterAttrs.line;
var colorbarAttrs = require('../../components/colorbar/attributes');

var marker = extendFlat({
var line = extendFlat({
editType: 'calc'
}, colorAttributes('marker', {editType: 'calc'}),
}, colorAttributes('line', {editType: 'calc'}),
{
showscale: scatterMarkerAttrs.showscale,
showscale: scatterLineAttrs.showscale,
colorbar: colorbarAttrs,
shape: {
valType: 'enumerated',
values: ['straight', 'curved'],
dflt: 'curved',
values: ['linear', 'hspline'],
dflt: 'linear',
role: 'info',
editType: 'plot',
description: 'Sets the shape of the paths'},
Expand Down Expand Up @@ -166,7 +166,7 @@ module.exports = {
description: 'The dimensions (variables) of the parallel categories diagram.'
},

marker: marker,
line: line,
counts: {
valType: 'number',
min: 0,
Expand Down
18 changes: 9 additions & 9 deletions src/traces/parcats/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,28 @@ module.exports = function calc(gd, trace) {

// Handle path colors
// ------------------
var marker = trace.marker;
var line = trace.line;
var markerColorscale;

// Process colorscale
if(marker) {
if(hasColorscale(trace, 'marker')) {
colorscaleCalc(trace, trace.marker.color, 'marker', 'c');
if(line) {
if(hasColorscale(trace, 'line')) {
colorscaleCalc(trace, trace.line.color, 'line', 'c');
}
markerColorscale = Drawing.tryColorscale(marker);
markerColorscale = Drawing.tryColorscale(line);
} else {
markerColorscale = Lib.identity;
}

// Build color generation function
function getMarkerColorInfo(index) {
var value;
if(!marker) {
if(!line) {
value = parcatConstants.defaultColor;
} else if(Array.isArray(marker.color)) {
value = marker.color[index % marker.color.length];
} else if(Array.isArray(line.color)) {
value = line.color[index % line.color.length];
} else {
value = marker.color;
value = line.color;
}

return {color: markerColorscale(value), rawColor: value};
Expand Down
22 changes: 11 additions & 11 deletions src/traces/parcats/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ var colorbarDefaults = require('../../components/colorbar/defaults');

function markerDefaults(traceIn, traceOut, defaultColor, layout, coerce) {

coerce('marker.color', defaultColor);

if(traceIn.marker) {
coerce('marker.cmin');
coerce('marker.cmax');
coerce('marker.cauto');
coerce('marker.colorscale');
coerce('marker.showscale');
coerce('marker.shape');
colorbarDefaults(traceIn.marker, traceOut.marker, layout);
coerce('line.color', defaultColor);

if(traceIn.line) {
coerce('line.cmin');
coerce('line.cmax');
coerce('line.cauto');
coerce('line.colorscale');
coerce('line.showscale');
coerce('line.shape');
colorbarDefaults(traceIn.line, traceOut.line, layout);
}
}

Expand Down Expand Up @@ -64,7 +64,7 @@ function dimensionsDefaults(traceIn, traceOut) {

// Pass through catValues, catorder, and catlabels (validated in calc since this is where unique info is available)

// pass through marker (color, line)
// pass through line (color)
// Pass through font

commonLength = Math.min(commonLength, dimensionOut.values.length);
Expand Down
10 changes: 5 additions & 5 deletions src/traces/parcats/parcats.js
Original file line number Diff line number Diff line change
Expand Up @@ -1318,10 +1318,10 @@ function createParcatsViewModel(graphDiv, layout, wrappedParcatsModel) {
// Handle path shape
// -----------------
var pathShape;
if(trace.marker && trace.marker.shape) {
pathShape = trace.marker.shape;
if(trace.line && trace.line.shape) {
pathShape = trace.line.shape;
} else {
pathShape = 'curved';
pathShape = 'linear';
}

// Initialize parcatsViewModel
Expand Down Expand Up @@ -1582,7 +1582,7 @@ function updatePathViewModels(parcatsViewModel) {

// build svg path
var svgD;
if(parcatsViewModel.pathShape === 'curved') {
if(parcatsViewModel.pathShape === 'hspline') {
svgD = buildSvgPath(leftXPositions, pathYs, dimWidths, pathHeight, 0.5);
} else {
svgD = buildSvgPath(leftXPositions, pathYs, dimWidths, pathHeight, 0);
Expand Down Expand Up @@ -1791,7 +1791,7 @@ function createDimensionViewModel(parcatsViewModel, dimensionModel) {
* If 'forward' then sort paths based on dimensions from left to right. If 'backward' sort based on dimensions
* from right to left
* @property {String} pathShape
* The shape of the paths. Either 'straight' or 'curved'.
* The shape of the paths. Either 'linear' or 'hspline'.
* @property {DimensionViewModel|null} dragDimension
* Dimension currently being dragged. Null if no drag in progress
* @property {Margin} margin
Expand Down
2 changes: 1 addition & 1 deletion test/image/mocks/parcats_bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{"label": "Two", "values": ["A", "B", "A", "B", "C", "C", "A", "B", "C"]},
{"label": "Three", "values": [11, 11, 11, 11, 11, 11, 11, 11, 11]}],
"bundlecolors": true,
"marker": {
"line": {
"color": [0, 0, 1, 1, 0, 1, 0, 0, 0]
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/image/mocks/parcats_bundled_reversed.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{"label": "Three", "values": [11, 11, 11, 11, 11, 11, 11, 11, 11]}],
"bundlecolors": true,
"sortpaths": "backward",
"marker": {
"line": {
"color": [0, 0, 1, 1, 0, 1, 0, 0, 0]
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/image/mocks/parcats_unbundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
{"label": "Two", "values": ["A", "B", "A", "B", "C", "C", "A", "B", "C"]},
{"label": "Three", "values": [11, 11, 11, 11, 11, 11, 11, 11, 11]}],
"bundlecolors": false,
"marker": {
"line": {
"color": [0, 0, 1, 1, 0, 1, 0, 0, 0],
"shape": "straight"
"shape": "hspline"
}
}
],
Expand Down

0 comments on commit 7b75100

Please sign in to comment.