sdInteractiveChartPlugin as a stand-alone PHP Library

As promised a few times now I have finally got round to modifying the code slightly to remove any Symfony dependencies (Although there might still be some).

This download has been created using version 0.5.0 of the Symfony plugin. An example PHP page “example.php” has been added under the web directory to show the required JS scripts and a quick example of creating a chart using it. More details can be found here: http://www.symfony-project.org/plugins/sdInteractiveChartPlugin

Downloads:

sdInteractiveChart.zip

sdInteractiveChart.tar.gz

  • Chris Li

    I downloaded your sdInteractiveChartPlug for Symfony, I but I don’t know how to use it. I looked at your source codes and think your sample code should place at template file but it did not show anything at my page; If I put sample code at action file, how can I access and display the object? Thanks for your help.

    • Seb Dangerfield

      Yes the sample code provided can be copied and pasted straight into a template file and it will work. Make sure that your page is loading in jQuery 1.4+ and the sdInteractiveChartPlugin js file is been loaded in to. To use the sample code in your action class simply add the following lines to your appropriate execute function inside your action class:

      sfContext::getInstance()->getConfiguration()->loadHelpers('sdInteractiveChart');
       
            $chart = InteractiveChart::newAreaChart();
            $chart->setWidthAndHeight('400', '240');
            $chart->setDataColors(array('#220000'));
            $chart->setBaselineColor('#ccc');
            $chart->inlineGraph(array('hits' => array(1,9,5)), array('Monday', 'Tuesday', 'Wednesday'), 'chart_div');
       
            $this->chart1 = $chart;

      And then add the following to your template:

      <?php
      $chart1->render();
      ?>
      <div id="chart_div"></div>

      If no chart is appearing check the html source of the page to make sure the inline javascript to define the chart is present and then make sure no javascript errors are occurring.