dc-js / dc.js

Multi-Dimensional charting built to work natively with crossfilter rendered with d3.js
Apache License 2.0
7.41k stars 1.81k forks source link

Serialize/deserialize filters #1795

Closed kum-deepak closed 3 years ago

kum-deepak commented 3 years ago

These capabilities can allow a few interesting use cases:

Currently, these are not covered by test cases. I have modified the stocks sample to add options to save and restore.

Give it a spin when you have time.

kum-deepak commented 3 years ago

Before the final release of this library, I have the following additional targets:

There is also a peculiar issue with the current .filter call in the charts - it returns only the first item if there is more than one filter. This may confuse users - it is not necessary to tackle for this release though.

gordonwoodhull commented 3 years ago

Great plan, thanks for explaining.

Yes, .filter() returning one filter is sort of consistent because .filter() also takes one filter and toggles it, and there is .filters() too.

But it’s a weird interface for sure. Don’t forget how .filter() can take an array where the first element is an array of filters, and each one is toggled!

My guess is that the need for more than one filter was not originally anticipated. But I haven’t looked back that far.

I tend to think it would be too confusing to keep the same method name and change the meaning, since there are so many examples out there. But I’m not dogmatic about it. The new version, with or without a new library name, is going to be a big change.

kum-deepak commented 3 years ago

I agree with .filter being used widely. I am not keeping it a priority, because it works and does not hamper any feature anywhere.

kum-deepak commented 3 years ago

Merged commits other than the sample. I will be working on samples as separate PR(s).