-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When scale distr:2, scaleMin and scaleMax have wrong values #555
Comments
this is "by design" (see #212). to get timestamps you should use
uPlot natively only works with continuous scales that can be interpolated using math functions. ordinal scales are discontinuous and unpredictable, so you'll have to manually scan your data to figure out where you want the ticks. let's say there was no trading on the weekend, and that Sunday falls on the 1st of the next month, plus Monday is a national holiday also without trading, where do you put the tick for the 1st? what if you're zoomed and the 1st of the month is out of visible range, where should the 1st tick go? and what if that tick lands on a weekend? what about DST roll-overs? timezone offsets? that's just a few of a bunch of situations that makes discontinuous scales tricky to get "correct" from logical and performance perspectives. if you'd like to take a stab at it with a custom |
Most of the stock charts (e.g. yahoo) show the month label at the first trading day of the month (or between the last trading day of the old month and the first trading day of the new month) I was hoping that you (or someone) has already come up with a solution for that, as it seems a common use case. I am having a hard time trying to understand the various options described in https://github.com/leeoniya/uPlot/tree/master/docs#axis--grid-opts Could you maybe help to clarify the following:
I'm sorry if the questions seem basic, but I am almost sure that I'm not the only one confused with this part. |
yes, sorry, the "docs" are in very poor shape. most of the API "docs" are simply reading the comments in the typings file: Lines 926 to 986 in b079030
you can think of i looked at how https://www.tradingview.com/chart/ does this, and as you said, it will simply call the label "Nov" if it's actually Nov 2 instead of trying to place labels on Nov 1. if you want similar behavior, basically just override |
btw, feel free to PR your changes to the candlestick demo if you're happy with them, and i'll review. |
Not sure if this is a bug, but when I set distr:2 on the x scale, the scaleMin and scaleMax values that are passed to the function:
space: (self, axisIdx, scaleMin, scaleMax, plotDim)
are not the values of the x-data array but their indexes. So , in my case, instead of getting timestamps, I get the min and max index of the timestamp array.
I am trying to get somewhat meaningful splits/ticks with temporal data and distr:2 (for a simple stock price line chart).
Do you maybe have some examples how to achieve this? The default splits (e.g. for months) don't start at the beginning of the month)
The text was updated successfully, but these errors were encountered: