Advertisement
ADL_Rodrigo_Silva

Untitled

May 30th, 2022
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. $(document).ready( function() {
  3.  
  4.     var datosPokemon = [];
  5.     var options = {
  6.         animationEnabled: true,
  7.         theme: "light2",
  8.         title: {
  9.             text: "Valor del Dolor el último mes"
  10.         },
  11.         axisX: {
  12.             title: "Nombre de la Versión",
  13.         },
  14.         axisY: {
  15.             title: "Game Index",
  16.             titleFontSize: 24,
  17.         },
  18.         data: [{
  19.             type: "column", //change it to line, area, bar, pie, etc
  20.             legendText: "Try Resizing with the handle to the bottom right",
  21.             showInLegend: true,
  22.             dataPoints: datosPokemon
  23.         }]
  24.     };
  25.     $.ajax({
  26.         type: "GET",
  27.         url: "https://pokeapi.co/api/v2/pokemon/ditto",
  28.         dataType: "json",
  29.         success: function(datos) {
  30.             //console.log(datos);
  31.             let datosAPI = datos.game_indices;
  32.  
  33.             for (var iterador=0;iterador<datosAPI.length;iterador++){
  34.                 datosPokemon.push({
  35.                     label: datosAPI[iterador].version.name,
  36.                     y: datosAPI[iterador].game_index,
  37.                 });
  38.             }
  39.             console.log(datosPokemon);
  40.             $("#contenedor").CanvasJSChart(options);
  41.         }
  42.     });
  43.  
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement