How i Can Bound Chart.js to My Table Database

Last Reply 11 days ago By Mudassar

Posted 11 days ago

Hi Friends

i'm using Chart Bar in my page (Chart.js) such as below :

<html xmlns="">
<head runat="server">
    <title>DataBase Chart</title>
    <script src=""></script>
    <div class="container" style="width:50%;height:500px;">
        <canvas id="myChart"></canvas>

    var ctx = document.getElementById('myChart').getContext('2d');
    var myChart = new Chart(ctx, {
        type: 'bar',
        data: {
            labels: ['user1', 'user2', 'user3', 'user4', 'user5', 'user6', 'user7'],
            datasets: [{
                label: 'Sum(Countticket)',
                data: [12, 19, 3, 17, 6, 3, 7],
                backgroundColor: "rgba(153,255,51,0.6)"
            }, {
                label: 'Sum(Priceticket)',
                data: [2, 29, 5, 5, 2, 3, 10],
                backgroundColor: "rgba(255,153,0,0.6)"

my table in datase is this :


CREATE TABLE [Customers](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[codecenter] [int] NULL,
	[usercode] [int] NULL,
	[codeprogram] [int] NULL,
	[dateservice] [nvarchar](50) NULL,
	[sans] [nvarchar](50) NULL,
	[countticket] [int] NULL,
	[description] [ntext] NULL,
	[priceticket] [bigint] NULL

now i want show sum(countticket) & sum(priceticket) for every usercode in my chart.

please Guide me i need that

thanks alot

You are viewing reply posted by: Mudassar 11 days ago.
Posted 11 days ago

We can give reference article and you have to code.

If you are stuck in code you can share and and we can correct.

But we cannot write code as per your Database table.


I agree, here is the link: