Chart filters with inclusive default stacked values

55 views
Skip to first unread message

Steven Lovell

unread,
Dec 24, 2019, 5:19:44 AM12/24/19
to Google Visualization API
Hi All,

I'm new to Google charts and was wondering if anyone out there knows if it is possible to have a combo chart with filters that do the following.

The stacked values should always be present on the chart and the filter will only act upon the line data values.

So far I can hide the stacked values from the filter. When using the filter it removes the stacked section, only leaving the filtered values on the chart. I've attached my attempt if anyone would like to take a look.

Any help would be greatly appreciated.

Regards,
Steve.
Chart.PNG
FilterChart.txt

Daniel LaLiberte

unread,
Dec 24, 2019, 12:26:15 PM12/24/19
to Google Visualization API
Hi Steve,

I'm not sure if what you want is possible, but if it is, I expect you will have to do some fancy footwork.  You basically want the filtering to be applied to only part of the data, so you should probably first separate your data into two parts: the rows and columns for the line data and for the stacked data.

Then do the filtering of the line data, and finally join that with the stacked data, using the join function.  See details on the join function here:   https://developers.google.com/chart/interactive/docs/reference#google_visualization_data_join

Hope that helps. 

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/723b6ea3-7448-422d-bd0a-ccd76abe651c%40googlegroups.com.


--

Steven Lovell

unread,
Jan 6, 2020, 6:35:20 AM1/6/20
to Google Visualization API
Hi Daniel,

Thanks for pointing me in the direction of data joins. That all seems to work and the filter is aligned to the correct data array. Unfortunately it seems to be a bit confusing trying to plot the data on the chart as it still filters out the default values.

The issue seems to be in the code below, hopefully I'll crack it soon.

Regards,
Steve.

    function setChartView () {
        var state = columnFilter.getState();
        var row;
        var view = {
            columns: [0]
        };
        for (var i = 0; i < state.selectedValues.length; i++) {
            row = columnsTable.getFilteredRows([{column: 1, value: state.selectedValues[i]}])[0];
            view.columns.push(columnsTable.getValue(row, 0));
        }
        // sort the indices into their original order
        view.columns.sort(function (a, b) {
            return (a - b);
        });
        if (state.selectedValues.length > 0) {
          chart.setView(view);
        } else {
          chart.setView(null);
        }
        chart.draw();
    }
    google.visualization.events.addListener(columnFilter, 'statechange', setChartView);

Daniel LaLiberte

unread,
Jan 6, 2020, 7:21:25 AM1/6/20
to Google Visualization API
Hi Steve,

If you could set up a publicly viewable page that demonstrates your code, that would make it possible for me to debug it.   

It is possible that the ChartWrapper's setView method has some bugs in it that we are not aware of (I see only one simple test).    If it turns out you have found a bug, it might be best to find an alternative way to implement a similar effect, using your own DataView instead of the ChartWrapper.


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

Steven Lovell

unread,
Jan 6, 2020, 9:02:15 AM1/6/20
to Google Visualization API
Hi Daniel,

Not sure how to post a public page but you are quite welcome to see the whole code in the attached.

Regards,
Steve.


On Tuesday, 24 December 2019 10:19:44 UTC, Steven Lovell wrote:
Multi testing with filters and data join.txt
Reply all
Reply to author
Forward
0 new messages