Topic: mdbootstrap chart with json data - how to import

Klaudia free asked 5 years ago


I would really appreciate if somebody could help me with figured out how to import data from external json file into the bootsrap chart.

I have already tried to write something based on the line chart but it doesn't show any data on the chart.

Here is the part of the full code:

$(document).ready(function() { var data = []; $.getJSON("https://api.myjson.com/bins/45rin", function(result) { for (var i = 0; i <= result.dataPoints.length - 1; i++) { data.push({ labels:result.dataPoints[i].label, datasets:({

    data: parseInt(result.dataPoints[i].y)
  })
})}

var ctxL = document.getElementById("BBBB").getContext('2d'); var myLineChart = new Chart(ctxL, { type: 'line', data: data

});

myLineChart.update();


Magdalena Dembna staff commented 5 years ago

Hi, can you create a code snippet here: https://mdbootstrap.com/snippets/? It would be much easier to reproduce your case and find a solution.


Klaudia free commented 5 years ago

https://mdbootstrap.com/snippets/jquery/garncarczyk/1267102 - here is the link

id= chartContainer - it is an example which I found (It works in CHROME on my comp) id=lineChartA1 - mdbootsrap chart id=BBBB - mdbootrap chart into which I would like to upload the data from json


Magdalena Dembna staff commented 5 years ago

I have created a code snippet with the call to your API: https://mdbootstrap.com/snippets/jquery/m-dembna/1275976#js-tab-view


Klaudia free commented 5 years ago

Thank you very much! That is exactly what I was looking for :)



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: DELL
  • Browser: CHROME
  • OS: Windows 7
  • Provided sample code: No
  • Provided link: Yes