TypeError: Cannot read property 'getBasePixel' of undefined
See original GitHub issueI’m getting an error trying to plot two datasets on a line chart with 2 different y-axis. If I specify the different Y axis, i get a TypeError: Cannot read property 'getBasePixel' of undefined
error.
Here is the render method of my component:
const data = {
labels: [...labels],
datasets: [
{
label: 'Crimes',
fill: false,
lineTension: 0.5,
backgroundColor: 'rgba(75,192,192,0.4)',
borderColor: 'rgba(75,192,192,1)',
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: 'rgba(75,192,192,1)',
pointBackgroundColor: '#fff',
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: 'rgba(75,192,192,1)',
pointHoverBorderColor: 'rgba(220,220,220,1)',
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
data: crimeData,
yAxisID: 'y-axis-1'
},
{
label: 'Video games sales',
fill: false,
lineTension: 0.5,
backgroundColor: '#F95F62',
borderColor: '#F95F62',
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: '#F95F62',
pointBackgroundColor: '#fff',
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: '#F95F62',
pointHoverBorderColor: 'rgba(220,220,220,1)',
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
data: gameData,
yAxisID: 'y-axis-2'
}
]
};
const options ={
responsive: true,
scales: {
yAxes: [
{
type: 'linear',
display: true,
position: 'left',
id: 'y-axis-1',
gridLines: {
display: false
},
labels: {
show: true
}
},
{
type: 'linear',
display: true,
position: 'right',
id: 'y-axis-2',
gridLines: {
display: false
},
labels: {
show: true
}
}
]
}
}
return (
<div className="chartsContainer">
{this.props.selectedRegion}
<div className="lineChart">
<Line data={data}
options={options}
width={50}
height={300}
options={{
maintainAspectRatio: false
}} />
</div>
</div>
)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:7
Top Results From Across the Web
Multi Line Chart.js with two Y-Axes - javascript
Chart.bundle.min.js:10 Uncaught TypeError: Cannot read property 'getBasePixel' of undefined at i.updateElement (Chart.bundle.min.js:10) at ...
Read more >Chart JS -TypeError: Cannot read property 'getBasePixel' ...
Surely I am not encountering a bug, but rather having issues because of my lack of experience and knowledge. I'm trying to add...
Read more >chart js cannot set property 'options' of undefined
Uncaught TypeError: Cannot read property 'innerHTML' of null All this means is that you are trying to access a property of an object...
Read more >Chart.js: Uncaught TypeError: Cannot read property &
This problem is not caused by our product. There's something wrong with Charts or Moment libraries, that the moment is undefined error is...
Read more >ChartJS - [Cannot read properties of undefined ...
[LWC component's @wire target property or method threw an error ... Original error: [Cannot read properties of undefined (reading 'data')]].
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same issue but I forgot to add the key scales in the options object. And for your problem you have 2 props options in you Line component.
Closing as not relevant to wrapper