score:0
Accepted answer
modified my code to this and got the chart displayed. i don't know what the issue was but it could be that i hadn't added getcontext. i also created the ref outside my state.
class radarchart extends component {
constructor(props) {
super(props);
}
chartref = react.createref();
componentdidmount () {
const mychartref = this.chartref.current.getcontext("2d");
new chart(mychartref, {
type: 'radar',
data: {
labels: this.props.labels,
datasets: [
{
label: "my second dataset",
backgroundcolor: "rgba(26,179,148,0.2)",
bordercolor: "rgba(26,179,148,1)",
pointbackgroundcolor: "rgba(26,179,148,1)",
pointbordercolor: "rgba(26,179,148,1)",
data: this.props.data
}
]
},
options: {
responsive: true,
legend: {
display: false
}
}
})
}
render() {
return <canvas ref={this.chartref} />
}
}
Source: stackoverflow.com
Related Query
- Cannot read property 'length' of undefined for ChartJS when I use it inside React
- TypeError: Cannot read property 'defaults' of undefined when using the react wrapper of chartjs
- Getting "Uncaught TypeError: Cannot read properties of undefined (reading 'map')" when using Chartjs inside react axios method
- Chartjs cannot read property datasets of undefined
- chartjs - multi axis line chart - cannot read property 'min' of undefined
- chartjs & asp.net: Cannot read property 'labels' of undefined
- Chartjs + Vue.js - Cannot read property '_meta' of undefined
- Uncaught TypeError: Cannot read property 'draw' of undefined for object scale
- Uncaught (in promise) TypeError: Cannot read property 'length' of undefined in chartjs with Vuejs
- Cannot read property '_index' of undefined ChartistJs for value 0 or null
- Cannot read property 'map' of undefined when looking at an array with no index
- Chart Js Cannot read property 'length' of undefined
- Uncaught TypeError: Cannot read property 'offsetWidth' of undefined - chart.js
- Cannot read property 'labels' of undefined
- Chart.js Cannot read property 'fontSize' of undefined
- TypeError: Cannot read property 'legend' of undefined | Angular + ng2-charts
- ChartJS: Uncaught TypeError: Cannot read property 'call' of undefined
- Cannot read property 'transition' null chartjs
- Uncaught TypeError: Cannot read property 'draw' of undefined
- Ionic/Chart.js - Cannot read property 'nativeElement' of undefined
- Updating Chart.js with JSON, cannot read property 'length' of undefined
- Angular / ng2-charts: Fetching json data in chart object showing: Cannot read property 'length' of undefined
- Problems with ChartJS "Uncaught TypeError: Cannot read property 'length' of null"
- Uncaught TypeError: Cannot read property 'draw' of undefined : Angular chart js
- Cannot read property 'reactiveProp' of undefined in vue-chartjs
- react-chartjs integration error. Cannot read property 'xLabels' of undefined
- chartjs undefined length when using 2 datasets
- Angular 12 + Chartjs 3.3.2 TypeError: Cannot read property 'left'
- ChartJS and JSON result: Cannot set property 'fillColor' of undefined
- chartjs; cannot read property '0' of undefined
More Query from same tag
- Number value format with comma and two decimal points
- Chart.js | Trouble refreshing line chart with "setInterval"
- Dynamically populate array with Firebase Data Vue.js
- Chartjs is stripping trailing zeros in decimal datasets
- ChartJs x axis labels on waterfall chart
- How to position yAxes labels in chartJS
- Chart JS + Laravel - How to add 0 to array
- Chartjs scatter chart's x axis is heavily padded
- Filling area between two lines - Chart.js v2
- Chartjs tooltip anchor point position on bar charts
- Chart.js "display:none" Issue
- Setting min and max values chart.js
- Charts.js - Bar chart different colors for value intervals not working
- How to add images to chart labels with vue-chartjs?
- Chart.js combined line and bar chart with differing data points
- How to detect click on chart js 3.7.1 axis label?
- Return 0 as data for months with no data
- Uncaught TypeError: Chart is not a constructor when using Chart.js
- Starting a Chart.js Time Scale at 0
- how to set color of label in chartjs?
- Chart.js: evenly distribute ticks when using maxTicksLimit
- Chart.js data background color is overwriting point background color
- Wrong display of xAxes in Chartjs
- vue js bar-chart gradient color not showing
- Ticks callback not displaying strings containing decimal
- Yii2 unable to view chart
- syntax error, unexpected ' ' Laravel 5.6 ConsoleTvs chart js
- how to insert dynamic data from sql into chartjs stacked bar chart javascript
- Chart.js how to rewrite x for webAPP
- Date selection not happening with a click in chartjs in the context of vuejs