So verwende ich diese highcharts Erweiterung auf Yii. Und ich hole die Daten mit Hilfe der Datenbank (von meinem Controller). Und der Blick sieht wie folgt aus:Yii Highchart-Erweiterung - Ändern Sie die Farbe basierend auf Wert
<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>
fand ich diese Antwort here über die Balkenfarben basierend auf dem Wert zu ändern. Aber es ist im JSON-Format, und ich muss es Yii Widget-Format verwenden. Ich dachte, es ist einfach, aber es scheint nicht zu funktionieren. Was mache ich falsch?
ich versuchte, dies zu setzen:
'colorByPoint' => true,
Oberhalb dem zones =>
Dingen, die Farben durch die Punkte aber nicht von Wert zu ändern, wie ich sie will. Ich stelle es auch unter series
Array, aber es funktioniert auch nicht.