Skip to content
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

Transition line-chart dots along with the lines #1181

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion spec/line-chart-spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global appendChartID, loadDateFixture, makeDate */
/* global appendChartID, flushAllD3Transitions, loadDateFixture, makeDate */
describe('dc.lineChart', function () {
var id, chart, data;
var dimension, group;
Expand Down Expand Up @@ -224,6 +224,7 @@ describe('dc.lineChart', function () {
describe('for vertical ref lines', function () {
var x;
beforeEach(function () {
flushAllD3Transitions();
var dot = chart.select('circle.dot');
dot.on('mousemove').call(dot[0][0]);
x = dot.attr('cx');
Expand All @@ -240,6 +241,7 @@ describe('dc.lineChart', function () {
describe('for a left y-axis chart', function () {
var x;
beforeEach(function () {
flushAllD3Transitions();
var dot = chart.select('circle.dot');
dot.on('mousemove').call(dot[0][0]);
x = dot.attr('cx');
Expand All @@ -256,6 +258,7 @@ describe('dc.lineChart', function () {
var x;
beforeEach(function () {
chart.useRightYAxis(true).render();
flushAllD3Transitions();
var dot = chart.select('circle.dot');
dot.on('mousemove').call(dot[0][0]);
x = dot.attr('cx');
Expand Down
8 changes: 5 additions & 3 deletions src/line-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ dc.lineChart = function (parent, chartGroup) {
.attr('r', getDotRadius())
.style('fill-opacity', _dataPointFillOpacity)
.style('stroke-opacity', _dataPointStrokeOpacity)
.attr('fill', _chart.getColor)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, without this the dots will be black and transition to the color. I caught this visually but this spec will also catch it.

.on('mousemove', function () {
var dot = d3.select(this);
showDot(dot);
Expand All @@ -299,15 +300,16 @@ dc.lineChart = function (parent, chartGroup) {
hideRefLines(g);
});

dots
dots.call(renderTitle, d)
.transition()
.duration(_chart.transitionDuration())
.attr('cx', function (d) {
return dc.utils.safeNumber(_chart.x()(d.x));
})
.attr('cy', function (d) {
return dc.utils.safeNumber(_chart.y()(d.y + d.y0));
})
.attr('fill', _chart.getColor)
.call(renderTitle, d);
.attr('fill', _chart.getColor);

dots.exit().remove();
});
Expand Down