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.

Updating chart inside 'created' event listener

See original GitHub issue

I’m trying to amend the top padding of my chart in a plugin inside the ‘created’ event listener but update() does not seem to work.

Here’s some code:

function myPlugin(options) {
            return function myPlugin(chart) {

                var theChart = chart;

                chart.on('created', function (data) {
                        theChart.options.chartPadding.top = 160;
                        theChart.update();
                });
            };
}

The property is updated ok, but there is no visual update - Any ideas?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
gionkunzcommented, Jun 26, 2015

The true option will make sure existing options will stay but the one you specify will be overriden

1reaction
gionkunzcommented, Jun 26, 2015

Actually you can run chart.update(null, {chartPadding: {top: 100, bottom: 0, left: 0, right: 0}}, true) within your plugin initialization function. Just make sure that you don’t run it inside your created listener.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript: Add Event Listener to an Event Listener
I have a onClick function defined for the chart which changes the data for the chart and calls an update() function. It looks...
Read more >
Dynamically Add Chart Event Listener using Plain JS
This article tells you how to dynamically add chart event listener to your chart using plain JS.
Read more >
Handling Events | Charts - Google Developers
Overview. Google charts can fire events that you can listen for. Events can be triggered by user actions, such as when a user...
Read more >
Adding Listener to update charts on ButtonClick
Hi, non-coder getting to grips with Javascript. I want to change the isStacked status of a chart on ButtonClick.
Read more >
Overview – Event Handling in Charts - CanvasJS.com
Sets the mouseover event handler for dataSeries/dataPoint which is triggered when user moves Mouse Over a dataSeries/dataPoint. Upon event, a parameter that ...
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