Skip to content

Commit fadf89c

Browse files
Fixed Problem Markers on Removed Lines
1 parent a262be0 commit fadf89c

7 files changed

Lines changed: 115 additions & 31 deletions

File tree

dist/dimple.v1.2.0.js

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,16 +3098,30 @@ var dimple = {
30983098
.attr("stroke-width", series.lineWeight);
30993099
}
31003100
})
3101-
.each(drawMarkers);
3101+
.each(function (d) {
3102+
// Pass line data to markers
3103+
d.markerData = d.data;
3104+
drawMarkers(d);
3105+
});
3106+
31023107
// Update
31033108
updated = chart._handleTransition(theseShapes, duration, chart)
31043109
.attr("d", function (d) { return d.update; })
3105-
.each(drawMarkers);
3110+
.each(function (d) {
3111+
// Pass line data to markers
3112+
d.markerData = d.data;
3113+
drawMarkers(d);
3114+
});
31063115

31073116
// Remove
31083117
removed = chart._handleTransition(theseShapes.exit(), duration, chart)
31093118
.attr("d", function (d) { return d.exit; })
3110-
.each(drawMarkers);
3119+
.each(function (d) {
3120+
// Using all data for the markers fails because there are no exits in the markers
3121+
// only the whole line, therefore we need to clear the points here
3122+
d.markerData = [];
3123+
drawMarkers(d);
3124+
});
31113125

31123126
dimple._postDrawHandling(series, updated, removed, duration);
31133127

@@ -3466,6 +3480,7 @@ var dimple = {
34663480
keyString: keyString,
34673481
color: "white",
34683482
data: [],
3483+
markerData: [],
34693484
points: [],
34703485
line: {},
34713486
entry: {},
@@ -3559,17 +3574,30 @@ var dimple = {
35593574
.attr("stroke-width", series.lineWeight);
35603575
}
35613576
})
3562-
.each(drawMarkers);
3577+
.each(function (d) {
3578+
// Pass line data to markers
3579+
d.markerData = d.data;
3580+
drawMarkers(d);
3581+
});
35633582

35643583
// Update
35653584
updated = chart._handleTransition(theseShapes, duration, chart)
35663585
.attr("d", function (d) { return d.update; })
3567-
.each(drawMarkers);
3586+
.each(function (d) {
3587+
// Pass line data to markers
3588+
d.markerData = d.data;
3589+
drawMarkers(d);
3590+
});
35683591

35693592
// Remove
35703593
removed = chart._handleTransition(theseShapes.exit(), duration, chart)
35713594
.attr("d", function (d) { return d.exit; })
3572-
.each(drawMarkers);
3595+
.each(function (d) {
3596+
// Using all data for the markers fails because there are no exits in the markers
3597+
// only the whole line, therefore we need to clear the points here
3598+
d.markerData = [];
3599+
drawMarkers(d);
3600+
});
35733601

35743602
dimple._postDrawHandling(series, updated, removed, duration);
35753603

@@ -3711,9 +3739,9 @@ var dimple = {
37113739
rem;
37123740
if (series.lineMarkers) {
37133741
if (series._markerBacks === null || series._markerBacks === undefined || series._markerBacks[lineDataRow.keyString] === undefined) {
3714-
markerBacks = chart._group.selectAll("." + markerBackClasses.join(".")).data(lineDataRow.data);
3742+
markerBacks = chart._group.selectAll("." + markerBackClasses.join(".")).data(lineDataRow.markerData);
37153743
} else {
3716-
markerBacks = series._markerBacks[lineDataRow.keyString].data(lineDataRow.data, function (d) { return d.key; });
3744+
markerBacks = series._markerBacks[lineDataRow.keyString].data(lineDataRow.markerData, function (d) { return d.key; });
37173745
}
37183746
// Add
37193747
markerBacks
@@ -3777,9 +3805,9 @@ var dimple = {
37773805

37783806
// Deal with markers in the same way as main series to fix #28
37793807
if (series._markers === null || series._markers === undefined || series._markers[lineDataRow.keyString] === undefined) {
3780-
markers = chart._group.selectAll("." + markerClasses.join(".")).data(lineDataRow.data);
3808+
markers = chart._group.selectAll("." + markerClasses.join(".")).data(lineDataRow.markerData);
37813809
} else {
3782-
markers = series._markers[lineDataRow.keyString].data(lineDataRow.data, function (d) {
3810+
markers = series._markers[lineDataRow.keyString].data(lineDataRow.markerData, function (d) {
37833811
return d.key;
37843812
});
37853813
}

dist/dimple.v1.2.0.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/methods/_drawMarkerBacks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
rem;
88
if (series.lineMarkers) {
99
if (series._markerBacks === null || series._markerBacks === undefined || series._markerBacks[lineDataRow.keyString] === undefined) {
10-
markerBacks = chart._group.selectAll("." + markerBackClasses.join(".")).data(lineDataRow.data);
10+
markerBacks = chart._group.selectAll("." + markerBackClasses.join(".")).data(lineDataRow.markerData);
1111
} else {
12-
markerBacks = series._markerBacks[lineDataRow.keyString].data(lineDataRow.data, function (d) { return d.key; });
12+
markerBacks = series._markerBacks[lineDataRow.keyString].data(lineDataRow.markerData, function (d) { return d.key; });
1313
}
1414
// Add
1515
markerBacks

src/methods/_drawMarkers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
// Deal with markers in the same way as main series to fix #28
1313
if (series._markers === null || series._markers === undefined || series._markers[lineDataRow.keyString] === undefined) {
14-
markers = chart._group.selectAll("." + markerClasses.join(".")).data(lineDataRow.data);
14+
markers = chart._group.selectAll("." + markerClasses.join(".")).data(lineDataRow.markerData);
1515
} else {
16-
markers = series._markers[lineDataRow.keyString].data(lineDataRow.data, function (d) {
16+
markers = series._markers[lineDataRow.keyString].data(lineDataRow.markerData, function (d) {
1717
return d.key;
1818
});
1919
}

src/objects/plot/area.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,16 +356,30 @@
356356
.attr("stroke-width", series.lineWeight);
357357
}
358358
})
359-
.each(drawMarkers);
359+
.each(function (d) {
360+
// Pass line data to markers
361+
d.markerData = d.data;
362+
drawMarkers(d);
363+
});
364+
360365
// Update
361366
updated = chart._handleTransition(theseShapes, duration, chart)
362367
.attr("d", function (d) { return d.update; })
363-
.each(drawMarkers);
368+
.each(function (d) {
369+
// Pass line data to markers
370+
d.markerData = d.data;
371+
drawMarkers(d);
372+
});
364373

365374
// Remove
366375
removed = chart._handleTransition(theseShapes.exit(), duration, chart)
367376
.attr("d", function (d) { return d.exit; })
368-
.each(drawMarkers);
377+
.each(function (d) {
378+
// Using all data for the markers fails because there are no exits in the markers
379+
// only the whole line, therefore we need to clear the points here
380+
d.markerData = [];
381+
drawMarkers(d);
382+
});
369383

370384
dimple._postDrawHandling(series, updated, removed, duration);
371385

src/objects/plot/line.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
keyString: keyString,
101101
color: "white",
102102
data: [],
103+
markerData: [],
103104
points: [],
104105
line: {},
105106
entry: {},
@@ -193,17 +194,30 @@
193194
.attr("stroke-width", series.lineWeight);
194195
}
195196
})
196-
.each(drawMarkers);
197+
.each(function (d) {
198+
// Pass line data to markers
199+
d.markerData = d.data;
200+
drawMarkers(d);
201+
});
197202

198203
// Update
199204
updated = chart._handleTransition(theseShapes, duration, chart)
200205
.attr("d", function (d) { return d.update; })
201-
.each(drawMarkers);
206+
.each(function (d) {
207+
// Pass line data to markers
208+
d.markerData = d.data;
209+
drawMarkers(d);
210+
});
202211

203212
// Remove
204213
removed = chart._handleTransition(theseShapes.exit(), duration, chart)
205214
.attr("d", function (d) { return d.exit; })
206-
.each(drawMarkers);
215+
.each(function (d) {
216+
// Using all data for the markers fails because there are no exits in the markers
217+
// only the whole line, therefore we need to clear the points here
218+
d.markerData = [];
219+
drawMarkers(d);
220+
});
207221

208222
dimple._postDrawHandling(series, updated, removed, duration);
209223

tmp/dimple.js

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,16 +3098,30 @@ var dimple = {
30983098
.attr("stroke-width", series.lineWeight);
30993099
}
31003100
})
3101-
.each(drawMarkers);
3101+
.each(function (d) {
3102+
// Pass line data to markers
3103+
d.markerData = d.data;
3104+
drawMarkers(d);
3105+
});
3106+
31023107
// Update
31033108
updated = chart._handleTransition(theseShapes, duration, chart)
31043109
.attr("d", function (d) { return d.update; })
3105-
.each(drawMarkers);
3110+
.each(function (d) {
3111+
// Pass line data to markers
3112+
d.markerData = d.data;
3113+
drawMarkers(d);
3114+
});
31063115

31073116
// Remove
31083117
removed = chart._handleTransition(theseShapes.exit(), duration, chart)
31093118
.attr("d", function (d) { return d.exit; })
3110-
.each(drawMarkers);
3119+
.each(function (d) {
3120+
// Using all data for the markers fails because there are no exits in the markers
3121+
// only the whole line, therefore we need to clear the points here
3122+
d.markerData = [];
3123+
drawMarkers(d);
3124+
});
31113125

31123126
dimple._postDrawHandling(series, updated, removed, duration);
31133127

@@ -3466,6 +3480,7 @@ var dimple = {
34663480
keyString: keyString,
34673481
color: "white",
34683482
data: [],
3483+
markerData: [],
34693484
points: [],
34703485
line: {},
34713486
entry: {},
@@ -3559,17 +3574,30 @@ var dimple = {
35593574
.attr("stroke-width", series.lineWeight);
35603575
}
35613576
})
3562-
.each(drawMarkers);
3577+
.each(function (d) {
3578+
// Pass line data to markers
3579+
d.markerData = d.data;
3580+
drawMarkers(d);
3581+
});
35633582

35643583
// Update
35653584
updated = chart._handleTransition(theseShapes, duration, chart)
35663585
.attr("d", function (d) { return d.update; })
3567-
.each(drawMarkers);
3586+
.each(function (d) {
3587+
// Pass line data to markers
3588+
d.markerData = d.data;
3589+
drawMarkers(d);
3590+
});
35683591

35693592
// Remove
35703593
removed = chart._handleTransition(theseShapes.exit(), duration, chart)
35713594
.attr("d", function (d) { return d.exit; })
3572-
.each(drawMarkers);
3595+
.each(function (d) {
3596+
// Using all data for the markers fails because there are no exits in the markers
3597+
// only the whole line, therefore we need to clear the points here
3598+
d.markerData = [];
3599+
drawMarkers(d);
3600+
});
35733601

35743602
dimple._postDrawHandling(series, updated, removed, duration);
35753603

@@ -3711,9 +3739,9 @@ var dimple = {
37113739
rem;
37123740
if (series.lineMarkers) {
37133741
if (series._markerBacks === null || series._markerBacks === undefined || series._markerBacks[lineDataRow.keyString] === undefined) {
3714-
markerBacks = chart._group.selectAll("." + markerBackClasses.join(".")).data(lineDataRow.data);
3742+
markerBacks = chart._group.selectAll("." + markerBackClasses.join(".")).data(lineDataRow.markerData);
37153743
} else {
3716-
markerBacks = series._markerBacks[lineDataRow.keyString].data(lineDataRow.data, function (d) { return d.key; });
3744+
markerBacks = series._markerBacks[lineDataRow.keyString].data(lineDataRow.markerData, function (d) { return d.key; });
37173745
}
37183746
// Add
37193747
markerBacks
@@ -3777,9 +3805,9 @@ var dimple = {
37773805

37783806
// Deal with markers in the same way as main series to fix #28
37793807
if (series._markers === null || series._markers === undefined || series._markers[lineDataRow.keyString] === undefined) {
3780-
markers = chart._group.selectAll("." + markerClasses.join(".")).data(lineDataRow.data);
3808+
markers = chart._group.selectAll("." + markerClasses.join(".")).data(lineDataRow.markerData);
37813809
} else {
3782-
markers = series._markers[lineDataRow.keyString].data(lineDataRow.data, function (d) {
3810+
markers = series._markers[lineDataRow.keyString].data(lineDataRow.markerData, function (d) {
37833811
return d.key;
37843812
});
37853813
}

0 commit comments

Comments
 (0)