Skip to content

Commit 1d9db9b

Browse files
committed
register ChartDataLabels plugin in stats box component to avoid production fail
1 parent c8328d5 commit 1d9db9b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/components/StatsBoxGrid/GridItem.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
PointElement,
88
ScriptableContext,
99
} from "chart.js"
10+
import ChartDataLabels from "chartjs-plugin-datalabels"
1011
import { Line } from "react-chartjs-2"
1112
import { MdInfoOutline } from "react-icons/md"
1213
import { Box, Flex, Icon, Text } from "@chakra-ui/react"
@@ -33,7 +34,16 @@ type GridItemProps = {
3334
}
3435

3536
// ChartJS config
36-
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Filler)
37+
ChartJS.register(
38+
CategoryScale,
39+
LinearScale,
40+
PointElement,
41+
LineElement,
42+
Filler,
43+
// to avoid a production error, we must include this plugin even if we do
44+
// not use it (we are using it on the energy consumption chart)
45+
ChartDataLabels
46+
)
3747

3848
export const GridItem = ({ metric }: GridItemProps) => {
3949
const { title, description, state, buttonContainer, range } = metric
@@ -186,7 +196,7 @@ export const GridItem = ({ metric }: GridItemProps) => {
186196
</Box>
187197
{hasData && (
188198
<Box position="absolute" insetInline="0" bottom={7} height="60%">
189-
<Line options={chartOptions} data={chartData} updateMode="none" />
199+
<Line options={chartOptions} data={chartData} />
190200
</Box>
191201
)}
192202
<Flex

src/components/StatsBoxGrid/StatsBoxGrid.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Meta, StoryObj } from "@storybook/react"
33
import ChartComponent from "."
44

55
const meta = {
6+
title: "Charts / StatsBoxGrid",
67
component: ChartComponent,
78
} satisfies Meta<typeof ChartComponent>
89

0 commit comments

Comments
 (0)