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 the first series and set the data
31
series1 = chart.marker(data1);
32
33
// configure the visual settings of the first series
34
series1.normal().fill("#00cc99", 0.3);
35
series1.hovered().fill("#00cc99", 0.1);
36
series1.selected().fill("#00cc99", 0.5);
37
series1.normal().stroke("#00cc99", 1, "10 5", "round");
38
series1.hovered().stroke("#00cc99", 2, "10 5", "round");
39
series1.selected().stroke("#00cc99", 4, "10 5", "round");
40
41
// create the second series and set the data
42
series2 = chart.marker(data2);
43
44
// configure the visual settings of the second series
45
series2.normal().fill("#0066cc", 0.3);
46
series2.hovered().fill("#0066cc", 0.1);
47
series2.selected().fill("#0066cc", 0.5);
48
series2.normal().hatchFill("percent50", "#0066cc");
49
series2.hovered().hatchFill("percent50", "#0066cc");
50
series2.selected().hatchFill("percent50", "#0066cc");
51
series2.normal().stroke("#0066cc");
52
series2.hovered().stroke("#0066cc", 2);
53
series2.selected().stroke("#0066cc", 4);
54
55
// set the size of markers
56
series1.normal().size(15);
57
series1.hovered().size(20);
58
series1.selected().size(20);
59
series2.normal().size(15);
60
series2.hovered().size(20);
61
series2.selected().size(20);
62
63
// set the chart title
64
chart.title("Marker Chart: Appearance");
65
66
// set the titles of the axes
67
chart.xAxis().title("Year");
68
chart.yAxis().title("Sales, $");
69
70
// set the container id
71
chart.container("container");
72
73
// initiate drawing the chart
74
chart.draw();
75
});