2017 © Pedro Peláez
 

yii2-extension rgraph

Graphing with RGraph

image

klikar3/rgraph

Graphing with RGraph

  • Wednesday, April 18, 2018
  • by klikar3
  • Repository
  • 1 Watchers
  • 0 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

# yii2-RGraph

example.jpg oder, (*1)

example2.jpg

yii2 extension for the RGraph graphing library, based on robregonm's work
RGraph is available under GPL, (*2)

http://www.rgraph.net/open-source, (*3)

Example:, (*4)

---- controller:, (*5)

    public function actionDetail($cntr,$id,$days)
    {

        $servername = $this->getServername($id);

        date_default_timezone_set('Europe/Berlin'); 
        $dt = date('Y-m-d H:i:s',time() - 60 * 60 * 24 * $days);

        return $this->render('detail', [
            'id' => $id,
            'cntr' => $cntr,
            'servername' => $servername,
            'dataset' => $this->getPerfmonDataset($servername,$cntr,$dt),
        ]);
    }

    public function getServername($id)
    {
        $lconn = \Yii::$app->db;        
        $cmd = $lconn
                ->createCommand('SELECT [Server] FROM ServerData WHERE id=:id');
        $cmd->bindValue(':id', $id);
        $servername = $cmd->queryScalar();

        return $servername;

    }

    public function getPerfmonDataset($srvr,$cntr,$dt)
    {
        $pcid = (new \yii\db\Query())
        ->select('id')->from('PerfCounterDefault')->where('counter_name=:cntr',
        array('cntr' => $cntr))
        ->scalar();

        $dataset = (new \yii\db\Query())
        ->select('value, CaptureDate')->from('PerfMonData')->where('Server=:srvr AND Counter_id=:pcid AND CaptureDate>:dt',
        array('srvr' => $srvr, 'pcid' => $pcid, 'dt' => $dt ))
        ->all();

        return $dataset;

    }
```php

---- View:

```html


    use yii\helpers\ArrayHelper;
    use yii\helpers\Html;
    use yii\helpers\Url;
    use yii\web\JsExpression;
    use yii\widgets\ListView;

    use klikar3\rgraph\RGraph;
    use klikar3\rgraph\RGraphLine;


    $this->title = 'BaseLine';


    ```html

    <div class="site-index">


        <div class="body-content">

    <h3><?php echo 'Server: '.$servername ?></h3> <?= Html::a('Ressources',Url::toRoute(['res_cpu', 'id' => $id])); ?>


    <?= 'Refreshed on '.date('d.m.Y H:i:s'); ?>
    <div class="row">
      <?= RGraphLine::widget([
              'data' => !empty($dataset) ? array_map('intval',ArrayHelper::getColumn($dataset,'value')) : [ 0 ],
              'allowDynamic' => true,
              'allowTooltips' => true,
              'allowContext' => true,
              'options' => [
                  'height' => '600px',
                  'width' => '800px',
                  'colors' => ['blue'],
                  'filled' => true,
    //              'spline' => true,
                  'clearto' => ['white'],
                  'labels' => !empty($dataset) ? array_map(function($val){return substr($val,1,15);},
                                        array_column(array_chunk(ArrayHelper::getColumn($dataset,'CaptureDate'),count($dataset)/10),0)
                              ) : [ 'No Data' ],
                  'tooltips' => !empty($dataset) ? ArrayHelper::getColumn($dataset,'value') : [ 'No Data' ],
                  'numxticks' => 10,
                  'textAngle' => 45,
                  'textSize' => 8,
                  'gutter' => ['left' => 45, 'bottom' => 50, 'top' => 50],
                  'title' => $cntr,
                  'titleSize' => 12,
                  'titleBold' => false,
                  'tickmarks' => 'none',
                  'ymax' => 100,
                  'backgroundColor' => 'Gradient(red:orange:white)',
                  'backgroundGridAutofitNumvlines' => 10,
                  'key' => ['keyInteractive' => true],
                  'contextmenu' => [
                      ['24h', new JsExpression("function go() {window.location.assign(\"".Url::toRoute(['detail','cntr' => $cntrs[0], 'id' => $id, 'days' => 1 ])."\");}") ],
                      ['7 days',new JsExpression("function go() {window.location.assign(\"".Url::toRoute(['detail','cntr' => $cntrs[0], 'id' => $id, 'days' => 7 ])."\");}") ],
                      ['32 days',new JsExpression("function go() {window.location.assign(\"".Url::toRoute(['detail','cntr' => $cntrs[0], 'id' => $id, 'days' => 32 ])."\");}") ],
                      ['1 year', new JsExpression("function go() {window.location.assign(\"".Url::toRoute(['detail','cntr' => $cntrs[0], 'id' => $id, 'days' => 366 ])."\");}") ],
                      ['All', new JsExpression("function go() {window.location.assign(\"".Url::toRoute(['detail','cntr' => $cntrs[0], 'id' => $id, 'days' => 9999 ])."\");}") ],
                  ],
              ]
      ]);
      ? >

    </div>
       </div>
    </div>

The Versions

18/04 2018

dev-master

9999999-dev http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GPL-3.0 LGPL-3.0-or-later

The Requires

 

The Development Requires

yii2 rgraph

26/03 2018

dev-Entwicklung

dev-Entwicklung http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

yii2 rgraph

26/03 2018

1.0.0-alpha2

1.0.0.0-alpha2 http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

yii2 rgraph

19/02 2018

dev-develop

dev-develop http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GNU GENERAL PUBLIC LICENSE LGPL-3.0-or-later

The Development Requires

rgraph

19/02 2018

1.0.0-alpha1

1.0.0.0-alpha1 http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

LGPL-3.0-or-later

The Requires

 

The Development Requires

yii2 rgraph

02/12 2016

v0.0.6-alpha

0.0.6.0-alpha http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

yii2 rgraph

08/04 2016

v0.0.5-alpha

0.0.5.0-alpha http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

yii2 rgraph

06/04 2016
11/02 2016

v0.0.3-alpha

0.0.3.0-alpha http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

yii2 rgraph

05/01 2016

v0.0.2-alpha

0.0.2.0-alpha http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

yii2 rgraph

21/12 2015

v0.0.1-alpha

0.0.1.0-alpha http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

yii2 rgraph

15/12 2015

v0.0.0-alpha

0.0.0.0-alpha http://github.com/klikar3/yii2-rgraph

Graphing with RGraph

  Sources   Download

GNU GENERAL PUBLIC LICENSE

The Requires

 

The Development Requires

yii2 rgraph