score:3
vue-chartjs author here.
About the mixins: There are two mixins included. Mixins in vue simply extract some logic and functionality into seperate files, so you can reuse them.
Like in the docs said, there are two mixins.
- reactiveProp and
- reactiveData
Because, there are two main scenarios, how you pass data to the chart component. Possibility one is for example in a laravel environment where you pass your data over the props directly to your component.
<my-chart :chart-data="..."></my-chart>
The other usecase is, if you have an API and make a fetch / API request. But then your chart data is not a prop, is a variable in the data() function of vue.
Fix
Well you overcomplicate your code a bit.
You rather need the reactiveProp mixin.
<script>
import { Doughnut, mixins } from 'vue-chartjs'
export default Doughnut.extend({
mixins: [mixins.reactiveProp],
props: ["options"],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
</script>
The mixin will create a prop named chartData and add a watcher to it. Every time the data changes, it will either update the chart or re-render. If you add new datasets the chart needs to be re-rendered.
Your Questions
- Well you don't need $ref, if you use the right mixin
- camelCase in templates needs to be written with a dash '-'
- Maybe it is buggy, because you duplicated the data attribute. The mixins always automatically create your chartData as a property or data() function variable. So you don't need to create it by your own. However I guess it could be a race condition. Where data is not set in the create() hook of vue. https://vuejs.org/v2/guide/instance.html#Lifecycle-Diagram
Source: stackoverflow.com
Related Query
- VueJs + Chart.js - Avoid ref for reactive updates
- VueJS + Chartjs - Chart only renders after code change
- getting additional value fields from data source for dx.chartjs doughnut chart
- How can labels/legends be added for all chart types in chart.js (chartjs.org)?
- Chart Js Change Label orientation on x-Axis for Line Charts
- Chartjs random colors for each part of pie chart with data dynamically from database
- Chart.js how to show cursor pointer for labels & legends in line chart
- Chart JS - Use time for xAxes
- show label in tooltip but not in x axis for chartjs line chart
- How to add second Y-axis for Bar and Line chart in Chart.js?
- chart.js Line chart with different background colors for each section
- reactive chart with chart.js in meteor
- Chart JS - set start of week for x axis time series
- Problem for display a chart with Chart.js and Angular
- Chart js. How to change font styles for "labels" array?
- Different color for each column in angular-chartjs bar chart
- Border radius for the bar chart in ChartJS
- Chart JS show multiple data points for the same label
- Chart.js tooltip hover customization for mixed chart
- Can I specify a different font size for each row of text in Chart Title?
- Chartjs - data format for bar chart with multi-level x-axes
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- Chart js different background for y axis
- How to use 'time' (data from database, data type: timestamp ) for plotting graph in Chart JS
- (Vue, ChartJS) Create gradient background for chart from child component canvas context
- How do I obtain a Chart instance for Chart.js
- Change labels colors for radar chart js
- how to set chart.js grid color for line chart
- Grouping the object by key for Chartjs bar chart
- PrimeNg bar chart how to show a label for the y-axis
More Query from same tag
- Images in ChartJS CustomTooltips
- how to use chart.js with angular-chart using requirejs
- Javascript not showing up total value in middle of Oracle APEX Donut chart
- Chart.JS Not Formatting Y-Axis-1 Properly
- Canvas JS using ajax call
- Change Step Area Color Based on Value
- How to add prefix to legend in ng charts using angular
- How to generate chartjs charts to pdf using laravel?
- How do I change the colours of specific labels in ng2-charts?
- Angular Dynamic Chart Generate
- Chart.js - In Graph Data for Pie & Doughnut Charts
- ChartJS show gaps in time data
- Chartjs - my old data show sometimes, bugs?
- Position tooltip in center of bar
- Start bar-chart at 0 using ChartJS
- ChartJS Tooltip - Change Data Format Displayed
- Dataset push in for loop only 1 time instead of 3
- How do I type string in the tooltip in Chart.js?
- Chart.Mvc scale begin at 0 - Nullable bool property remains null
- Chart.js animation: onComplete event fired on hover
- Chart JS flicker when new data is added to chart (Vue)
- Chart.JS not working in Xpages, chart not defined errror
- Chart.js remove gridline
- chartjs-plugin-annotation box in Django app
- JSX element type 'Line' is not a constructor function for JSX elements
- chartjs not following height when parent's height is 200px
- How to expand the slice of donut chart in chartjs?
- Chart only prints out first value using jquery ajax php
- ChartJS: Chart not displaying full range of data
- I can't display the vue-chart.js on the page