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
// To work with the data adapter you need to reference the data adapter script file from AnyChart CDN
3
// https://cdn.anychart.com/releases/v8/js/anychart-data-adapter.min.js
4
5
// Load CSV data and create a chart by CSV data
6
// The data used in this sample can be obtained from the CDN
7
// https://cdn.anychart.com/samples/general-features/load-csv-data/data.csv
8
anychart.data.loadCsvFile(
9
'https://cdn.anychart.com/samples/general-features/load-csv-data/data.csv',
10
function (data) {
11
// create bar chart
12
var chart = anychart.bar();
13
14
// set chart title
15
chart.title('Top 10 Cosmetic Products by Revenue');
16
17
// create data set on our data
18
var dataSet = anychart.data.set(data);
19
// map mapping
20
var mapping = dataSet.mapAs({ x: 0, value: 1 });
21
22
// create bar series
23
var series = chart.bar();
24
// set chart data
25
series.data(mapping);
26
27
// set tooltip settings
28
series.tooltip().titleFormat('{%X}').format('Revenue: ${%Value}');
29
30
// set yAxis labels formatter
31
chart.yAxis().labels().format('{%Value}{groupsSeparator: }');
32
33
// set titles for axises
34
chart.xAxis().title('Products by Revenue');
35
chart.yAxis().title('Revenue in Dollars');
36
37
// set container id for the chart
38
chart.container('container');
39
// initiate chart drawing
40
chart.draw();
41
}
42
);
43
});