mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-01 13:47:27 +02:00
Fix: created vs archived rendering errors; memoize options (#10562)
Fixes the rendering / max update depth exceeded errors we were seeing in the console for this chart by memoizing the options. <img width="1710" height="1420" alt="image" src="https://github.com/user-attachments/assets/9a24d4e5-b563-4a3c-9a76-915e0a5fda24" /> Now the chart doesn't throw any errors anymore.
This commit is contained in:
parent
7fb523e348
commit
b071b17dd6
@ -134,57 +134,62 @@ export const CreationArchiveChart: FC<ICreationArchiveChartProps> = ({
|
|||||||
const data =
|
const data =
|
||||||
notEnoughData || isLoading ? placeholderData : aggregateOrProjectData;
|
notEnoughData || isLoading ? placeholderData : aggregateOrProjectData;
|
||||||
|
|
||||||
|
const options = useMemo(
|
||||||
|
() => ({
|
||||||
|
responsive: true,
|
||||||
|
interaction: {
|
||||||
|
mode: 'index' as const,
|
||||||
|
intersect: false,
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
position: 'bottom' as const,
|
||||||
|
labels: {
|
||||||
|
color: theme.palette.text.secondary,
|
||||||
|
usePointStyle: true,
|
||||||
|
padding: 21,
|
||||||
|
boxHeight: 8,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
enabled: false,
|
||||||
|
position: 'average' as const,
|
||||||
|
external: createTooltip(setTooltip),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
locale: locationSettings.locale,
|
||||||
|
scales: {
|
||||||
|
x: {
|
||||||
|
type: 'time' as const,
|
||||||
|
display: true,
|
||||||
|
time: {
|
||||||
|
unit: 'week' as const,
|
||||||
|
tooltipFormat: 'PPP',
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
type: 'linear' as const,
|
||||||
|
position: 'left' as const,
|
||||||
|
beginAtZero: true,
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: 'Number of flags',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
[theme, locationSettings, setTooltip],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Chart
|
<Chart
|
||||||
type='bar'
|
type='bar'
|
||||||
data={data}
|
data={data}
|
||||||
options={{
|
options={options}
|
||||||
responsive: true,
|
|
||||||
interaction: {
|
|
||||||
mode: 'index',
|
|
||||||
intersect: false,
|
|
||||||
},
|
|
||||||
plugins: {
|
|
||||||
legend: {
|
|
||||||
position: 'bottom' as const,
|
|
||||||
labels: {
|
|
||||||
color: theme.palette.text.secondary,
|
|
||||||
usePointStyle: true,
|
|
||||||
padding: 21,
|
|
||||||
boxHeight: 8,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
enabled: false,
|
|
||||||
position: 'average',
|
|
||||||
external: createTooltip(setTooltip),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
locale: locationSettings.locale,
|
|
||||||
scales: {
|
|
||||||
x: {
|
|
||||||
type: 'time',
|
|
||||||
display: true,
|
|
||||||
time: {
|
|
||||||
unit: 'week',
|
|
||||||
tooltipFormat: 'PPP',
|
|
||||||
},
|
|
||||||
grid: {
|
|
||||||
display: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
y: {
|
|
||||||
type: 'linear',
|
|
||||||
position: 'left',
|
|
||||||
beginAtZero: true,
|
|
||||||
title: {
|
|
||||||
display: true,
|
|
||||||
text: 'Number of flags',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
height={100}
|
height={100}
|
||||||
width={250}
|
width={250}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user