having problem in displaying flash data-line chart with database contents

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bandy
    New Member
    • Mar 2010
    • 25

    having problem in displaying flash data-line chart with database contents

    HI there,
    Need Help...

    This is data file's result:
    Code:
    { "elements": [ { "type": "line", "values": [ 107, 107, 121, 107, 109, 107, 121, 108, 108, 107, 120, 120, 120, 107 ], "dot-style": { "type": "dot", "tip": "#val#", "dot-size": 5, "colour": "#DFC329" }, "width": 2, "colour": "0x9933CC", "tip": "#Hello#", "text": "DisHonest Follower", "font-size": 10 }, { "type": "line", "values": [ 9, 9, 0, 9, 8, 9, 0, 8, 8, 8, 0, 0, 0, 8 ], "dot-style": { "type": "star", "dot-size": 5 }, "width": 2, "colour": "0xCC3399", "text": "ActiveHonest Follower", "font-size": 10 }, { "type": "line", "values": [ 5, 5, 0, 5, 4, 5, 0, 5, 5, 5, 0, 0, 0, 5 ], "width": 2, "colour": "0x80a033", "text": "InactiveHonest Follower", "font-size": 10 } ], "bg_colour": "#FFFFFF", "x_axis": { "steps": 86400, "labels": { "text": "#date: jS, M Y#", "steps": 86400, "visible-steps": 1, "rotate": 60 } }, "y_axis": { "min": 0, "max": 400, "steps": 50 } }
    This is the code for it:
    Code:
    { //these arrays are declared above
    
    	$data_1[] = intval($disf[$i]);
    	$data_2[] = intval($af[$i]);
    	$data_3[] = intval($inf[$i]);
            $data_4[] = $logindate[$i];
    	
    }
    
    //***** Purple line
    
    $default_dot = new dot();
    //$default_dot->tooltip('#x_label#<br>#val#');
    $default_dot->tooltip('#val#');
    $default_dot->size(5)->colour('#DFC329');
    $line_dot = new line();
    $line_dot->set_default_dot_style($default_dot);
    $line_dot->set_width( 2 );
    $line_dot->set_colour( '0x9933CC' );
    $line_dot->set_values( $data_1 );
    $line_dot->set_tooltip('#Hello#');
    $line_dot->set_key( "DisHonest Follower", 10 );
    
    //***** Pink line 
    
    $default_hollow_dot = new hollow_dot();
    $default_hollow_dot->tooltip('#x_label#<br>#val#');
    $default_hollow_dot->size(5)->colour('#6363AC');
    
    $line_hollow = new line();
    $line_hollow->set_default_dot_style($default_hollow_dot);
    $line_hollow->set_width( 2 );
    $line_hollow->set_colour( '0xCC3399' );
    $line_hollow->set_values( $data_2 );
    $line_hollow->set_key( "ActiveHonest Follower", 10 );
    
    //***** Green line
    
    $star = new star();
    $star->size(5);
    //$star->set_tooltip("#x_label#<br>#val#");
    $line = new line();
    $line_hollow->set_default_dot_style($star);
    $line->set_width( 2 );
    $line->set_colour( '0x80a033' );
    $line->set_values( $data_3 );
    $line->set_key( "InactiveHonest Follower", 10 );
    
    //*****create an X Axis object setting X-axis labels
    $x = new x_axis();
    // grid line and tick every 10 show ticks and grid lines for every day:
    // grid line and tick every 10
    
    $x->set_range(
        mktime(0, 0, 0, 6, 1, date('Y')),    // <-- min 
        mktime(0, 0, 0, 6, 16, date('Y'))    // <-- max 
        );   
    $x->set_steps(86400);
    
    $labels = new x_axis_labels();
    
    $labels->text('#date: jS, M Y#');                      // tell the labels to render the number as a date:
    $labels->set_steps(86400);                             // setting each day as a step
    $labels->visible_steps(1);							  // only display every other label (every other day)
    //$labels->set_size(20);
    $labels->rotate(60); 
    //$labels->set_labels($data_4);                      // setting date array as label
    
    $x->set_labels($labels);							// finally attach the label definition to the x axis  
    
    //*****setting Y-axis labels
    
    
    $y = new y_axis();
    $y->set_range( 0, 400, 50); // Y-axis points to set
    $colour = '#FFFFFF';
    $chart_1 = new open_flash_chart();	               // creating open flash chart object
    //$chart_1->set_title( new title( $uname ) );        // setting title
    $chart_1->set_bg_colour( $colour );
    $chart_1->set_x_axis( $x );
    $chart_1->set_y_axis( $y );
    
    // here we add our data sets to the chart:
    $chart_1->add_element( $line_dot );
    $chart_1->add_element( $line_hollow );
    $chart_1->add_element( $line );
    
     echo $chart_1->toPrettyString();
    Here in chart i am getting all values on y-axis only.
    Lines are not getting displayed

    Can you help please??
  • kurdong

    #2
    1st-time poster

    The x-value of your data should correspond to the x_axis values set by
    Code:
    $x->set_range(
        mktime(0, 0, 0, 6, 1, date('Y')),    // <-- min
        mktime(0, 0, 0, 6, 16, date('Y'))    // <-- max
        );
    $x->set_steps(86400);
    You should consider revising how your data values are declared:
    Code:
    for($i = 0; $i < ARRAY_VALUE_COUNT; $i++) { //these arrays are declared above
        $x = mktime(0, 0, 0, 6, ($i + 1), date('Y'));
        $data_1[] = new scatter_value($x, intval($disf[$i]));
        $data_2[] = new scatter_value($x, intval($af[$i]));
        $data_3[] = new scatter_value($x, intval($inf[$i]));
        $data_4[] = $logindate[$i];
    }

    Comment

    Working...