Yii 1.1: flot

EFlot plotting library encapsulation

This extension encapsulates the jQuery flot graph library see flot


Flot says:

Flot is a pure Javascript plotting library for jQuery. It produces graphical plots of arbitrary datasets on-the-fly client-side.

The focus is on simple usage (all settings are optional), attractive looks and interactive features like zooming and mouse tracking.

The plugin works with Internet Explorer 6/7/8, Firefox 2.x+, Safari 3.0+, Opera 9.5+ and Konqueror 4.x+ with the HTML canvas tag (the excanvas Javascript emulation helper is used for IE).



  • Yii 1.1 or above (not tested on 1.0 but might work)


  • Extract the release file under protected/extensions
  • The API doc is included in assets
  • the pie plugin is documented in assets/flotpie.html


See the following code example:

example view for flot graphs
// lines and bars in same graph
                'label'=> 'line', 
                'label'=> 'bars', 
                    'backgroundOpacity'=> 0.5
//Pie chart example
$format_func = <<<EOD
js:function(label, series){
    return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';}
            array('label'=>'cows', 'data'=>20),
            array('label'=>'sheep', 'data'=>20),
            array('label'=>'chickens', 'data'=>30),
            'series'=> array('pie'=>array(
                'radius'=> 3/4,
                'formatter'=> $format_func,
            'legend'=> array('show'=>false),

Change Log

May 4, 2010

  • Initial release.

May 5, 2010

  • V1.1
  • Rezipped to create EFlot dir under extensions
  • Cleaned up case errors in includes (thats what happens if you develop in Windows..)
  • t.b.d. auto include of other js-plugins when specified in data or options

Total 16 comments

#16362 report it
ASAP at 2014/02/14 09:50am
Yii 2

Dear community.

Now Flot Charts Extension is available for Yii 2


#15053 report it
mbetel at 2013/10/02 02:00pm
Maintaining EFlot

Hi Arthur (and others),

No sorry, I was not really planning on maintaining it, I just wrote it because I needed it and it did what I wanted it to do. I posted it so others could use it or change it according to their needs. Feel free to change or add to it! If I would have the time….. but then I also need to eat :)



#15052 report it
Artur Oliveira at 2013/10/02 01:43pm
Flot Update & Add Flot Plugins

Hi there

Do you plan on updating this plugin and maybe include some flot plugins ?


#15031 report it
teo_ne at 2013/09/30 11:10am


thanks a lot for your time saver extensions, but I have a question.

I can't manage how to show labels on hovering points in a line graph. My code is:

                                'xaxis'=> array('mode'=> "time", 'axisLabel'=> 'Settimana','timeformat'=>'%d-%m-%y'), 
                                'grid'=>array('borderWidth'=>null,'clickable'=> true,'hoverable'=> true)

The graph is hoverable as it change a bit while hovering a point, but it doesn't show any label. How can I make this happen?

#5929 report it
kusanagi at 2011/11/26 03:18pm
add legend

how can i add legend into diffenent div with id? by default legend show in main div or i need manually add new div for legend?

#5555 report it
toronto at 2011/10/20 05:13am
how to modify the label,x axis, and y?

Nice extension..it sure does gave me a clear light in the dark.

but may I ask you something? if I would like to modify the label name, X line data becomes month (ex:'Jan','Feb',etc), and Y data becomes Year ('2011','2012',etc). what should I do? is there are any documentation that I can read? Thank You for your kind response.

#5247 report it
mbetel at 2011/09/26 09:57am
Updating EFlot

Hi all,

Mostly I develop an extension when the need arises in one of my own projects. If it works for me then I'm happy, and when I think someone else might benefit I upload it. However, I'll look into updating Eflot, taking heed of the comments here when I have time, which soonest will be next weekend.

#5245 report it
Gordon Cowtan at 2011/09/26 07:27am

Just wondering if there's any plan to update this so that it incorporates the 0.7 release of flot?

Not being the world's greatest expert with either yii or flot it took me a while to realise that the reason one of the options I was specifying wasn't working was because I was reading the documentation for flot 0.7 and using flot 0.6. (I got round it eventually by just downloading flot 0.7 and overwriting the contents of the Eflot/assets directory. The 'yaxis'=>array('show'=>false) option then started working but obviously this might not work for all version related issues.)

#4977 report it
weirdcanada at 2011/09/02 05:29pm
Issue with TimeStamp xaxis


I'm trying to use a timestamped axis and it's not working (i.e. not generating dates on the x-axis, just the timestamp miliseconds). This might stem from the lack of double-quotes that gets generated for the "time" and "timeformat" options.

Here is my code:

                'label'=> 'line', 
                    'backgroundOpacity'=> 0.5

and the script that gets generated on the page looks like:

<script type="text/javascript">
jQuery(function($) {
$.plot($('#yw1'), [{'label':'line',
jQuery('body').undelegate('#yt0','click').delegate('#yt0','click',function(){if(confirm('Are you sure you want to delete this item?')) {jQuery.yii.submitForm(this,'/analytics/index.php?r=campaign/delete&id=256',{});return false;} else return false;});
#2584 report it
balrok at 2011/01/19 01:49pm
folder naming

definitly there is something wrong with the folder naming.. i changed the asset importpath:

-           $basePath=Yii::getPathOfAlias('application.extensions.Eflot.assets');
+           $basePath = dirname(__FILE__).DIRECTORY_SEPARATOR.'assets';

so i use EFlot now as foldername

#59 report it
sirganya at 2010/09/29 04:37pm
How Do I

add this plugin to the extension?


#522 report it
DarkNSF at 2010/05/05 07:39pm
nice implmenetation

great documentation.

#525 report it
mbetel at 2010/05/05 02:45am
path under extension

Sorry about that.. I'll rezip the package so it will create a dir EFlot under extensions.

#526 report it
mocapapa at 2010/05/04 09:12pm
very nice extension, though


#527 report it
mocapapa at 2010/05/04 09:09pm

I should say:

<Yii::import('application.extensions.Eflot.EFlotWidget'); >Yii::import('application.extensions.Eflot.EFlotWidget');

#528 report it
mocapapa at 2010/05/04 09:07pm
modification of the source needed???

It is not clear that we should make a directory of "Eflot" or "EFlot" under protected/extensions.

This package did not work until I made a directory of "Eflot" and made a modification as follows.

EFlotGraphWidget.php: <Yii::import('application.extensions.EFlot.EFlotWidget');

Yii: :import('application.extensions.Eflot.EFlotWidget');

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: mbetel
  • Category: User Interface
  • Votes: +15
  • Downloaded: 2,997 times
  • Created on: May 4, 2010
  • Last updated: May 6, 2010