initial commit
[power-brultech.git] / charts / canvas / examples / 26-some-common-options-across-all-chart-types / hide-and-unhide-data-series-from-legend.html
1 <!DOCTYPE HTML>\r
2 <html>\r
3 <head>\r
4         <script type="text/javascript">\r
5                 window.onload = function () {\r
6                         var chart = new CanvasJS.Chart("chartContainer", {\r
7                                 title: {\r
8                                         text: "Click on legend items to hide/unhide dataseries"\r
9                                 },\r
10                                 legend: {\r
11                                         cursor: "pointer",\r
12                                         itemclick: function (e) {\r
13                                                 if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {\r
14                                                         e.dataSeries.visible = false;\r
15                                                 } else {\r
16                                                         e.dataSeries.visible = true;\r
17                                                 }\r
18 \r
19                                                 e.chart.render();\r
20                                         }\r
21                                 },\r
22                                 data: [{\r
23                                         showInLegend: true,\r
24                                         type: "line",\r
25                                         dataPoints: [\r
26                                                 { x: 10, y: 5 },\r
27                                                 { x: 20, y: 9 },\r
28                                                 { x: 30, y: 17 },\r
29                                                 { x: 40, y: 32 },\r
30                                                 { x: 50, y: 22 },\r
31                                                 { x: 60, y: 14 },\r
32                                                 { x: 70, y: 25 },\r
33                                                 { x: 80, y: 18 },\r
34                                                 { x: 90, y: 20 }\r
35                                         ]\r
36                                 }, {\r
37                                         showInLegend: true,\r
38                                         type: "line",\r
39                                         dataPoints: [\r
40                                                 { x: 10, y: 31 },\r
41                                                 { x: 20, y: 35 },\r
42                                                 { x: 30, y: 30 },\r
43                                                 { x: 40, y: 35 },\r
44                                                 { x: 50, y: 35 },\r
45                                                 { x: 60, y: 38 },\r
46                                                 { x: 70, y: 38 },\r
47                                                 { x: 80, y: 34 },\r
48                                                 { x: 90, y: 44 }\r
49                                         ]\r
50                                 }, {\r
51                                         showInLegend: true,\r
52                                         type: "line",\r
53                                         dataPoints: [\r
54                                                 { x: 10, y: 25 },\r
55                                                 { x: 20, y: 30 },\r
56                                                 { x: 30, y: 20 },\r
57                                                 { x: 40, y: 45 },\r
58                                                 { x: 50, y: 30 },\r
59                                                 { x: 60, y: 10 },\r
60                                                 { x: 70, y: 15 },\r
61                                                 { x: 80, y: 18 },\r
62                                                 { x: 90, y: 20 }\r
63                                         ]\r
64                                 }]\r
65                         });\r
66 \r
67                         chart.render();\r
68                 }\r
69         </script>\r
70         <script src="../../canvasjs.min.js"></script>\r
71         <title>CanvasJS Example</title>\r
72 </head>\r
73 <body>\r
74         <div id="chartContainer" style="height: 400px; width: 100%;">\r
75         </div>\r
76 </body>\r
77 </html>