/**
  * Series output
  */
 public function testData()
 {
     $chart = new Highchart();
     $chart->series($this->series);
     $this->assertRegExp('/\\{"name":"Data Serie #1","data":\\[1,2,4,5,6,3,8\\]\\}/', $chart->render());
     $this->assertRegExp('/\\{"name":"Data Serie #2","data":\\[7,3,5,1,6,5,9\\]\\}/', $chart->render());
 }
Exemple #2
0
 /**
  * useUTC option (true/false)
  */
 public function testGlobal()
 {
     $chart = new Highchart();
     $chart->global->useUTC("true");
     $this->assertRegExp('/global: \\{"useUTC":"true"\\}/', $chart->render());
     $chart->global->useUTC("false");
     $this->assertRegExp('/global: \\{"useUTC":"false"\\}/', $chart->render());
 }
 /**
  * Enabled option (true/false)
  */
 public function testEnabledDisabled()
 {
     $chart = new Highchart();
     $chart->legend->enabled(false);
     $this->assertRegExp('/legend: \\{"enabled":false\\}/', $chart->render());
     $chart->legend->enabled(true);
     $this->assertRegExp('/legend: \\{"enabled":true\\}/', $chart->render());
 }
 /**
  * Series output
  */
 public function testColors()
 {
     $linechart = new Highchart();
     $colors = array('#FF0000', '#00FF00', '#0000FF');
     $linechart->colors($colors);
     $this->assertRegExp('/colors: \\[\\["#FF0000","#00FF00","#0000FF"\\]\\]/', $linechart->render());
 }
Exemple #5
0
 /**
  * Scrollbar config output
  */
 public function testConfig()
 {
     $chart = new Highchart();
     foreach ($this->scrollbar as $key => $value) {
         // Config randomization
         if (mt_rand(0, 5) === 0) {
             continue;
         }
         $this->usedOptions[$key] = $value;
         $chart->scrollbar->{$key}($value);
     }
     preg_match('|scrollbar: (\\{[^\\}]+\\})+|', $chart->render(), $matches);
     $options = json_decode($matches[1], true);
     $this->assertEquals(count($this->usedOptions), count(array_intersect($this->usedOptions, $options)));
 }
 /**
  * width option (integer - width in px)
  */
 public function testWidth()
 {
     $chart = new Highchart();
     $chart->exporting->width(300);
     $this->assertRegExp('/exporting: \\{"width":300\\}/', $chart->render());
 }
 public function testStartAngle()
 {
     $chart = new Highchart();
     $chart->pane->startAngle(5);
     $this->assertRegExp('/pane: \\{"startAngle":5\\}/', $chart->render());
 }
 /**
  * noData option (string)
  */
 public function testLang()
 {
     $chart = new Highchart();
     $chart->lang->noData("No data to display");
     $this->assertRegExp('/"noData":"No data to display"/', $chart->render());
 }
 /**
  * shadow option (true/false)
  */
 public function testShadow()
 {
     $chart = new Highchart();
     $chart->tooltip->shadow("true");
     $this->assertRegExp('/tooltip: \\{"shadow":"true"\\}/', $chart->render());
     $chart->tooltip->shadow("false");
     $this->assertRegExp('/tooltip: \\{"shadow":"false"\\}/', $chart->render());
 }
 public function exportGantt(Highchart $ob, $filename, $width = 800)
 {
     $logger = $this->logger;
     // Create the file
     $chemin = 'tmp/' . $filename . '.json';
     $destination = 'tmp/' . $filename . '.png';
     $render = $ob->render();
     // On garde que ce qui est intéressant
     $render = strstr($render, '{', false);
     $render = substr($render, 1);
     $render = strstr($render, '{', false);
     $render = substr($render, 0, strrpos($render, '}'));
     // on tronque jusqu'a la dernire ,
     $render = substr($render, 0, strrpos($render, '}'));
     // on tronque jusqu'a la dernire ,
     $render .= '}';
     $fp = fopen($chemin, 'w');
     if ($fp) {
         if (fwrite($fp, $render) === false) {
             $logger->err("exportGantt: impossible d'écrire dans le fichier .json (" . $chemin . ')');
             return false;
         }
         fclose($fp);
     } else {
         $logger->err('exportGantt: impossible de créer le fichier .json (' . $chemin . ')');
         return false;
     }
     $cmd = 'phantomjs js/highcharts-convert.js -infile ' . $chemin . ' -outfile ' . $destination . ' -width ' . $width . ' -constr Chart';
     $output = shell_exec($cmd);
     //l'execution de la commande affiche des messages de fonctionnement. On ne retient que la 3eme ligne (celle de la destination quand tout fonctionne bien).
     //Highcharts.options.parsed Highcharts.customCode.parsed tmp/gantt411ENS.png
     $temp = preg_split('#\\n#', $output);
     $output = $temp[2];
     if (strncmp($output, $destination, strlen($destination)) == 0) {
         if (file_exists($destination)) {
             return true;
         } else {
             $logger->err("exportGantt: le fichier final n'existe pas (" . $destination . ')');
             return false;
         }
     } else {
         $logger->err("exportGantt: erreur lors de la génération de l'image: " . $output, array('cmd' => $cmd));
         return false;
     }
 }
 /**
  * Set localized weekday names
  */
 public function testWeekDays()
 {
     $chart = new Highchart();
     $chart->lang->weekdays(array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'));
     $this->assertRegExp('/lang: \\{"weekdays":\\["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"\\]\\}/', $chart->render());
 }
 /**
  * Look for that mean trailing comma
  */
 public function testIeFriendliness()
 {
     $chart = new Highchart();
     $chart->chart->setTitle('Am I IE friendly yet?');
     $this->assertRegExp('/\\}(?<!,)\\n?\\r?\\s*\\}\\);\\n?\\r?\\s*\\}\\);/', $chart->render());
 }