score:1
Accepted answer
the issue is merely occurring due to the fact that, you have placed the options
object/property, inside the data
property, while it should be outside.
here is the revised version of your code :
var ctx = document.getelementbyid("chart_canvas").getcontext('2d')
var basic_line = new chart(ctx, {
type: 'line',
data: {
labels: data.labels,
datasets: [{
label: 'price',
yaxisid: 'b',
fill: false,
bordercolor: ["#668cff"],
data: data.price
}, {
label: 'sales',
yaxisid: 'a',
fill: false,
bordercolor: ["grey"],
data: data.sales
}]
},
options: {
scales: {
yaxes: [{
id: 'a',
position: 'left',
type: 'linear'
}, {
id: 'b',
position: 'right',
type: 'linear'
}]
},
responsive: true,
maintainaspectratio: false
}
});
Source: stackoverflow.com
Related Query
- chartjs - multi axis line chart - cannot read property 'min' of undefined
- Chart Js Cannot read property 'length' of undefined
- Chartjs cannot read property datasets of undefined
- TypeError: Cannot read property 'defaults' of undefined when using the react wrapper of chartjs
- chartjs & asp.net: Cannot read property 'labels' 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
- Chartjs + Vue.js - Cannot read property '_meta' of undefined
- Cannot read property 'length' of undefined for ChartJS when I use it inside React
- Chart JS Error : Uncaught TypeError: Cannot read property 'top' of undefined
- Uncaught (in promise) TypeError: Cannot read property 'length' of undefined in chartjs with Vuejs
- Chart.js Line graph legend yields error: Uncaught TypeError: Cannot read property '0' of undefined
- Uncaught TypeError: Cannot read property 'offsetWidth' of undefined - chart.js
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- show label in tooltip but not in x axis for chartjs line chart
- Cannot read property 'labels' of undefined
- Chart.js Cannot read property 'fontSize' of undefined
- Map event position to y axis value in chartjs line chart
- 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
- Problems with ChartJS "Uncaught TypeError: Cannot read property 'length' of null"
- Cannot read property 'reactiveProp' of undefined in vue-chartjs
- react-chartjs integration error. Cannot read property 'xLabels' of undefined
- ChartJS automatically scaled chart has undefined min and max
- Angular 12 + Chartjs 3.3.2 TypeError: Cannot read property 'left'
- Chartjs dynamic chart return both x & y axis undefined
More Query from same tag
- Why tooltip position absolute does not apply using js?
- Angular-Charts - Pie Chart,show labels inside each slice of data
- Remove gap when updating ChartJS
- Eror: chart.min.js:13 Uncaught (in promise) Error: Canvas is already in use. Chart with ID '0' must be destroyed before the canvas can be reused
- How to include adapters and plugins with ChartJS
- How to target only X or Y value in jsonObj array
- How to make animated bar graph with canvas?
- Chart.js - remove labels
- ChartJs - pie chart not showing
- Chart.js stacked line chart with differently styled sections
- labelling the pop up Chart js
- ChartJS legend background color while using point styles
- How do I use my chart.js line chart with handlebars?
- How to make a max value in doughnut chart
- In Chart.js, how do I hide certain axis labels from a stacked bar chart?
- ChartJS v2 - Outer arc when hover on a pie/doughnut segment
- How to put indicator between yAxis values on yAxis chartJs?
- Creating a heart rate monitor
- Chartjs remove text striking on legend
- start y-axis from 0 in ng2-charts
- Chartjs duration horizontal bar chart
- How to implement scattered chart using chart.js which is not available by default?
- What is the order in which the hooks (plugins) of Chart.js are executed?
- How to create a bar and a line in a same graph using chart.js in React?
- How to replace the data array of my ChartJS
- int Array with empty value
- Error in created hook (Promise/async): "TypeError: Cannot read property 'position' of undefined"
- Tooltip flickering when hovered on chart
- Why won't my chart.js chart render in React?
- Show base64 image next to canvas with charts.js