-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: A undifined canvas error occuring in react-native #1198
Comments
I got the same issue when I use in my React Native project created by expo. package versions error This error is located at: |
What is the solution for this?? my code is import React, { useEffect, useState } from 'react'; const Graph: React.FC = () => { useEffect(() => { const fetchData = async () => {
}; const chartData = { return ( export default Graph; still i am getting error Render Error |
Apparently this library isn't meant to be used with react native for any future users #323 (comment) |
Would you like to work on a fix?
Current and expected behavior
I am facing this error, and i couldnt find a any way to solve it. Anyone have ever faced it? I see that in the frequent questions, there is "how to access canvas component", but still not useful.
I am using the simple code exaple that they give as exemple here
`import React from "react";
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
} from "chart.js";
import { Line } from "react-chartjs-2";
import { Faker, de, de_CH, en_US } from "@faker-js/faker";
export const faker = new Faker({
locale: [de_CH, de],
});
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend
);
export const options = {
responsive: true,
plugins: {
legend: {
position: "top" as const,
},
title: {
display: true,
text: "Chart.js Line Chart",
},
},
};
const labels = ["January", "February", "March", "April", "May", "June", "July"];
export const data = {
labels,
datasets: [
{
label: "Dataset 1",
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })),
borderColor: "rgb(255, 99, 132)",
backgroundColor: "rgba(255, 99, 132, 0.5)",
},
{
label: "Dataset 2",
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })),
borderColor: "rgb(53, 162, 235)",
backgroundColor: "rgba(53, 162, 235, 0.5)",
},
],
};
export function ContractChart2() {
return ;
}`
Reproduction
https://react-chartjs-2.js.org/examples/line-chart
chart.js version
^4.4.0
react-chartjs-2 version
5.2.0
Possible solution
No response
The text was updated successfully, but these errors were encountered: