Yii 如何正确使用highchart构建多个向下钻取?
我想使用frameworkYii 如何正确使用highchart构建多个向下钻取?,yii,highcharts,yii2,Yii,Highcharts,Yii2,我想使用frameworkYii2制作多个深入图表。我想根据年龄制作学生图表。我已经通过composer安装了highcharts。我还将它注册到了我的php文件中,但我不知道为什么深入分析图表不起作用。我想,这是因为我的密码不正确 这是我的桌子: 学院2011 部门2011 major2011 这是我的控制器: <?php namespace app\controllers; use yii\web\Controller; use yii\helpers\
Yii2
制作多个深入图表。我想根据年龄制作学生图表。我已经通过composer安装了highcharts。我还将它注册到了我的php
文件中,但我不知道为什么深入分析图表不起作用。我想,这是因为我的密码不正确
这是我的桌子:
学院2011
部门2011
major2011
这是我的控制器:
<?php
namespace app\controllers;
use yii\web\Controller;
use yii\helpers\Json;
class MagisterrinciController extends Controller
{
public function actionIndex()
{
//data usia fakultas
$faculty = (new \yii\db\Query())
->select(['Faculty'])
->from('facultyin2011')
->limit(10)
->column();
$age1 = (new \yii\db\Query())
->select(['lessthan25'])
->from('facultyin2011')
->limit(10)
->column();
$age2 = (new \yii\db\Query())
->select(['btween25to29'])
->from('facultyin2011')
->limit(10)
->column();
$age1 = array_map('floatval', $age1);
$age2 = array_map('floatval', $age2);
$data['ageforfacultystudent'] = json_encode($faculty);
$data['age1'] = json_encode($age1);
$data['age2'] = json_encode($age2);
// next
$department = (new \yii\db\Query())
->select(['Department'])
->from('department2011')
->limit(10)
->column();
$agedepartment1 = (new \yii\db\Query())
->select(['lessthan25'])
->from('department2011')
->limit(10)
->column();
$agedepartment2 = (new \yii\db\Query())
->select(['btween25to29'])
->from('department2011')
->limit(10)
->column();
$agedepartment1 = array_map('floatval', $agedepartment1);
$agedepartment2 = array_map('floatval', $agedepartment2);
$data['agefordepartmentstudent'] = json_encode($department);
$data['agedepartment1'] = json_encode($agedepartment1);
$data['agedepartment2'] = json_encode($agedepartment2);
//next
$majorstudent = (new \yii\db\Query())
->select(['major'])
->from('major2011')
->limit(10)
->column();
$agemajor1 = (new \yii\db\Query())
->select(['lessthan25'])
->from('department2011')
->limit(10)
->column();
$agemajor2 = (new \yii\db\Query())
->select(['btween25to29'])
->from('department2011')
->limit(10)
->column();
$agemajor1 = array_map('floatval', $agemajor1);
$agemajor2 = array_map('floatval', $agemajor2);
$data['ageformajorstudent'] = json_encode($majorstudent);
$data['agemajor1'] = json_encode($agemajor1);
$data['agemajor2'] = json_encode($agemajor2);
return $this->render('index',$data);
}
}
<?php
use app\assets\HighchartsAsset;
HighchartsAsset::register($this);
$this->title = 'Highcharts Test';
?>
<!-- data selanjutnya -->
<div class="container">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="x_panel">
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<?php $this->registerJs("
$(function () {
// Create the chart
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Basic drilldown'
},
xAxis: {
categories: $ageforfacultystudent
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
}
}
},
series: [
{
name: 'lessthan25',
data: $age1,
drilldown: 'department1'
},
{
name: 'btween25to29',
data: $age2,
drilldown: 'department2'
}],
drilldown: {
series: [{
id: 'department1',
name: 'Departemen',
data: [{
name: 'lessthan25',
data: $agedepartment1,
drilldown: 'major1'
},
{
name: 'btween25to29',
data: $agedepartment2,
drilldown: 'major2'
}
]
}, {
id: 'major1',
data: $agemajor1
},
{
id: 'major2',
data: $agemajor2
}]
}
})
});
")?>
</div>
</div>
也许会让你的生活更轻松一些我用过这些代码。但是我的深入分析图表仍然无法运行@gms您能检查一下我上面的代码吗?可能有一些不正确的代码,但我不知道如何纠正他们在代码你张贴你没有使用我链接的模块。如果你仍然不想使用它,并且你更愿意坚持自己的解决方案,你应该至少提供你所犯的错误是什么我已经编辑了我的问题,并且我已经告诉了我所犯的错误是什么。我将代码的结果发布到我的问题上。错误是当我单击其中一个图表时,它无法向下钻取@gmcI猜测您的控制台中显示了一些js错误。张贴