Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have just downloaded a Bootstrap Template from internet, there is a chart control with static data's
.html Page

C#
<div class="panel-body">
<div id="morris-area-chart"></div>
</div>



.js Page
JavaScript
$(function() {

    Morris.Area({
        element: 'morris-area-chart',
        data: [{
            period: '2010 Q1',
            iphone: 2666,
            ipad: null,
            itouch: 2647
        }, {
            period: '2010 Q2',
            iphone: 2778,
            ipad: 2294,
            itouch: 2441
        }, {
            period: '2010 Q3',
            iphone: 4912,
            ipad: 1969,
            itouch: 2501
        }, {
            period: '2010 Q4',
            iphone: 3767,
            ipad: 3597,
            itouch: 5689
        }, {
            period: '2011 Q1',
            iphone: 6810,
            ipad: 1914,
            itouch: 2293
        }, {
            period: '2011 Q2',
            iphone: 5670,
            ipad: 4293,
            itouch: 1881
        }, {
            period: '2011 Q3',
            iphone: 4820,
            ipad: 3795,
            itouch: 1588
        }, {
            period: '2011 Q4',
            iphone: 15073,
            ipad: 5967,
            itouch: 5175
        }, {
            period: '2012 Q1',
            iphone: 10687,
            ipad: 4460,
            itouch: 2028
        }, {
            period: '2012 Q2',
            iphone: 8432,
            ipad: 5713,
            itouch: 1791
        }],
        xkey: 'period',
        ykeys: ['iphone', 'ipad', 'itouch'],
        labels: ['iPhone', 'iPad', 'iPod Touch'],
        pointSize: 2,
        hideHover: 'auto',
        resize: true
    });

}


Here , Instead of static data i have to fetch data from sql table , any help is highly appreciated.
Thanks
Posted
Updated 11-May-18 23:33pm
v3
Comments
Thanks7872 7-Jul-15 6:49am    
Make a ajax request,get data from db in required format and pass it to 'data'. What is the issue?

See this : http://stackoverflow.com/a/16105057

1 solution

function Onsuccess(response) {
var str1 = JSON.parse(response.d);
Morris.Area({
element: 'morris-area-chart',
data:str1,

xkey: ['year'],
ykeys: ['sales','value'],
labels: ['value'],
pointSize: 3,
fillOpacity: 0,
pointStrokeColors: ['#55ce63', '#009efb', '#2f3d4a'],
behaveLikeLine: true,
gridLineColor: '#e0e0e0',
lineWidth: 3,
hideHover: 'auto',
lineColors: ['#55ce63', '#009efb', '#2f3d4a'],
resize: true
});
}
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900