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, size: 3},
6
{x: 2001, value: 800, size: 3},
7
{x: 2002, value: 1100, size: 3},
8
{x: 2003, value: 1500, size: 2},
9
{x: 2004, value: 921, size: 4},
10
{x: 2005, value: 1000, size: 3},
11
{x: 2006, value: 1400, size: 2}
12
];
13
14
var data2 = [
15
{x: 2000, value: 900, size: 1},
16
{x: 2001, value: 950, size: 4},
17
{x: 2002, value: 800, size: 2},
18
{x: 2003, value: 1000, size: 3},
19
{x: 2004, value: 800, size: 3},
20
{x: 2005, value: 750, size: 1},
21
{x: 2006, value: 800, size: 2}
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
var series1 = chart.bubble(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
var series2 = chart.bubble(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("percent30", "#0066cc", 1, 15);
49
series2.hovered().hatchFill("percent30", "#0066cc", 1, 15);
50
series2.selected().hatchFill("percent30", "#0066cc", 1, 15);
51
series2.normal().stroke("#0066cc");
52
series2.hovered().stroke("#0066cc", 2);
53
series2.selected().stroke("#0066cc", 4);
54
55
// enable the legend
56
chart.legend(true);
57
58
// set the chart title
59
chart.title("Bubble Chart: Appearance");
60
61
// set the titles of the axes
62
chart.xAxis().title("Year");
63
chart.yAxis().title("Sales, $");
64
65
// set the container id
66
chart.container("container");
67
68
// initiate drawing the chart
69
chart.draw();
70
});