ChartAct / web /AnyChart /line /chart_0050_line.html
wumumu's picture
Add files using upload-large-folder tool
7b52e07 verified
Raw History Blame Contribute Delete
3.86 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>BCT General Settings 01</title>
<link href="https://playground.anychart.com/docs/samples/BCT_General_Settings_01/iframe" rel="canonical">
<meta content="Line Chart" name="keywords">
<meta content="AnyChart - JavaScript Charts designed to be embedded and integrated" name="description">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link href="_deps/cdn.anychart.com/releases/8.14.1/css/anychart-ui.min_qe95e7e741b.css" rel="stylesheet" type="text/css">
<style>html, body, #container {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}</style>
</head>
<body>
<div id="container"></div>
<script src="_deps/cdn.anychart.com/releases/8.14.1/js/anychart-base.min_qe95e7e741b.js"></script>
<script src="_deps/cdn.anychart.com/releases/8.14.1/js/anychart-exports.min_qe95e7e741b.js"></script>
<script src="_deps/cdn.anychart.com/releases/8.14.1/js/anychart-ui.min_qe95e7e741b.js"></script>
<script type="text/javascript">anychart.onDocumentReady(function () {
// create a data set
var data = anychart.data.set([
["Jan", 3.8, 5.5, 6.9],
["Feb", 5.5, 7.0, 9.6],
["Mar", 9.9, 11.7, 13.3],
["Apr", 15.7, 17.6, 19.7],
["May", 21.5, 23.3, 25.8],
["Jun", 26.3, 28.5, 30.2],
["Jul", 29.3, 31.6, 33.5],
["Aug", 28.4, 30.6, 32.8],
["Sep", 24.4, 26.5, 28.0],
["Oct", 18.3, 20.6, 22.4],
["Nov", 12.3, 14.4, 16.5],
["Dec", 6.6, 8.7, 10.4]
]);
// map the data
var seriesData_1 = data.mapAs({x: 0, value: 1});
var seriesData_2 = data.mapAs({x: 0, value: 2});
var seriesData_3 = data.mapAs({x: 0, value: 3});
// set the chart type
var chart = anychart.line();
// set the interactivity mode
chart.interactivity().hoverMode("single");
// create the first series (area), set the data and name
var series1 = chart.area(seriesData_1);
series1.name("Average for 20 Years");
// configure the visual settings of the first series
series1.normal().fill("#04b4ae", 0.3);
series1.hovered().fill("#04b4ae", 0.1);
series1.selected().fill("#04b4ae", 0.5);
series1.normal().hatchFill("zig-zag", "#808080", 1, 15);
series1.hovered().hatchFill("zig-zag", "#808080", 1, 15);
series1.selected().hatchFill("zig-zag", "#808080", 1, 15);
series1.normal().stroke("#04b4ae");
series1.hovered().stroke("#04b4ae", 2);
series1.selected().stroke("#04b4ae", 4);
// create the second series (line), set the data and name
var series2 = chart.line(seriesData_2);
series2.name("2016");
// configure the visual settings of the second series
series2.normal().stroke("#04b404");
series2.hovered().stroke("#04b404", 2);
series2.selected().stroke("#04b404", 4);
// create the third series (line), set the data and title
var series3 = chart.line(seriesData_3);
series3.name("2017 (Forecast)");
// configure the visual settings of the third series
series3.normal().stroke("#aeb404", 1, "10 5", "round");
series3.hovered().stroke("#aeb404", 2, "10 5", "round");
series3.selected().stroke("#aeb404", 4, "10 5", "round");
// turn the legend on
chart.legend(true);
// set the chart title
chart.title("Visual Settings");
// set the titles of the axes
chart.xAxis().title("Month");
chart.yAxis().title("Temperature, \xb0C");
// set the container id
chart.container("container");
// initiate drawing the chart
chart.draw();
});</script>
</body>
</html>