Skip to content

Commit

Permalink
fix(axis): Correct rotated x axis rendering
Browse files Browse the repository at this point in the history
At the initialization, transition element can have an incorrect rendering when non-transition selection is returned.
When the condition met, cancelling the transition is needed.

Fix #230
Close #234
  • Loading branch information
netil committed Jan 9, 2018
1 parent 29bd17e commit 2b02a03
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions spec/axis-spec.js
Expand Up @@ -921,16 +921,20 @@ describe("AXIS", function() {
args = {
data: {
columns: [
["data1", 5, 10, 15]
],
types: {
data1: "bar"
}
["data1", 30, 200, 100, 400, 150],
["data2", 50, 20, 10, 40, 15],
["data3", 50, 20, 10, 40, 15],
["data4", 30, 200, 130, 400, 30],
["data5", 50, 20, 10, 40, 415]
]
},
legend: {
show: false
},
axis: {
x: {
type: "category",
categories: ["text1", "text2", "text3"]
categories: ["cat1", "cat2", "cat3", "cat4", "cat5"]
},
rotated: true
}
Expand All @@ -941,7 +945,7 @@ describe("AXIS", function() {
const barRects = chart.internal.main.select(".bb-event-rects").selectAll("rect.bb-event-rect");
const ticks = chart.internal.main.select(".bb-axis-x").selectAll("g.tick").nodes();

barRects.each(function(rect, idx){
barRects.each(function(d, idx){
const y = d3.select(this).attr("y");
const tick = d3.select(ticks[idx]);

Expand Down
2 changes: 1 addition & 1 deletion src/axis/bb.axis.js
Expand Up @@ -118,7 +118,7 @@ export default function(params = {}) {

function transitionise(selection) {
return params.withoutTransition ?
selection : selection.transition(transition);
selection.interrupt() : selection.transition(transition);
}

function axis(g) {
Expand Down

0 comments on commit 2b02a03

Please sign in to comment.