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.

defaults = _chart["defaults"].defaults is undefined

See original GitHub issue

Hi and greattings, i maked a project in cube.js and afther that a “dashboard-app” of type ‘real time dashboard’ everything is ok until I run the app and response whit that message:

TypeError: _chart.default is undefined

and i could’t advanced afther that.

so i goes to the file node_modules/react-chartjs-2/es/index.js:644 and I make a log of the variable ‘_chart’ and I see that only exist the field “_chart[“default”]”

so i fix the error whit this:

// I change this:
// var defaults = _chart["default"].defaults;
// For this:
var defaults = _chart["defaults"];

I hope someone can fix this or use that issue for help

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19

github_iconTop GitHub Comments

6reactions
jtrembackcommented, Apr 13, 2021

Might be good to put this requirement on 2.9.4 in the readme. Right now, when I come to this repo and try out the library, it is broken out of the box

3reactions
jtrembackcommented, Apr 13, 2021

Using chart.js 2.9.4 does not seem to fix this.

Here are my dependencies:

    "chart.js": "2.9.4",
    "react-chartjs-2": "^2.11.1",

I have also verified that 2.9.4 is the version installed in my node_modules folder.

Here is my code:

import React from "react";
import { Line } from "react-chartjs-2";

const data = {
  labels: ["January", "February", "March", "April", "May", "June", "July"],
  datasets: [
    {
      label: "My First dataset",
      fill: false,
      lineTension: 0.1,
      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: [65, 59, 80, 81, 56, 55, 40],
    },
  ],
};

export const ReactChartJs = () => {
  return (
    <div>
      <h2>Line Example</h2>
      <Line data={data} />
    </div>
  );
};

Here is the error:

TypeError: Cannot read property 'defaults' of undefined
(anonymous function)
node_modules/react-chartjs-2/es/index.js:643
  640 | }(_react["default"].Component);
  641 | 
  642 | exports.Scatter = Scatter;
> 643 | var defaults = _chart["default"].defaults;
  644 | exports.defaults = defaults;
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'defaults' of undefined when ...
The error that shows is the following: TypeError: Cannot read property 'defaults' of undefined (anonymous function) C ...
Read more >
Defaults" Of Undefined" Error While Using Reactchartjs2
DataTables: Uncaught TypeError: Cannot read property 'defaults' of undefined. Solution: The problem is that dataTable is not defined at the point you are....
Read more >
Chart.defaults.global.tooltips is undefined in AngularJS-Chart.js
Coding example for the question TypeError: Chart.defaults.global.tooltips is undefined in AngularJS-Chart.js.
Read more >
Fonts | Chart.js
There are special global settings that can change all of the fonts on the chart. These options are in Chart.defaults.font .
Read more >
How to use the react-chartjs-2.defaults.global function ... - Snyk
defaults.global.animation = false; const loadSheetPropertiesIntoState = ( that, columnCount, thumbCount, secondsPerRowTemp = undefined, ) => { that.setState({ ...
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