No type errors, but when rendering this error is thrown.
"react-charts": "3.0.0-beta.54"
import { Chart as GoogleChart } from "react-google-charts";
import { AxisOptions, Chart as ReactChart } from 'react-charts';
...
function TemperatureChartReact({ normals }: { normals: Record<Month, { tmin: number, tmax: number }> }) {
type Temperature = {
month: Month,
temperature: number,
}
type Series = {
label: string,
data: Temperature[]
}
const data = useMemo(() => {
return Object
.entries(normals)
.map(([month, normal]) =>({
month: Number.parseInt(month) as Month,
temperature: normal.tmax
}))
}, [normals])
const series: Series[] = [
{
label: 'Temperature',
data
}
]
const primaryAxis = React.useMemo(
(): AxisOptions<Temperature> => ({
getValue: datum => datum.month
}),
[]
)
const secondaryAxes = React.useMemo(
(): AxisOptions<Temperature>[] => [
{
getValue: datum => datum.temperature
}
],
[]
)
return (
<ReactChart
options={{
data: series,
primaryAxis,
secondaryAxes
}}
/>
)
}
Series object
[
{
label: 'Temperature',
data: [
{ month: 1, temperature: 22.46 },
{ month: 2, temperature: 24.56 },
{ month: 3, temperature: 26.67 },
{ month: 4, temperature: 29.56 },
{ month: 5, temperature: 32.25 },
{ month: 6, temperature: 33.48 },
{ month: 7, temperature: 33.14 },
{ month: 8, temperature: 32.59 },
{ month: 9, temperature: 31.46 },
{ month: 10, temperature: 29.36 },
{ month: 11, temperature: 27.36 },
{ month: 12, temperature: 24.04 }
]
}
]
No type errors, but when rendering this error is thrown.
"react-charts": "3.0.0-beta.54"Series object