I'd like to be able to show/hide the lines on my line graph when clicking the relevant key in the legend, is this possible?
相关问题
- Broken axis in Google charts
- Google Charts backgroundColor not working with exa
- Drawing a chart after a click of a button in Googl
- Set API key with embed API google analytics
- Google Charts-Code for Category Filter
相关文章
- Google Chart veritcal axis with percentage sign
- Google Combo Chart add horizontal and vertical lin
- Google charts X-axis don't look so good
- GWT with Charts API example from Google not workin
- How to output javascript Date in json
- PHP array into google charts
- How to set google chart API locale
- Google Charts - Avoid showing negative values in y
To hide show lines on your GWT Visualization LineChart, follow these steps:-
1.Create a DataView object based on an existing DataTable object:
2.Hide the column of the curve/line that you want to hide in the DataView:
3.Draw the entire chart again based on the DataView:
Please note that there is a caveat here, step 3 is a costly step, for us it is taking almost 20-30 sec. for the the new graph to be drawn. But if the data is not large it should be manageable in your context.
Note: You will have to make your own legend with a checkbox and do the above stuff when user checks/unchecks a checkbox.
If you don't need to include scaling and animation then one option is just hide data using lineWidth and areaOpacity values;
Following code display goggle line chart and have functionality to hide/show graph line by clicking on legend label. #graph_sales_data is id of div which display chart and sales_data_graph is variable containg record.