question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing options to renderChart simply doesn't work

See original GitHub issue

I’m trying to initialise my line chart with some options. I have my chart as a plugin inside of plugins/LineChart.js within my Nuxt JS app and do not understand why the options simply don’t work…

import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins

export default {
  extends: Line,
  mixins: [reactiveProp],
  data () {
    return {
      localData: null
    }
  },
  mounted () {
    this.localData = this.chartData

    const options = {
      responsive: false,
      maintainAspectRatio: false,
      legend: {
        display: false
      }
    }

    console.log(options)

    // this.chartData is created in the mixin.
    // If you want to pass options please create a local options object
    this.renderChart(this.localData, options)
  },
  watch: {
    chartData: {
      handler: function (val, oldVal) {
        this.localData = val
      },
      deep: true
    }
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aperturelesscommented, Nov 11, 2020

Can you provide a minimal codepen / codesandbox for reproduction?

0reactions
kondlacommented, Dec 23, 2020

@sts-ryan-holton try passing a complete options object via a method in the prop. E.g.

<template>
  <div>
    <line-chart :chart-data="dataCollection" :chart-options="fillOptions()" class="data-chart"></line-chart>
  </div>
</template>
...,
methods: {
    fillOptions() {
        return { your: "options", here: "inside" };
      },
...
Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue.js using chart.js options not working - Stack Overflow
Just pass the options object as a second parameter to the render method. Right now your options are within the first object passed...
Read more >
Not understanding options · Issue #93 · apertureless/vue-chartjs
I'm trying to set custom options on a chart. I had tried passing them in as an option, but, that didn't work. So...
Read more >
Getting Started - vue-chartjs
For this purpose, you should utilize Vue.js props to pass in chart options and chart data. This way, the parent component itself does...
Read more >
Updating Charts - Chart.js
Updating Options. To update the options, mutating the options property in place or passing in a new options object are supported.
Read more >
Methods - ApexCharts.js
var chart = new ApexCharts(el, options); chart.render() ... you will find an example of how variable number of parameters are passed to different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found