我正在使用2amigos/yii2-chartjs-widget来绘制图表,除了图表方向之外,一切都正常,我想让它水平。如下所示:
我的代码是:
<?=ChartJs::widget([
'type' => 'bar',
'id'=> 'agent'.$index,
'options' => [
'indexAxis'=> 'y',
'responsive'=> true,
'height' => 200,
'width' => 400
],
'data' => [
'radius' => "90%",
'labels' => array_keys($productschart),
'datasets' => [
[
'data' =>array_values($productschart),
'label' => '',
'backgroundColor' => Charts::Colors(count($productschart)),
'borderColor' => [
'#fff',
'#fff',
'#fff'
],
'borderWidth' => 1,
'hoverBorderColor'=>["#999","#999","#999"],
]
]
],
]);
?>
即使添加了'indexAxis' =〉'y',图表仍然是垂直的,如下所示:
1条答案
按热度按时间isr3a4wc1#
解决方案是使用'type' =〉'horizontalBar'而不是'type' =〉'bar'