高图扩展-根据值更改颜色


Yii Highchart extension - Change color based on value

所以,我在Yii上使用了这个highcharts扩展。我使用数据库(从我的控制器)获取数据。视图是这样的

<div class="hero-unit" id="content" style="position:relative;border: solid green">
<div style="max-width:100%;overflow:auto;">
    <div style="width:2200px;">
        <center> 
            <?php
            $label = array(); //inisiasi label axis
            $nilai = array(); //inisiasi nilai data
            foreach ($dataProvider3->getData() as $i => $ii) {
                $label[$i] = array($ii['no'] . '. ' . $ii['namapek']);//this is fetched from SQL syntax in controller
                $nilai[$i] = (float) $ii['pek']; //this is fetched from SQL syntax in controller
            }
            $this->widget('application.extensions.highcharts.HighchartsWidget', array(
                'scripts' => array(
                    'modules/exporting',
                    'themes/epcGray',
                    'highcharts-more',
                ),
                'options' => array(
                    'chart' => array('defaultSeriesType' => 'column', 'backgroundColor' => 'rgba(255, 255, 255, 0.1)'),
                    'title' => FALSE,
                    'legend' => array(
                        'enabled' => false,
                    ),
                    'xAxis' => array(
                        'categories' => $label,
                    ), //nama axis
                    'yAxis' => array(
                        'min' => 0,
                        'title' => array(
                            'text' => 'Percentage'
                        ),
                    ),
                    'series' => array(
                        array('data' => $nilai)//data,
                    ),
                    'tooltip' => array(
                        'formatter' => 'js:function() {return "<b>Step "+ this.x +"</b><br/>" + "Finished: "+ Highcharts.numberFormat(this.y, 2) +"%"; }',
                    ),
                    'plotOptions' => array(
                        'column' => array(
                            'zones' =>
                            array('value' => 50, 'color' => '#EB4011'),
                            array('value' => 120, 'color' => '#aaff99'),
                        ),
                        'series' => array(
                            'point' => array(
                                'events' => array(
                                    'click' => 'js:function() {
                                var cat = this.category;
                                var res = parseInt(cat, 10);
                                window.open ("index.php?r=reports/rinci&id=" + res); }',
                                )
                            ),
                        )
                    ),
                    'credits' => array('enabled' => false),
                )
            ));
            ?>
        </center>
    </div>
</div>

我在这里找到了关于根据值改变栏颜色的答案。但它是json格式,我需要使用它的Yii小部件格式。我以为这很容易做到,但似乎行不通。我做错了什么?

我试着把这个:

'colorByPoint' => true,

zones =>上面,颜色随点而变化,而不是按我想要的值。我也把它放在series数组下,但它也不起作用

所以我尝试了很多事情使它工作。但这似乎是扩展本身的缺陷。

所以我直接在我的视图上使用highchart js文件。这很好。如果有人遇到同样的问题,我建议离开这个扩展,如果它缺少太多有用的功能。

这些是必需的js文件:

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>

使用此处的示例