Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a8c702

Browse filesBrowse files
committed
bar: add object constancy to transitions
1 parent 709ee2f commit 9a8c702
Copy full SHA for 9a8c702

File tree

Expand file treeCollapse file tree

2 files changed

+11
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-1
lines changed

‎src/traces/bar/plot.js

Copy file name to clipboardExpand all lines: src/traces/bar/plot.js
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ var appendArrayPointValue = require('../../components/fx/helpers').appendArrayPo
3131
// padding in pixels around text
3232
var TEXTPAD = 3;
3333

34+
function keyFunc(d) {return d.id;}
35+
function getKeyFunc(trace) {
36+
if(trace.ids) {
37+
return keyFunc;
38+
}
39+
}
40+
3441
function dirSign(a, b) {
3542
return (a < b) ? 1 : -1;
3643
}
@@ -103,7 +110,8 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback)
103110

104111
var pointGroup = Lib.ensureSingle(plotGroup, 'g', 'points');
105112

106-
var bars = pointGroup.selectAll('g.point').data(Lib.identity);
113+
var keyFunc = getKeyFunc(trace);
114+
var bars = pointGroup.selectAll('g.point').data(Lib.identity, keyFunc);
107115

108116
bars.enter().append('g')
109117
.classed('point', true);

‎test/image/mocks/animation_bar.json

Copy file name to clipboardExpand all lines: test/image/mocks/animation_bar.json
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"type": "bar",
44
"x": ["A", "B", "C"],
55
"y": [24, 5, 8],
6+
"ids": ["A", "B", "C"],
67
"error_y": {"array": [3, 2, 1]}
78
}],
89
"layout": {
@@ -17,6 +18,7 @@
1718
{"data": [{"width": 0.25}]},
1819
{"data": [{"marker": {"line": {"width": 10}}}]},
1920
{"data": [{"marker": {"line": {"color": ["orange", "yellow", "blue"]}}}]},
21+
{"data": [{"ids": ["B", "C", "A"]}]},
2022
{"layout": {"yaxis": {"range": [0, 20]}}}
2123
]
2224
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.