Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

can't shown value in line chart

Anonymous
2010-09-30
2013-05-28

  • Anonymous
    2010-09-30

    Hi all ,
    I want to retrieve data from mysql  and using these to produce JSON , but when I show in browser , the line char only shown $data_1 and $data_2 ,
    But can't shown $data_3 , anyone knows what's happen ?
    Let me know if you need any help , please !

    <?php
    include "open-flash-chart.php";
            $link = mysql_connect("Server_IP", "id", "pwd") or die("Could not connect : " . mysql_error());
            mysql_select_db("db_name") or die("Could not select database");  

            $sql = "select value  from result  where id1 =1 and id2 = 2  limit 10";
           
            $result = mysql_query($sql);
                    if (!$result) {
                die("Query to show fields from table failed");
                    }
                    $result_num = mysql_num_rows($result);
                   
    $data_1 = array();
    $data_2 = array();
    $data_3 = array();
    while ($row = mysql_fetch_array($result))
    {
           
            $t = $row;
           
            $data_1 = 50;
          $data_2 = 80;
            $data_3 = $t;
    }

    $title = new title( date("D M d Y") );
    $line_1_default_dot = new dot();
    $line_1_default_dot->colour('#f00000');
    $line_1 = new line();
    $line_1->set_default_dot_style($line_1_default_dot);
    $line_1->set_values( $data_1 );
    $line_1->set_width( 1 );
    // ----- LINE 2 ---
    $line_2_default_dot = new dot();
    $line_2_default_dot->size(3)->halo_size(1)->colour('#3D5C56');
    $line_2 = new line();
    $line_2->set_default_dot_style($line_2_default_dot);
    $line_2->set_values( $data_2 );
    $line_2->set_width( 2 );
    $line_2->set_colour( '#3D5C56' );
    // ----- LINE 2 ---
    $line_3_default_dot = new dot();
    $line_3_default_dot->size(4)->halo_size(2);
    $line_3 = new line();
    $line_3->set_default_dot_style($line_3_default_dot);
    $line_3->set_values( $data_3 );
    $line_3->set_width( 6 );
    $y = new y_axis();
    $y->set_range( 0, 120, 10 );
    $chart = new open_flash_chart();
    $chart->set_title( $title );
    $chart->add_element( $line_1 );
    $chart->add_element( $line_2 );
    $chart->add_element( $line_3 );
    $chart->set_y_axis( $y );
    mysql_close($link);
    echo $chart->toPrettyString();
    ?>

    Cheers,
    Stefan