Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

OpenFlashCharts - multiple charts

Options
  • 15-04-2010 3:47pm
    #1
    Registered Users Posts: 7


    Hi, can anybody point me the right direction for a tutioral or perhaps code on multiple charts displaying on a web page.
    At present i have one chart working fine, ive being following the tutorial on the OpenFlashCharts website for the multiple charts, but it wont work for me.. please help...


Comments

  • Registered Users Posts: 1,821 ✭✭✭Skud


    post the code and someone will look at it


  • Registered Users Posts: 7 ger_curran


    <?php

    include_once '/Libraries/PHP/OpenFlashChart/php-ofc-library/open-flash-chart.php';
    $title = new title( date("D M d Y") );

    $bar = new bar();
    $bar->set_values( array(9,8,7,6,5,4,3,2,1) );
    $bar->set_colour( '#94D700' );

    $chart_1 = new open_flash_chart();
    $chart_1->set_title( $title );
    $chart_1->add_element( $bar );
    //
    //
    $data_1 = $chart_1->toPrettyString();
    //
    //

    //
    // CHART 2
    //
    // generate some random data
    srand((double)microtime()*1000000);

    $tmp = array();
    for( $i=0; $i<9; $i++ )
    $tmp[] = rand(1,10);

    $bar_2 = new bar();
    $bar_2->set_values( $tmp );

    $chart_2 = new open_flash_chart();
    $chart_2->set_title( new title( "Chart 2 :-)" ) );
    $chart_2->add_element( $bar_2 );
    //
    //
    $data_2 = $chart_2->toPrettyString();
    ?>
    <html>
    <head>

    <script type="text/javascript" src="js/json/json2.js"></script>
    <script type="text/javascript" src="js/swfobject.js"></script>
    <script type="text/javascript">

    /*

    don't forget to include the JSON JS library :-) ^^

    */

    swfobject.embedSWF(
    "open-flash-chart.swf", "div_chart_1",
    "300", "300", "9.0.0", "expressInstall.swf",
    {"get-data":"get_data_1"} );

    swfobject.embedSWF(
    "open-flash-chart.swf", "div_chart_2",
    "450", "300", "9.0.0", "expressInstall.swf",
    {"get-data":"get_data_2"} );


    function ofc_ready()
    {
    // alert('ofc_ready');
    }


    function get_data_1()
    {
    // alert( 'reading data 1' );
    return JSON.stringify(data_1);
    }

    function get_data_2()
    {
    // alert( 'reading data 2' );
    // alert(JSON.stringify(data_2));
    return JSON.stringify(data_2);
    }

    var data_1 = $data_1;

    //
    // to help debug:
    //
    // alert(JSON.stringify(data_1));

    var data_2 = $data_2;

    </script>
    </body>
    </html>

    <div id="div_chart_1"></div>
    <div id="div_chart_2"></div>


    Granted this is the sample code from the openflashchart website.. Once I get this working I can work my own data into it.. At the moment with I run this, the following error comes up ;

    Open Flash Chart
    IO ERROR
    Loading test data
    Error #2032

    This is the URL that I tried to open:../../data-files/y-axis-auto-st

    Open Flash Chart
    IO ERROR
    Loading test data
    Error #2032

    This is the URL that I tried to open:../../data-files/y-axis-auto-steps.txt

    Ive trying to get this working for a couple of days now with no joy.. Thanks for the reply, help will be extremely appreciated..


  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    ger_curran wrote: »
    This is the URL that I tried to open:../../data-files/y-axis-auto-steps.txt
    Is this directory outside the web space area (outside DOCUMENT_ROOT)?
    If so, it might be blocked by php's security settings.
    Try putting the file beside the php script to see if it works.


  • Registered Users Posts: 7 ger_curran


    Thanks for the reply, i might have misunderstood your advice, but what i did was copy the y-axis-auto-steps.txt into my htdocs folder (where my php file is located). Two graphs appeared but there were the same graph and not the graph that i coded.. It appears to have graphed a default one.. Have u ever come across that before??

    Thanks


  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    ger_curran wrote: »
    Thanks for the reply, i might have misunderstood your advice, but what i did was copy the y-axis-auto-steps.txt into my htdocs folder (where my php file is located). Two graphs appeared but there were the same graph and not the graph that i coded.. It appears to have graphed a default one.
    Yup, that is what I meant. It does sound like some progress.
    I don't know OpenFlashCharts at all so I only have general debugging strategies.

    Do you have any example code you could try? If that works then it might imply that your data file is corrupt.


  • Advertisement
Advertisement