I have Line chart on my react project. I want to translate labels and chart breaks if component re renders after I switch language. Error is "Cannot read property 'getPixelForValue' of undefined" so if I hard code labels errors is gone. I found that I should use datasetKeyProvider if I want unique string value. But I have problem in implementing that.
I tried to set it like this:
class LineChart extends Component {
datasetKeyProvider() {
return Math.random();
}
render() {
return (
<>
<Line
data={this.state.chartData}
datasetKeyProvider={this.datasetKeyProvider}
options={{
legend: {
display: true,
position: "bottom"
},
maintainAspectRatio: false,
scales: {
xAxes: [
{
type: "time",
time: {
unit: "year"
}
}
]
/>
</>
)
}
}