Mikhus/canvas-gauges

updated values failed to redraw the correct needle value

Open

#170 geöffnet am 29. Mai 2018

Auf GitHub ansehen
 (7 Kommentare) (0 Reaktionen) (1 zugewiesene Person)JavaScript (402 Forks)github user discovery
bughelp wanted

Repository-Metriken

Stars
 (1.601 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

When updating the needle values for the radial gauge component, the watch function will not update the needle value on the first try. It settles at zero a few times before accepting the new value.

<template>
  <canvas class="canvas-gauges"></canvas>
</template>

<script>
import { RadialGauge } from 'canvas-gauges'
export default {
  props: {
    value: Number,
    options: {
      type: Object,
      default: () => ({})
    }
  },
  data: function () {
    return {
      chart: null
    }
  },
  mounted: function () {
    this.chart = new RadialGauge(Object.assign({}, this.options, { renderTo: this.$el, value: this.value }))
      .draw()
  },
  beforeDestroy: function () {
    this.chart.destroy()
  },
  watch: {
    value: function (val) {
      this.chart.value = val
    },
    options: function (opt) {
      this.chart.destroy()
      this.chart = new RadialGauge(Object.assign({}, this.options, {renderTo: this.$el, value: this.value})).draw()
    }
  }
}
</script>

Contributor Guide