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.

Is there a way to update options?

See original GitHub issue

Hi,

I have a form with inputs and when that form is filed and submited, I woulf like to change main title and title for axis.

This is component: <bar-chart :data="barData" :options="barOptions" :height="400"></bar-chart> import { Line, mixins } from "vue-chartjs"; export default Line.extend({ props: ["options", "chartData"], mixins: [mixins.reactiveProp], mounted() { this.renderChart(this.chartData, this.options); } });

and these are the options: barOptions: { title: { display: true, text: 'Change this thing', fontSize: 16, padding: 24 } }

I am wondering is there a way to change options on event or any other way after rendering of chart?

I am using importing component so I thought that I can call render function with LineChart.options.methods.renderChart(this.barData, this.barOptions) but this give me an error ‘canvas is undefined’

Environment

  • vue.js version: 2.3.3
  • vue-chart.js version: 2.8.6
  • npm version: 5.3.0

Issue Analytics

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

github_iconTop GitHub Comments

9reactions
zanechuacommented, Jul 30, 2019

Probably the most correct way would be to do the following

    watch: {
        options: function() {
            this.$data._chart.options = this.options;
            this.$data._chart.update();
        },
    },
9reactions
aperturelesscommented, Sep 13, 2017

Simply add a watcher to your chart component. So everytime you change the options it will re-render the chart.

import { Line, mixins } from "vue-chartjs";
export default Line.extend({
  props: ["options", "chartData"],
  mixins: [mixins.reactiveProp],
  mounted() {
    this.renderChart(this.chartData, this.options);
   },
   watch: {
     options () {
        this.renderChart(this.chartData, this.options);
     }
   }
});

Another way, would be over an EventBus or vuex . There are many possibilities 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Change Windows Update Settings (Windows 11, 10+)
Right-click the Start button, and choose Settings. · Choose Windows Update from the menu on the left. · Select Advanced Options. · The...
Read more >
Manage updates in Windows - Microsoft Support
Manage updates in Windows · Select Start > Settings > Windows Update . · Select Schedule the restart and choose a time that's...
Read more >
How to Change Windows Update Settings - Support.com's
Open the Start Menu, and select Settings. ... Select Update and recovery. Settings menu with Update and Recovery highlighted. Select Windows Update on...
Read more >
Change Software Update settings on Mac - Apple Support
To open Software Update settings, choose Apple menu > System Settings, click General in the sidebar (you may need to scroll down), then...
Read more >
How to find & manage Windows 10 Update options. - wintips.org
On Windows 10, Windows Update options have moved from the standard location (the old and classic Control Panel), to a new location in...
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