public function testRenderOptionsEncoding() { //Check for encoding problems $chart = new Highchart(); $chart->test->utf8String = "áù anything ü"; $chart->test->iso88591 = iconv("UTF-8", "ISO-8859-1", "áù anything ü"); $result = $chart->renderOptions(); $this->assertEquals('{"test":{"utf8String":"\\u00e1\\u00f9 anything \\u00fc","iso88591":"\\u00e1\\u00f9 anything \\u00fc"}}', $result); }
public function approvals($start, $end) { $columns = ['id', 'approved_offline']; $approvals = Approval::whereBetween('created_at', [$start, $end])->get($columns); if ($approvals->isEmpty()) { $json = ['status' => 'error', 'title' => 'Error', 'message' => 'No approvals found in this date range!']; return $json; } $offline = $online = 0; foreach ($approvals as $approval) { if ($approval['approved_offline']) { $offline++; } else { $online++; } } $chart = new Highchart(); $chart->chart->height = "250"; $chart->credits->enabled = false; $chart->title->text = ""; $chart->plotOptions->pie->colors = array("#D4D4D4", "#8DB6CD"); $data[] = array("Offline", $offline); $data[] = array("Online", $online); $chart->series[] = array('type' => "pie", 'name' => "Approvals", 'data' => $data); echo $chart->renderOptions(); }
<?php use Ghunti\HighchartsPHP\Highchart; use Ghunti\HighchartsPHP\HighchartJsExpr; $chart = new Highchart(); $chart->includeExtraScripts(); $chart->chart = array('renderTo' => 'container', 'type' => 'waterfall'); $chart->title->text = 'Highcharts Waterfall'; $chart->xAxis->type = 'category'; $chart->xAxis->title->text = 'USD'; $chart->legend->enabled = false; $chart->tooltip->pointFormat = '<b>${point.y:,.2f}</b> USD'; $chart->series = array(array('upColor' => new HighchartJsExpr('Highcharts.getOptions().colors[2]'), 'color' => new HighchartJsExpr('Highcharts.getOptions().colors[3]'), 'data' => array(array('name' => 'Start', 'y' => 120000), array('name' => 'Product Revenue', 'y' => 569000), array('name' => 'Service Revenue', 'y' => 231000), array('name' => 'Positive Balance', 'isIntermediateSum' => true, 'color' => new HighchartJsExpr('Highcharts.getOptions().colors[1]')), array('name' => 'Fixed Costs', 'y' => -342000), array('name' => 'Variable Costs', 'y' => -233000), array('name' => 'Balance', 'isSum' => true, 'color' => new HighchartJsExpr('Highcharts.getOptions().colors[1]'))), 'dataLabels' => array('enabled' => true, 'formatter' => new HighchartJsExpr("function () {\n return Highcharts.numberFormat(this.y / 1000, 0, ',') + 'k';\n }"), 'style' => array('color' => '#FFFFFF', 'fontWeight' => 'bold', 'textShadow' => '0px 0px 3px black')), 'pointPadding' => 0)); ?> <html> <head> <title>Waterfall</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php $chart->printScripts(); ?> </head> <body> <div id="container"></div> <script type="text/javascript"><?php echo $chart->render("chart1"); ?> </script> </body> </html>
<?php use Ghunti\HighchartsPHP\Highchart; use Ghunti\HighchartsPHP\HighchartJsExpr; $chart = new Highchart(Highchart::HIGHSTOCK); $chart->includeExtraScripts(); $chart->chart->type = 'arearange'; $chart->rangeSelector->selected = 2; $chart->title->text = "Temperature variation by day"; $chart->tooltip->valueSuffix = 'ºC'; $chart->series[] = array('name' => 'Temperatures', 'data' => new HighchartJsExpr('data')); ?> <html> <head> <title>Area range</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php $chart->printScripts(); ?> </head> <body> <div id="container"></div> <script type="text/javascript"> $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=range.json&callback=?', function(data) { $('#container').highcharts('StockChart', <?php echo $chart->renderOptions(); ?> )}); </script> </body>
<?php use Ghunti\HighchartsPHP\Highchart; use Ghunti\HighchartsPHP\HighchartJsExpr; $chart = new Highchart(Highchart::HIGHSTOCK); $chart->chart->renderTo = "container"; $chart->rangeSelector->selected = 2; $chart->title->text = "AAPL Stock Price"; $chart->series[] = array('type' => "ohlc", 'name' => "AAPL Stock Price", 'data' => new HighchartJsExpr("data"), 'dataGrouping' => array('units' => array(array("week", array(1)), array("month", array(1, 2, 3, 4, 6))))); ?> <html> <head> <title>OHLC</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php $chart->printScripts(); ?> </head> <body> <div id="container"></div> <script type="text/javascript"> $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlc.json&callback=?', function(data) { <?php echo $chart->render("chart"); ?> ; }); </script> </body> </html>
$masterChart->yAxis->min = 0.6; $masterChart->yAxis->showFirstLabel = false; $masterChart->tooltip->formatter = new HighchartJsExpr("function() {\n return false; }"); $masterChart->legend->enabled = false; $masterChart->credits->enabled = false; $masterChart->plotOptions->series->fillColor->linearGradient = array(0, 0, 0, 70); $masterChart->plotOptions->series->fillColor->stops[] = array(0, '#4572A7'); $masterChart->plotOptions->series->fillColor->stops[] = array(1, 'rgba(0,0,0,0)'); $masterChart->plotOptions->series->lineWidth = 1; $masterChart->plotOptions->series->marker->enabled = false; $masterChart->plotOptions->series->shadow = false; $masterChart->plotOptions->series->states->hover->lineWidth = 1; $masterChart->plotOptions->series->enableMouseTracking = false; $masterChart->series[] = array('type' => "area", 'name' => "USD to EUR", 'pointInterval' => 24 * 3600 * 1000, 'pointStart' => new HighchartJsExpr("Date.UTC(2006, 0, 01)"), 'data' => new HighchartJsExpr("data")); $masterChart->exporting->enabled = false; $detailChart = new Highchart(); $detailChart->chart->marginBottom = 120; $detailChart->chart->renderTo = "detail-container"; $detailChart->chart->reflow = false; $detailChart->chart->marginLeft = 50; $detailChart->chart->marginRight = 20; $detailChart->chart->style->position = "absolute"; $detailChart->credits->enabled = false; $detailChart->title->text = "Historical USD to EUR Exchange Rate"; $detailChart->subtitle->text = "Select an area by dragging across the lower chart"; $detailChart->xAxis->type = "datetime"; $detailChart->yAxis->title->text = null; $detailChart->yAxis->maxZoom = 0.1; $detailChart->tooltip->formatter = new HighchartJsExpr("function() {\n var point = this.points[0];\n return '<b>'+ point.series.name +'</b><br/>'+\n Highcharts.dateFormat('%A %B %e %Y', this.x) + ':<br/>'+\n '1 USD = '+ Highcharts.numberFormat(point.y, 2) +' EUR';\n }"); $detailChart->tooltip->shared = 1; $detailChart->legend->enabled = false;
<?php use Ghunti\HighchartsPHP\Highchart; use Ghunti\HighchartsPHP\HighchartJsExpr; use Ghunti\HighchartsPHP\HighchartOption; $chart = new Highchart(); $chart->chart->renderTo = 'container'; $chart->title->text = 'Daily visits at www.highcharts.com'; $chart->subtitle->text = 'Source: Google Analytics'; $chart->xAxis->type = 'datetime'; $chart->xAxis->tickInterval = 7 * 24 * 3600 * 1000; $chart->xAxis->tickWidth = 0; $chart->xAxis->gridLineWidth = 1; $chart->xAxis->labels->align = 'left'; $chart->xAxis->labels->x = 3; $chart->xAxis->labels->y = -3; $leftYaxis = new HighchartOption(); $leftYaxis->title->text = null; $leftYaxis->labels->align = 'left'; $leftYaxis->labels->x = 3; $leftYaxis->labels->y = 16; $leftYaxis->labels->formatter = new HighchartJsExpr("function() { return Highcharts.numberFormat(this.value, 0);}"); $leftYaxis->showFirstLabel = false; $chart->yAxis[] = $leftYaxis; $rightYaxis = new HighchartOption(); $rightYaxis->linkedTo = 0; $rightYaxis->gridLineWidth = 0; $rightYaxis->opposite = true; $rightYaxis->title->text = null; $rightYaxis->labels->align = 'right'; $rightYaxis->labels->x = -3;
use Ghunti\HighchartsPHP\HighchartJsExpr; $chart = new Highchart(); $chart->chart->renderTo = "container"; $chart->chart->type = "pie"; $chart->title->text = "Browser market share, April, 2011"; $chart->yAxis->title->text = "Total percent market share"; $chart->plotOptions->pie->shadow = false; $chart->tooltip->formatter = new HighchartJsExpr("function() {\n return '<b>'+ this.point.name +'</b>: '+ this.y +' %'; }"); $chart->series[] = array('name' => "Browsers", 'data' => new HighchartJsExpr("browserData"), 'size' => "60%", 'dataLabels' => array('formatter' => new HighchartJsExpr("function() {\n return this.y > 5 ? this.point.name : null; }"), 'color' => 'white', 'distance' => -30)); $chart->series[1]->name = "Versions"; $chart->series[1]->data = new HighchartJsExpr("versionsData"); $chart->series[1]->innerSize = "60%"; $chart->series[1]->dataLabels->formatter = new HighchartJsExpr("function() {\n return this.y > 1 ? '<b>'+ this.point.name +':</b> '+ this.y +'%' : null;}"); // We can also use Highchart library to produce any kind of javascript // structures $chartData = new Highchart(); $chartData[0]->y = 55.11; $chartData[0]->color = new HighchartJsExpr("colors[0]"); $chartData[0]->drilldown->name = "MSIE versions"; $chartData[0]->drilldown->categories = array('MSIE 6.0', 'MSIE 7.0', 'MSIE 8.0', 'MSIE 9.0'); $chartData[0]->drilldown->data = array(10.85, 7.35, 33.06, 2.81); $chartData[0]->drilldown->color = new HighchartJsExpr("colors[0]"); $chartData[1]->y = 21.63; $chartData[1]->color = new HighchartJsExpr("colors[1]"); $chartData[1]->drilldown->name = "Firefox versions"; $chartData[1]->drilldown->categories = array('Firefox 2.0', 'Firefox 3.0', 'Firefox 3.5', 'Firefox 3.6', 'Firefox 4.0'); $chartData[1]->drilldown->data = array(0.2, 0.83, 1.58, 13.12, 5.43); $chartData[1]->drilldown->color = new HighchartJsExpr("colors[1]"); $chartData[2]->y = 11.94; $chartData[2]->color = new HighchartJsExpr("colors[2]"); $chartData[2]->drilldown->name = "Chrome versions";
public static function workingTime($days, $type) { $data = self::workingTimeData($days, $type); foreach ($data as $division => $division_data) { foreach ($division_data as $key => $values) { $chart = new Highchart(); switch ($key) { case "ticket_count": $chart->colors = ["#ECA9A9"]; break; // pastel red // pastel red case "sum": $chart->colors = ["#E4CFA1"]; break; // pastel yellow // pastel yellow case "average": $chart->colors = ["#ABC1E2"]; break; // pastel blue } $chart->xAxis->type = "datetime"; $chart->title->text = ""; $chart->chart->width = 190; $chart->chart->height = 35; $chart->chart->backgroundColor = null; $chart->chart->borderWidth = 0; $chart->chart->margin = [2, 0, 2, 0]; $chart->tooltip->backgroundColor = "#FFF"; $chart->tooltip->borderWidth = 0; $chart->tooltip->shadow = false; $chart->tooltip->useHTML = true; $chart->tooltip->hideDelay = 0; $chart->tooltip->shared = true; $chart->tooltip->padding = 0; $chart->legend->enabled = false; $chart->credits->enabled = false; $chart->plotOptions->area->marker->enabled = false; $chart->series[0]->type = 'area'; $chart->series[0]->data = []; foreach ($values['historical'] as $date => $value) { $datetime = strtotime($date); $datetime_utc = new HighchartJsExpr("Date.UTC(" . date('Y', $datetime) . "," . (date('m', $datetime) - 1) . "," . date('d,H,i,s', $datetime) . ")"); $chart->series[0]->data[] = [$datetime_utc, (double) $value]; } $data[$division][$key]['chart'] = $chart->renderOptions(); } } return $data; }