$chart->yAxis->title->text = "Value";
$chart->yAxis->plotLines[] = array('value' => 0, 'width' => 1, 'color' => "#808080");
$chart->tooltip->formatter = new HighchartJsExpr("function() {\n    return '<b>'+ this.series.name +'</b><br/>'+\n    Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+\n    Highcharts.numberFormat(this.y, 2); }");
$chart->legend->enabled = false;
$chart->exporting->enabled = false;
$chart->series[0]->name = "Random data";
$chart->series[0]->data = new HighchartJsExpr("(function() {\n    var data = [],\n        time = (new Date()).getTime(),\n        i;\n\n    for (i = -19; i <= 0; i++) {\n        data.push({\n            x: time + i * 1000,\n            y: Math.random()\n        });\n    }\n    return data; })()");
$globalOptions = new HighchartOption();
$globalOptions->global->useUTC = false;
?>

<html>
  <head>
    <title>Spline updating each second</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php 
foreach ($chart->getScripts() as $script) {
    echo '<script type="text/javascript" src="' . $script . '"></script>';
}
?>
  </head>
  <body>
    <div id="container"></div>
    <script type="text/javascript">
    <?php 
echo Highchart::setOptions($globalOptions);
echo $chart->render("chart1");
?>
    </script>
  </body>
</html>
Esempio n. 2
0
$chart = new Highchart(Highchart::HIGHSTOCK);
$chart->chart->renderTo = "container";
$chart->chart->events->load = new HighchartJsExpr("function() {\n    var series = this.series[0];\n    setInterval(function() {\n        var x = (new Date()).getTime(), // current time\n        y = Math.round(Math.random() * 100);\n        series.addPoint([x, y], true, true);\n    }, 1000); }");
$chart->rangeSelector->buttons = array(array('type' => "minute", 'count' => 1, 'text' => "1M"), array('type' => "minute", 'count' => 5, 'text' => "5M"), array('type' => "all", 'text' => "All"));
$chart->rangeSelector->inputEnabled = false;
$chart->rangeSelector->selected = 0;
$chart->title->text = "Live random data";
$chart->exporting->enabled = false;
$chart->series[] = array('name' => "Random data", 'data' => new HighchartJsExpr("(function() {\n    var data = [], time = (new Date()).getTime(), i;\n\n    for( i = -999; i <= 0; i++) {\n        data.push([\n          time + i * 1000,\n          Math.round(Math.random() * 100)\n        ]);\n    }\n    return data;\n  })()"));
?>

<html>
    <head>
        <title>Dynamically updated data</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 
$option = new HighchartOption();
$option->global->useUTC = false;
echo Highchart::setOptions($option);
echo $chart->render("chart");
?>
        </script>
    </body>
</html>