You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.6 KiB
37 lines
1.6 KiB
3 years ago
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
||
|
<meta content="utf-8" http-equiv="encoding">
|
||
|
|
||
|
<script src="../dist/index.js" type="text/javascript"></script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="chart" style="width: 500px; height: 500px;"></div>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
const startTime = 1590590148;
|
||
|
const arrayLength = 20;
|
||
|
const data1 = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 40), startTime + idx * 10000]);
|
||
|
const data2 = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 100), startTime + idx * 10000]);
|
||
|
const data3 = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 20) + 90, startTime + idx * 10000]);
|
||
|
const zoomIn = (ranges) => { const range = ranges[0]; options.axis.x.range = range; pod.updateData(undefined, options) }
|
||
|
const zoomOut = (ranges) => { console.log('zoomout'); options.axis.x.range = undefined; pod.updateData(undefined, options) }
|
||
|
let options = {
|
||
|
renderLegend: false, usePanning: false, axis: { y: { invert: false, range: [0, 350] }, x: { format: 'time' } },
|
||
|
eventsCallbacks: { zoomIn: zoomIn, zoomOut }
|
||
|
}
|
||
|
var pod = new ChartwerkLineChart(
|
||
|
document.getElementById('chart'),
|
||
|
[
|
||
|
{ target: 'test1', datapoints: data1, color: 'green' },
|
||
|
{ target: 'test2', datapoints: data2, color: 'blue' },
|
||
|
{ target: 'test3', datapoints: data3, color: 'orange' },
|
||
|
],
|
||
|
options
|
||
|
);
|
||
|
pod.render();
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|