Closed kamal-hothi closed 11 years ago
Thanks Kamal, im traveling right now so sorry for not sending a code sample.
To get the behavior that you want you just have to replace the second argument of the classed function to true (for the points and the color key) using d.color_group != category, then copy those lines below and use == instead of != and false for the second argument of the classed function.
Let me know how it went
Best, Nacho
Thanks, didn't get it to work that way. But I'll try and follow the instructions more closely and get it sorted.
Thanks for taking the time to answer.
Cheers, Kamal
Any chance you could give me a code sample if it isn't too much bother? Cheers.
Here's the link to what I'm trying to reverse - http://interactives.co.nz/2013/Jul/ncea/ap.html
When I reverse this is what I get - http://interactives.co.nz/2013/Jul/ncea/ap1.html
It works on odd number of selections and not even ones. I'd appreciate any help. Thanks
Sure, here's the JS:
toggle_points = function(category) {
g_points.filter(function(d) {
return d.color_group !== category;
}).classed("hide", true);
g_color_group_keys.filter(function(d) {
return d !== category;
}).classed("hide", true);
g_points.filter(function(d) {
return d.color_group === category;
}).classed("hide", false);
g_color_group_keys.filter(function(d) {
return d === category;
}).classed("hide", false);
if (g_points.filter(":not(.hide)")[0].length === 0) {
g_color_group_keys.classed("hide", false);
return g_points.classed("hide", false);
}
};
Or coffeescript if you prefer:
g_points.filter((d)-> d.color_group != category).classed("hide", true)
g_color_group_keys.filter((d)-> d != category).classed("hide", true)
g_points.filter((d)-> d.color_group == category).classed("hide", false)
g_color_group_keys.filter((d)-> d == category).classed("hide", false)
I had made a mistake before, so I edited my previous comment. Sorry about that.
Thanks Nacho! I appreciate you taking the time to reply. That worked just fine. Thanks a lot.
No problem. I hope you find Clickme useful.
As a data journalist and R user, I find ClickMe wonderful. Thanks for developing it.
This might not be an issue, so much as a query. I'm new to github, so if that violates any rules please let me know.
With the new points template, I'm trying to make it so that instead of a category being de-selected, the opposite happens. That is the rest of them disappear.
This works fine if I change the line in toggle function to return d.color_group != category
However, when I select two categories, it reverts to old behaviour. Then with 3 it works fine qtqin. I think there is something obvious I'm missing. I'd rather take the time to figure it out, but I'm in deadline and I'd appreciate any help.
Great work on Clickme though.