score:1
i could find the solution. have a look at this link. i defined my variable as below (this solved all the errors i mentioned above):
private test2: any[] = [{ data: [] }];
also, i changes the location of calling the barchartdata
.
first, in export class:
public barchartdata;
then, inside my function that calls the backend data:
this.barchartdata = [
{data: this.test2, label: 'data 1'},
{data: this.test3, label: 'data 2'}
];
this worked for me.
score:0
you are inserting data dynamically so you need to make an update on change. you will need changedetectorref
for this. do the following steps:
1) add this in your imports:
import { changedetectorref } from '@angular/core';
2) add this in the constructor:
private cdref: changedetectorref
3) after changing the data do this:
this.cdref.detectchanges();
Source: stackoverflow.com
Related Query
- chart cannot read multiple datasets from the back-end (single data is fine)
- Chart JS show multiple data points for the same label
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- Angular / ng2-charts: Fetching json data in chart object showing: Cannot read property 'length' of undefined
- How do I customize y-axis labels and randomly pick the value from the data range for x-axis in Chart js
- Update the chart data from an array stored in a variable on button click
- The chart doesn't display the data from my call to the API with Axios
- Using number/text input field to set the data values in ChartJs stops the chart from being displayed
- Chart.js - Multiple JSON data object array [{x: Date, y: count}....] representing each dataset of the chart
- How to stop displaying the data values from different data objects on Chart JS 2.x?
- How to start the chart from specific time and offest hour and then show the data on chart from target datetime in chartjs
- How do i have a single Chart.vue component instead of different chart components and then display charts from it by changing id of the API
- Why is the data from my API not displaying on my chart.js chart in React?
- Chart is not populating when getting the data from AJAX call
- getting additional value fields from data source for dx.chartjs doughnut chart
- Multiple Chart.js charts on a single page, from 1 function but different data
- Accessing data from the callback function of a bar chart using chart js
- How to set the data of chart in angular which is taken from the backend nodejs api that is store in mongodb and showing on the html page
- Created an onclick function to remove data from a line chart in ChartsJs, but getting "Cannot read property 'data' of undefined" error
- how to add multiple data in chart js dynamically from JSON
- Realtime chart JS in Java obtaining the data from a sensor ;Chart.js: Failed to create chart: can't acquire context from the given item
- Multiple axis line chart with Chart.js and JSON data from Google Sheet
- Loading multiple doughnut chart from chart.JS in a single component of angular 6
- Bar Chart cannot read data and label in laravel
- Chart JS: Donut/Doughnut Chart: Tooltip to be shown always for all the data. All tooltip is not shown when multiple data are with 0 data
- Cannot make my chart to work with data from mongoDB
- How to clear a chart from a canvas so that hover events cannot be triggered?
- Chartjs random colors for each part of pie chart with data dynamically from database
- Chart Js Cannot read property 'length' of undefined
- Chartjs cannot read property datasets of undefined
More Query from same tag
- How to catch an onClick event on bubble chart?
- How to connect Firebase in Chart.js?
- How can i add additional Data(Type) to chart.js
- chartjs with local dates
- How can I create a long tail chart with chart.js
- How can I change the position of legends in chart.js?
- Chart.js -> Displaying % on pie chart
- Chart.js fix minimum axes?
- Chart.js line chart not showing point on top most value
- Chart.js - change which data the legend uses for the coloured box
- ChartJS not showing data for time series bar chart
- Call chartjs in rhino using java
- Chartjs 2 - Stacked bar with marker on top
- Unexpected text "NaN" appearing near y-axis of the Chart
- Trouble using utcoffset with Chart.js
- ChartJS - PieChart's Label too long and hide the PieChart
- Type error in using chartjs and tc-angular-chartjs
- Chart JS not showing all data
- Chartjs tooltip anchor point position on bar charts
- Pie Chart shows up only when I zoom in-out
- Using chart js options with react-chartjs-2 and typescript
- How to make bars change color based on value in chartsjs
- How to set max/min on x axis to display time range in Chart.js?
- Chart.js setting maximum bar size of bar chart
- Chart JS version 3+. How to get a tick's label in a tick callback function?
- How can i fix my code so i can read my data
- Chart Js flickering or switching as i move mouse on canvas
- Angular 13, Chart.js, ng2-chart Update data from API dynamically
- ReactJS - Moving vertical line when hovering over Line chart using chart.js v3.7.1
- chart.js: Show labels outside pie chart