|
|
|
@ -1,11 +1,10 @@
|
|
|
|
|
<template> |
|
|
|
|
<div id="chart"> |
|
|
|
|
asdsa |
|
|
|
|
</div> |
|
|
|
|
<div id="chart"></div> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
|
|
import { defineComponent } from 'vue'; |
|
|
|
|
import { ChartwerkLineChart } from "@chartwerk/line-pod"; |
|
|
|
|
|
|
|
|
|
// TODO: place chartwerk |
|
|
|
|
// TODO: fetch data from API |
|
|
|
@ -13,6 +12,31 @@ import { defineComponent } from 'vue';
|
|
|
|
|
export default defineComponent({ |
|
|
|
|
name: 'Graph', |
|
|
|
|
props: {}, |
|
|
|
|
mounted() { |
|
|
|
|
console.log(this.$el); |
|
|
|
|
const startTime = 1590590148; |
|
|
|
|
const arrayLength = 20; |
|
|
|
|
const data1: [number, number][] = Array.from({ length: arrayLength }, (el, idx) => [Math.floor(Math.random() * 40), 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' }, |
|
|
|
|
], |
|
|
|
|
options |
|
|
|
|
); |
|
|
|
|
pod.render(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
@ -20,7 +44,6 @@ export default defineComponent({
|
|
|
|
|
#chart { |
|
|
|
|
margin: auto; |
|
|
|
|
width: 80%; |
|
|
|
|
height: 50%; |
|
|
|
|
background: red; |
|
|
|
|
height: 350px; |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|