Yii2:使用PHP数组制作双轴hightchart
我想创建双轴海图,如图所示,我已经安装了扩展 我的yii2代码Yii2:使用PHP数组制作双轴hightchart,php,highcharts,yii2,Php,Highcharts,Yii2,我想创建双轴海图,如图所示,我已经安装了扩展 我的yii2代码 <?php use miloschuman\highcharts\Highcharts; $emp = ['zxc', 'sdf', 'fgh', 'ggg']; $totalData[] = ['name' => 'Total', 'type' => 'column', 'data' => [23,45,34,34]]; $avgData[] = ['name' =&g
<?php
use miloschuman\highcharts\Highcharts;
$emp = ['zxc', 'sdf', 'fgh', 'ggg'];
$totalData[] = ['name' => 'Total', 'type' => 'column', 'data' => [23,45,34,34]];
$avgData[] = ['name' => 'Avarage', 'type' => 'spline', 'data' => [2.3,4.5,3.4,3.0]];
echo Highcharts::widget([
'options' => [
'chart'=>[
//'type'=>'column',
'zoomType' => 'xy',
],
'exporting'=>[
'enabled'=>false,
],
'credits'=>[
'enabled'=>false,
],
'title'=>[
'text'=>Yii::t('comm', $model->fg_name),
],
'subtitle'=>[
'text'=>'',
'margin'=>0,
],
'xAxis'=>[
'type' => 'category',
'labels' => [
'rotation' => -45,
'style' => [
'fontSize' => '13px',
'fontFamily' => 'Verdana, sans-serif'
]
],
'categories'=> $emp,
'title'=>[
'text'=>'<b>'.Yii::t('comm', 'Employee').'</b>',
],
],
'yAxis'=>[
'title'=>[
'text'=>Yii::t('comm', 'TOTAL/AVARAGE'),
],
],
'legend' => [
'enabled' => false
],
'plotOptions'=>[
'column'=>[
'pointPadding'=>0.2,
'borderWidth'=>0
],
],
'series'=> [$avgData,$totalData]
],
]);
?>
我使用,但我确信过程是相同的,下面是我用来生成双轴图表的最新示例:
'yAxis' => [ // primary axis
[
'title' => [
'text' => 'Weeks'
],
'tickInterval' => 5,
],
[ // secondary axis
'gridLineWidth' => 0,
'title' => [
'text' => '%'
],
'max' => 100,
'min' => 0,
'opposite' => true,
]
],
我的系列剧结局如下:
'series' => [$series,$line, $percent]
它们本身就是数组:这里是其中一个数组的示例,您可以在其中声明数据属于哪个轴,在我的例子中,我猜您的yAxis
将是0或1。将类型
更改为您喜欢的任何类型,此数组是一列,但其他数组是一列
$series Array
(
[name] => 90th Percentile
[type] => column
[yAxis] => 0
[tooltip] => Array
(
[valueSuffix] => Weeks
)
[data] => Array
(
[0] => 16.86
[1] => 11.29
[2] => 13.86
[3] => 32.14
[4] => 17.71
[5] => 7.57
[6] => 19
[7] => 37.57
[8] => 10.14
[9] => 5.43
[10] => 7.14
[11] => 31.57
[12] => 17.52
)
)