HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
var chart = anychart.line();
3
chart.legend(true);
4
5
var series1 = chart.line([
6
{x: 'January', value: 35},
7
{x: 'February', value: 15},
8
{x: 'March', value: 20},
9
{x: 'April', value: 19},
10
{x: 'May', value: 40},
11
{x: 'June', value: 10},
12
{x: 'Jule', value: 23}
13
]);
14
series1.legendItem({text: 'Light blue line', iconType: 'circle', iconFill: '#81D4FA'});
15
16
var series2 = chart.line([
17
{x: 'January', value: 4},
18
{x: 'February', value: 6},
19
{x: 'March', value: 4},
20
{x: 'April', value: 9},
21
{x: 'May', value: 20},
22
{x: 'June', value: 30},
23
{x: 'Jule', value: 43}
24
]);
25
series2.legendItem({text: 'Blue line', iconType: 'square', iconFill: '#90CAF9'});
26
27
chart.title('Get and modify legend item');
28
chart.container('container');
29
chart.draw();
30
31
// Get legend item.
32
var legendItem = series1.legendItem();
33
legendItem.disabled(true);
34
});