Add/Remove Column Views in Google Charts

Viewed 215

In google charts I am creating a Line Chart with multiple columns and different values inside of there. I am wondering how I can filter my charts to show only certain columns while inside the Google Chart itself, not from the code.

Here is an example table:

name | job       | salary | bonus
Joe  | Mech. Eng.| 150000 | 20000
Jim  | Soft. Eng.| 175000 | 10000
Tom  | Chem. Eng.| 250000 | 25000

JavaScript to hide columns (in the code itself not the selection filter that I am wondering how to do) is just the view: {'columns': [0,2,3]}. Is there a filter I can use to have the user on the webpage to be able to change the view by selecting or deselecting columns?

var chart = new google.visualization.ChartWrapper({
                                'chartType': 'LineChart',
                                'containerId': 'salary',
                                'options': { 'left': '25%',
                                    'title':'Job Salary and Bonus',
                                    'hAxis':{ 'title': '$$$'},
                                    'vAxis':{ 'title': 'Name'},
                                    'interpolateNulls': true,
                                    'height': '80%',
                                    'width': '80%' ,
                                    'width':800,
                                    'height':600,
                                'view': { 'columns': [0,2,3]}
                                }
                    });

Shows:

enter code here

On a larger scale, I would like to be able to select Name or Job to compare salary/bonus to other jobs. I was wondering if there was a way to do this in Google Charts.

EDIT: See link posted in comments

0 Answers
Related