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.

Static scaling options not working on live chart?

See original GitHub issue

I’m working with v1.0.11 and have setup a chart where the x and y scale use a static range scale, e.g: let opts = { scales: { "x": { time: false, auto: false, range: [0, 100] }, "y": { auto: false, range: [0, 100] }, }, }

This works fine until I try to zoom and update the data. To do that, I call e.g. setRange('y', { min: 4, max: 10}) setScale('y', { min: 4, max: 10}). When I now call setData on my chart instance, it resets my previously set scale.

I also noted, that the API documentation states that there is a second parameter on setData allowing to prevent this behavior, but when I do that, it not only does not reset the scale, it also does not redraw anymore.

/** sets the chart data & redraws. (default resetScales = true) */
setData(data: uPlot.AlignedData, resetScales?: boolean): void;

I would have expected that it would accept the data and redraw it on the existing scaling.

The only way I could find to get the desired behavior so far was to set the data and then fix the scale, e.g.:

setData(myData, false);
setScale('y', { min: 4, max: 10})

But this can’t be the way it should be, can it?

I think the streaming-data demo has the same issue. Even though zooming seems to be possible, it doesn’t work.

Edited: Corrected the wrongly used: ‘setRange’ to what I actually meant: ‘setScale’.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
leeoniyacommented, Jul 20, 2020

gonna close this since i’m not sure there’s anything left to do here, but feel free to discuss further if necessary.

0reactions
leeoniyacommented, Jul 16, 2020

i pushed a few commits, but they’ll make little difference for the streaming case.

It could respect the limitations, when a ‘range’ is provided (as you said: let the range act as adjuster and ‘refine’ the scale).

well, not the way it works now, which is to grab the data min/max (in auto mode) and pass those to range() and respect whatever range() returns as the final answer. anything different would be pretty confusing.

the whole thing is rather nuanced because for streaming you may want x.auto: true, but only when “zoomed out”. there are a lot other behaviors you may need, and simply relying on auto is insufficient for a zoomable streaming case - you still need to do a custom range and call setData/false & setScale / redraw() granularly because there’s not one solution i can think of that is sensible for everyone given the vast array of options that can be active.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix a "Squished" Price Chart Scale in Thinkorswim Tutorial
Ever notice that when you add indicators to a new chart, sometimes the price ... Robinhood app, Options trading, TD Ameritrade Thinkorswim, ...
Read more >
Chart Scale and Scale Adjusting - Sierra Chart
Follow the instructions below to open the Scale Settings window for a Chart or Trade DOM window. Select Chart >> Chart Settings on...
Read more >
Autoscaling guidance - Best practices for cloud applications
Horizontal scaling, also called scaling out and in, means adding or removing instances of a resource. The application continues running ...
Read more >
Setup - Working with Charts - MetaTrader 4 Help
Scale fix – fix the current chart scale. If the scale has not been fixed, the chart will be automatically scaled vertically. This...
Read more >
Line Chart - Google Developers
You can smooth the lines by setting the curveType option to function : ... Note: Material Charts will not work in old versions...
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