/** * @param DataSet $dataSet * @return ColumnLine */ public function addLine(DataSet $dataSet) { $dataSet->setAttribute('parentyaxis', 'S'); $dataSet->setAttribute('renderas', 'Line'); $this->lines[] = $dataSet->getXML(); return $this; }
/** * @param DataSet $dataSet * @return Plot */ public function addPlots(DataSet $dataSet) { $this->plots[] = $dataSet->getXML(); return $this; }
<?php use FusionCharts\Chart\ColumnLine; use FusionCharts\Tag\Categories; use FusionCharts\Tag\Category; use FusionCharts\Tag\DataSet as Columns; use FusionCharts\Tag\Set as Column; // Data from db $months = array('Jan', 'Feb', 'Mar', 'Apr'); $values = array(100, 200, 150, 210); $chart = new ColumnLine('chart-container'); $categories = new Categories(); foreach ($months as $month) { $category = new Category($month); $categories->addCategory($category); } $columns = new Columns(); foreach ($values as $value) { $column = new Column($value); $columns->addSet($column); } $chart->setName('Chart Columns Example')->setWidth(800)->setHeight(400)->setLabelRotate(true)->setXdescription('x values')->setYdescription('y values')->setAttribute('showyaxisvalues', '0')->addCategories($categories)->addColumns($columns); // render chart in the index.php
/** * @param DataSet $dataSet * @return Line */ public function addLine(DataSet $dataSet) { $this->lines[] = $dataSet->getXML(); return $this; }
<?php use FusionCharts\Chart\Plot; use FusionCharts\Tag\Categories; use FusionCharts\Tag\Category; use FusionCharts\Tag\DataSet; use FusionCharts\Tag\Set; // Data from db $months = array('Jan', 'Feb', 'Mar', 'Apr'); $xValues = array(100, 200, 300, 400); $yValues = array(150, 120, 200, 220); $chart = new Plot('chart-container'); $categories = new Categories(); foreach ($months as $index => $month) { $category = new Category(); $category->setAttribute('label', $month)->setAttribute('x', $xValues[$index])->setAttribute('showVerticalLine', '1'); $categories->addCategory($category); } $plots = new DataSet(); $plots->setAttribute('color', '000080')->setAttribute('anchorbgcolor', '000080')->setAttribute('anchorradius', '4')->setAttribute('anchorsides', '4'); foreach ($yValues as $index => $value) { $plot = new Set(); $plot->setAttribute('y', $value)->setAttribute('x', $xValues[$index]); $plots->addSet($plot); } $chart->setName('Chart Plot Example')->setWidth(800)->setHeight(400)->setLabelRotate(true)->setXdescription('x values')->setYdescription('y values')->setAttribute('showyaxisvalues', '0')->addCategories($categories)->addPlots($plots); // render chart in the index.php
use FusionCharts\Tag\Categories; use FusionCharts\Tag\Category; use FusionCharts\Tag\DataSet; use FusionCharts\Tag\Set; use FusionCharts\Tag\Line; use FusionCharts\Tag\TrendLines; // Data from db $months = array('Jan', 'Feb', 'Mar', 'Apr'); $valLine1 = array(100, 200, 150, 210); $valLine2 = array(50, 300, 90, 400); $chart = new LineChart('chart-container'); $categories = new Categories(); foreach ($months as $month) { $categories->addCategory(new Category($month)); } $line1 = new DataSet(); foreach ($valLine1 as $value) { $line1->addSet(new Set($value)); } $line2 = new DataSet(); foreach ($valLine2 as $value) { $line2->addSet(new Set($value)); } $trendLine1 = new Line(); $trendLine1->setValue(250)->setColor('FF0000')->setDisplayValue('Trendline1 Example: 250')->setValueOnRight(); $trendLine2 = clone $trendLine1; $trendLine2->setValue(390)->setDisplayValue('Trendline2 Example: 390'); $trendLines = new TrendLines(); $trendLines->addLine($trendLine1)->addLine($trendLine2); $chart->setName('Line Chart Example')->setWidth(800)->setHeight(400)->setAttribute('showvalues', '0')->setLabelRotate(true)->addCategories($categories)->addLine($line1)->addLine($line2)->addTrendLines($trendLines); // render chart in the index.php