Re: how to hide and show a line on label click inside a line chart?

29 views
Skip to first unread message

asgallant

unread,
Oct 29, 2012, 2:32:19 PM10/29/12
to google-visua...@googlegroups.com
Here's a jsfiddle I wrote a while back that does this: http://jsfiddle.net/asgallant/X2zJA/

On Monday, October 29, 2012 4:55:01 AM UTC-4, Nathan DELMA wrote:
Hi! 
I'm new to google visualization. and I try to show and hide lines when there corresponding label is clicked. 
Please tell ou show me from the following code from google how to do it.

<html>
 
<head>
   
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
   
<script type="text/javascript">
      google
.load("visualization", "1", {packages:["corechart"]});
      google
.setOnLoadCallback(drawChart);
     
function drawChart() {
       
var data = google.visualization.arrayToDataTable([
         
['Year', 'Sales', 'Expenses'],
         
['2004',  1000,      400],
         
['2005',  1170,      460],
         
['2006',  660,       1120],
         
['2007',  1030,      540]
       
]);

       
var options = {
          title
: 'Company Performance'
       
};

       
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        chart
.draw(data, options);
     
}
   
</script>
 
</head>
 
<body>
   
<div id="chart_div" style="width: 900px; height: 500px;"></div>
 
</body>
</html>
thanks

Reply all
Reply to author
Forward
0 new messages