Exemplo n.º 1
0
 /**
  * @param Chart $value
  * @return string
  */
 public function render($value)
 {
     $data = $value->data();
     if (!$data) {
         return '[no data]';
     }
     $data = json_encode($data);
     $options = json_encode($value->options());
     $type = $value->chartType();
     $id = uniqid("{$type}-chart-");
     return (string) new Element('div', [], [new Element('canvas', ['id' => $id]), new Element('script', [], ["\n                var ctx = document.getElementById('{$id}').getContext('2d');\n                new Chart(ctx).{$type}({$data}, {$options});\n            "])]);
 }
Exemplo n.º 2
0
 /**
  * @param DataPoint[] $dataPoints
  */
 public function __construct(array $dataPoints = [])
 {
     parent::__construct();
     $this->dataPoints = $dataPoints;
 }
Exemplo n.º 3
0
 /**
  * LineChart constructor.
  * @param null|string[] $labels
  * @param DataSet[] $dataSets
  */
 public function __construct(array $labels = null, array $dataSets = [])
 {
     parent::__construct();
     $this->labels = $labels;
     $this->dataSets = $dataSets;
 }
Exemplo n.º 4
0
 protected function defaultOptions()
 {
     return array_merge(parent::defaultOptions(), ['showTooltips' => true, 'scaleShowHorizontalLines' => true, 'scaleShowLabels' => true, 'scaleLabel' => "<%=value%>", 'scaleArgLabel' => "<%=value%>", 'multiTooltipTemplate' => '<%=datasetLabel%>: <%=arg%>; <%=value%>', 'scaleBeginAtZero' => true, 'datasetStroke' => false]);
 }