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
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(); }",
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.