PHPackages                             klikar3/rgraph - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. klikar3/rgraph

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

klikar3/rgraph
==============

Graphing with RGraph

1.0.0-beta.1(2y ago)086LGPL-3.0-or-laterPHPPHP &gt;=7.4.0

Since Dec 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/klikar3/yii2-RGraph)[ Packagist](https://packagist.org/packages/klikar3/rgraph)[ Docs](http://github.com/klikar3/yii2-rgraph)[ RSS](/packages/klikar3-rgraph/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (9)Dependencies (3)Versions (20)Used By (0)

yii2-RGraph
===========

[](#yii2-rgraph)

---

[![example.jpg](https://raw.githubusercontent.com/klikar3/yii2-RGraph/master/example.jpg)](https://raw.githubusercontent.com/klikar3/yii2-RGraph/master/example.jpg)oder [![example2.jpg](https://raw.githubusercontent.com/klikar3/yii2-RGraph/master/example2.jpg)](https://raw.githubusercontent.com/klikar3/yii2-RGraph/master/example2.jpg)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#oder)

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

[](http://www.rgraph.net/open-source)

Example:

\---- controller:

```
    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
