예제 #1
0
 /**
  * Process all the bindings for a Dashboard.
  *
  * Turns the chart and control wrappers into new Google Visualization Objects.
  *
  * @access public
  * @return string
  */
 public function processBindings()
 {
     $output = '';
     $bindings = $this->dashboard->getBindings();
     foreach ($bindings as $binding) {
         switch ($binding::TYPE) {
             case 'OneToOne':
                 $controls = $binding->getControlWrappers()[0]->toJavascript();
                 $charts = $binding->getChartWrappers()[0]->toJavascript();
                 break;
             case 'OneToMany':
                 $controls = $binding->getControlWrappers()[0]->toJavascript();
                 $charts = $this->mapWrapperArray($binding->getChartWrappers());
                 break;
             case 'ManyToOne':
                 $controls = $this->mapWrapperArray($binding->getControlWrappers());
                 $charts = $binding->getChartWrappers()[0]->toJavascript();
                 break;
             case 'ManyToMany':
                 $controls = $this->mapWrapperArray($binding->getControlWrappers());
                 $charts = $this->mapWrapperArray($binding->getChartWrappers());
                 break;
         }
         $output .= sprintf('$this.dashboard.bind(%s, %s);', $controls, $charts);
     }
     return $output;
 }
예제 #2
0
 /**
  * Stores a dashboard in the volcano datastore.
  *
  * @param  \Khill\Lavacharts\Dashboards\Dashboard $dashboard Dashboard to store in the volcano.
  * @return boolean
  */
 public function storeDashboard(Dashboard $dashboard)
 {
     $this->dashboards[(string) $dashboard->getLabel()] = $dashboard;
     return true;
 }