question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'getBasePixel' of undefined

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:7

github_iconTop GitHub Comments

23reactions
FlorianGGcommented, Apr 3, 2019

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.

const options = {};
options.scales = {};
options.scales.yAxes = [
  {
        type: 'linear',
	display: true,
	position: 'left',
	id: 'y-axis-1',
    },
    {
	type: 'linear',
	display: true,
	position: 'right',
	id: 'y-axis-2',
    },
];
14reactions
Pringelscommented, Dec 5, 2019

Closing as not relevant to wrapper

Read more comments on GitHub >

github_iconTop 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 &#38
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found