0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Chart.jsでプルダウンと連動して表示を切り替える

Posted at

グラフが再描画されない

プルダウンを選択すると、それに合わせてchart.jsで描画する内容を変えたかった。
・・・が、変わらない。

$setを使ってみる

this.$set(chartData, 'data', response)

としてみたけど、これでも変わらない。

Chart.js側の設定が必要だった

reactivePropを追加してあげればOKだった。

import { Line, mixins } from 'vue-chartjs'    ☆★ mixinsを追加! ☆★
const { reactiveProp } = mixins               ☆★ これを追加! ☆★

export default {
  extends: Line,
  mixins: [reactiveProp],                     ☆★ これを追加! ☆★
  props: {
    chartData: { type: Object, default: null },
    options: { type: Object, default: null }
  },

  mounted () {
    this.renderChart(this.chartData, this.options)
  }
}

Chart.js#Updating Charts

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?