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 a chart
4
var chart = anychart.marker();
5
6
// create series, set the data and names
7
chart.marker([[1,1],[1,1],[5,4],[10,1]]).name("Drug 1");
8
chart.marker([[2,3],[1,5],[7,3],[13,6]]).name("Drug 2");
9
chart.marker([[2,1],[1,2],[3,3],[8,1]]).name("Placebo");
10
11
// enable major grids
12
chart.xGrid(true);
13
chart.yGrid(true);
14
15
// enable minor grids
16
chart.xMinorGrid(true);
17
chart.yMinorGrid(true);
18
19
// enable the legend
20
var legend = chart.legend();
21
legend.enabled(true);
22
23
// set the position mode of the legend
24
legend.positionMode("inside");
25
26
// set the padding of the legend
27
legend.padding(35);
28
29
// configure the background of the legend
30
legend.background().enabled(true);
31
legend.background().fill("white");
32
legend.background().stroke("3 #96a6a6");
33
34
// enable the drag-and-drop mode of the legend
35
legend.drag(true);
36
37
/* listen to the dragStart event
38
and configure the background of the chart */
39
legend.listen("drag", function() {
40
chart.background().fill("#96a6a6 0.2");
41
});
42
43
/* listen to the dragEnd event
44
and reset the background of the chart */
45
legend.listen("dragEnd", function() {
46
chart.background().fill("white");
47
});
48
49
// set the chart title
50
chart.title().useHtml(true);
51
chart.title("Events: Legend<br><br>" +
52
"<span style='font-size:12; font-style:italic'>" +
53
"Drag the Legend");
54
55
// set the container id
56
chart.container("container");
57
58
// initiate drawing the chart
59
chart.draw();
60
});