TIF_E41201756/static/assets/plugins/apexcharts/samples/vanilla-js/misc/range-annotations-example.html

154 lines
4.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Line Chart with Range Annotations</title>
<link href="../../assets/styles.css" rel="stylesheet" />
<style>
#chart {
max-width: 650px;
margin: 35px auto;
}
</style>
</head>
<body>
<div id="chart">
</div>
<script src="https://cdn.jsdelivr.net/npm/apexcharts@latest"></script>
<script src="../../assets/stock-prices.js"></script>
<script>
var options = {
annotations: {
yaxis: [{
y: 8600,
y2: 9000,
borderColor: '#FEB019',
opacity: 0.1,
label: {
borderColor: '#333',
style: {
fontSize: '10px',
color: '#333',
background: '#FEB019',
},
text: 'Y-axis range',
}
}],
xaxis: [{
x: new Date('23 Nov 2017').getTime(),
x2: new Date('28 Nov 2017').getTime(),
borderColor: '#00E396',
opacity: 0.5,
label: {
borderColor: '#00E396',
style: {
fontSize: '10px',
color: '#fff',
background: '#00E396',
},
offsetY: -10,
text: 'X-axis range',
}
}]
},
chart: {
width: 350,
height: 220,
type: 'line',
sparkline: {
// enabled: true
}
},
plotOptions: {
bar: {
columnWidth: '50%'
}
},
markers: {
size: 0
},
dataLabels: {
enabled: false
},
stroke: {
curve: 'straight'
},
series: [ {
type: 'bar',
data: series.monthDataSeries2.prices
}, {
type: 'line',
data: series.monthDataSeries1.prices
}],
legend: {
show: false,
},
labels: series.monthDataSeries1.dates,
xaxis: {
type: 'datetime',
labels: {
show: false
}
},
yaxis: {
labels: {
show: false
}
}
}
var chart = new ApexCharts(
document.querySelector("#chart"),
options
);
chart.render();
// adding annotation through chart instance by calling direct method
chart.addYaxisAnnotation({
y: 9200,
y2: 9400,
borderColor: '#64b5f6',
label: {
borderColor: '#333',
style: {
fontSize: '10px',
color: '#333',
background: '#64b5f6',
},
text: 'Y-axis - runtime',
}
});
chart.addXaxisAnnotation({
x: new Date('16 Nov 2017').getTime(),
x2: new Date('18 Nov 2017').getTime(),
borderColor: '#ef9a9a',
label: {
orientation: 'vertical',
borderColor: '#ef9a9a',
style: {
fontSize: '10px',
color: '#fff',
background: '#ef9a9a',
},
offsetY: -10,
text: 'X-axis - runtime',
}
});
</script>
</body>
</html>