Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
Use Ajax Json Data para graficar

Tengo una respuesta ajax como esta

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

Quiero usar estos datos en mi gráfico que tiene datos estáticos como este

 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);

Quiero usar la columna DÍA en los datos de xAxis y la columna REGISTROS y VISITAS en la serie, lo he intentado mucho pero no puedo encontrar la forma adecuada de hacerlo. Lo siento, soy principiante y no tengo el conocimiento adecuado de JavaScript.

¡Gracias!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si desea pasar los datos del día como una matriz a los datos de xAxis, debe crear una matriz como esta:

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

después de esto, su matriz es así:

 [11, 12]

y ahora puedes pasarlo a tu objeto xAxis...

y también puede usar este método para SUSCRIPCIONES y VISITAS también.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!