-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.vue
49 lines (45 loc) · 1.4 KB
/
index.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!-- https://github.com/recogizer/gauge-chart
https://recogizer.github.io/gauge-chart/docs/
-->
<template>
<div :id="this.gaugeId" class="vue-gauge-item"></div>
</template>
<script>
let GaugeChart = require('./assets/bundle.js');
export default {
name: 'vue-gauge',
props:['refid','options'],
mounted() {
this.initPlugin(this.options);
},
methods: {
initPlugin(options = {}){
if(this.gaugeId){
let config = {
hasNeedle: true,
needleColor: '#f76c57',
needleUpdateSpeed: 1000,
arcColors: ['#85a3ca', '#d3d3d3'],
arcDelimiters: [70],
rangeLabel: ['0', '100'],
chartWidth: 250,
needleValue: 70
};
config = { ...config, ...options };
// Element inside which you want to see the chart
let element = document.querySelector("#"+this.gaugeId );
// Drawing and updating the chart
GaugeChart.gaugeChart(element, config.chartWidth, config).updateNeedle(config.needleValue);
}
}
},
computed: {
gaugeId(){
if(typeof this.refid != 'undefined'){
return this.refid;
}
return "vue-gauge";
}
},
}
</script>