Friday, February 26, 2016

Yii2, Gauge and also Google Chart

I needed to put a gauge to a dashboard in my application so I started looking for widgets that could do the job.
I found two:
yii2-justgage which is based on this component canv-gauge. Which has nice graphics.
And Google Charts which are very easy to use and a little bit more clean design which was more suitable to my case.

yii2-google-chart

The good part of this widget is that it allows you to use not only the gauge but all google chart apis, even maps.
As you can see in docs, to use it is as simple as this:

            echo GoogleChart::widget( array('visualization' => 'Gauge', 'packages' => 'gauge',
echo GoogleChart::widget( array('visualization' => 'Gauge', 'packages' => 'gauge', 'data' => array( array('Label', 'Value'), array('Memory', 80), array('CPU', 55), array('Network', 68), ), 'options' => array( 'width' => 400, 'height' => 120, 'redFrom' => 90, 'redTo' => 100, 'yellowFrom' => 75, 'yellowTo' => 90, 'minorTicks' => 5 ) ));

No comments:

Post a Comment