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] Add Heatmap #13209

Merged
merged 38 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7da1e51
Update TS to support heatmap series type in the config
alexfauquette May 27, 2024
767279b
Allow to extend formatter and extremum getter
alexfauquette May 27, 2024
1646b27
Rework color management
alexfauquette May 27, 2024
477d2b2
Creat heatmap atoms
alexfauquette May 27, 2024
431d5af
Demonstrate first heatmap
alexfauquette May 27, 2024
67cd276
Mark heatmap as unstable
alexfauquette May 27, 2024
76c2566
fix missing export
alexfauquette May 27, 2024
dac626b
Merge remote-tracking branch 'upstream/master' into heatmap
alexfauquette May 29, 2024
3fde5c1
WIP
alexfauquette May 30, 2024
ea9175c
ts fix
alexfauquette May 31, 2024
ed30368
proptypes
alexfauquette May 31, 2024
1950199
prettier
alexfauquette May 31, 2024
d8f6f64
Merge remote-tracking branch 'upstream/master' into heatmap
alexfauquette Jun 6, 2024
2d93107
Merge remote-tracking branch 'upstream/master' into heatmap
alexfauquette Jun 12, 2024
b43b8f4
Add zAxis by default to the container
alexfauquette Jun 12, 2024
b6ecd2a
clean TS depending on which charts use z axis
alexfauquette Jun 12, 2024
5aed676
fixes
alexfauquette Jun 12, 2024
45dfd48
Merge remote-tracking branch 'upstream/master' into heatmap
alexfauquette Jun 13, 2024
1ddb6fb
PoC Highlight
alexfauquette Jun 14, 2024
655d4e2
Modify url from "heat-map" to "heatmap" for consistency
alexfauquette Jun 14, 2024
97b2317
WIP tooltip
alexfauquette Jun 14, 2024
36ece85
Fix TS
alexfauquette Jun 14, 2024
fe50157
move heatmap in the docs
alexfauquette Jun 17, 2024
8a5b516
Merge remote-tracking branch 'upstream/master' into heatmap
alexfauquette Jun 18, 2024
e6d4f86
docs
alexfauquette Jun 18, 2024
0bc6ff9
fix proptypes
alexfauquette Jun 19, 2024
3e3b502
add slots and classes
alexfauquette Jun 19, 2024
007977d
Add slots demo
alexfauquette Jun 19, 2024
ba7cfc1
more demos
alexfauquette Jun 19, 2024
329102c
merge
alexfauquette Jun 20, 2024
c0bed66
fix
alexfauquette Jun 20, 2024
8c7e635
document highlight
alexfauquette Jun 20, 2024
8912c07
Merge remote-tracking branch 'upstream/master' into heatmap
alexfauquette Jun 20, 2024
edff1b9
modify default color
alexfauquette Jun 20, 2024
3ed6d46
feedback
alexfauquette Jun 20, 2024
fdefab3
share data accross example
alexfauquette Jun 20, 2024
585bf47
Merge remote-tracking branch 'upstream/master' into heatmap
alexfauquette Jul 1, 2024
198568f
fix
alexfauquette Jul 1, 2024
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
8 changes: 0 additions & 8 deletions docs/data/charts-component-api-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ const apiPages: MuiPage[] = [
pathname: '/x/api/charts/charts-axis-highlight',
title: 'ChartsAxisHighlight',
},
{
pathname: '/x/api/charts/charts-axis-tooltip-content',
title: 'ChartsAxisTooltipContent',
},
{
pathname: '/x/api/charts/charts-clip-path',
title: 'ChartsClipPath',
Expand All @@ -57,10 +53,6 @@ const apiPages: MuiPage[] = [
pathname: '/x/api/charts/charts-grid',
title: 'ChartsGrid',
},
{
pathname: '/x/api/charts/charts-item-tooltip-content',
title: 'ChartsItemTooltipContent',
},
{
pathname: '/x/api/charts/charts-legend',
title: 'ChartsLegend',
Expand Down
19 changes: 19 additions & 0 deletions docs/data/charts/heatmap/BasicHeatmap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import '@mui/x-charts-pro/typeOverloads';
import { UnstableHeatmap } from '@mui/x-charts-pro/Heatmap';
import { data } from './dumbData';

export default function BasicHeatmap() {
return (
<Box sx={{ width: '100%', maxWidth: 400 }}>
<UnstableHeatmap
xAxis={[{ data: [1, 2, 3, 4] }]}
yAxis={[{ data: ['A', 'B', 'C', 'D', 'E'] }]}
series={[{ data }]}
margin={{ top: 5, right: 5, left: 20 }}
height={300}
/>
</Box>
);
}
19 changes: 19 additions & 0 deletions docs/data/charts/heatmap/BasicHeatmap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import '@mui/x-charts-pro/typeOverloads';
import { UnstableHeatmap } from '@mui/x-charts-pro/Heatmap';
import { data } from './dumbData';

export default function BasicHeatmap() {
return (
<Box sx={{ width: '100%', maxWidth: 400 }}>
<UnstableHeatmap
xAxis={[{ data: [1, 2, 3, 4] }]}
yAxis={[{ data: ['A', 'B', 'C', 'D', 'E'] }]}
series={[{ data }]}
margin={{ top: 5, right: 5, left: 20 }}
height={300}
/>
</Box>
);
}
7 changes: 7 additions & 0 deletions docs/data/charts/heatmap/BasicHeatmap.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<UnstableHeatmap
xAxis={[{ data: [1, 2, 3, 4] }]}
yAxis={[{ data: ['A', 'B', 'C', 'D', 'E'] }]}
series={[{ data }]}
margin={{ top: 5, right: 5, left: 20 }}
height={300}
/>
123 changes: 123 additions & 0 deletions docs/data/charts/heatmap/ColorConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import * as React from 'react';
import { interpolateBlues } from 'd3-scale-chromatic';
import '@mui/x-charts-pro/typeOverloads';
import { UnstableHeatmap } from '@mui/x-charts-pro/Heatmap';

const dataset = [
{
london: 59,
paris: 57,
newYork: 86,
seoul: 21,
month: 'January',
},
{
london: 50,
paris: 52,
newYork: 78,
seoul: 28,
month: 'February',
},
{
london: 47,
paris: 53,
newYork: 106,
seoul: 41,
month: 'March',
},
{
london: 54,
paris: 56,
newYork: 92,
seoul: 73,
month: 'April',
},
{
london: 57,
paris: 69,
newYork: 92,
seoul: 99,
month: 'May',
},
{
london: 60,
paris: 63,
newYork: 103,
seoul: 144,
month: 'June',
},
{
london: 59,
paris: 60,
newYork: 105,
seoul: 319,
month: 'July',
},
{
london: 65,
paris: 60,
newYork: 106,
seoul: 249,
month: 'August',
},
{
london: 51,
paris: 51,
newYork: 95,
seoul: 131,
month: 'September',
},
{
london: 60,
paris: 65,
newYork: 97,
seoul: 55,
month: 'October',
},
{
london: 67,
paris: 64,
newYork: 76,
seoul: 48,
month: 'November',
},
{
london: 61,
paris: 70,
newYork: 103,
seoul: 25,
month: 'December',
},
];

const data = dataset.flatMap(({ london, paris, newYork, seoul }, monthIndex) => [
[0, monthIndex, london],
[1, monthIndex, paris],
[2, monthIndex, newYork],
[3, monthIndex, seoul],
]);

const xData = ['London', 'Paris', 'NewYork', 'Seoul'];
const yData = dataset.flatMap(({ month }) => month);

export default function ColorConfig() {
return (
<UnstableHeatmap
height={400}
width={600}
xAxis={[{ data: xData }]}
yAxis={[{ data: yData }]}
series={[{ data }]}
zAxis={[
{
min: 20,
max: 300,
colorMap: {
type: 'continuous',
color: interpolateBlues,
},
},
]}
/>
);
}
126 changes: 126 additions & 0 deletions docs/data/charts/heatmap/ColorConfig.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import * as React from 'react';
import { interpolateBlues } from 'd3-scale-chromatic';
import '@mui/x-charts-pro/typeOverloads';
import { UnstableHeatmap } from '@mui/x-charts-pro/Heatmap';
import { HeatmapValueType } from '@mui/x-charts-pro/models';

const dataset = [
{
london: 59,
paris: 57,
newYork: 86,
seoul: 21,
month: 'January',
},
{
london: 50,
paris: 52,
newYork: 78,
seoul: 28,
month: 'February',
},
{
london: 47,
paris: 53,
newYork: 106,
seoul: 41,
month: 'March',
},
{
london: 54,
paris: 56,
newYork: 92,
seoul: 73,
month: 'April',
},
{
london: 57,
paris: 69,
newYork: 92,
seoul: 99,
month: 'May',
},
{
london: 60,
paris: 63,
newYork: 103,
seoul: 144,
month: 'June',
},
{
london: 59,
paris: 60,
newYork: 105,
seoul: 319,
month: 'July',
},
{
london: 65,
paris: 60,
newYork: 106,
seoul: 249,
month: 'August',
},
{
london: 51,
paris: 51,
newYork: 95,
seoul: 131,
month: 'September',
},
{
london: 60,
paris: 65,
newYork: 97,
seoul: 55,
month: 'October',
},
{
london: 67,
paris: 64,
newYork: 76,
seoul: 48,
month: 'November',
},
{
london: 61,
paris: 70,
newYork: 103,
seoul: 25,
month: 'December',
},
];

const data = dataset.flatMap(
({ london, paris, newYork, seoul }, monthIndex): HeatmapValueType[] => [
[0, monthIndex, london],
[1, monthIndex, paris],
[2, monthIndex, newYork],
[3, monthIndex, seoul],
],
);

const xData = ['London', 'Paris', 'NewYork', 'Seoul'];
const yData = dataset.flatMap(({ month }) => month);

export default function ColorConfig() {
return (
<UnstableHeatmap
height={400}
width={600}
xAxis={[{ data: xData }]}
yAxis={[{ data: yData }]}
series={[{ data }]}
zAxis={[
{
min: 20,
max: 300,
colorMap: {
type: 'continuous',
color: interpolateBlues,
},
},
]}
/>
);
}
46 changes: 46 additions & 0 deletions docs/data/charts/heatmap/CustomItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import '@mui/x-charts-pro/typeOverloads';
import { UnstableHeatmap } from '@mui/x-charts-pro/Heatmap';
import { data } from './dumbData';

function CustomCell(props) {
const { x, y, width, height, ownerState, ...other } = props;

return (
<React.Fragment>
<rect
{...other}
x={x + 4}
y={y + 4}
width={width - 2 * 4}
height={height - 2 * 4}
fill={ownerState.color}
clipPath={ownerState.isHighlighted ? undefined : 'inset(0px round 10px)'}
/>
<text
x={x + width / 2}
y={y + height / 2}
textAnchor="middle"
dominantBaseline="middle"
pointerEvents="none"
>
{ownerState.value}
</text>
</React.Fragment>
);
}
export default function CustomItem() {
return (
<Box sx={{ width: '100%', maxWidth: 400 }}>
<UnstableHeatmap
slots={{ cell: CustomCell }}
xAxis={[{ data: [1, 2, 3, 4] }]}
yAxis={[{ data: ['A', 'B', 'C', 'D', 'E'] }]}
series={[{ data, highlightScope: { highlight: 'item' } }]}
margin={{ top: 5, right: 5, left: 20 }}
height={300}
/>
</Box>
);
}
Loading