score:0
i'm using 2.8.0 (current latest). earlier versions as suggested here did not help.
the solution to this error for me was providing the correct element id for the context. i was giving new chart()
"chartjs-1" because i blindly copied an example, but my canvas id was "mycanvas". giving new chart()
the actual id of my canvas fixed the problem.
note, the error in the question is from firefox. chrome gave a different error that clued me into the real culprit: cannot read property 'length' of null
score:2
put the javascript code (start with <script type="text/javascript">var ctx ...</script>
) after the canvas element. this ensures that the canvas element is already present at the time when it gets referenced by var ctx = document.getelementbyid("mychart");
this should solve your problem.
score:4
solved, apparently the script link i was using was bugged. changed it to https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.4.0/chart.min.js and it works fine. see chris g
's comment.
Source: stackoverflow.com
Related Query
- Error with Chart.js : TypeError: t is undefined
- ERROR TypeError: "this.canvas is undefined" | Problem with creating a chart with angular and chart.js
- Chart JS Error : Uncaught TypeError: Cannot read property 'top' of undefined
- what is wrong with my code ? java script chart position
- Chart js error in angular: Canvas is already in use. Chart with ID '0' must be destroyed before the canvas can be reused. Fix?
- Cannot read properties of undefined with react-chartjs-2 and chart js problem
- 404 Not Found Error when trying to display a chart with Chart.js
- How can I create a horizontal scrolling Chart.js line chart with a locked y axis?
- Chartjs random colors for each part of pie chart with data dynamically from database
- ChartJS New Lines '\n' in X axis Labels or Displaying More Information Around Chart or Tooltip with ChartJS V2
- Why does nuxt give me this error with vue-chartjs?
- How to prevent first/last bars from being cut off in a chart with time scale
- ChartJS - Draw chart with label by month, data by day
- Chart Js Cannot read property 'length' of undefined
- Horizontal stacked bar chart with chart.js
- line chart with {x, y} point data displays only 2 values
- Vertical stacked bar chart with chart.js
- Display line chart with connected dots using chartJS
- react-chartjs-2 with chartJs 3: Error "arc" is not a registered element
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- Chart.js - line chart with two yAxis: "TypeError: yScale is undefined"
- How to fix chart Legends width-height with overflow scroll in ChartJS
- How to display Line Chart dataset point labels with Chart.js?
- chart js how to fill legend box with colour
- Chart.js Mixed Bar and Line chart with different scales
- chart.js Line chart with different background colors for each section
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- reactive chart with chart.js in meteor
- chartjs: How to plot multi-line chart with irregular intervals
- Problem for display a chart with Chart.js and Angular
More Query from same tag
- drawing bar chart with Chart.js
- Drawing line chart in chart.js with json response
- Connecting Chart.js to MySQL database
- TypeError: Cannot read property 'legend' of undefined | Angular + ng2-charts
- ChartJS : How to leave just points without lines
- show xAxes on click
- Chart.js add border around line chart, and yAxis unit title ([s])
- not able to move my range slector
- chart.js not accepting data in dataset which stored in local storage
- How to inject data into chartjs plugin function?
- Position tooltip based on mouse position
- Chart JS: is possible mix Scatter and bar chart in Chart JS?
- Implementing hover callback in Chart.js
- Chart.js parser returns the wrong date (suddenly back in 1990)
- Chart.js Label Issue
- ChartJs title not showing
- How can i add an image as background in Chartjs?
- ChartJS with React: Only one value showing on time chart
- chart.js in mvc graph are not show
- Chartjs error : time scale: "time.format" is deprecated. Please use "time.parser" instead
- How to determine chart type inside 'chart.js' pluginservice
- chart.js mixed chart types
- chartjs angular update order
- Se Chartjs horizontal
- Change tool-tip direction in react-chartjs2
- How to make integer scale in Chartjs
- chart js tooltip how to control the data that show
- Chart won't draw. Returning a string value not a Number value - Meteor - Chartjs
- How to set only min and max values in y-axis (chart js)
- "Cannot read property 'xyz' of undefined": How to use map or foreach on numeric json?