Open DSC-CSTS opened 3 years ago
I am able to make this work using this. But it remove the whole point of using this library. Because the library is not exposing the updateNeedles to parent. I am end up referencing GaugeChart object myself
...
// import gaugechart object on imports statement
let GaugeChart = require('vue-gauge/assets/bundle.js')
...
mounted() {
// Get element
let element = document.querySelector('#gauge-1')
// get svg tags
let [svg] = element.getElementsByTagName('svg')
// remove initial svg element created by the library
svg.remove()
// reinit rendering GaugeChart and referencing it to global variable
this.gauge = GaugeChart.gaugeChart(element, 250, this.config)
this.gauge.updateNeedle(this.needleValue)
// updating the global gaugechart variable
this.currentInterval = setInterval(() => {
if (this.needleValue < 100) this.needleValue += 10
if (this.currentInterval && this.needleValue === 100) clearInterval(this.currentInterval)
this.gauge.updateNeedle(this.needleValue)
}, 1000);
We can force re-render and re-init gaugeChart to updateNeedle using v-if too.
any clean version to achive this
@vano20 what is this.config here ?
@vano20 what is this.config here ?
I'm referring to this vanilla gaugeChart config
Hi,
I want to build a component but having trouble to dynamically update the needle value. Gauge-chart states this needs to be done via the updateNeedle function with the example:
Here is my code. It all happens in the watch->gaugeValue. I tried all the lines in there but with no success. It is done like this because eventually the needle value will come from a $store. For the test a 4 second interval is implemented to change the needle value by 10 every time. Is there someone who can point me in the right direction?
Regards, Dirk