diff --git a/components/Infographic.tsx b/components/Infographic.tsx index efa5acb..a9be5e8 100644 --- a/components/Infographic.tsx +++ b/components/Infographic.tsx @@ -1,7 +1,7 @@ "use client"; -import { Fragment, useState } from "react"; -import { LineChart } from "@/components/LineChart"; +import { useState } from "react"; +import dynamic from "next/dynamic"; import { ChartData, ChartOptions } from "chart.js"; import { stringToUniqueColour } from "@/lib/stringToUniqueColour"; import { transformDataToDatasets } from "@/lib/transformDataToDatasets"; @@ -11,6 +11,10 @@ type InfographicProps = { electricCars: Car[]; }; +const DynamicLineChart = dynamic(() => import("../components/LineChart"), { + loading: () =>

Loading...

, +}); + export const Infographic = ({ electricCars }: InfographicProps) => { const initialDatasets: ChartDataset[] = transformDataToDatasets( electricCars, @@ -82,7 +86,7 @@ export const Infographic = ({ electricCars }: InfographicProps) => { return ( <>
- +

Make

diff --git a/components/LineChart.tsx b/components/LineChart.tsx index aefd2e1..85a573a 100644 --- a/components/LineChart.tsx +++ b/components/LineChart.tsx @@ -34,3 +34,5 @@ type LineChartProps = { export const LineChart = ({ data, options }: LineChartProps) => { return ; }; + +export default LineChart;