Advertisement
ADL_Rodrigo_Silva

Untitled

May 31st, 2022
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. $(document).ready( function() {
  3.  
  4.     var datosCovid = [];
  5.     var options = {
  6.         animationEnabled: true,
  7.         theme: "light2",
  8.         title: {
  9.             text: "Casos Positivos COVID durante toda la pandemia"
  10.         },
  11.         axisX: {
  12.             title: "Fecha",
  13.             valueFormatString: "YYYY MM DD"
  14.         },
  15.         axisY: {
  16.             title: "Casos Positivos",
  17.             titleFontSize: 24,
  18.         },
  19.         data: [{
  20.             type: "spline", //change it to line, area, bar, pie, etc
  21.             legendText: "Try Resizing with the handle to the bottom right",
  22.             showInLegend: true,
  23.             dataPoints: datosCovid
  24.         }]
  25.     };
  26.     $.ajax({
  27.         type: "GET",
  28.         //url: "https://api.covidtracking.com/v1/us/daily.json",
  29.         url: "http://localhost:3000/covid",
  30.         dataType: "json",
  31.         success: function(datos) {
  32.             console.log(datos);
  33.             let datosAPI = datos;
  34.             console.log(datosAPI);
  35.             for (var iterador=0;iterador<datosAPI.length;iterador++){
  36.  
  37.                 datosCovid.push({
  38.                     x: new Date(datosAPI[iterador].dateChecked),
  39.                     y: datosAPI[iterador].onVentilatorCurrently,
  40.                 });
  41.              
  42.             }
  43.             console.log(datosCovid);
  44.             $("#contenedor").CanvasJSChart(options);
  45.         }
  46.     });
  47.  
  48. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement