Remove Line from composite Chart

147 views
Skip to first unread message

chaturbhuj prajapat

unread,
Nov 17, 2014, 7:41:39 AM11/17/14
to dc-js-us...@googlegroups.com
My issue is that, in my composite chart few lines added by clicking on button, When we again click on same button it again draw few lines in same group.

Now for example, If in first time button press, 10 lines was draw. and in second click if only 2 lines draw, in that case, i am also see previous 8 lines , but i dont want.

So if in these case i am able to remove all previous 10 lines and able to add new 2 lines that will be better. Is there any existing option please let me know or please enhance this feature in dc.js.

Thanks

Gordon Woodhull

unread,
Nov 17, 2014, 7:57:23 AM11/17/14
to chaturbhuj prajapat, dc-js-us...@googlegroups.com

To clarify, is your question how to remove child charts from a composite chart?

Although there isn't a way to do exactly that, you can replace the children by calling the compose method with the new set of children, and removing the graphical elements using child.g().remove()

You can see this technique at work in the series chart:

https://github.com/dc-js/dc.js/blob/master/src/series-chart.js#L82-90

chaturbhuj prajapat

unread,
Nov 17, 2014, 8:08:44 AM11/17/14
to dc-js-us...@googlegroups.com
Thanks @Gordon Woodhull for you kind reply. Will you please more clear about this function.
function clearChart(c) {
if (_charts[c].g()) {
_charts[c].g().remove();
}
delete _charts[c];
}

I did not get what is "c" here.

Also my way to add chart in to composite chart is like this:

mainChart.compose(getChartArrFromSpider(flyingChart));
where flying chart is my line chart.

chaturbhuj prajapat

unread,
Nov 17, 2014, 8:11:18 AM11/17/14
to dc-js-us...@googlegroups.com

chaturbhuj prajapat

unread,
Nov 17, 2014, 8:17:14 AM11/17/14
to dc-js-us...@googlegroups.com
Again if i handle this remove from jquery manually, and after click on again button or else event on same composite chart those lines will come back...so we want something that completly remove from dc.js history.

Gordon Woodhull

unread,
Nov 17, 2014, 8:19:40 AM11/17/14
to chaturbhuj prajapat, dc-js-us...@googlegroups.com

You would have to look at the rest of the series chart code to understand the c. I was only linking to it as an example of the technique, which is to both to compose the child charts you want to keep, and also manually remove the g elements of the charts you are removing.

It is not ideal, and I agree it would be better for the composite chart to support removing directly, just trying to point you to a workaround for the time being.

Reply all
Reply to author
Forward
0 new messages