Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Highcharts-如何添加/显示标签';s name count()查询结果中的数据_Javascript_Mysql_Highcharts - Fatal编程技术网

Javascript Highcharts-如何添加/显示标签';s name count()查询结果中的数据

Javascript Highcharts-如何添加/显示标签';s name count()查询结果中的数据,javascript,mysql,highcharts,Javascript,Mysql,Highcharts,我们想问你们所有人从count()的查询结果中显示标签名称的问题。我们已经计算了2天,但没有找到解决方案 首先,这是数据库 其次,我们生成了查询结果(这是我们模型的类) 此查询的结果是 第三,这是显示饼图的视图(这是javascript代码的快照)(我们使用的是highcharts) $('.grafik')。高图({ 图表:{ 键入“pie”, 玛金托普:50, renderTo:“容器” }, 学分:{ 已启用:false }, 工具提示:{ pointFormat:“{series.

我们想问你们所有人从count()的查询结果中显示标签名称的问题。我们已经计算了2天,但没有找到解决方案

首先,这是数据库

其次,我们生成了查询结果(这是我们模型的类)

此查询的结果是

第三,这是显示饼图的视图(这是javascript代码的快照)(我们使用的是highcharts)


$('.grafik')。高图({
图表:{
键入“pie”,
玛金托普:50,
renderTo:“容器”
},
学分:{
已启用:false
},
工具提示:{
pointFormat:“{series.name}:{point.y}Orang”
},
标题:{
文字:“Lama Waktu Tunggu untuk Pekerjaan Pertama”
},
副标题:{
正文:“鲁鲁桑校友2015-2016”
},
xAxis:{
类别:['Waktu Tunggu xAxis'],
标签:{
风格:{
fontSize:'10px',
fontFamily:“Verdana,无衬线”
}
}
},
图例:{
labelFormatter:function(){
如果(this.name=='Langsung Bekerja')
返回this.name+':1橙色';
else if(this.name=='1 Bulan'){
返回this.name+':2橙色';
}
}
},
打印选项:{
馅饼:{
allowPointSelect:true,
光标:“指针”,
数据标签:{
已启用:true
},
showInLegend:对
}
},
系列:[{
“姓名”:“朱姆拉”,
“数据”:[
]
}]
});

最后,我们要问的是。这是网页的屏幕截图。

问题: 我们想用数据库中的值添加标签的名称。不仅显示“切片”。我们希望显示数据库中数据的名称。 请为大家提供任何解决方案或建议

很抱歉,这个新手问题。
非常感谢您的提示和解决方案。

为饼图中的每个点指定一个名称-默认情况下,数据标签上有点的名称文本-感谢您的回复@morganfree,但我们不需要echo手册或特定名称。我们希望动态标签的名称来自我们创建的查询结果数据。您还有其他建议吗?这是一个关于后端的问题-如何从数据库中检索适当的数据?如果是这样的话,我建议删掉这个问题的前端部分,然后问一个新问题。如果您已经从db中正确地检索了数据,那么您必须将其放在config对象中-通过回显-通过点的名称或感谢@morganfree,我已经找到了我们想要的方式。非常感谢你的建议,我很感激。很高兴认识你,再见。
public function ambilDataLamaWaktuTunggu(){
  // select f5, count(*) from tracer_study as pilihanF5 GROUP BY f5 
  $this->db->select("f5, count(id_tracer_study) as'pilihanF5'");
  $this->db->from('tracer_study');
  $this->db->group_by('f5');
  $result = $this->db->get()->result();
  return $result;
}
<script type="text/javascript">
<?php
  foreach ($num as $row){
    $data[] = $row->pilihanF5;
    $dataNama[] = $row->f5;
  }
?>

$('.grafik').highcharts({
  chart:{
    type: 'pie',
    marginTop: 50,
    renderTo: 'container'
  },
  credits:{
    enabled:false
  },
  tooltip:{
    pointFormat: '{series.name}: <b>{point.y} Orang</b>'
  },
  title:{
    text: 'Lama Waktu Tunggu untuk Pekerjaan Pertama'
  },
  subtitle:{
    text: 'Alumni Lulusan 2015-2016'
  },
  xAxis:{
    categories:['Waktu Tunggu xAxis'],
    labels:{
      style:{
        fontSize: '10px',
        fontFamily: 'Verdana, sans-serif'
      }
    }
  },
  legend:{
    labelFormatter: function(){
      if(this.name == 'Langsung Bekerja')
        return this.name + ': 1 Orang';
      else if (this.name == '1 Bulan') {
        return this.name + ': 2 Orang';
      }
    }
  },
  plotOptions:{
    pie:{
      allowPointSelect: true,
      cursor: 'pointer',
      dataLabels:{
        enabled:true
      },
      showInLegend: true
    }
  },
  series:[{
    'name':'Jumlah ',
    'data':[
       <?php echo join( $data, ',')?>
    ]
  }]
});