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] Move dataset to distinct files in the demos #10197

Closed
oliviertassinari opened this issue Aug 31, 2023 · 6 comments
Closed

[charts] Move dataset to distinct files in the demos #10197

oliviertassinari opened this issue Aug 31, 2023 · 6 comments
Assignees
Labels
component: charts This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation enhancement This is not a bug, nor a new feature

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 31, 2023

I was trying to understand how some of the charts of the docs were built but struggle with a lot of line to scroll associated for the data set, e.g. https://mui.com/x/react-charts/bars/#layout

I think that we should move the data set to the bottom of the page:

diff --git a/docs/data/charts/bars/HorizontalBars.tsx b/docs/data/charts/bars/HorizontalBars.tsx
index 0f5de1074..ef153edd6 100644
--- a/docs/data/charts/bars/HorizontalBars.tsx
+++ b/docs/data/charts/bars/HorizontalBars.tsx
@@ -10,6 +10,21 @@ const chartSetting = {
   width: 500,
   height: 400,
 };
+
+const valueFormatter = (value: number) => `${value}mm`;
+
+export default function HorizontalBars() {
+  return (
+    <BarChart
+      dataset={dataset}
+      yAxis={[{ scaleType: 'band', dataKey: 'month' }]}
+      series={[{ dataKey: 'seoul', label: 'Seoul rainfall', valueFormatter }]}
+      layout="horizontal"
+      {...chartSetting}
+    />
+  );
+}
+
 const dataset = [
   {
     london: 59,
@@ -96,17 +111,3 @@ const dataset = [
     month: 'Dec',
   },
 ];
-
-const valueFormatter = (value: number) => `${value}mm`;
-
-export default function HorizontalBars() {
-  return (
-    <BarChart
-      dataset={dataset}
-      yAxis={[{ scaleType: 'band', dataKey: 'month' }]}
-      series={[{ dataKey: 'seoul', label: 'Seoul rainfall', valueFormatter }]}
-      layout="horizontal"
-      {...chartSetting}
-    />
-  );
-}

Examples

Context

In the future, we might want to have a custom data set.

And maybe even have it interactive:

Screen.Recording.2023-09-01.at.00.32.18.mov

https://www.chartjs.org/docs/latest/samples/scales/linear-step-size.html

Your environment 🌎

v6.0.0-alpha.9

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation status: waiting for maintainer These issues haven't been looked at yet by a maintainer component: charts This is the name of the generic UI component, not the React module! labels Aug 31, 2023
@oliviertassinari oliviertassinari changed the title [charts] Move [charts] Move dataset to the bottom of the demos Aug 31, 2023
@flaviendelangle
Copy link
Member

I would love if someday, the data-rich components have a data tab on the demo, like Nivo demos and receives a data prop on the demo.

The data of MyDemo.{js|tsx} could come from MyDemo.data.json or even MyDemo.data.js if we need some dynamic data generation like the current useDemoData or useMovieData.

Because for a given demo, 99% of the time the data is fixed once the component is mounted. We only have those hooks to avoid duplicate the logic for each demo.
But if we could load the rows and columns prop from a file and display there value in a tab it would greatly improve the comprehension of the demo for users.
And the same clearly applies to charts and tree view.

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Sep 1, 2023

We only have those hooks to avoid duplicate the logic for each demo.

There is also a notion of allowing a straightforward demo copy & paste experience.

have a data tab on the demo

I'm connecting this to a docs-infra issue, we explored this for another problem in the past: mui/material-ui#38911.

@flaviendelangle
Copy link
Member

There is also a notion of allowing a straightforward demo copy & paste experience.

The main downside of the current approach being that it's hard to understand the demo code because some logic is hidden behind custom hooks that are somethings very complex (useDemoData)

@oliviertassinari
Copy link
Member Author

The main downside of the current approach being that it's hard to understand the demo code because some logic is hidden behind custom hooks that are somethings very complex (useDemoData)

@flaviendelangle When we introduced useDemoData, the idea was to limit it to data that are not relevant to the feature the demo covers. So I think we should always default to override the data of useDemoData if it's important to understand the demo.

Issue created: mui/material-ui#38911. We could use a tab to host the data.

@alexfauquette alexfauquette added the enhancement This is not a bug, nor a new feature label Sep 27, 2023
@romgrk romgrk removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 12, 2023
@alexfauquette alexfauquette changed the title [charts] Move dataset to the bottom of the demos [charts] Move dataset to distinct files in the demos Apr 26, 2024
@alexfauquette alexfauquette self-assigned this Aug 13, 2024
@alexfauquette
Copy link
Member

I'm closing because most of the demos now have a dataset in a distinct file.

Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@oliviertassinari: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation enhancement This is not a bug, nor a new feature
Projects
None yet
Development

No branches or pull requests

4 participants