Skip to content

Commit 22d8e85

Browse files
authored
Merge pull request #7167 from plotly/alex/ternary-ids
Fix scatterternary with ids attribute
2 parents 52975c3 + e7b519b commit 22d8e85

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

draftlogs/7167_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Render scatterternary traces correctly if they have the `ids` attribute [[#7164](https://github.com/plotly/plotly.js/pull/7164)]

src/traces/scatterternary/calc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = function calc(gd, trace) {
1515
var displaySum = ternary.sum;
1616
var normSum = trace.sum || displaySum;
1717
var arrays = {a: trace.a, b: trace.b, c: trace.c};
18+
var ids = trace.ids;
1819

1920
var i, j, dataArray, newArray, fillArray1, fillArray2;
2021

@@ -58,6 +59,9 @@ module.exports = function calc(gd, trace) {
5859
y = a;
5960
x = c - b;
6061
cd[i] = {x: x, y: y, a: a, b: b, c: c};
62+
if (ids) {
63+
cd[i].id = ids[i];
64+
}
6165
} else cd[i] = {x: false, y: false};
6266
}
6367

test/image/mocks/ternary_simple.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"a": [2, 1, 1],
55
"b": [1, 2, 1],
66
"c": [1, 1, 2.12345],
7+
"ids": ["first ID", "second ID", "third ID"],
78
"type": "scatterternary"
89
}
910
],

test/jasmine/tests/select_test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,7 @@ describe('Test select box and lasso per trace:', function() {
20792079
function() {
20802080
assertPoints([[0.5, 0.25, 0.25]]);
20812081
assertSelectedPoints({0: [0]});
2082+
expect(selectedData.points[0].id).toBe("first ID")
20822083
},
20832084
[380, 180],
20842085
BOXEVENTS, 'scatterternary select'

test/jasmine/tests/ternary_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var assertHoverLabelContent = customAssertions.assertHoverLabelContent;
2121

2222
var SORTED_EVENT_KEYS = [
2323
'data', 'fullData', 'curveNumber', 'pointNumber', 'pointIndex',
24-
'xaxis', 'yaxis', 'a', 'b', 'c',
24+
'xaxis', 'yaxis', 'a', 'b', 'c', 'id',
2525
'bbox'
2626
].sort();
2727

0 commit comments

Comments
 (0)