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

492
Views
¿Enlazar conjuntos de datos en chart.js?

¿Cómo agrego ambos conjuntos de datos al gráfico que recorre la matriz? Agregué un conjunto de datos, pero cuando intento agregar un bucle para agregar ambos conjuntos de datos, no puedo entender cómo hacerlo funcionar.

 <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script> <canvas id="myChart" style="width:100%;max-width:700px"></canvas> <script> const datasetValue = [] datasetValue[0] = { data: [860,1140,1060,1060,1070,1110,1330,2210,7830,2478], borderColor: "red", fill: false } datasetValue[1] = { data: [1600,1700,1700,1900,2000,2700,4000,5000,6000,7000], borderColor: "green", fill: false } var xValues = [100,200,300,400,500,600,700,800,900,1000]; new Chart("myChart", { type: "line", data: { labels: xValues, datasets: [{ data: datasetValue[0].data, borderColor: datasetValue[0].borderColor, fill: datasetValue[0].fill }] }, options: { legend: {display: false} } }); </script>
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

simplemente pase la variable datasetValues directamente al campo de conjuntos de datos:

 const datasetValue = [] datasetValue[0] = { data: [860, 1140, 1060, 1060, 1070, 1110, 1330, 2210, 7830, 2478], borderColor: "red", fill: false } datasetValue[1] = { data: [1600, 1700, 1700, 1900, 2000, 2700, 4000, 5000, 6000, 7000], borderColor: "green", fill: false } var xValues = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]; new Chart("myChart", { type: "line", data: { labels: xValues, datasets: datasetValue }, options: { legend: { display: false } } });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script> <canvas id="myChart" style="width:100%;max-width:700px"></canvas>

about 4 years ago · Santiago Trujillo 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!