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

XYChart BarSeries issue with scale time #1738

Open
m-arre opened this issue Aug 3, 2023 · 1 comment
Open

XYChart BarSeries issue with scale time #1738

m-arre opened this issue Aug 3, 2023 · 1 comment

Comments

@m-arre
Copy link

m-arre commented Aug 3, 2023

Hi, I've come across an issue while using the XYChart with an xScale of type time in combination with the BarSeries.
There are some scenarios causing problems:

  1. When using the BarSeries without the BarGroup, their size and offset appear to be incorrect. This results in the following output (for reference, the LineSeries above is shown):
    barseries2

  2. If the BarSeries is wrapped by BarGroup, the BarSeries renders with the correct offsets, but their width becomes equal to 0 (similar to issue <BarSeries> bars have 0 width when using time scale #1457 ):
    barseries1

  3. Using the BarStack component, the bars are stacked correctly, but their size and offsets are incorrect.
    barseries3

I tried using the band scale, which displays the charts correctly. However, in my case, I cannot use it as I need to synchronize all the timeseries charts of a dashboard.

In the first scenario, the problem arises when I set an xScale of type "time" with a custom domain that exceeds the effective domain of the data passed as a prop.

In the second scenario, upon examining the code, it seems not to support scales other than the band scale.

I replicated the issue here https://codesandbox.io/s/loving-mayer-j2xwdm?file=/ExampleControls.tsx

@williaster
Copy link
Collaborator

williaster commented Aug 4, 2023

thanks @m-arre for the report. I think it's time (hah) we update the algorithm for determining bar width for non-band scales. the current (naive/simple) approach is to divide the available width by the number of data points ... but this doesn't work for missing values.

if we were able to detect the granularity of time that was being plotted (which could vary widely from chart to chart), we could then generate a band scale behind the scenes using time scale intervals. there's some discussion of that in this stack overflow question.

open to other suggestions for how to do this in a generic way. once we align on a solution I'm happy to PR, or happy to review a PR if there's community interest 🙏

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

2 participants