score:1
Accepted answer
Please check this example jquery 2.2.4
// find elements
var ctx = document.getElementById('myChart');
var ctx = document.getElementById('myChart').getContext('2d');
var ctx = $('#myChart');
var ctx = 'myChart';
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<canvas id="myChart" width="400" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" type="text/javascript"></script>
score:1
It works perfectly fine if you properly source the jQuery library. Check here https://jsfiddle.net/g7qmh8wL/1/
// no code changes required.
Source: stackoverflow.com
Related Query
- Chart Js Cannot read property 'length' of undefined
- chartjs - multi axis line chart - cannot read property 'min' of undefined
- Angular / ng2-charts: Fetching json data in chart object showing: Cannot read property 'length' of undefined
- Uncaught TypeError: Cannot read property 'draw' of undefined : Angular chart js
- Chart JS Error : Uncaught TypeError: Cannot read property 'top' of undefined
- Uncaught TypeError: Cannot read property 'offsetWidth' of undefined - chart.js
- Chartjs cannot read property datasets of undefined
- TypeError: Cannot read property 'defaults' of undefined when using the react wrapper of chartjs
- 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
- 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
- chartjs & asp.net: Cannot read property 'labels' of undefined
- Cannot read property 'reactiveProp' of undefined in vue-chartjs
- react-chartjs integration error. Cannot read property 'xLabels' of undefined
- Chartjs + Vue.js - Cannot read property '_meta' of undefined
- chartjs; cannot read property '0' of undefined
- Chart.js Cannot read property 'apply' of undefined
- Cannot read property 'length' of undefined for ChartJS when I use it inside React
- react-chartjs error Cannot read property 'Chart' of undefined
- Uncaught TypeError: Cannot read property 'draw' of undefined for object scale
- ERROR TypeError: Cannot read property 'testMethod' of undefined
- Uncaught (in promise) TypeError: Cannot read property 'length' of undefined in chartjs with Vuejs
- Angular and CharJS - ERROR TypeError: Cannot read property '15' of undefined
- Uncaught TypeError: Cannot read property 'format' of undefined
- Cannot read properties of undefined with react-chartjs-2 and chart js problem
- Angular4 ng2-charts TypeError: Cannot read property 'length' of undefined
More Query from same tag
- How to display grouped data in ChartJs
- Use Ternary Option with Chart.js and AngularJs
- How could I skip drawing empty/zero value and its value on tooltip
- How to make a chart scroll horizontally (when using Chart.js)
- How to use php variables in a chart js chart
- How to draw a linear regression line in Chart.js
- How to render tooltip text on a different div with Chart.JS
- json file to charts
- Cannot find module /chartjs.helpers while using chartjs-plugins-datalabels (ReactJS)
- PHP string data passed to Chart.js not rendering well
- How to stop axis label from being cut off in chart JS?
- Barchart reducing space between bars
- Svelte , pass data to chartjs from API
- Bug in canvas class in chart js
- How to add data labels in each bar in stacked bar chart in chart.js?
- Y-axis label in chartjs 2.0.0
- Chart.js load new data
- chart.js custom legend colour based
- Chart.js library V.2 change Cursor to not allowed
- How to filter dropdown based on the choice of another dropdown in JS?
- How to compute x,y values from a click event using x,y pixel coordinates in ChartJS?
- How do I add JSON Data into ChartJS
- Chart.js 2 - Always display only some tooltips in bubble chart
- How to draw x axis and y-axis origin line draw in ng2-google-charts?
- How to give break line in data label
- Hide/show spefic data in ChartJS
- Meteor and ChartJS dynamically create a chart
- using library without 'require' when using CDN
- Php array and chartjs
- Chartjs doughnut chart for conditional data