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

[charts] Support BarChart with Date data #13471

Merged
merged 6 commits into from
Jun 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test
  • Loading branch information
alexfauquette committed Jun 13, 2024
commit 242b64fc3b266a650fe3c9f04fc3c0b775d7a9d9
8 changes: 6 additions & 2 deletions packages/x-charts/src/context/CartesianContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,12 @@ function CartesianContextProvider(props: CartesianContextProviderProps) {
if (axis.scaleType === 'ordinal-time') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could skip the craetion of the special scaletype with

Suggested change
if (axis.scaleType === 'ordinal-time') {
if (axis.data[0] instanceof Date) {

But that would add some kind of magic

const timeScale = scaleTime(axis.data!, range);
completedXAxis[axis.id].valueFormatter =
axis.valueFormatter ?? timeScale.tickFormat(axis.tickNumber);
completedXAxis[axis.id].tickInterval = timeScale.ticks(axis.tickNumber);
axis.valueFormatter ??
((v, { location }) =>
location === 'tick'
? timeScale.tickFormat(axis.tickNumber)(v)
: `${v.toLocaleString()}`);
// completedXAxis[axis.id].tickInterval = timeScale.ticks(axis.tickNumber);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be sure the generated tick exist in the data

}
}
if (isPointScaleConfig(axis)) {
Expand Down
Loading