Skip to content

Commit 6bc7157

Browse files
committed
add parcats mock to Plotly.react noop tests and fix it
... by storing 'calc'ed categoryarray and ticktext as using '_', so that Plots.supplyDefaults doesn't pickup spurious changes.
1 parent ee5fcea commit 6bc7157

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/traces/parcats/calc.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ module.exports = function calc(gd, trace) {
174174
var cats = dimensionModels[d].categories;
175175

176176
if(cats[catInd] === undefined) {
177-
var catValue = trace.dimensions[containerInd].categoryarray[catInd];
178-
var catLabel = trace.dimensions[containerInd].ticktext[catInd];
177+
var catValue = trace.dimensions[containerInd]._categoryarray[catInd];
178+
var catLabel = trace.dimensions[containerInd]._ticktext[catInd];
179179
cats[catInd] = createCategoryModel(d, catInd, catValue, catLabel);
180180
}
181181

@@ -480,19 +480,19 @@ function validateDimensionDisplayInds(trace) {
480480
function validateCategoryProperties(dim, uniqueInfoDim) {
481481

482482
// Update categoryarray
483-
dim.categoryarray = uniqueInfoDim.uniqueValues;
483+
dim._categoryarray = uniqueInfoDim.uniqueValues;
484484

485485
// Handle ticktext
486486
if(dim.ticktext === null || dim.ticktext === undefined) {
487-
dim.ticktext = [];
487+
dim._ticktext = [];
488488
} else {
489489
// Shallow copy to avoid modifying input array
490-
dim.ticktext = dim.ticktext.slice();
490+
dim._ticktext = dim.ticktext.slice();
491491
}
492492

493493
// Extend ticktext with elements from uniqueInfoDim.uniqueValues
494-
for(var i = dim.ticktext.length; i < uniqueInfoDim.uniqueValues.length; i++) {
495-
dim.ticktext.push(uniqueInfoDim.uniqueValues[i]);
494+
for(var i = dim._ticktext.length; i < uniqueInfoDim.uniqueValues.length; i++) {
495+
dim._ticktext.push(uniqueInfoDim.uniqueValues[i]);
496496
}
497497
}
498498

test/jasmine/assets/mock_lists.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var svgMockList = [
2727
['range_selector_style', require('@mocks/range_selector_style.json')],
2828
['range_slider_multiple', require('@mocks/range_slider_multiple.json')],
2929
['sankey_energy', require('@mocks/sankey_energy.json')],
30+
['parcats_basic', require('@mocks/parcats_basic.json')],
3031
['scattercarpet', require('@mocks/scattercarpet.json')],
3132
['shapes', require('@mocks/shapes.json')],
3233
['splom_iris', require('@mocks/splom_iris.json')],

0 commit comments

Comments
 (0)