Link to home
Start Free TrialLog in
Avatar of andybrooke
andybrooke

asked on

Flot chart powered by mysql database

Hi,

I have a flot chart page that is working fine with static values. But I want this to be driven from mysql, so its up to date. This is where I'm stuck on how to get the data to link to the charts.

I'm using framework fuel php, php 5.3, mysql 5.5. I will be having multiple graphs on the page and at present I have a $data array that currently brings back 2 different query results. So I have $results and $results2.

My first graph needs to take values from $results. I've looked for example online but don't seem to be getting anywhere.

Does anyone have a guide for this I could follow? Currently PHP file with the flot is below, I would also want my xaxis to be driven from the database as well.

Thanks
<script>

$(function () {
    var css_id = "#placeholder";
    var data = [
        {label: 'Calls', data: [[1,300], [2,300], [3,300], [4,300], [5,300]]},
        {label: 'Minutes', data: [[1,800], [2,600], [3,400], [4,200], [5,0]]},
    ];
    var options = {
        series: {
                 lines: {show: true, steps: false },},
                // bars: {show: true, barWidth: 0.9, align: 'center',},},
        xaxis: {ticks: [[1,'Monday'], [2,'Tuesday'], [3,'Wednesday'], [4,'Thursday'], [5,'Friday']]},
        points: {  
        show: true,  
        radius: 4  
    }  
    };

    $.plot($(css_id), data, options);
});
</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of StealthyDev
StealthyDev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial