score:1
Accepted answer
The problem here is you use an async
method getTecajRazdoblje()
. But you're trying to fill the array sync
way. So you need to correct that. Try this:
this.hnbProvider.getTecajRazdoblje(datum_poc, datum_kraj).subscribe(tecaj =>
{
this.tecaj = tecaj;
var i = 0;
for (var key in this.tecaj) {
if (this.tecaj[key].valuta == this.o_valuta){
this.array[i] = this.tecaj[key].srednji_tecaj;
i++;
}
this.lineChart = new Chart(this.lineCanvas.nativeElement,
{
type: 'line',
data: {
labels: this.lista_valuta,
datasets: [
{
label: "My First dataset",
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(75,192,192,0.4)",
borderColor: "rgba(75,192,192,1)",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "rgba(75,192,192,1)",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "rgba(75,192,192,1)",
pointHoverBorderColor: "rgba(220,220,220,1)",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
data:this.array,
spanGaps: false,
}
]
}
});
}
});
}
Source: stackoverflow.com
Related Query
- Ionic 3 + Angular 4 + chart.js - loading data from array
- Update the chart data from an array stored in a variable on button click
- Update Chart js chart dynamically in angular 2 from data getting from nodejs service
- chart js not dispalying data array that comes from an axios request
- Chart JS can't access data from array within an object
- angular 4 line chart data is not showing data from http get
- Realtime data from a service in ionic / angular
- Create a pie chart using an array from a data table in chart.js
- getting additional value fields from data source for dx.chartjs doughnut chart
- concatenate on tooltip from data array in 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
- How to take data from an API and create a chart on that using Chart.js and Angular 8?
- Loading multiple doughnut chart from chart.JS in a single component of angular 6
- Chartjs random colors for each part of pie chart with data dynamically from database
- How to add datas to chart js from javascript array itself?
- How to display data labels outside in pie chart with lines in ionic
- How to use 'time' (data from database, data type: timestamp ) for plotting graph in Chart JS
- How to update data Chart in async way in Angular Chart.js?
- Using data from API with Chart JS
- chart js with angular2 loading dynamic data only after zoomin
- Can't pass array to chart.js which got its data from @Input
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- Chart not displaying from JSON data
- Angular chart how to show the legend data value by default along with legend name
- How to create chartjs chart with data from database C#
- Redraw Chart.js Chart with Json_encoded array from ajax request
- Ionic 3 Angular Chart.js update data
- How to get chart from data points (arrays) with inconsistent time intervals and chart.js?
- Angular Charts.js: Can't refresh chart with data
- Calling data from search bar to chart.js graph in Angular
More Query from same tag
- ChartJs functional component does not refresh even when forceUpdate
- Loop datasets into chart.js?
- Getting chart.js to work with Django and Apache
- Chart.js Bar Chart: How to remove space between the bars in v2.3?
- Chart.js V2.7.2 How to make Horizontal scroll bar without loosing Y-Axis
- ChartJs - Labelling minimum and maximum value of the Y Axis
- How to fix a stacked logarithmic bar chart values to fit the grid
- Angular 6 with chart.js TypeError: item is null
- How to reduce the distance between yAxes in Chart.js?
- Chart.js doesn't show chart while on flask blueprint
- ChartJS tooltip position / placement
- How to add a horizontal line at a specific point in chart.js when hovering?
- How to save in chart original ID of element in array that is used to build chart data labels?
- How to shade between 2 lines on a line graph using chart.js version2
- How do you limit the blur in a linear gradient on a canvas?
- Update Chart in Javascript using Chart.js
- Chart.js - draw horizontal line based on a certain y-value
- Boxplot chartjs make min and max dynamic by leaving some space on both side
- How to add Canvas tag inside repeater
- Customize legend AngularJS
- Chart.js how to set start and end values to plot
- How to add index labels(on top of bar charts) in Chart.js
- In Chart.js multibar graph, is there a way to highlight a single category?
- How to resolve npm error needing an appropriate loader?
- Chart.js – how to remove data entries from the tooltip?
- Chart.js bar chart barWidth is Inconsistent
- chart js draw line chart by points instead of by lines
- How to get x-axis value in chart as string?
- To display data from mock server into chartjs using ember
- I need to build an array of arrays, having trouble conceptualizing