Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
Use Ajax Json Data to Chart

I have ajax response like this

{
  "status": "success",
  "data": [
    {
      "DAY": "11",
      "SIGNUPS": 0,
      "VISITS": "0"
    },
    {
      "DAY": "12",
      "SIGNUPS": 3,
      "VISITS": "13"
    }
  ]
}

I want use this data to my chart which have static data like this

var chartDom1 = document.getElementById('traffic_chart');
            var myChart1 = echarts.init(chartDom1);
            var option1;
            
            option1 = {
              title: {
                text: 'Stacked Line',
                show: false
              },
              tooltip: {
                trigger: 'axis'
              },
              legend: {
                data: ['Visits', 'Signups'],
                show:false
              },
              grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
              },
              toolbox: {
                feature: {
                  saveAsImage: {}
                }
              },
              xAxis: {
                type: 'Day',
                boundaryGap: false,
                data: [1,2]
              },
              yAxis: {
                type: 'value'
              },
              series: [
                {
                  name: 'Visits',
                  type: 'line',
                  stack: 'Total',
                  data: [150, 232]
                },
                {
                  name: 'Signups',
                  type: 'line',
                  stack: 'Total',
                  data: [150, 232]
                }
              ]
            };
            
            option1 && myChart1.setOption(option1);

I want use DAY Column in xAxis data and SIGNUPS and VISITS Column in Series, I have tried lot but not able to find proper way to do it. Sorry I am beginner and have not proper knowledge of JavaScript.

Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want to pass the Day data as an array to xAxis data you should make an array like this:

let array = [];
for (const i in response.data) {
   array.push(response.data[i].DAY);
}

after this your array is like this:

[11, 12]

and now you can pass it to your xAxis object ...

and also you can use this method for SIGNUPS and VISITS too.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda