Skip to content

Commit

Permalink
Fix missing animation for grid-lines opacity
Browse files Browse the repository at this point in the history
* Remove opacity from gridlines css (this was overriding the opacity animation on render)
* Update grid-chart-spec to test that the opacity value after render is 0.5
* Update gridMixin to display the gridlines with opacity 0.5 and remove overriding transition

Fixes: dc-js#1500
  • Loading branch information
louMoxy committed Nov 24, 2018
1 parent 87cf58e commit a07351b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
34 changes: 34 additions & 0 deletions spec/coordinate-grid-chart-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ describe('dc.coordinateGridChart', function () {
chart
.renderHorizontalGridLines(true)
.renderVerticalGridLines(true)
.transitionDuration(300)
.render();
});

Expand Down Expand Up @@ -351,6 +352,23 @@ describe('dc.coordinateGridChart', function () {
expect(nthGridLine(2).attr('y1')).toBe('43');
});
});

describe("after renderlet", function() {
var opacityValue;
beforeEach(function(done) {
chart.on("renderlet", function(chart) {
opacityValue = chart.select(".grid-line.horizontal line")
.attr("opacity");

done();
});
});

it("should have 0.5 opacity", function() {
expect(opacityValue).toBe("0.5");
});
});

});

describe('vertical grid lines', function () {
Expand Down Expand Up @@ -398,6 +416,22 @@ describe('dc.coordinateGridChart', function () {
expect(chart.selectAll('.grid-line.vertical line').size()).toBe(6);
});
});

describe("after renderlet", function() {
var opacityValue;
beforeEach(function(done) {
chart.on("renderlet", function(chart) {
opacityValue = chart.select(".grid-line.vertical line")
.attr("opacity");

done();
});
});

it("should have 0.5 opacity", function() {
expect(opacityValue).toBe("0.5");
});
});
});
});

Expand Down
10 changes: 4 additions & 6 deletions src/coordinate-grid-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,10 @@ dc.coordinateGridMixin = function (_chart) {
.attr('y2', 0)
.attr('opacity', 0);
dc.transition(linesGEnter, _chart.transitionDuration(), _chart.transitionDelay())
.attr('opacity', 1);
.attr('opacity', 0.5);

// update
var linesGEnterUpdate = linesGEnter.merge(lines);
dc.transition(linesGEnterUpdate, _chart.transitionDuration(), _chart.transitionDelay())
dc.transition(lines, _chart.transitionDuration(), _chart.transitionDelay())
.attr('x1', function (d) {
return _x(d);
})
Expand Down Expand Up @@ -721,11 +720,10 @@ dc.coordinateGridMixin = function (_chart) {
})
.attr('opacity', 0);
dc.transition(linesGEnter, _chart.transitionDuration(), _chart.transitionDelay())
.attr('opacity', 1);
.attr('opacity', 0.5);

// update
var linesGEnterUpdate = linesGEnter.merge(lines);
dc.transition(linesGEnterUpdate, _chart.transitionDuration(), _chart.transitionDelay())
dc.transition(lines, _chart.transitionDuration(), _chart.transitionDelay())
.attr('x1', 1)
.attr('y1', function (d) {
return scale(d);
Expand Down
1 change: 0 additions & 1 deletion style/dc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ div.dc-chart {
.grid-line, .axis .grid-line, .grid-line line, .axis .grid-line line {
fill: none;
stroke: $color_celeste;
opacity: .5;
shape-rendering: crispEdges;
}
.brush {
Expand Down

0 comments on commit a07351b

Please sign in to comment.