TypeError: (0 , {imported module [project]/nodemodules/highcharts/modules/exporting.js [app-client] (ecmascript)}.default) is not a function.
My code is like the following:
Code: Select all
"use client";
import React, { useRef } from "react";
import * as Highcharts from "highcharts/highstock";
import HighchartsExporting from "highcharts/modules/exporting";
import { HighchartsReact } from "highcharts-react-official";
if (typeof Highcharts === "object") {
HighchartsExporting(Highcharts);
}
const options: Highcharts.Options = {
title: {
text: "My chart",
},
series: [
{
type: "line",
data: [1, 2, 3],
},
],
};
const PriceVolChart = (props: HighchartsReact.Props) => {
const chartComponentRef = useRef<HighchartsReact.RefObject>(null);
return (
<HighchartsReact
highcharts={Highcharts}
constructorType="stockChart"
options={options}
ref={chartComponentRef}
{...props}
/>
);
};
export default PriceVolChart;
I also tried
Code: Select all
"use client";
import React, { useRef } from "react";
import Highcharts from "highcharts/es-modules/masters/highstock.src.js";
import { HighchartsReact } from "highcharts-react-official";
import "highcharts/es-modules/masters/modules/boost.src.js";
import "highcharts/es-modules/masters/modules/boost.src.js";
import "highcharts/es-modules/masters/modules/accessibility.src.js";
const options: Highcharts.Options = {
title: {
text: "My chart",
},
series: [
{
type: "line",
data: [1, 2, 3],
},
],
};
const PriceVolChart = (props: HighchartsReact.Props) => {
const chartComponentRef = useRef<HighchartsReact.RefObject>(null);
return (
<HighchartsReact
highcharts={Highcharts}
constructorType="stockChart"
options={options}
ref={chartComponentRef}
{...props}
/>
);
};
export default PriceVolChart;
But then I got the following error:
⨯ TypeError: Cannot read properties of undefined (reading 'createEvent').
How can I properly implement a stock chart in next js?