<?php require '../../lib/BarChart.php'; ?> <h2>No autoscaling</h2> <?php $values1 = array(-10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110); $values2 = array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130); $chart = new BarChart('bvg', 500, 200); $chart->setDataFormat(Chart::TEXT); $chart->setAutoscale(Chart::AUTOSCALE_OFF); $data1 = new ChartData($values1); $data1->setAutoscale(false); $chart->addData($data1); $data2 = new ChartData($values2); $data2->setColor('336699'); $data2->setAutoscale(false); $chart->addData($data2); $y_axis = new ChartAxis('y'); $chart->addAxis($y_axis); echo $chart->toHtml(); var_dump($chart->getQuery()); ?> <h2>Chart-wide manual scaling (text encoding)</h2> <?php $chart->setScale(-10, 130); echo $chart->toHtml(); var_dump($chart->getQuery()); ?>
<?php require '../../lib/BarChart.php'; ?> <h2>Chart autoscaling by values (text encoding)</h2> <?php $values1 = array(-10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110); $values2 = array(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130); $chart = new BarChart('bvg', 500, 200); $chart->setDataFormat(Chart::TEXT); $chart->setAutoscale(Chart::AUTOSCALE_VALUES); $data = new ChartData($values1); $chart->addData($data); $data = new ChartData($values2); $data->setColor('336699'); $chart->addData($data); $y_axis = new ChartAxis('y'); $chart->addAxis($y_axis); echo $chart->toHtml(); var_dump($chart->getQuery()); ?> <h2>Chart autoscaling by values (simple encoding)</h2> <?php $chart->setDataFormat(Chart::SIMPLE_ENCODING); echo $chart->toHtml(); var_dump($chart->getQuery());
* User: martinmatak * Date: 06/03/16 * Time: 18:25 */ namespace graph_library; require_once '../Autoloader.php'; header('Content-Type:image/png'); $platno = new Canvas(); $podaci = new DataCollection(); $barchart = new BarChart('Cijena dionica', 295, 500); $legend = new Legend(); $legend->addItem(new LegendItem('Relativni odnos dionica zadnjih 5 godina')); $podaci->addItems(array(new DataCollectionItem([2011, 10]), new DataCollectionItem([2012, 15]), new DataCollectionItem([2013, 8]), new DataCollectionItem([2014, 19]), new DataCollectionItem([2015, 22]))); $barchart->setLegend($legend, 10, 25); $barchart->colorData(16, 80, 57, $barchart->addData($podaci)); $platno->addChart($barchart, 30, 305); $lineChart = new LineChart('Cijena dionica', 300, 300); $lineChart->setLegend($legend, 10, 30); $lineChart->colorData(16, 80, 57, $lineChart->addData($podaci)); $platno->addChart($lineChart, 2, 0); // pie chart $pieChart = new PieChart('naslov pie charta', 300, 300); $legend = new Legend(); $legend->addItem(new LegendItem('1. item legende')); $legend->addItem(new LegendItem('2. item legende')); $podatak = new DataCollection(); $podatak->addItem(new DataCollectionItem([5])); $id_podataka = $pieChart->addData($podatak); $pieChart->colorData(56, 80, 57, $id_podataka); $podatak = new DataCollection();
<?php /** * Created by PhpStorm. * User: martinmatak * Date: 06/03/16 * Time: 17:50 */ namespace graph_library; require_once '../Autoloader.php'; header('Content-Type:image/png'); $platno = new Canvas(); $podaci = new DataCollection(); $line_chart = new BarChart('Cijena dionica', 300, 300); $legend = new Legend(); $legend->addItem(new LegendItem('Relativni odnos dionica zadnjih 5 godina')); $podaci->addItems(array(new DataCollectionItem([10, '2011']), new DataCollectionItem([15, '2012']), new DataCollectionItem([8, '2013']), new DataCollectionItem([19, '2014']), new DataCollectionItem([22, '2015']))); $line_chart->setLegend($legend, 10, 25); $id_podataka = $line_chart->addData($podaci); $line_chart->colorData(16, 80, 57, $id_podataka); $platno->addChart($line_chart, 0, 0); $slika = $platno->render(); imagepng($slika); $platno->save('bar.png');