akhibam

Load FusionCharts in JSP from MySQL

Recommended Posts

Hi, before this Im working with flot.js with PHP and MYSQL.

Currently im working on JSP with FusionCharts. I want to load 10 latest data(this is done in query) from MySQL and load it in FusionCharts Line Chart. Question is how to do this? Really blank right now.

This is how I take data from MySQL in PHP :

 

 

iNxyr3m.jpg

 

PHP

 <?php
	$dataGlucose = array();
	$ctrGlucose = 0;
	while ($rowGlucose = mysql_fetch_array($resultGlucose, MYSQL_ASSOC)){
	    $dataGlucose[] = array( $ctrGlucose, $rowGlucose['glucose'] );
	    $ctrGlucose++;
	}
?>

Javascript (Flot.js)

$(function() {

    var d1 = <?php echo json_encode($dataSys); ?>;

    var d2 = <?php echo json_encode($dataDias); ?>;

    var stack = 0,
    bars = false,
    lines = true,
    steps = false;

    function plotWithOptions() {
            $.plot("#graphBlood", [ d1, d2], {
                    series: {
                            stack: stack,
                            lines: {
                                    show: lines,
                                    fill: true,
                                    steps: steps
                            },
                            bars: {
                                    show: bars,
                                    barWidth: 0.5
                            }
                    },
                    colors: ["#4BB74C", "#840000"],
            });
    }
    
    plotWithOptions();
    
    });

Hope the pros here can help me. Thanks a lot :)

Edited by akhibam

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now