Skip to content

Fix parcats + Plotly.react bug #3072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/traces/parcats/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ module.exports = function calc(gd, trace) {
var cats = dimensionModels[d].categories;

if(cats[catInd] === undefined) {
var catValue = trace.dimensions[containerInd].categoryarray[catInd];
var catLabel = trace.dimensions[containerInd].ticktext[catInd];
var catValue = trace.dimensions[containerInd]._categoryarray[catInd];
var catLabel = trace.dimensions[containerInd]._ticktext[catInd];
cats[catInd] = createCategoryModel(d, catInd, catValue, catLabel);
}

Expand Down Expand Up @@ -480,19 +480,19 @@ function validateDimensionDisplayInds(trace) {
function validateCategoryProperties(dim, uniqueInfoDim) {

// Update categoryarray
dim.categoryarray = uniqueInfoDim.uniqueValues;
dim._categoryarray = uniqueInfoDim.uniqueValues;

// Handle ticktext
if(dim.ticktext === null || dim.ticktext === undefined) {
dim.ticktext = [];
dim._ticktext = [];
} else {
// Shallow copy to avoid modifying input array
dim.ticktext = dim.ticktext.slice();
dim._ticktext = dim.ticktext.slice();
}

// Extend ticktext with elements from uniqueInfoDim.uniqueValues
for(var i = dim.ticktext.length; i < uniqueInfoDim.uniqueValues.length; i++) {
dim.ticktext.push(uniqueInfoDim.uniqueValues[i]);
for(var i = dim._ticktext.length; i < uniqueInfoDim.uniqueValues.length; i++) {
dim._ticktext.push(uniqueInfoDim.uniqueValues[i]);
}
}

Expand Down
1 change: 1 addition & 0 deletions test/jasmine/assets/mock_lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var svgMockList = [
['range_selector_style', require('@mocks/range_selector_style.json')],
['range_slider_multiple', require('@mocks/range_slider_multiple.json')],
['sankey_energy', require('@mocks/sankey_energy.json')],
['parcats_basic', require('@mocks/parcats_basic.json')],
['scattercarpet', require('@mocks/scattercarpet.json')],
['shapes', require('@mocks/shapes.json')],
['splom_iris', require('@mocks/splom_iris.json')],
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/drawing_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ describe('Drawing', function() {
'width', 'left', 'right'
].forEach(function(dim) {
// give larger dimensions some extra tolerance
var tol = Math.max(expected[dim] / 10, 3);
var tol = Math.max(expected[dim] / 10, 3.5);
expect(actual[dim]).toBeWithin(expected[dim], tol, dim);
});
}
Expand Down
4 changes: 0 additions & 4 deletions test/jasmine/tests/parcats_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,6 @@ describe('Drag to reordered dimensions', function() {

Plotly.newPlot(gd, mock)
.then(function() {
console.log(gd.data);
restyleCallback = jasmine.createSpy('restyleCallback');
gd.on('plotly_restyle', restyleCallback);

Expand Down Expand Up @@ -1229,9 +1228,6 @@ describe('Click events', function() {
/** @type {ParcatsViewModel} */
var parcatsViewModel = d3.select('g.trace.parcats').datum();

console.log(gd.data[0]);
console.log(parcatsViewModel.hoverinfoItems);

gd.on('plotly_click', function(data) {
clickData = data;
});
Expand Down
14 changes: 7 additions & 7 deletions test/jasmine/tests/pie_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ describe('Pie traces:', function() {
expect(title.size()).toBe(1);
var titlePos = getClientPosition('g.titletext');
var pieCenterPos = getClientPosition('g.trace');
expect(Math.abs(titlePos[0] - pieCenterPos[0])).toBeLessThan(2);
expect(Math.abs(titlePos[1] - pieCenterPos[1])).toBeLessThan(2);
expect(Math.abs(titlePos[0] - pieCenterPos[0])).toBeLessThan(4);
expect(Math.abs(titlePos[1] - pieCenterPos[1])).toBeLessThan(4);
})
.catch(failTest)
.then(done);
Expand Down Expand Up @@ -229,15 +229,15 @@ describe('Pie traces:', function() {
var pieBox = d3.select('g.trace').node().getBoundingClientRect();
var radius = 0.1 * Math.min(pieBox.width / 2, pieBox.height / 2);
var pieCenterPos = getClientPosition('g.trace');
// unfortunately boundingClientRect is inaccurate and so we allow an error of 2
// unfortunately boundingClientRect is inaccurate and so we allow an error of 3
expect(_verifyPointInCircle(titleBox.left, titleBox.top, pieCenterPos, radius))
.toBeLessThan(2);
.toBeLessThan(3);
expect(_verifyPointInCircle(titleBox.right, titleBox.top, pieCenterPos, radius))
.toBeLessThan(2);
.toBeLessThan(3);
expect(_verifyPointInCircle(titleBox.left, titleBox.bottom, pieCenterPos, radius))
.toBeLessThan(2);
.toBeLessThan(3);
expect(_verifyPointInCircle(titleBox.right, titleBox.bottom, pieCenterPos, radius))
.toBeLessThan(2);
.toBeLessThan(3);
})
.catch(failTest)
.then(done);
Expand Down
8 changes: 4 additions & 4 deletions test/jasmine/tests/sliders_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,13 @@ describe('sliders interactions', function() {
d3.select(gd).selectAll('.slider-group').each(function(d, i) {
var sliderBB = this.getBoundingClientRect();
var gdBB = gd.getBoundingClientRect();

if(i === 0) {
expect(sliderBB.left - gdBB.left)
.toBeWithin(12, 3, 'left: ' + msg);
}
else {
.toBeWithin(12, 5.1, 'left: ' + msg);
} else {
expect(gdBB.bottom - sliderBB.bottom)
.toBeWithin(8, 3, 'bottom: ' + msg);
.toBeWithin(8, 5.1, 'bottom: ' + msg);
}
});
}
Expand Down