score:1
Accepted answer
please remind that $.ajax()
makes an asynchronous http request. in you code however, you create the chart even before ans answer from that request is received.
the problem can be solved by moving the code responsible for chart creation inside the $.ajax()
block as shown below.
$.ajax({
success: function(response) {
var jsonarr = $.parsejson(response);
var k = 0;
for (var key in jsonarr) {
days[k] = jsonarr[key]["days"];
values[k] = parseint(jsonarr[key]["values"]);
k++;
};
var a = {
labels: days,
datasets: [{
backgroundcolor: ktapp.getstatecolor("danger"),
data: values
}]
};
new chart(...);
});
Source: stackoverflow.com
Related Query
- Chart.js - Ajax response not accept
- Chart is not populating when getting the data from AJAX call
- Not able to draw Doughnut Chart from json response
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- how to not repeat code while creating multiple charts in chart js
- ReferenceError: Chart is not defined - chartjs
- Chart.js: bar chart first bar and last bar not displaying in full
- Chart.js responsive option - Chart not filling container
- show label in tooltip but not in x axis for chartjs line chart
- Html chart does not fit a small Android WebView
- Chart.js ng2-charts colors in pie chart not showing
- Chart.JS Mixed Chart - Bars Not Showing
- Chart looks only grey, does not show the color - Chartjs,discordjs
- Angular-chart.js - Make line chart does not curve
- angular-chartjs line chart TypeError: t.merge is not a function
- Chart.js line chart is not displaying
- Chart.js: width and height of a pie chart not respected
- Uncaught TypeError: Chart is not a constructor when using Chart.js
- Line chart is not being displayed in Chart.js
- Series Details Not Showing in Angular Chart with Charts.js
- Drawing line chart in chart.js with json response
- Chartjs not rendering chart and no error thrown
- Chart.js pie chart not showing in Google Chrome canvas
- Chart.js Chart in Angular does not load until resizing browser window
- vue.js vue-chartjs chart not updating when chartData replaced, updated etc
- Chart.js update function (chart,labels,data) will not update the chart
- Time series line chart is not displayed
- Chart JS custom tooltip not showing
- Time Series Line chart js in react not working
- Annotation events not update the chart
More Query from same tag
- How to fix size of mixed chart with bubble chart in Chart.js?
- ChartJS options with Chartkick
- How to add faded background to stack chart in react native
- Chartjs Custom Legend with Time on Y-axis
- Canvas not rendering after animation without resizing viewport
- Change Legend Box Outline Chart.js 2
- Problem with primeNG chart: Module not found: Error: Can't resolve 'chart.js/auto'
- Ng2-charts Time xAxes : unwanted high zoom on click
- chart js put meter square / superscript on y axis
- Chartjs x axis scaling
- how to show multiple values in point hover using chart.js
- how to combine to array for chartjs width php
- Chartjs line graph goes over panel
- How to show stacked and unstacked bar graphs together in Chart.js
- Chart.js scatter plot fill portions of chart based on value
- Strikethough labels when data is hidden
- Chartjs - Insert additional data into chart tooltip
- Chart.js Bar graph will not start at zero as minimum value
- ng2-charts: Datalabels values are not shown in my grapghs
- Calculate Ideal Burndown
- How do I place 2 <div>s side by side
- Loop through each tooltips to add different TimeStamps
- How to remove the line/rule of an axis in Chart.js?
- Chart.js Stacked Group Bar model after updating version Chart.js 2.9.4 -> Chart.js 3.5.0
- Chart.js - How to create an auto-scaling line diagram for a big amount of data happenning over time
- How to edit the ID of each button in a class if a condition is true in JavaScript?
- How to update JS variable in value field of charts.js?
- Chart.js - Responsiveness not correctly working on device orientation change
- Chart.js changing the color of the max value bar
- How to show bar chart labels clearly using ChartJS?