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
- How to customize chart js Bar chart shape?
- How do you use user input as data values in chart.js?
- diplay barchart in a <div>
- Modify the legend of a double doughnut with chart js
- How to toggle between Custom tooltip and normal tooltip in chartjs and angular
- ChartJS Update callbacks
- Load data into chartjs using promises in vue.js
- Filter ChartJS using data from PHP
- ChartJs: x-axes min and max value not working
- gradient background on radar chartjs
- Error: Failed to create chart: can't acquire context from the given item
- Chart.js Change color of the values *inside* the bars of a Bar chart
- Create chart in SPA(Aurelia) with MVVM pattern
- Chartjs: how to show only max and min values on y-axis
- How can I add new data points to an existing chart with chart.js?
- Chartjs blocks jumping to a section in ASP.NET MVC 5
- How can I express this element?
- Remove Legends ChartsJS 2.8.0
- How do I destroy/update Chart Data in this chart.js code example?
- Chart.js 3.7 version. How to modify legend label?
- Chart.js mixed chart : Lines not starting at zero
- Chart.js Radar background color of background
- How to determine chart type inside 'chart.js' pluginservice
- How to draw one line with different colors in chartjs2?
- dynamic line styling in chartjs
- Histogram like chart with intensity colored columns and per bin opacity to show intensity
- Keep chart.js doughnut with fixed width and height centered in container
- Unix Timestamp Chart.js with PHP echo
- Map through datasets in chartjs
- Creating a horizontal bar chart extension on Chart.js