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

Stack fails to plot time series data over daylight savings change #2988

Closed
2 tasks done
sandwichsudo opened this issue Nov 23, 2024 · 1 comment
Closed
2 tasks done
Labels
Type: Bug 🐛 Oh no! A bug or unintentional behavior

Comments

@sandwichsudo
Copy link

sandwichsudo commented Nov 23, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Victory version

37.3.2

Code Sandbox link

https://codesandbox.io/p/sandbox/stack-fails-to-plot-timeseries-m6dm4h?workspaceId=90ff9bfc-5f7c-41ee-be73-afe0ddcdced4

Bug report

Plotting a simple bar chart of time series data using a VictoryStack fails to render correctly. Only a subset of the bars are rendered.

// this chart doesn't render all the bars

<VictoryChart scale={{ x: "time" }}>
    <VictoryStack colorScale={"qualitative"}>
        <VictoryBar barWidth={5} data={DSTChangeDay1} />
    </VictoryStack>
</VictoryChart>
Screenshot 2024-11-23 at 21 43 18

Plotting the same data without wrapping the Bar in a Stack works correctly.

// this works fine

      <VictoryChart scale={{ x: "time" }}>
        <VictoryBar barWidth={3} data={DSTChangeDay1} />
      </VictoryChart>
Screenshot 2024-11-23 at 21 42 58


### Steps to reproduce

```markdown
1. Go to [code sandbox](https://codesandbox.io/p/sandbox/multiple-axes-with-victorygroup-forked-m6dm4h?workspaceId=90ff9bfc-5f7c-41ee-be73-afe0ddcdced4)
2. Look at the first chart rendering correctly
3. Look at the second chart rendering a subset of the bars

Expected behavior

Stack should render all the bars. If we use a time series that does not include a Daylight Savings change, then it all works correctly.
Screenshot 2024-11-23 at 21 48 22

Actual behavior

Not all bars are rendered for a Stack chart when using a time series where daylight savings time change happens

Changing the ordering fixes this for some reason!

https://codesandbox.io/p/sandbox/stack-fails-to-plot-timeseries-forked-njs2mt?workspaceId=90ff9bfc-5f7c-41ee-be73-afe0ddcdced4

Chart works with the point

 {
    x: 1729987200000,
    y: 0.118,
  }

at index 2

Screenshot 2024-11-23 at 22 20 50

rendering problem occurs with the point

 {
    x: 1729987200000,
    y: 0.118,
  }

at index 3

Screenshot 2024-11-23 at 22 21 15

Environment

- Device: Any
- OS: Any
- Node: LTS
- npm: any
@sandwichsudo sandwichsudo added the Type: Bug 🐛 Oh no! A bug or unintentional behavior label Nov 23, 2024
@sandwichsudo
Copy link
Author

sandwichsudo commented Nov 23, 2024

Sorting the chart data fixes this - there is probably a bug here, but this is a reasonable workaround.

function sortChartItems(a, b) {
    if (a.x < b.x) {
        return -1;
    } else if (a.x > b.x) {
        return 1;
    }
    // a must be equal to b
    return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 Oh no! A bug or unintentional behavior
Projects
None yet
Development

No branches or pull requests

1 participant