-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Add Heatmap #13209
[charts] Add Heatmap #13209
Conversation
I like the idea of the enhanceable And if we want a single container, then as you said we need to be able to add some logic to this container. We need to be very sure that we don't need to have several of those pro components in the container, for me we could support an array of plugins (the concept can be named differently): import { heatMapContainerPlugin } from '@mui/x-charts-pro/Heatmap';
<ChartContainer
plugins={[heatMapContainerPlugin]}
>
</ChartContainer> You could even imagine requiring people to do this for some lesser-used community charts in the future to keep the bundle size reasonable. |
What would be in these
It should be fairly straight forward to accept both Further on data formats, one idea we could start looking at is allowing users to add "transformers" to the dataset, instead of specifying data at a specific format, eg: const dataset = [
{
foo: 1,
bar: 2,
baz: 'blue',
xyz: 'lake',
}
]
<Chart
...
dataset={dataset}
series={[{
transform: (v) => ([v.foo, v.bar, v.baz])
}]}
/>
You could technically interpolate between 3 colors, but that might be too far fetched 😅 But |
With the plunging strategy, I could do
This would provide processing steps to the different providers. Effectively if we need an additional provider we will ned to either
I'm reluctant to go in the direction of implementing additional kinds of data transformation. When I added the From your comment, I conclude that
What do you mean by interpolating between 3 colors ? |
👍 looks good
I agree the current way data input is handled is a bit confusing, we could delve deeper into that eventually, but I would guess the issue lies in the fact that My suggestion with
I don't think // this
data={dataset.map(obj => [obj.x, obj.y, obj.value])}
// is much different from this
data={dataset.map(([x, y, value]) => ({ x, y, value }))} Arrays are indeed simpler, but harder for humans to read when you got a lot of data. We can always extend later.
Nvm, I didn't read your phrase right. I was thinking the user could use the x-axis to define the colors, but we have the colorScale there for that instead 😅 |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Deploy preview: https://deploy-preview-13209--material-ui-x.netlify.app/ Updated pages: |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this change introduced https://app.ahrefs.com/site-audit/3523498/data-explorer?columns=pageRating%2Curl%2Ctraffic%2ChttpCode%2Cdepth%2Ccompliant%2CincomingAllLinks%2Corigin¤t=12-07-2024T022123&filterId=91013c8aafad4fe1f7a0ad504eccad42&issueId=c64da643-d0f4-11e7-8ed1-001e67ed4656&sorting=-pageRating.
Not all the links in https://mui.com/x/react-charts/tooltip/#api works.
@@ -2,6 +2,9 @@ import { styled } from '@mui/material/styles'; | |||
import { shouldForwardProp } from '@mui/system'; | |||
import { chartsTooltipClasses } from './chartsTooltipClasses'; | |||
|
|||
/** | |||
* @ignore - internal component. | |||
*/ | |||
export const ChartsTooltipPaper = styled('div', { | |||
name: 'MuiChartsTooltip', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it strange to have this component as ignore ( * @ignore - internal component.
) and having a name that is reachable with theme overrides (and normally global CSS too, I mean, I imagine Pigment CSS output clear class names in this context using the name of the styled called, assuming uniqueness property is guaranteed cc @brijeshb42 for context). It feels like it's not completely private nor public.
@@ -6,3 +6,5 @@ export * from './ChartsItemTooltipContent'; | |||
|
|||
export * from './DefaultChartsAxisTooltipContent'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? I would expect from a public component not to have default.
export * from './DefaultChartsAxisTooltipContent'; | |
export * from './ChartsAxisTooltipContent'; |
If it's a slot, the default part of the name is implicit.
PoC for #7926
Preview: https://deploy-preview-13209--material-ui-x.netlify.app/x/react-charts/heatmap/
Topics to discuss
The overall strategy
Data Pipeline
For now, charts share the same container that supports line, bar, scatter, and pie series. It allows for mixing them, which is useful for bar+line chart, or scatter + line. But it forces us to put the processing logic of every chart type in the container. Whic is an issue for splitting pro/community code, which puts in your bundle processing you don't need.
Since heatmap (and most of the future components) do not have usecases for mixing with other series types, I propose creating dedicated containers
<HeatmapContainer />
based on the same provider, but have only the needed logic.Another could have been to use
<ChartsContainer />
with some props to add the heatmap logic. Whoch would lead to something likeMaybe the second option is more interesting because it avoids creating a component for each chart, and even if the DX is not incredible, most user will probably use the single component version
<Heatmap />
, or the composition would be made once and re-exported. The drawback is that the<ChartsContainer />
props will be more complex.Typing
I modified the TS definition to rely mostly on the
ChartsSeriesConfig
interface.The idea is to be able to add any series type by its configuration which represents the series at different stages: from the props provided to the stats stored in the context.
Data format
For now, I went with
[x-ndex, y-index, value]
Benchmark
id
is the row, thenx
is the column, andy
the valueHighcharts: same as proposed
[number, number, number][]
Echarts: same as proposed
Another approach could be
{x, y, value}[]
data type. But we then should handle what append if the x/y value does not have a correct value.I think both are good, user preferences will mostly depend on the data format returned by their server. So might be better to follow Highcharts/Echarts on this point
Customization
Having a single component
The single component is not yet created, but I wonder if we should simplify the customization, by:
zAxis
which could be renamedcolorScale
since its an important aspect of the chart, and we only have one (I can imaging center examples, but not sure they with it)Follow up