Example #1
0
...

<script>
    // This will gather all charts and activate the JS library to convert the provided JSON to a Graph
    <?php echo $chart->getFactory()->getJsPartial(); ?>
</script>
</html>
        </pre>

        <div class="alert alert-info">Take a close look at the last lines. In order to convert all json objects (generated by the libary) to graphs, the correct javascript snipped need to be included within your page.</div>
        <br /><br />

        <h2 id="line-chart">Line chart</h2>
<?php 
try {
    $graph = $chart->add(PHPChart::TYPE_LINE, 'Line', ['width' => '100%', 'height' => 400]);
    $graph->setLine([100, 75, 50, 75, 50, 75, 100], ['label' => 'Series A'])->setLine([90, 65, 40, 65, 40, 65, 150], ['label' => 'Series B'])->setDimensions(['2006', '2007', '2008', '2009', '2010', '2011', '2012']);
    $graph->generate();
    ?>

        <div class="row">
            <div class="col-md-6">

                <?php 
    echo $graph->generate();
    ?>

            </div>
            <div class="col-md-6">
                <pre>
use koenster\PHPGraphs\PHPChart;