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
3
// create data
4
var data1 = [
5
{x: 2000, value: 1100},
6
{x: 2001, value: 800},
7
{x: 2002, value: 1100},
8
{x: 2003, value: 1500},
9
{x: 2004, value: 921},
10
{x: 2005, value: 1000},
11
{x: 2006, value: 1400}
12
];
13
14
var data2 = [
15
{x: 2000, value: 900},
16
{x: 2001, value: 950},
17
{x: 2002, value: 800},
18
{x: 2003, value: 1000},
19
{x: 2004, value: 800},
20
{x: 2005, value: 790},
21
{x: 2006, value: 800}
22
];
23
24
// create a chart
25
var chart = anychart.cartesian();
26
27
// set the interactivity mode
28
chart.interactivity().hoverMode("by-x");
29
30
// create series and set the data
31
var series1 = chart.marker(data1);
32
var series2 = chart.marker(data2);
33
34
// set the type of markers
35
series1.normal().type("star4");
36
series1.hovered().type("star5");
37
series1.selected().type("star6");
38
series2.normal().type("star4");
39
series2.hovered().type("star5");
40
series2.selected().type("star6");
41
42
// set the size of markers
43
series1.normal().size(20);
44
series2.normal().size(25);
45
series1.hovered().size(25);
46
series2.hovered().size(30);
47
series1.selected().size(25);
48
series2.selected().size(30);
49
50
// set the chart title
51
chart.title("Marker Chart: Type");
52
53
// set the titles of the axes
54
chart.xAxis().title("Year");
55
chart.yAxis().title("Sales, $");
56
57
// set the container id
58
chart.container("container");
59
60
// initiate drawing the chart
61
chart.draw();
62
});