Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey,
I'm wondering if anyone knows if it is possible to change charttype based on selection. In my particular case I display a scatter plot but I want it to change to a line graph when the user zooms in. E.g, the scatter chart displays sales per region/time combination but as soon as the user selects a region the trend should be displayed as a line graph.
Well, technically it is possible with a macro. But it's easier to use two separate charts and show/hide them as needed. Charts that are hidden aren't calculated so they don't impact performance. On the Layout tab of the charts properties window you can enter an expression if you select the Conditional option. Something like =if(getselectedcount(Region)=1, 1, 0) for the line chart and =if(getselectedcount(Region)=1, 0, 1) for the scatter chart.
Can use a macro, fired off by a trigger on a change of the region (Settings>Document>Triggers) that contains commands like these:
set chart = ActiveDocument.GetSheetObject("CH01")
chart.SetProperties p
chart.SetChartType 4 'line
I would avoid the use of macros though as they sometimes don't work on Ajax.
You could instead just create two charts and set the show condition to show one when the count(distinct Region)=1 or count(distinct Region)>1
Jonathan
Well, technically it is possible with a macro. But it's easier to use two separate charts and show/hide them as needed. Charts that are hidden aren't calculated so they don't impact performance. On the Layout tab of the charts properties window you can enter an expression if you select the Conditional option. Something like =if(getselectedcount(Region)=1, 1, 0) for the line chart and =if(getselectedcount(Region)=1, 0, 1) for the scatter chart.
That's incredibly helpful Gysbert, thanks.
One more question though, how can I integrate both graphs in a container without having double the amount of tabs?
That's not going to happen.
But since you now know how to show/hide objects you can use buttons or textboxes to show/hide the objects instead of putting them in a container. You can add a Set Variable action to a button or textbox to change the value of a variable and use the variable in the conditional expression of a chart. For example a variable vMyVariable that changes between 0 and -1 (i.e. False and True). Add a Set Variable action to the button, choose vMyVariable as variable and as value: =not vMyVariable. You can use the same variable to change the text on the button of textbox: =if(vMyVariable, 'Hide chart xx', 'Show chart xx').
This gives you much more flexibility than a container can.
I was afraid so. Got to redesign the app then. Thanks a lot again!