Skip to content
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

Not possible to set min/max for timeseries axis #11842

Open
mp3500 opened this issue Jul 22, 2024 · 6 comments
Open

Not possible to set min/max for timeseries axis #11842

mp3500 opened this issue Jul 22, 2024 · 6 comments

Comments

@mp3500
Copy link

mp3500 commented Jul 22, 2024

Expected behavior

I have 2 exactly the same charts showing same data with the only difference, that one chart is "time" and the other one is "timeseries". Both charts have min/max dates set on x axis to display full year. Both charts's axis should start with Jan and end with Dec.

Current behavior

"time" chart works as expected, but "timeseries" chart does not show full year on the x axis. It looks like the data between "min" and the first data point and between the last data point and "max" is removed as a part of timeseries functionality.

Reproducible sample

https://codepen.io/mp3500/pen/GRbqJwY

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

v4.4.1

Browser name and version

Chrome 126.0.6478.128 64bit

Link to your project

No response

@Mairu
Copy link

Mairu commented Aug 1, 2024

This was changed with v4.3.1, we also stumbled over that problem and had to fix versions, to be able to use zoom plugin with time series.

#11388 -> https://github.com/chartjs/Chart.js/pull/11388/files#diff-f646705ee87e1da4be6cb4fca41e8322ba91e9db6f31ff76b2a868d9ff7f35e5R114

From my point of view, min and max should not be ignored or the behavior should be configurable.

@Pi77Bull
Copy link

I just encountered this bug too. I'd appreciate it if someone could look into this.

@Mairu
Copy link

Mairu commented Nov 18, 2024

Now that I have looked into it again I have come to the conclusion, that the current behaviour is exactly, what the purpose of the time-series scale is in comparison to the time scale, to have the same distance between any data point independent of the time difference between the data points.

However, for the time series scale, each data point is spread equidistant.

So if you need a linear scale that does not depend on the data, you should use the time scale.

The issue should be closed.

@Pi77Bull
Copy link

Pi77Bull commented Nov 19, 2024

My use-case is a bit different: I'm implementing panning with a timeseries on a candlestick chart. Overscrolling on the left should load new data from a server. But since overscrolling a timeseries is impossible, this feature is basically impossible to implement.

I think there should be an additional way to set min/max in a linear fashion on a timeseries. For example by index of a dataset.
So [5, 10] should show the datapoints at index 5 through 10. If that interval goes out of bounds, it should adjust accordingly (possible because points are spread equidistant). So [-5, 10] would show datapoints from 0 to 10, but with padding in the beginning that is 5 times the width of the distant between datapoints.

@mp3500
Copy link
Author

mp3500 commented Nov 20, 2024

I was also using candlestick charts when reported this bug. I just wanted to make my report as simple as possible, so I used scatter charts and did not go into too many details.

Basically, my original problem was that I wanted to display candlestick chart with no weekends/holidays and with extra space (1 month or so) on the right. I was able to make that extra space using time chart and min/max properties, but then weekends/holidays were shown as blank points in the chart. If I used timeseries, weekend/holiday problem was gone, but now I was not able to make a space on a right hand side using min/max properties because of how timeseries works.

Havent received any feedback regarding my bug report, so I came up with a workaround myself. I simply added more fake data to the candlestick data, where open price was set to "undefined" and high, low and close was set to the latest real close price. In this way, those fake bars were not showing on a chart, but the chart space was still reserved for them and my chart got extended to the right by the number of fake bars the way I wanted.

I am not sure if min/max should work for timeseries or not, but I hope that my usage scenario might help to make decision.

image

@Pi77Bull
Copy link

I simply added more fake data to the candlestick data, where open price was set to "undefined" and high, low and close was set to the latest real close price.

I had the same idea but couldn't figure out how to hide those datapoints. Thank you for that workaround!

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

No branches or pull requests

3 participants