Skip to content

Performance - option to override the canvas pixel ratio to avoid large slower graph updates #876

Closed
@jeffvandyke

Description

@jeffvandyke

Latest version, working setup, not a bug, simple feature request, a jsfiddle would take some setup, but let me know if one's needed.

Context: Great library, especially for performance. I was previously using Echarts to plot about 30k data points that got updated multiple times per second, and this library, with not too much optimization, was 3-4x faster on desktop!

Problem: Unfortunately, it was quite bit slower than Echarts on mobile, because the resolution of the canvas matches the actual resolution of the phone's screen, instead of the CSS pixels, resulting in an enormous canvas size. It does look nice, and seriously, kudos for doing it, but it would be nice to have the user be able to turn it off for performance reasons on mobile devices.

Proposal: I think there should be a new option, perhaps "canvasPixelRatio", which takes a float, or a function(originalRatio): float, that can be checked in the few places we use getContextPixelRatio() to return the ratio for the canvas's display. It's nice to have a function so perhaps one can use Math.min() to limit it to 2, or something like that.

I'm happy to make a pull request for this, just let me know if it would be something we're OK with, or if there are any better ideas or suggestions. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions