Beispiel #1
0
<?php

require_once "class.ui.Charts.php";
require_once "class.db.Datacenter.php";
if (isset($_GET["action"])) {
    if ($_GET["action"] == "pv_distribute") {
        //pv分布
        $db = new DatacenterDB();
        $d = $db->selectPvDistribute();
        $chart_series = array();
        $categories = array();
        $wd = array("name" => "PV分布", "data" => array(), "dataLabels" => array("enabled" => "true", "rotation" => 0, "format" => "{point.y} %"));
        $totalpv = 0;
        foreach ($d as $pvdistribute) {
            $totalpv = $totalpv + (int) $pvdistribute["num"];
        }
        foreach ($d as $pvdistribute) {
            array_push($categories, $pvdistribute["name"]);
            array_push($wd["data"], round($pvdistribute["num"] / $totalpv * 100, 2));
        }
        $chart_series[0] = $wd;
        //设置图表参数
        $chart_lw = new LineChart();
        $chart_lw->data["chart"]["type"] = "bar";
        $chart_lw->data["title"] = array("text" => "PV分布");
        $chart_lw->data["subtitle"] = array("text" => "各页面pv占总数百分比");
        $chart_lw->data["xAxis"] = array("title" => array("text" => ""), "categories" => $categories);
        $chart_lw->data["yAxis"] = array("title" => array("text" => "百分比(%)"));
        $chart_lw->data["tooltip"] = array("pointFormat" => "<span style='color:{series.color}'>● {series.name}</span>: <b>{point.y} %</b>");
        $chart_lw->data["series"] = $chart_series;
        echo $chart_lw->getChartJson();