Solved

Flot chart powered by mysql database

Posted on 2012-12-24
1
3,661 Views
Last Modified: 2013-02-08
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

0
Comment
Question by:andybrooke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
StealthyDev earned 500 total points
ID: 38719708
Hi,

You can create a JSON, array for xaxis and dynamically populate it in PHP and assign to the attribute.

Have a look at the below thread.

http://stackoverflow.com/questions/1312302/retrieve-data-from-mysql-by-php-to-create-flot-graph#1312446

Thanks,
Senthur
0

Featured Post

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question