How to toggle series visibility when grouped?

I know that I can toggle series 'x' visibility on a multi-series chart using

chartName.control.series[x].isVisible = true/false;

and I can loop through the series to find which one I want to toggle.


However, I have a situation where there is only one series in a line chart but it is split out by a hierarchy, so I effectively get one line per brand. I want to toggle the visibility on each individual line.


I can get the points on the line I need by a variation of

chartName.control.series[0].getGroupedPoints().forEach(function (i) { console.log(i[0]._groupingSource[0].members[0].caption);})

but I don't know how to show or hide them.


Surely there should be a simple way to do this?

You can always use a checkbox list filter for the hierarchy placed on the columns. This won't require any script. Is there a specific reason you want to use a script here?

Yes, because I want to toggle it with images not a checkbox list.

In that case - you can create a table visualization that contains an image column. Then you can setup an interaction that will filter your line chart when clicking on the specific image. Here is a simple example of what it could look like:


Here are the steps to create it:

1. create an additional table visualization and use an image column to reflect the images of the different series (for example, you can set that to be a URL ro the image path). Make sure your table also contains a column for the hierarchy you have on the line chart column (the column doesn't have to visibile but do need to exist in the table)

2. create a member filter and connect it to the hierarchy you have on the line chart columns but not to the table visualization. Note that filter control doesn't have to exist but you do need the view parameter.

3. on the table, setup a filter interaction, make sure it is bound to "any bound visual" and under the "setup parameters" you map the hierarchy filter value to the view parameter you created in step #2.


This should do the trick with no script. Let me know if that works for you.

Firstly this seems like a complicated way of doing things, and there should be a better way, preferably via script so I can have more control over what happens when.

Secondly, I don't think this helps as I want to toggle them individually. So I want to see them all initially, then I want to hide Australia and Canada. Then I want to show Canada. Then I want to hide Germany etc.

I think your workaround changes which some is shown but doesn't give me the control I need over which combination is shown.

I think you want a collection member view parameter, and to select the members via script, correct? Try the collectionMember example in this article:

http://www.dundas.com/support/support-center/support-articles/scripting/modify-a-filter-/-view-parameter-using-scripting

Thanks Elia - that worked.