0

How I can connect my chart to database?

My chart source is:

var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
  type: 'bar',
  data: {
    labels: ['agency1', 'agency2', 'agency3', 'agency4', 'agency5', 'agency6', 'agency7'],
    datasets: [{
      label: 'all sell',
      data: [1200, 1900, 300, 1700, 600, 300, 700],
      backgroundColor: "rgba(53,24,51,0.6)"
    }, {
      label: 'count ticket',
      data: [200, 290, 500, 50, 200, 300, 1000],
      backgroundColor: "rgba(255,53,0,0.6)"
    }]
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.min.js"></script>
<div class="container">
  <canvas id="myChart"></canvas>
</div>

So, I have customer_table, for every agency I have sum(countticket) & sum(Epayprice) for tickets.

Now how I can load my data from customer_table?

Please, guide me.

Dale K
  • 25,246
  • 15
  • 42
  • 71
iAm.Hassan
  • 53
  • 1
  • 10
  • 1
    You can check this [link](https://stackoverflow.com/questions/10540217/passing-variable-from-asp-net-to-javascript) for reference, then create your values from your aspx.cs – Anjo Apr 12 '18 at 15:45

1 Answers1

-1

you can use a web method to send data to client side: https://www.codeproject.com/Tips/1259126/Visual-Data-using-Chart-js-in-ASP-NET

Zolfaghari
  • 1,259
  • 1
  • 15
  • 14