function createHighchart($options) { $chartName = nextChartName(); $options['chart']['renderTo'] = $chartName; $chartdescr = Highcharts::create($chartName, $options); $chartdiv = '<div style="padding:0em" id="' . $chartName . '"> </div>'; //min-width="800" height="300 margin: 0 auto" return $chartdescr . $chartdiv; }
/** * * @Title: hrEmployeesEduChart * @Description: todo(文化程度统计) * @author renling * @date 2014-3-28 下午3:50:37 * @throws */ public function hrEmployeesEduChart() { //引入Chart import('@.ORG.BaseCharts.Highcharts'); //创建chart对象 $chart = new Highcharts(); //设置x坐标 $chart->setX('name'); //设置Y坐标orderno $chart->setY('count'); $this->assign("defaultSelect", 2); $this->assign("title", "员工文化程度统计"); $chart->setTitle('文化程度'); $list = $this->eduList(); $this->assign("headerFormat", "<span>{point.key}:</span>"); $this->assign("pointFormat", "<b>{point.y}</b>人"); $this->assign("text", "人数(人)"); $this->assign("distype", "pie"); //生成图表 $chart->builderChart(Highcharts::$SINGLE_SERIES, $list); $this->assign("xAxis", $chart->getCategories()); $this->assign("series", $chart->getResults()); }
public function actionDetail() { $use = new User(); $order = new Orders(); $config = new Configweb_model(); $pid = Yii::app()->session['pid']; $data['user'] = $use->Get_detail($pid); $data['order'] = $order->get_order_user($pid); //Chart Order Month $chart = new Highcharts(); $Month = $config->MonthShot(); $categories = implode("','", $Month); $order_month = $order->get_order_month($pid); foreach ($order_month as $datas) { $column[] = $datas['PRICE_TOTAL']; } $column_value = implode(",", $column); $chart->set_id("chart-month"); $chart->set_type("column"); $chart->set_title("ข้อมูลการซื้อสินค้าในแต่ละเดือนที่ผ่านมา"); $year = date("Y"); $year_now = $year + 543; $chart->set_subtitle("ปี พ.ศ. " . $year_now); $chart->set_categories($categories); $chart->set_yAxis("จำนวน(บาท)"); $chart->set_series_name("จำนวน "); $chart->set_value($column_value); $graph = $chart->Bar_chart(); $data['chartmonth'] = $graph; //Chart Order Month Visit $chart_visit = new Highcharts(); $order_month_vidit = $order->get_order_month_visit($pid); foreach ($order_month_vidit as $datavisit) { $column_visit[] = $datavisit['TOTAL']; } $column_visit_value = implode(",", $column_visit); $chart_visit->set_id("chart-month-visit"); $chart_visit->set_type("bar"); $chart_visit->set_title("ข้อมูลการซื้อสินค้าในแต่ละเดือนที่ผ่านมา(ครั้ง)"); $chart_visit->set_subtitle("ปี พ.ศ. " . $year_now); $chart_visit->set_categories($categories); $chart_visit->set_yAxis("จำนวน(ครั้ง)"); $chart_visit->set_series_name("จำนวน "); $chart_visit->set_value($column_visit_value); $data['chartvisit'] = $chart_visit->chart_spline(); //Chart Order type $type_model = new Type_product(); $type = $type_model->Get_all(); foreach ($type as $Ptype) { $Ptype_arr[] = $Ptype['type_name']; } $categories_type = implode("','", $Ptype_arr); $data['categories_type'] = $categories_type; $chart_type = new Highcharts(); $order_type = $order->get_order_type($pid); foreach ($order_type as $rs_type) { $column_type[] = $rs_type['TOTAL']; } $column_type_value = implode(",", $column_type); $chart_type->set_id("chart-type"); //$chart_type->set_type("bar"); $chart_type->set_color("#ffff00"); $chart_type->set_title("ข้อมูลการซื้อสินค้าแต่ละประเภท"); $chart_type->set_subtitle("ปี พ.ศ. " . $year_now); $chart_type->set_categories($categories_type); $chart_type->set_yAxis("จำนวน(บาท)"); $chart_type->set_series_name("ประเภท "); $chart_type->set_value($column_type_value); $data['charttype'] = $chart_type->chart_spline(); $this->render("//user/detail", $data); }
<!-- jQuery and Highchart JS --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="http://www.highcharts.com/js/highcharts.js" type="text/javascript"></script> <?php // Include the library require_once '../src/highcharts.php'; // Start by adding a new reference object // and adding some configuration for the chart $oHighcharts = new Highcharts(new HighchartsChart('container', HighchartsChart::SERIES_TYPE_COLUMN)); // Title typeof HighchartsTitle $oHighcharts->title = new HighchartsTitle('Stacked bar chart'); // Description of xAxis $oHighcharts->xAxis->categories = array('Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'); // Options for yAxis $oHighcharts->yAxis->min = 0; $oHighcharts->yAxis->setTitle(new HighchartsTitle('Total fruit consumption')); $oHighcharts->legend->reversed = true; // The formatter is a javascript callback $oHighcharts->tooltip->formatter = "function() {\n return this.series.name +': '+ this.y +'';\n }"; // If stacking, choose normal $oHighcharts->plotOptions->column->stacking = HighchartsPlotOptionsColumn::HIGHCHARTS_PLOT_OPTIONS_COLUMN_STACKING_NORMAL; // These are your data $oHighcharts->series->addSerie(new HighchartsSerie('John', array(5, 3, 4, 7, 2))); $oHighcharts->series->addSerie(new HighchartsSerie('Jane', array(2, 2, 3, 2, 1))); $oHighcharts->series->addSerie(new HighchartsSerie('Joe', array(3, 4, 4, 2, 5))); // Render chart echo $oHighcharts->render(); // Enjoy your new chart echo '<div id="container" style="width: 340px; height: 240px;"> </div>';
function __construct() { parent::WebPage('Basic Highchart, config from array'); $config = array( 'chart' => array( 'defaultSeriesType' => 'line', 'marginRight' => 130, 'marginBottom' => 25 ), 'credits' => array('enabled' => false), 'title' => array( text => 'Monthly Average Temperature', x => -20 //center ), 'subtitle' => array( 'text' => 'Source : WorldClimate.com', 'x' => -20 ), 'xAxis' => array( 'categories' => array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec') ), 'yAxis' => array( 'title' => array( 'text' => 'Temperature (°C)' ), 'plotLines' => array( array( 'value' => 0, 'width' => 1, 'color' => '#808080') ) ), 'tooltip' => array( 'formatter' => new ClientEvent("return '<b>'+ this.series.name +'</b><br/>'+ this.x +' : '+ this.y +'°C';") ), 'legend' => array( 'layout' => 'vertical', 'align' => 'right', 'verticalAlign' => 'top', 'x' => -10, 'y' => 100, 'borderWidth' => 0 ), 'series' => array( array( 'name' => 'Tokyo', 'data' => array(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6) ), array( 'name' => 'New York', 'data' => array(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5) ), array( 'name' => 'Berlin', 'data' => array(-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0) ), array( 'name' => 'London', 'data' => array(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8) )) ); $this->Controls->Add($chart = new Highcharts()); $chart->SetConfig($config); // $chart->Exportable = true; }