Example #1
0
 public function export_in_json()
 {
     $dashboard_id = $this->getDashboardId();
     $json_env = parent::export_in_json();
     // Find all the lines of this graph
     $graphs = Graph::findAll($dashboard_id);
     $json_graphs_array = array();
     foreach ($graphs as $graph_in_dashboard) {
         // Export them in JSON
         $json_graphs_array[] = $graph_in_dashboard->export_in_json();
     }
     // Implode them
     $json_graph = "\"graphs\":[";
     if (!empty($json_graphs_array)) {
         $json_graph .= implode(",", $json_graphs_array);
     }
     $json_graph .= "]";
     // Replace the last } of the json
     $json_env[strlen($json_env) - 1] = ",";
     // Concat the graph with its lines
     $json_env .= $json_graph . "}";
     return $json_env;
 }
Example #2
0
 public function export_in_json()
 {
     $graph_id = $this->getGraphId();
     $json_env = parent::export_in_json();
     // Find all the lines of this graph
     $lines = Line::findAll($graph_id);
     $json_lines_array = array();
     foreach ($lines as $line_in_graph) {
         // Export them in JSON
         $json_lines_array[] = $line_in_graph->export_in_json();
     }
     // Implode them
     $json_lines = "\"lines\":[";
     if (!empty($json_lines_array)) {
         $json_lines .= implode(",", $json_lines_array);
     }
     $json_lines .= "]";
     // Erase the last } of the json
     $json_env[strlen($json_env) - 1] = ",";
     // Concat the graph with its lines
     $json_env .= $json_lines . "}";
     return $json_env;
 }