8000 Funnelarea traces by archmoj · Pull Request #3876 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Funnelarea traces #3876

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 37 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d77474e
add funnelarea to lib components plot api etc
archmoj May 17, 2019
2d090d1
refactor other traces to reuse code in funnelarea
archmoj May 17, 2019
7b0e602
add funnelarea trace code
archmoj May 17, 2019
1b8caed
add funnelarea jasmine and image tests
archmoj May 17, 2019
32b7b0b
correct groupscale in various dim ratios
archmoj May 18, 2019
68bebc2
Merge branch 'master' into funnelarea-traces
etpinard May 20, 2019
7c3369b
rm 'i' & 'v' from funnelarea event data
etpinard May 20, 2019
abc3b39
revise hiddenlabels coerce - rm hiddenLabels unused category - rm _ha…
archmoj May 20, 2019
316aff9
more explicit funnelarea marker line color - dont inherit from sunburst
archmoj May 20, 2019
7f2dc2a
drop round stroke line join
archmoj May 20, 2019
7e6b9ae
drop quadrants and move func from funnelarea plot - add todo comment …
archmoj May 20, 2019
8bd1875
default funnelarea textinfo to percent not value
archmoj May 21, 2019
fa5b273
move convexPolygonArea to funnelarea_test - add another set of tests …
archmoj May 21, 2019
38b474d
revise funnelarea title attribute - drop support for old API
archmoj May 21, 2019
de8b517
add mock light and dark colorways for pie and funnelarea
archmoj May 21, 2019
a6a6d62
drop sort from one jasmine mock
archmoj May 21, 2019
42ca38e
moduleHasUnSelected > moduleHasUnselected
archmoj May 21, 2019
32c96d2
no need to outsidetextfont attribute in funnelarea
archmoj May 21, 2019
8000
2ad1843
fixup name of funnelarea mock used in mock list
etpinard May 21, 2019
8af4d12
add textposition inside none - change pie title and textposition edit…
archmoj May 21, 2019
4711c5c
Merge branch 'funnelarea-traces' into funnelarea-traces_dev
archmoj May 21, 2019
a9625b6
drop funnelarea sort - auto sort when funnelarea is aggregated - fixu…
archmoj May 21, 2019
1426be7
Merge branch 'master' into funnelarea-traces
etpinard May 21, 2019
79415cd
use trace._meta for funnelarea title.text
etpinard May 21, 2019
e227763
remove outsudetext from funnelarea mock
archmoj May 21, 2019
04b14a8
clear TODO comment for hiddenlabels role
archmoj May 21, 2019
4d89d1d
apply domain width and height with aspectratio
archmoj May 21, 2019
23bc199
add delay between sort-by-value tests
etpinard May 21, 2019
dd673a2
add test for pie title.position restyle calls
etpinard May 21, 2019
6673fac
:hocho: "TODO: test" for attrs that already have sufficient coverage
etpinard May 21, 2019
c64fe84
drop @flaky on @noCI test
etpinard May 21, 2019
77f1c59
drop @noCI on funnel & waterfall select tests
etpinard May 21, 2019
28b2f14
improve funnelarea scalegroup
archmoj May 22, 2019
c42a899
add shapes around domain boxes in funnelarea mocks
archmoj May 22, 2019
84b0dd1
flip processing aspectratio
archmoj May 22, 2019
08a1f7b
remove unused mock
archmoj May 22, 2019
b8b3d94
fit r using trace.aspectratio when having non scalegroup
archmoj May 22, 2019
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
Prev Previous commit
Next Next commit
drop funnelarea sort - auto sort when funnelarea is aggregated - fixu…
…p funnelarea tests without using sort
  • Loading branch information
archmoj committed May 21, 2019
commit a9625b6466cdd41c7c686e7dc516171c6eae52ac
4 changes: 1 addition & 3 deletions src/traces/funnelarea/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,5 @@ module.exports = {
description: [
'Sets the ratio between bottom length and maximum top length.'
].join(' ')
},

sort: extendFlat({}, pieAttrs.sort, { dflt: false })
}
};
1 change: 0 additions & 1 deletion src/traces/funnelarea/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
Lib.coerceFont(coerce, 'title.font', layout.font);
}

coerce('sort');
coerce('aspectratio');
coerce('baseratio');
};
6 changes: 5 additions & 1 deletion src/traces/pie/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function calc(gd, trace) {
var pullColor = makePullColorFn(fullLayout['_' + trace.type + 'colormap']);
var seriesLen = (hasVals ? vals : labels).length;
var vTotal = 0;
var isAggregated = false;

for(i = 0; i < seriesLen; i++) {
var v, label, hidden;
Expand Down Expand Up @@ -73,6 +74,8 @@ function calc(gd, trace) {
hidden: hidden
});
} else {
isAggregated = true;

pt = cd[thisLabelIndex];
pt.v += v;
pt.pts.push(i);
Expand All @@ -84,7 +87,8 @@ function calc(gd, trace) {
}
}

if(trace.sort) cd.sort(function(a, b) { return b.v - a.v; });
var shouldSort = (trace.type === 'funnelarea') ? isAggregated : trace.sort;
if(shouldSort) cd.sort(function(a, b) { return b.v - a.v; });

// include the sum of all values in the first point
if(cd[0]) cd[0].vTotal = vTotal;
Expand Down
Binary file modified test/image/baselines/funnelarea_simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions test/image/mocks/funnelarea_simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"data": [
{
"values": [
1,
2,
3,
5,
4,
5
3,
2,
1
],
"type": "funnelarea", "sort": true
"type": "funnelarea"
}
],
"layout": {
Expand Down
59 changes: 29 additions & 30 deletions test/jasmine/tests/funnelarea_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ describe('Funnelarea traces', function() {
Plotly.newPlot(gd, [{
values: [1, 2, 3, 4, 5],
type: 'funnelarea',
sort: false,
marker: {
line: {width: 3, color: 'rgba(100,100,100,0.7)'},
colors: [
Expand Down Expand Up @@ -206,17 +205,17 @@ describe('Funnelarea traces', function() {

it('propagate explicit colors to the same labels in earlier OR later traces', function(done) {
var data1 = [
{type: 'funnelarea', sort: true, values: [3, 2], marker: {colors: ['red', 'black']}, domain: {x: [0.5, 1]}},
{type: 'funnelarea', sort: true, values: [2, 5], domain: {x: [0, 0.5]}}
{type: 'funnelarea', values: [3, 2], marker: {colors: ['red', 'black']}, domain: {x: [0.5, 1]}},
{type: 'funnelarea', values: [2, 5], domain: {x: [0, 0.5]}}
];
var data2 = Lib.extendDeep([], [data1[1], data1[0]]);

Plotly.newPlot(gd, data1)
.then(_checkSliceColors(['255,0,0', '0,0,0', '0,0,0', '255,0,0']))
.then(_checkSliceColors(['255,0,0', '0,0,0', '255,0,0', '0,0,0']))
.then(function() {
return Plotly.newPlot(gd, data2);
})
.then(_checkSliceColors(['0,0,0', '255,0,0', '255,0,0', '0,0,0']))
.then(_checkSliceColors(['255,0,0', '0,0,0', '255,0,0', '0,0,0']))
.catch(failTest)
.then(done);
});
Expand Down Expand Up @@ -724,8 +723,8 @@ describe('funnelarea hovering', function() {
unhoverData = data;
});

mouseEvent('mouseover', width / 2 - 7, height / 2 - 7);
mouseEvent('mouseout', width / 2 - 7, height / 2 - 7);
mouseEvent('mouseover', width / 2 - 7, height / 2 + 50);
mouseEvent('mouseout', width / 2 - 7, height / 2 + 50);

expect(hoverData.points.length).toEqual(1);
expect(unhoverData.points.length).toEqual(1);
Expand Down Expand Up @@ -822,29 +821,29 @@ describe('funnelarea hovering', function() {
.then(_hover)
.then(function() {
assertLabel(
['4', '5', '33.3%'].join('\n'),
['0', '5', '33.3%'].join('\n'),
['rgb(31, 119, 180)', 'rgb(255, 255, 255)', 13, 'Arial', 'rgb(255, 255, 255)'],
'initial'
);

return Plotly.restyle(gd, 'text', [['A', 'B', 'C', 'D', 'E']]);
return Plotly.restyle(gd, 'text', [['E', 'D', 'C', 'B', 'A']]);
})
.then(_hover)
.then(function() {
assertLabel(
['4', 'E', '5', '33.3%'].join('\n'),
['0', 'E', '5', '33.3%'].join('\n'),
null,
'added text'
);

return Plotly.restyle(gd, 'hovertext', [[
'Apple', 'Banana', 'Clementine', 'Dragon Fruit', 'Eggplant'
'Eggplant', 'Dragon Fruit', 'Clementine', 'Banana', 'Apple'
]]);
})
.then(_hover)
.then(function() {
assertLabel(
['4', 'Eggplant', '5', '33.3%'].join('\n'),
['0', 'Eggplant', '5', '33.3%'].join('\n'),
null,
'added hovertext'
);
Expand All @@ -854,7 +853,7 @@ describe('funnelarea hovering', function() {
.then(_hover)
.then(function() {
assertLabel(
['4', 'SUP', '5', '33.3%'].join('\n'),
['0', 'SUP', '5', '33.3%'].join('\n'),
null,
'constant hovertext'
);
Expand All @@ -870,23 +869,23 @@ describe('funnelarea hovering', function() {
.then(_hover)
.then(function() {
assertLabel(
['4', 'SUP', '5', '33.3%'].join('\n'),
['0', 'SUP', '5', '33.3%'].join('\n'),
['rgb(255, 0, 0)', 'rgb(255, 255, 0)', 15, 'Roboto', 'rgb(0, 0, 255)'],
'new styles'
);

return Plotly.restyle(gd, 'hoverinfo', [[null, null, null, null, 'label+percent']]);
return Plotly.restyle(gd, 'hoverinfo', [['label+percent', null, null, null, null]]);
})
.then(_hover)
.then(function() {
assertLabel(['4', '33.3%'].join('\n'), null, 'new hoverinfo');
assertLabel(['0', '33.3%'].join('\n'), null, 'new hoverinfo');

return Plotly.restyle(gd, 'hoverinfo', [[null, null, null, null, 'dont+know+what+im-doing']]);
return Plotly.restyle(gd, 'hoverinfo', [['dont+know+what+im-doing', null, null, null, null]]);
})
.then(_hover)
.then(function() {
assertLabel(
['4', 'SUP', '5', '33.3%'].join('\n'),
['0', 'SUP', '5', '33.3%'].join('\n'),
null,
'garbage hoverinfo'
);
Expand Down Expand Up @@ -935,7 +934,7 @@ describe('funnelarea hovering', function() {
.then(_hover)
.then(function() {
assertLabel(
['4', '5', '33.3%'].join('\n'),
['0', '5', '33.3%'].join('\n'),
['rgb(31, 119, 180)', 'rgb(255, 255, 255)', 13, 'Arial', 'rgb(255, 255, 255)'],
'initial'
);
Expand All @@ -951,7 +950,7 @@ describe('funnelarea hovering', function() {
);

return Plotly.restyle(gd, {
'text': [['A', 'B', 'C', 'D', 'E']],
'text': [['E', 'D', 'C', 'B', 'A']],
'hovertemplate': '%{text}<extra></extra>'
});
})
Expand All @@ -978,12 +977,12 @@ describe('funnelarea hovering', function() {
.then(_hover)
.then(function() {
assertLabel(
['4'].join('\n'),
['0'].join('\n'),
null,
'hovertemplate %{label}'
);
})
.then(function() { return Plotly.restyle(gd, 'hovertemplate', [['', '', '', '', 'ht 5 %{percent:0.2%}<extra></extra>']]); })
.then(function() { return Plotly.restyle(gd, 'hovertemplate', [['ht 5 %{percent:0.2%}<extra></extra>', '', '', '', '']]); })
.then(_hover)
.then(function() {
assertLabel(
Expand All @@ -1003,12 +1002,12 @@ describe('funnelarea hovering', function() {
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
.then(_hover)
.then(function() {
assertHoverLabelContent({nums: '4\n5\n33.3%', name: 'looooooooooo...'}, 'base');
assertHoverLabelContent({nums: '0\n5\n33.3%', name: 'looooooooooo...'}, 'base');
})
.then(function() { return Plotly.restyle(gd, 'hoverlabel.namelength', 2); })
.then(_hover)
.then(function() {
assertHoverLabelContent({nums: '4\n5\n33.3%', name: 'lo'}, 'base');
assertHoverLabelContent({nums: '0\n5\n33.3%', name: 'lo'}, 'base');
})
.catch(failTest)
.then(done);
Expand Down Expand Up @@ -1050,15 +1049,15 @@ describe('Test event data of interactions on a funnelarea plot:', function() {
var point = data.points[0];

expect(point.curveNumber).toBe(0);
expect(point.pointNumber).toBe(4);
expect(point.pointNumbers).toEqual([4]);
expect(point.pointNumber).toBe(0);
expect(point.pointNumbers).toEqual([0]);
expect(point.data).toBe(gd.data[0]);
expect(point.fullData).toBe(gd._fullData[0]);
expect(point.label).toBe('4');
expect(point.label).toBe('0');
expect(point.value).toBe(5);
expect(point.color).toBe('#1f77b4');
expect(point.id).toEqual(['maggie']);
expect(point.customdata).toEqual([{9: 10}]);
expect(point.id).toEqual(['marge']);
expect(point.customdata).toEqual([{1: 2}]);

// no need for backward compat i/v
expect('i' in point).toBe(false);
Expand Down Expand Up @@ -1106,7 +1105,7 @@ describe('Test event data of interactions on a funnelarea plot:', function() {

expect(futureData.points[0].pointNumber).toBeUndefined();
expect(futureData.points[0].i).toBeUndefined();
expect(futureData.points[0].pointNumbers).toEqual([4, 9]);
expect(futureData.points[0].pointNumbers).toEqual([0, 5]);
});
});

Expand Down
0