HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// The data used in this sample can be obtained from the CDN
3
// https://cdn.anychart.com/samples/error-charts/marker-chart/data.json
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/error-charts/marker-chart/data.json',
6
function (data) {
7
// create scatter chart
8
var chart = anychart.marker();
9
10
// set chart padding
11
chart.padding([10, 20, 0, 10]);
12
13
// set chart title text settings
14
chart.title(
15
'Prime Costs and Prices for ACME Fashion\nCollection "Spring-Summer, 2016"'
16
);
17
18
// create marker series
19
var series = chart.marker(data);
20
21
// sets markers settings
22
series.stroke('1 #1976d2');
23
series.hovered().stroke('1 #1976d2');
24
25
// set tooltip formatter
26
series
27
.tooltip()
28
.useHtml(true)
29
.position('right')
30
.anchor('left-bottom')
31
.titleFormat(function () {
32
return this.getData('name');
33
})
34
.format(function () {
35
return (
36
'<span style="font-size: 12px; color: #E1E1E1">Prime cost: </span>$' +
37
this.getData('x') +
38
'<br/>' +
39
'<span style="font-size: 12px; color: #E1E1E1">Price: </span>$' +
40
this.getData('value')
41
);
42
});
43
44
// set titles for axises
45
chart.xAxis().title('Prime costs per item, $');
46
chart.yAxis().title('Price per item, $');
47
48
// set container id for the chart
49
chart.container('container');
50
// initiate chart drawing
51
chart.draw();
52
}
53
);
54
});