Hastic standalone https://hastic.io
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.

55 lines
1.3 KiB

3 years ago
<template>
3 years ago
<div id="chart"></div>
3 years ago
</template>
<script lang="ts">
import { defineComponent } from 'vue';
3 years ago
import { HasticPod } from "./hastic_pod";
3 years ago
import { getMetrics } from '../services/metrics.service';
import _ from "lodash";
3 years ago
// TODO: fetch data from API
// TODO: set height
export default defineComponent({
name: 'Graph',
props: {},
3 years ago
mounted() {
const endTime = Math.floor(Date.now() / 1000);
3 years ago
const startTime = endTime - 1000; // 1000 seconds
3 years ago
const step = Math.max(Math.round((endTime - startTime) / 5000), 1);
3 years ago
3 years ago
getMetrics(startTime, endTime, step).then(([target, values]) => {
3 years ago
// 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) }
3 years ago
3 years ago
var pod = new HasticPod(
document.getElementById('chart'),
[
{ target: target, datapoints: values, color: 'green' },
3 years ago
]
3 years ago
);
pod.render();
3 years ago
}).catch(e => {
this.$notify({
title: "Error during extracting metric",
text: e,
3 years ago
type: 'error'
3 years ago
});
console.error(e);
3 years ago
})
3 years ago
3 years ago
}
3 years ago
});
</script>
<style scoped lang="scss">
#chart {
margin: auto;
width: 80%;
3 years ago
height: 350px;
3 years ago
}
</style>