Skip to content

ChartJS: How do I control the animation of a chart? #637

Closed

Description

@itg-assistant

Nic Adams asked 2017-02-17 17:04:28 UTC

How can I stop a chart from animating when the data on it is changed?

Thanks

Nic

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2017-02-17 21:49:21 UTC

    Hi Nic,

    There is a global property for the animation duration. Look in startup.js "Chart.defaults.global.animation.duration = 0;". Maybe you can add a property to the ChartJS class as you did for the JustGage extension. If you do, make sure to download the latest source from the extensions page first. I will add this to the enhancements.

    The problem is that this is a global option applying to all charts. I don't know if it can be set on a single chart.

    Best,

    Luca

  2. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Nic Adams answered 2017-02-21 17:27:00 UTC

    Hi Luca,

    I actually found an answer in the UpdateData() method of the widget. This will update the data without animation. However in the current version this does not also update labels.

    I've attached an updated version of the chartjs extension. My changes are:

    • Labels now also get updated when UpdateData() is called - very useful for realtime charts :)

    • You can set the axis labels through new properties

    • You can set the scale type on the axis through a new property.

    • I've also commented out the "debugger" statements in startup,js that are in the extension download so the extension runs correctly.

    Hope that is helpful

    Nic

  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2017-03-06 21:21:43 UTC

    Hi Nic,

    Please update your ChartJS code with the latest source at /Extensions. It includes your enhancements, some fixes and the embedded js resources to be "internet-free".

  4. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Darren answered 2018-07-22 23:16:36 UTC

    Hi all,

    Animation value doesn't seem to have any effect for me when setting in UpdateData(x).

    It always seems to be 300mS.

    Saying that, perhaps I'm doing something wrong.

    I have two arrays, one for data and the other for x-axis time which I'm adding a new datapoint to every second.
    I then update the chart with UpdateData(x).

    Visually this looks awful because the chart is cleared and then loaded with the latest dataset, every second.

    What I'm trying to achieve is a smoothiechart-like appearance (i.e. a scrolling stripchart) but using chartjs.
    I need to use chartjs because I need to be able to pause the chart and scroll back and forth through historic data.

    Any tips?

    Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions