Yii 1.1: morris-js

Morris.JS widget
12 followers

MorrisJS widget for Yii. Quite simple.

Requirements

None AFAIK. Just vanilla Yii :)

Usage

$this->widget('application.extensions.morris.MorrisChartWidget', array(
    'id'      => 'myChartElement',
    'options' => array(
        'chartType' => 'Area',
        'data'      => array(
            array('y' => 2006, 'a' => 100, 'b' => 90),
            array('y' => 2007, 'a' => 40, 'b' => 60),
            array('y' => 2008, 'a' => 50, 'b' => 10),
            array('y' => 2009, 'a' => 60, 'b' => 50),
            array('y' => 2010, 'a' => 60, 'b' => 40),
        ),
        'xkey'      => 'y',
        'ykeys'     => array('a', 'b'),
        'labels'    => array('Series A', 'Series B'),
    ),
));

Resources

Morris.js is included

Total 1 comment

#17105 report it
Bjorn at 2014/05/03 01:31pm
Function

Hi,

Thanks for this widget. I like Morris and used it already, but with a Widget is't more clean.

Got a question. I want to use the dateFormat option. But this is set as a string. But I want to set a function.

Like:

'dateFormat' => "function (d) { d = new Date(d); return d.getDate(); }",

But this won't work because it's not a function, but probaly seen as a string.

Update:

Well, it's very simple (just gotta know it) use the "js:" tag: It's a build in option to prevent the encode function from wrapping function declaration with quotes.

'dateFormat' => "js:function (d) { d = new Date(d); return d.getDate(); }",

Leave a comment

Please to leave your comment.

Create extension