mdoc 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +8 -8
  2. data/README.md +2 -2
  3. data/examples/jqplot.html +62 -0
  4. data/examples/jqplot.md +8 -0
  5. data/examples/js/jquery.jqplot.css +259 -0
  6. data/examples/js/jquery.jqplot.js +11411 -0
  7. data/examples/js/jquery.jqplot.min.css +1 -0
  8. data/examples/js/jquery.jqplot.min.js +3 -0
  9. data/examples/js/jquery.js +9597 -0
  10. data/examples/js/jquery.min.js +5 -0
  11. data/examples/js/plugins/jqplot.BezierCurveRenderer.js +314 -0
  12. data/examples/js/plugins/jqplot.BezierCurveRenderer.min.js +3 -0
  13. data/examples/js/plugins/jqplot.barRenderer.js +801 -0
  14. data/examples/js/plugins/jqplot.barRenderer.min.js +3 -0
  15. data/examples/js/plugins/jqplot.blockRenderer.js +235 -0
  16. data/examples/js/plugins/jqplot.blockRenderer.min.js +3 -0
  17. data/examples/js/plugins/jqplot.bubbleRenderer.js +759 -0
  18. data/examples/js/plugins/jqplot.bubbleRenderer.min.js +3 -0
  19. data/examples/js/plugins/jqplot.canvasAxisLabelRenderer.js +203 -0
  20. data/examples/js/plugins/jqplot.canvasAxisLabelRenderer.min.js +3 -0
  21. data/examples/js/plugins/jqplot.canvasAxisTickRenderer.js +253 -0
  22. data/examples/js/plugins/jqplot.canvasAxisTickRenderer.min.js +3 -0
  23. data/examples/js/plugins/jqplot.canvasOverlay.js +1021 -0
  24. data/examples/js/plugins/jqplot.canvasOverlay.min.js +3 -0
  25. data/examples/js/plugins/jqplot.canvasTextRenderer.js +449 -0
  26. data/examples/js/plugins/jqplot.canvasTextRenderer.min.js +3 -0
  27. data/examples/js/plugins/jqplot.categoryAxisRenderer.js +679 -0
  28. data/examples/js/plugins/jqplot.categoryAxisRenderer.min.js +3 -0
  29. data/examples/js/plugins/jqplot.ciParser.js +116 -0
  30. data/examples/js/plugins/jqplot.ciParser.min.js +3 -0
  31. data/examples/js/plugins/jqplot.cursor.js +1108 -0
  32. data/examples/js/plugins/jqplot.cursor.min.js +3 -0
  33. data/examples/js/plugins/jqplot.dateAxisRenderer.js +741 -0
  34. data/examples/js/plugins/jqplot.dateAxisRenderer.min.js +3 -0
  35. data/examples/js/plugins/jqplot.donutRenderer.js +805 -0
  36. data/examples/js/plugins/jqplot.donutRenderer.min.js +3 -0
  37. data/examples/js/plugins/jqplot.dragable.js +225 -0
  38. data/examples/js/plugins/jqplot.dragable.min.js +3 -0
  39. data/examples/js/plugins/jqplot.enhancedLegendRenderer.js +305 -0
  40. data/examples/js/plugins/jqplot.enhancedLegendRenderer.min.js +3 -0
  41. data/examples/js/plugins/jqplot.funnelRenderer.js +943 -0
  42. data/examples/js/plugins/jqplot.funnelRenderer.min.js +3 -0
  43. data/examples/js/plugins/jqplot.highlighter.js +465 -0
  44. data/examples/js/plugins/jqplot.highlighter.min.js +3 -0
  45. data/examples/js/plugins/jqplot.json2.js +475 -0
  46. data/examples/js/plugins/jqplot.json2.min.js +3 -0
  47. data/examples/js/plugins/jqplot.logAxisRenderer.js +534 -0
  48. data/examples/js/plugins/jqplot.logAxisRenderer.min.js +3 -0
  49. data/examples/js/plugins/jqplot.mekkoAxisRenderer.js +611 -0
  50. data/examples/js/plugins/jqplot.mekkoAxisRenderer.min.js +3 -0
  51. data/examples/js/plugins/jqplot.mekkoRenderer.js +437 -0
  52. data/examples/js/plugins/jqplot.mekkoRenderer.min.js +3 -0
  53. data/examples/js/plugins/jqplot.meterGaugeRenderer.js +1029 -0
  54. data/examples/js/plugins/jqplot.meterGaugeRenderer.min.js +3 -0
  55. data/examples/js/plugins/jqplot.mobile.js +45 -0
  56. data/examples/js/plugins/jqplot.mobile.min.js +3 -0
  57. data/examples/js/plugins/jqplot.ohlcRenderer.js +373 -0
  58. data/examples/js/plugins/jqplot.ohlcRenderer.min.js +3 -0
  59. data/examples/js/plugins/jqplot.pieRenderer.js +904 -0
  60. data/examples/js/plugins/jqplot.pieRenderer.min.js +3 -0
  61. data/examples/js/plugins/jqplot.pointLabels.js +377 -0
  62. data/examples/js/plugins/jqplot.pointLabels.min.js +3 -0
  63. data/examples/js/plugins/jqplot.pyramidAxisRenderer.js +728 -0
  64. data/examples/js/plugins/jqplot.pyramidAxisRenderer.min.js +3 -0
  65. data/examples/js/plugins/jqplot.pyramidGridRenderer.js +429 -0
  66. data/examples/js/plugins/jqplot.pyramidGridRenderer.min.js +3 -0
  67. data/examples/js/plugins/jqplot.pyramidRenderer.js +514 -0
  68. data/examples/js/plugins/jqplot.pyramidRenderer.min.js +3 -0
  69. data/examples/js/plugins/jqplot.trendline.js +223 -0
  70. data/examples/js/plugins/jqplot.trendline.min.js +3 -0
  71. data/examples/js/raphael-min.js +11 -0
  72. data/examples/js/sequence-diagram-min.js +8 -0
  73. data/examples/js/underscore-min.js +5 -0
  74. data/lib/mdoc.rb +1 -0
  75. data/lib/mdoc/processor/jqplot.rb +48 -0
  76. data/lib/mdoc/version.rb +1 -1
  77. data/templates/default.html.erb +1 -1
  78. metadata +74 -2
@@ -0,0 +1,3 @@
1
+ /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com
2
+ jsDate | (c) 2010-2013 Chris Leonello
3
+ */(function(e){e.jqplot.DonutRenderer=function(){e.jqplot.LineRenderer.call(this)};e.jqplot.DonutRenderer.prototype=new e.jqplot.LineRenderer();e.jqplot.DonutRenderer.prototype.constructor=e.jqplot.DonutRenderer;e.jqplot.DonutRenderer.prototype.init=function(p,t){this.diameter=null;this.innerDiameter=null;this.thickness=null;this.padding=20;this.sliceMargin=0;this.ringMargin=null;this.fill=true;this.shadowOffset=2;this.shadowAlpha=0.07;this.shadowDepth=5;this.highlightMouseOver=true;this.highlightMouseDown=false;this.highlightColors=[];this.dataLabels="percent";this.showDataLabels=false;this.dataLabelFormatString=null;this.dataLabelThreshold=3;this.dataLabelPositionFactor=0.4;this.dataLabelNudge=0;this.startAngle=0;this.tickRenderer=e.jqplot.DonutTickRenderer;this._drawData=true;this._type="donut";if(p.highlightMouseDown&&p.highlightMouseOver==null){p.highlightMouseOver=false}e.extend(true,this,p);if(this.diameter!=null){this.diameter=this.diameter-this.sliceMargin}this._diameter=null;this._innerDiameter=null;this._radius=null;this._innerRadius=null;this._thickness=null;this._previousSeries=[];this._numberSeries=1;this._sliceAngles=[];this._highlightedPoint=null;if(this.highlightColors.length==0){for(var r=0;r<this.seriesColors.length;r++){var q=e.jqplot.getColorComponents(this.seriesColors[r]);var n=[q[0],q[1],q[2]];var s=n[0]+n[1]+n[2];for(var o=0;o<3;o++){n[o]=(s>570)?n[o]*0.8:n[o]+0.3*(255-n[o]);n[o]=parseInt(n[o],10)}this.highlightColors.push("rgb("+n[0]+","+n[1]+","+n[2]+")")}}t.postParseOptionsHooks.addOnce(l);t.postInitHooks.addOnce(g);t.eventListenerHooks.addOnce("jqplotMouseMove",b);t.eventListenerHooks.addOnce("jqplotMouseDown",a);t.eventListenerHooks.addOnce("jqplotMouseUp",j);t.eventListenerHooks.addOnce("jqplotClick",f);t.eventListenerHooks.addOnce("jqplotRightClick",m);t.postDrawHooks.addOnce(h)};e.jqplot.DonutRenderer.prototype.setGridData=function(s){var o=[];var t=[];var n=this.startAngle/180*Math.PI;var r=0;this._drawData=false;for(var q=0;q<this.data.length;q++){if(this.data[q][1]!=0){this._drawData=true}o.push(this.data[q][1]);t.push([this.data[q][0]]);if(q>0){o[q]+=o[q-1]}r+=this.data[q][1]}var p=Math.PI*2/o[o.length-1];for(var q=0;q<o.length;q++){t[q][1]=o[q]*p;t[q][2]=this.data[q][1]/r}this.gridData=t};e.jqplot.DonutRenderer.prototype.makeGridData=function(s,t){var o=[];var u=[];var r=0;var n=this.startAngle/180*Math.PI;this._drawData=false;for(var q=0;q<s.length;q++){if(this.data[q][1]!=0){this._drawData=true}o.push(s[q][1]);u.push([s[q][0]]);if(q>0){o[q]+=o[q-1]}r+=s[q][1]}var p=Math.PI*2/o[o.length-1];for(var q=0;q<o.length;q++){u[q][1]=o[q]*p;u[q][2]=s[q][1]/r}return u};e.jqplot.DonutRenderer.prototype.drawSlice=function(x,u,t,p,s){var n=this._diameter/2;var v=n-this._thickness;var w=this.fill;x.save();x.translate(this._center[0],this._center[1]);if(s){for(var q=0;q<this.shadowDepth;q++){x.save();x.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI),this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));o()}}else{o()}function o(){if(t>6.282+this.startAngle){t=6.282+this.startAngle;if(u>t){u=6.281+this.startAngle}}if(u>=t){return}x.beginPath();x.fillStyle=p;x.strokeStyle=p;x.arc(0,0,n,u,t,false);x.lineTo(v*Math.cos(t),v*Math.sin(t));x.arc(0,0,v,t,u,true);x.closePath();if(w){x.fill()}else{x.stroke()}}if(s){for(var q=0;q<this.shadowDepth;q++){x.restore()}}x.restore()};e.jqplot.DonutRenderer.prototype.draw=function(N,V,t,P){var Q;var J=(t!=undefined)?t:{};var q=0;var p=0;var u=1;if(t.legendInfo&&t.legendInfo.placement=="insideGrid"){var I=t.legendInfo;switch(I.location){case"nw":q=I.width+I.xoffset;break;case"w":q=I.width+I.xoffset;break;case"sw":q=I.width+I.xoffset;break;case"ne":q=I.width+I.xoffset;u=-1;break;case"e":q=I.width+I.xoffset;u=-1;break;case"se":q=I.width+I.xoffset;u=-1;break;case"n":p=I.height+I.yoffset;break;case"s":p=I.height+I.yoffset;u=-1;break;default:break}}var B=(J.shadow!=undefined)?J.shadow:this.shadow;var W=(J.showLine!=undefined)?J.showLine:this.showLine;var O=(J.fill!=undefined)?J.fill:this.fill;var s=N.canvas.width;var H=N.canvas.height;var G=s-q-2*this.padding;var R=H-p-2*this.padding;var v=Math.min(G,R);var T=v;var X=(this.ringMargin==null)?this.sliceMargin*2:this.ringMargin;for(var Q=0;Q<this._previousSeries.length;Q++){T-=2*this._previousSeries[Q]._thickness+2*X}this._diameter=this.diameter||T;if(this.innerDiameter!=null){var M=(this._numberSeries>1&&this.index>0)?this._previousSeries[0]._diameter:this._diameter;this._thickness=this.thickness||(M-this.innerDiameter-2*X*this._numberSeries)/this._numberSeries/2}else{this._thickness=this.thickness||v/2/(this._numberSeries+1)*0.85}var K=this._radius=this._diameter/2;this._innerRadius=this._radius-this._thickness;var o=this.startAngle/180*Math.PI;this._center=[(s-u*q)/2+u*q,(H-u*p)/2+u*p];if(this.shadow){var L="rgba(0,0,0,"+this.shadowAlpha+")";for(var Q=0;Q<V.length;Q++){var A=(Q==0)?o:V[Q-1][1]+o;A+=this.sliceMargin/180*Math.PI;this.renderer.drawSlice.call(this,N,A,V[Q][1]+o,L,true)}}for(var Q=0;Q<V.length;Q++){var A=(Q==0)?o:V[Q-1][1]+o;A+=this.sliceMargin/180*Math.PI;var z=V[Q][1]+o;this._sliceAngles.push([A,z]);this.renderer.drawSlice.call(this,N,A,z,this.seriesColors[Q],false);if(this.showDataLabels&&V[Q][2]*100>=this.dataLabelThreshold){var S,U=(A+z)/2,C;if(this.dataLabels=="label"){S=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(S,V[Q][0])}else{if(this.dataLabels=="value"){S=this.dataLabelFormatString||"%d";C=e.jqplot.sprintf(S,this.data[Q][1])}else{if(this.dataLabels=="percent"){S=this.dataLabelFormatString||"%d%%";C=e.jqplot.sprintf(S,V[Q][2]*100)}else{if(this.dataLabels.constructor==Array){S=this.dataLabelFormatString||"%s";C=e.jqplot.sprintf(S,this.dataLabels[Q])}}}}var n=this._innerRadius+this._thickness*this.dataLabelPositionFactor+this.sliceMargin+this.dataLabelNudge;var F=this._center[0]+Math.cos(U)*n+this.canvas._offsets.left;var E=this._center[1]+Math.sin(U)*n+this.canvas._offsets.top;var D=e('<span class="jqplot-donut-series jqplot-data-label" style="position:absolute;">'+C+"</span>").insertBefore(P.eventCanvas._elem);F-=D.width()/2;E-=D.height()/2;F=Math.round(F);E=Math.round(E);D.css({left:F,top:E})}}};e.jqplot.DonutAxisRenderer=function(){e.jqplot.LinearAxisRenderer.call(this)};e.jqplot.DonutAxisRenderer.prototype=new e.jqplot.LinearAxisRenderer();e.jqplot.DonutAxisRenderer.prototype.constructor=e.jqplot.DonutAxisRenderer;e.jqplot.DonutAxisRenderer.prototype.init=function(n){this.tickRenderer=e.jqplot.DonutTickRenderer;e.extend(true,this,n);this._dataBounds={min:0,max:100};this.min=0;this.max=100;this.showTicks=false;this.ticks=[];this.showMark=false;this.show=false};e.jqplot.DonutLegendRenderer=function(){e.jqplot.TableLegendRenderer.call(this)};e.jqplot.DonutLegendRenderer.prototype=new e.jqplot.TableLegendRenderer();e.jqplot.DonutLegendRenderer.prototype.constructor=e.jqplot.DonutLegendRenderer;e.jqplot.DonutLegendRenderer.prototype.init=function(n){this.numberRows=null;this.numberColumns=null;e.extend(true,this,n)};e.jqplot.DonutLegendRenderer.prototype.draw=function(){var q=this;if(this.show){var y=this._series;var B="position:absolute;";B+=(this.background)?"background:"+this.background+";":"";B+=(this.border)?"border:"+this.border+";":"";B+=(this.fontSize)?"font-size:"+this.fontSize+";":"";B+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";B+=(this.textColor)?"color:"+this.textColor+";":"";B+=(this.marginTop!=null)?"margin-top:"+this.marginTop+";":"";B+=(this.marginBottom!=null)?"margin-bottom:"+this.marginBottom+";":"";B+=(this.marginLeft!=null)?"margin-left:"+this.marginLeft+";":"";B+=(this.marginRight!=null)?"margin-right:"+this.marginRight+";":"";this._elem=e('<table class="jqplot-table-legend" style="'+B+'"></table>');var F=false,x=false,n,v;var z=y[0];var o=new e.jqplot.ColorGenerator(z.seriesColors);if(z.show){var G=z.data;if(this.numberRows){n=this.numberRows;if(!this.numberColumns){v=Math.ceil(G.length/n)}else{v=this.numberColumns}}else{if(this.numberColumns){v=this.numberColumns;n=Math.ceil(G.length/this.numberColumns)}else{n=G.length;v=1}}var E,D,p,t,r,u,w,C;var A=0;for(E=0;E<n;E++){if(x){p=e('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{p=e('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(D=0;D<v;D++){if(A<G.length){u=this.labels[A]||G[A][0].toString();C=o.next();if(!x){if(E>0){F=true}else{F=false}}else{if(E==n-1){F=false}else{F=true}}w=(F)?this.rowSpacing:"0";t=e('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+w+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+C+';"></div></div></td>');r=e('<td class="jqplot-table-legend" style="padding-top:'+w+';"></td>');if(this.escapeHtml){r.text(u)}else{r.html(u)}if(x){r.prependTo(p);t.prependTo(p)}else{t.appendTo(p);r.appendTo(p)}F=true}A++}}}}return this._elem};function c(r,q,o){o=o||{};o.axesDefaults=o.axesDefaults||{};o.legend=o.legend||{};o.seriesDefaults=o.seriesDefaults||{};var n=false;if(o.seriesDefaults.renderer==e.jqplot.DonutRenderer){n=true}else{if(o.series){for(var p=0;p<o.series.length;p++){if(o.series[p].renderer==e.jqplot.DonutRenderer){n=true}}}}if(n){o.axesDefaults.renderer=e.jqplot.DonutAxisRenderer;o.legend.renderer=e.jqplot.DonutLegendRenderer;o.legend.preDraw=true;o.seriesDefaults.pointLabels={show:false}}}function g(r,q,o){for(var p=1;p<this.series.length;p++){if(!this.series[p]._previousSeries.length){for(var n=0;n<p;n++){if(this.series[p].renderer.constructor==e.jqplot.DonutRenderer&&this.series[n].renderer.constructor==e.jqplot.DonutRenderer){this.series[p]._previousSeries.push(this.series[n])}}}}for(p=0;p<this.series.length;p++){if(this.series[p].renderer.constructor==e.jqplot.DonutRenderer){this.series[p]._numberSeries=this.series.length;if(this.series[p].highlightMouseOver){this.series[p].highlightMouseDown=false}}}}var k=false;function l(n){for(var o=0;o<this.series.length;o++){this.series[o].seriesColors=this.seriesColors;this.series[o].colorGenerator=e.jqplot.colorGenerator}}function d(r,q,p){var o=r.series[q];var n=r.plugins.donutRenderer.highlightCanvas;n._ctx.clearRect(0,0,n._ctx.canvas.width,n._ctx.canvas.height);o._highlightedPoint=p;r.plugins.donutRenderer.highlightedSeriesIndex=q;o.renderer.drawSlice.call(o,n._ctx,o._sliceAngles[p][0],o._sliceAngles[p][1],o.highlightColors[p],false)}function i(p){var n=p.plugins.donutRenderer.highlightCanvas;n._ctx.clearRect(0,0,n._ctx.canvas.width,n._ctx.canvas.height);for(var o=0;o<p.series.length;o++){p.series[o]._highlightedPoint=null}p.plugins.donutRenderer.highlightedSeriesIndex=null;p.target.trigger("jqplotDataUnhighlight")}function b(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var o=jQuery.Event("jqplotDataMouseOver");o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p);if(s.series[p[0]].highlightMouseOver&&!(p[0]==s.plugins.donutRenderer.highlightedSeriesIndex&&p[1]==s.series[p[0]]._highlightedPoint)){var n=jQuery.Event("jqplotDataHighlight");n.which=r.which;n.pageX=r.pageX;n.pageY=r.pageY;s.target.trigger(n,p);d(s,p[0],p[1])}}else{if(t==null){i(s)}}}function a(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];if(r.series[o[0]].highlightMouseDown&&!(o[0]==r.plugins.donutRenderer.highlightedSeriesIndex&&o[1]==r.series[o[0]]._highlightedPoint)){var n=jQuery.Event("jqplotDataHighlight");n.which=q.which;n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o);d(r,o[0],o[1])}}else{if(s==null){i(r)}}}function j(p,o,s,r,q){var n=q.plugins.donutRenderer.highlightedSeriesIndex;if(n!=null&&q.series[n].highlightMouseDown){i(q)}}function f(q,p,t,s,r){if(s){var o=[s.seriesIndex,s.pointIndex,s.data];var n=jQuery.Event("jqplotDataClick");n.which=q.which;n.pageX=q.pageX;n.pageY=q.pageY;r.target.trigger(n,o)}}function m(r,q,u,t,s){if(t){var p=[t.seriesIndex,t.pointIndex,t.data];var n=s.plugins.donutRenderer.highlightedSeriesIndex;if(n!=null&&s.series[n].highlightMouseDown){i(s)}var o=jQuery.Event("jqplotDataRightClick");o.which=r.which;o.pageX=r.pageX;o.pageY=r.pageY;s.target.trigger(o,p)}}function h(){if(this.plugins.donutRenderer&&this.plugins.donutRenderer.highlightCanvas){this.plugins.donutRenderer.highlightCanvas.resetCanvas();this.plugins.donutRenderer.highlightCanvas=null}this.plugins.donutRenderer={highlightedSeriesIndex:null};this.plugins.donutRenderer.highlightCanvas=new e.jqplot.GenericCanvas();var o=e(this.targetId+" .jqplot-data-label");if(o.length){e(o[0]).before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-donutRenderer-highlight-canvas",this._plotDimensions,this))}else{this.eventCanvas._elem.before(this.plugins.donutRenderer.highlightCanvas.createElement(this._gridPadding,"jqplot-donutRenderer-highlight-canvas",this._plotDimensions,this))}var n=this.plugins.donutRenderer.highlightCanvas.setContext();this.eventCanvas._elem.bind("mouseleave",{plot:this},function(p){i(p.data.plot)})}e.jqplot.preInitHooks.push(c);e.jqplot.DonutTickRenderer=function(){e.jqplot.AxisTickRenderer.call(this)};e.jqplot.DonutTickRenderer.prototype=new e.jqplot.AxisTickRenderer();e.jqplot.DonutTickRenderer.prototype.constructor=e.jqplot.DonutTickRenderer})(jQuery);
@@ -0,0 +1,225 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.8
6
+ * Revision: 1250
7
+ *
8
+ * Copyright (c) 2009-2013 Chris Leonello
9
+ * jqPlot is currently available for use in all personal or commercial projects
10
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
11
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
12
+ * choose the license that best suits your project and use it accordingly.
13
+ *
14
+ * Although not required, the author would appreciate an email letting him
15
+ * know of any substantial use of jqPlot. You can reach the author at:
16
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
17
+ *
18
+ * If you are feeling kind and generous, consider supporting the project by
19
+ * making a donation at: http://www.jqplot.com/donate.php .
20
+ *
21
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
22
+ *
23
+ * version 2007.04.27
24
+ * author Ash Searle
25
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
26
+ * http://hexmen.com/js/sprintf.js
27
+ * The author (Ash Searle) has placed this code in the public domain:
28
+ * "This code is unrestricted: you are free to use it however you like."
29
+ *
30
+ */
31
+ (function($) {
32
+
33
+ /**
34
+ * Class: $.jqplot.Dragable
35
+ * Plugin to make plotted points dragable by the user.
36
+ */
37
+ $.jqplot.Dragable = function(options) {
38
+ // Group: Properties
39
+ this.markerRenderer = new $.jqplot.MarkerRenderer({shadow:false});
40
+ this.shapeRenderer = new $.jqplot.ShapeRenderer();
41
+ this.isDragging = false;
42
+ this.isOver = false;
43
+ this._ctx;
44
+ this._elem;
45
+ this._point;
46
+ this._gridData;
47
+ // prop: color
48
+ // CSS color spec for the dragged point (and adjacent line segment or bar).
49
+ this.color;
50
+ // prop: constrainTo
51
+ // Constrain dragging motion to an axis or to none.
52
+ // Allowable values are 'none', 'x', 'y'
53
+ this.constrainTo = 'none'; // 'x', 'y', or 'none';
54
+ $.extend(true, this, options);
55
+ };
56
+
57
+ function DragCanvas() {
58
+ $.jqplot.GenericCanvas.call(this);
59
+ this.isDragging = false;
60
+ this.isOver = false;
61
+ this._neighbor;
62
+ this._cursors = [];
63
+ }
64
+
65
+ DragCanvas.prototype = new $.jqplot.GenericCanvas();
66
+ DragCanvas.prototype.constructor = DragCanvas;
67
+
68
+
69
+ // called within scope of series
70
+ $.jqplot.Dragable.parseOptions = function (defaults, opts) {
71
+ var options = opts || {};
72
+ this.plugins.dragable = new $.jqplot.Dragable(options.dragable);
73
+ // since this function is called before series options are parsed,
74
+ // we can set this here and it will be overridden if needed.
75
+ this.isDragable = $.jqplot.config.enablePlugins;
76
+ };
77
+
78
+ // called within context of plot
79
+ // create a canvas which we can draw on.
80
+ // insert it before the eventCanvas, so eventCanvas will still capture events.
81
+ // add a new DragCanvas object to the plot plugins to handle drawing on this new canvas.
82
+ $.jqplot.Dragable.postPlotDraw = function() {
83
+ // Memory Leaks patch
84
+ if (this.plugins.dragable && this.plugins.dragable.highlightCanvas) {
85
+ this.plugins.dragable.highlightCanvas.resetCanvas();
86
+ this.plugins.dragable.highlightCanvas = null;
87
+ }
88
+
89
+ this.plugins.dragable = {previousCursor:'auto', isOver:false};
90
+ this.plugins.dragable.dragCanvas = new DragCanvas();
91
+
92
+ this.eventCanvas._elem.before(this.plugins.dragable.dragCanvas.createElement(this._gridPadding, 'jqplot-dragable-canvas', this._plotDimensions, this));
93
+ var dctx = this.plugins.dragable.dragCanvas.setContext();
94
+ };
95
+
96
+ //$.jqplot.preInitHooks.push($.jqplot.Dragable.init);
97
+ $.jqplot.preParseSeriesOptionsHooks.push($.jqplot.Dragable.parseOptions);
98
+ $.jqplot.postDrawHooks.push($.jqplot.Dragable.postPlotDraw);
99
+ $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]);
100
+ $.jqplot.eventListenerHooks.push(['jqplotMouseDown', handleDown]);
101
+ $.jqplot.eventListenerHooks.push(['jqplotMouseUp', handleUp]);
102
+
103
+
104
+ function initDragPoint(plot, neighbor) {
105
+ var s = plot.series[neighbor.seriesIndex];
106
+ var drag = s.plugins.dragable;
107
+
108
+ // first, init the mark renderer for the dragged point
109
+ var smr = s.markerRenderer;
110
+ var mr = drag.markerRenderer;
111
+ mr.style = smr.style;
112
+ mr.lineWidth = smr.lineWidth + 2.5;
113
+ mr.size = smr.size + 5;
114
+ if (!drag.color) {
115
+ var rgba = $.jqplot.getColorComponents(smr.color);
116
+ var newrgb = [rgba[0], rgba[1], rgba[2]];
117
+ var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]);
118
+ drag.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')';
119
+ }
120
+ mr.color = drag.color;
121
+ mr.init();
122
+
123
+ var start = (neighbor.pointIndex > 0) ? neighbor.pointIndex - 1 : 0;
124
+ var end = neighbor.pointIndex+2;
125
+ drag._gridData = s.gridData.slice(start, end);
126
+ }
127
+
128
+ function handleMove(ev, gridpos, datapos, neighbor, plot) {
129
+ if (plot.plugins.dragable.dragCanvas.isDragging) {
130
+ var dc = plot.plugins.dragable.dragCanvas;
131
+ var dp = dc._neighbor;
132
+ var s = plot.series[dp.seriesIndex];
133
+ var drag = s.plugins.dragable;
134
+ var gd = s.gridData;
135
+
136
+ // compute the new grid position with any constraints.
137
+ var x = (drag.constrainTo == 'y') ? dp.gridData[0] : gridpos.x;
138
+ var y = (drag.constrainTo == 'x') ? dp.gridData[1] : gridpos.y;
139
+
140
+ // compute data values for any listeners.
141
+ var xu = s._xaxis.series_p2u(x);
142
+ var yu = s._yaxis.series_p2u(y);
143
+
144
+ // clear the canvas then redraw effect at new position.
145
+ var ctx = dc._ctx;
146
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
147
+
148
+ // adjust our gridData for the new mouse position
149
+ if (dp.pointIndex > 0) {
150
+ drag._gridData[1] = [x, y];
151
+ }
152
+ else {
153
+ drag._gridData[0] = [x, y];
154
+ }
155
+ plot.series[dp.seriesIndex].draw(dc._ctx, {gridData:drag._gridData, shadow:false, preventJqPlotSeriesDrawTrigger:true, color:drag.color, markerOptions:{color:drag.color, shadow:false}, trendline:{show:false}});
156
+ plot.target.trigger('jqplotSeriesPointChange', [dp.seriesIndex, dp.pointIndex, [xu,yu], [x,y]]);
157
+ }
158
+ else if (neighbor != null) {
159
+ var series = plot.series[neighbor.seriesIndex];
160
+ if (series.isDragable) {
161
+ var dc = plot.plugins.dragable.dragCanvas;
162
+ if (!dc.isOver) {
163
+ dc._cursors.push(ev.target.style.cursor);
164
+ ev.target.style.cursor = "pointer";
165
+ }
166
+ dc.isOver = true;
167
+ }
168
+ }
169
+ else if (neighbor == null) {
170
+ var dc = plot.plugins.dragable.dragCanvas;
171
+ if (dc.isOver) {
172
+ ev.target.style.cursor = dc._cursors.pop();
173
+ dc.isOver = false;
174
+ }
175
+ }
176
+ }
177
+
178
+ function handleDown(ev, gridpos, datapos, neighbor, plot) {
179
+ var dc = plot.plugins.dragable.dragCanvas;
180
+ dc._cursors.push(ev.target.style.cursor);
181
+ if (neighbor != null) {
182
+ var s = plot.series[neighbor.seriesIndex];
183
+ var drag = s.plugins.dragable;
184
+ if (s.isDragable && !dc.isDragging) {
185
+ dc._neighbor = neighbor;
186
+ dc.isDragging = true;
187
+ initDragPoint(plot, neighbor);
188
+ drag.markerRenderer.draw(s.gridData[neighbor.pointIndex][0], s.gridData[neighbor.pointIndex][1], dc._ctx);
189
+ ev.target.style.cursor = "move";
190
+ plot.target.trigger('jqplotDragStart', [neighbor.seriesIndex, neighbor.pointIndex, gridpos, datapos]);
191
+ }
192
+ }
193
+ // Just in case of a hickup, we'll clear the drag canvas and reset.
194
+ else {
195
+ var ctx = dc._ctx;
196
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
197
+ dc.isDragging = false;
198
+ }
199
+ }
200
+
201
+ function handleUp(ev, gridpos, datapos, neighbor, plot) {
202
+ if (plot.plugins.dragable.dragCanvas.isDragging) {
203
+ var dc = plot.plugins.dragable.dragCanvas;
204
+ // clear the canvas
205
+ var ctx = dc._ctx;
206
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
207
+ dc.isDragging = false;
208
+ // redraw the series canvas at the new point.
209
+ var dp = dc._neighbor;
210
+ var s = plot.series[dp.seriesIndex];
211
+ var drag = s.plugins.dragable;
212
+ // compute the new grid position with any constraints.
213
+ var x = (drag.constrainTo == 'y') ? dp.data[0] : datapos[s.xaxis];
214
+ var y = (drag.constrainTo == 'x') ? dp.data[1] : datapos[s.yaxis];
215
+ // var x = datapos[s.xaxis];
216
+ // var y = datapos[s.yaxis];
217
+ s.data[dp.pointIndex][0] = x;
218
+ s.data[dp.pointIndex][1] = y;
219
+ plot.drawSeries({preventJqPlotSeriesDrawTrigger:true}, dp.seriesIndex);
220
+ dc._neighbor = null;
221
+ ev.target.style.cursor = dc._cursors.pop();
222
+ plot.target.trigger('jqplotDragStop', [gridpos, datapos]);
223
+ }
224
+ }
225
+ })(jQuery);
@@ -0,0 +1,3 @@
1
+ /* jqPlot 1.0.8r1250 | (c) 2009-2013 Chris Leonello | jplot.com
2
+ jsDate | (c) 2010-2013 Chris Leonello
3
+ */(function(d){d.jqplot.Dragable=function(g){this.markerRenderer=new d.jqplot.MarkerRenderer({shadow:false});this.shapeRenderer=new d.jqplot.ShapeRenderer();this.isDragging=false;this.isOver=false;this._ctx;this._elem;this._point;this._gridData;this.color;this.constrainTo="none";d.extend(true,this,g)};function b(){d.jqplot.GenericCanvas.call(this);this.isDragging=false;this.isOver=false;this._neighbor;this._cursors=[]}b.prototype=new d.jqplot.GenericCanvas();b.prototype.constructor=b;d.jqplot.Dragable.parseOptions=function(i,h){var g=h||{};this.plugins.dragable=new d.jqplot.Dragable(g.dragable);this.isDragable=d.jqplot.config.enablePlugins};d.jqplot.Dragable.postPlotDraw=function(){if(this.plugins.dragable&&this.plugins.dragable.highlightCanvas){this.plugins.dragable.highlightCanvas.resetCanvas();this.plugins.dragable.highlightCanvas=null}this.plugins.dragable={previousCursor:"auto",isOver:false};this.plugins.dragable.dragCanvas=new b();this.eventCanvas._elem.before(this.plugins.dragable.dragCanvas.createElement(this._gridPadding,"jqplot-dragable-canvas",this._plotDimensions,this));var g=this.plugins.dragable.dragCanvas.setContext()};d.jqplot.preParseSeriesOptionsHooks.push(d.jqplot.Dragable.parseOptions);d.jqplot.postDrawHooks.push(d.jqplot.Dragable.postPlotDraw);d.jqplot.eventListenerHooks.push(["jqplotMouseMove",e]);d.jqplot.eventListenerHooks.push(["jqplotMouseDown",c]);d.jqplot.eventListenerHooks.push(["jqplotMouseUp",a]);function f(n,p){var q=n.series[p.seriesIndex];var m=q.plugins.dragable;var h=q.markerRenderer;var i=m.markerRenderer;i.style=h.style;i.lineWidth=h.lineWidth+2.5;i.size=h.size+5;if(!m.color){var l=d.jqplot.getColorComponents(h.color);var o=[l[0],l[1],l[2]];var k=(l[3]>=0.6)?l[3]*0.6:l[3]*(2-l[3]);m.color="rgba("+o[0]+","+o[1]+","+o[2]+","+k+")"}i.color=m.color;i.init();var g=(p.pointIndex>0)?p.pointIndex-1:0;var j=p.pointIndex+2;m._gridData=q.gridData.slice(g,j)}function e(o,l,h,t,m){if(m.plugins.dragable.dragCanvas.isDragging){var u=m.plugins.dragable.dragCanvas;var i=u._neighbor;var w=m.series[i.seriesIndex];var k=w.plugins.dragable;var r=w.gridData;var p=(k.constrainTo=="y")?i.gridData[0]:l.x;var n=(k.constrainTo=="x")?i.gridData[1]:l.y;var g=w._xaxis.series_p2u(p);var q=w._yaxis.series_p2u(n);var v=u._ctx;v.clearRect(0,0,v.canvas.width,v.canvas.height);if(i.pointIndex>0){k._gridData[1]=[p,n]}else{k._gridData[0]=[p,n]}m.series[i.seriesIndex].draw(u._ctx,{gridData:k._gridData,shadow:false,preventJqPlotSeriesDrawTrigger:true,color:k.color,markerOptions:{color:k.color,shadow:false},trendline:{show:false}});m.target.trigger("jqplotSeriesPointChange",[i.seriesIndex,i.pointIndex,[g,q],[p,n]])}else{if(t!=null){var j=m.series[t.seriesIndex];if(j.isDragable){var u=m.plugins.dragable.dragCanvas;if(!u.isOver){u._cursors.push(o.target.style.cursor);o.target.style.cursor="pointer"}u.isOver=true}}else{if(t==null){var u=m.plugins.dragable.dragCanvas;if(u.isOver){o.target.style.cursor=u._cursors.pop();u.isOver=false}}}}}function c(k,i,g,l,j){var m=j.plugins.dragable.dragCanvas;m._cursors.push(k.target.style.cursor);if(l!=null){var o=j.series[l.seriesIndex];var h=o.plugins.dragable;if(o.isDragable&&!m.isDragging){m._neighbor=l;m.isDragging=true;f(j,l);h.markerRenderer.draw(o.gridData[l.pointIndex][0],o.gridData[l.pointIndex][1],m._ctx);k.target.style.cursor="move";j.target.trigger("jqplotDragStart",[l.seriesIndex,l.pointIndex,i,g])}}else{var n=m._ctx;n.clearRect(0,0,n.canvas.width,n.canvas.height);m.isDragging=false}}function a(m,j,g,o,k){if(k.plugins.dragable.dragCanvas.isDragging){var p=k.plugins.dragable.dragCanvas;var q=p._ctx;q.clearRect(0,0,q.canvas.width,q.canvas.height);p.isDragging=false;var h=p._neighbor;var r=k.series[h.seriesIndex];var i=r.plugins.dragable;var n=(i.constrainTo=="y")?h.data[0]:g[r.xaxis];var l=(i.constrainTo=="x")?h.data[1]:g[r.yaxis];r.data[h.pointIndex][0]=n;r.data[h.pointIndex][1]=l;k.drawSeries({preventJqPlotSeriesDrawTrigger:true},h.seriesIndex);p._neighbor=null;m.target.style.cursor=p._cursors.pop();k.target.trigger("jqplotDragStop",[j,g])}}})(jQuery);
@@ -0,0 +1,305 @@
1
+ /**
2
+ * jqPlot
3
+ * Pure JavaScript plotting plugin using jQuery
4
+ *
5
+ * Version: 1.0.8
6
+ * Revision: 1250
7
+ *
8
+ * Copyright (c) 2009-2013 Chris Leonello
9
+ * jqPlot is currently available for use in all personal or commercial projects
10
+ * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
11
+ * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
12
+ * choose the license that best suits your project and use it accordingly.
13
+ *
14
+ * Although not required, the author would appreciate an email letting him
15
+ * know of any substantial use of jqPlot. You can reach the author at:
16
+ * chris at jqplot dot com or see http://www.jqplot.com/info.php .
17
+ *
18
+ * If you are feeling kind and generous, consider supporting the project by
19
+ * making a donation at: http://www.jqplot.com/donate.php .
20
+ *
21
+ * sprintf functions contained in jqplot.sprintf.js by Ash Searle:
22
+ *
23
+ * version 2007.04.27
24
+ * author Ash Searle
25
+ * http://hexmen.com/blog/2007/03/printf-sprintf/
26
+ * http://hexmen.com/js/sprintf.js
27
+ * The author (Ash Searle) has placed this code in the public domain:
28
+ * "This code is unrestricted: you are free to use it however you like."
29
+ *
30
+ */
31
+ (function($) {
32
+ // class $.jqplot.EnhancedLegendRenderer
33
+ // Legend renderer which can specify the number of rows and/or columns in the legend.
34
+ $.jqplot.EnhancedLegendRenderer = function(){
35
+ $.jqplot.TableLegendRenderer.call(this);
36
+ };
37
+
38
+ $.jqplot.EnhancedLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
39
+ $.jqplot.EnhancedLegendRenderer.prototype.constructor = $.jqplot.EnhancedLegendRenderer;
40
+
41
+ // called with scope of legend.
42
+ $.jqplot.EnhancedLegendRenderer.prototype.init = function(options) {
43
+ // prop: numberRows
44
+ // Maximum number of rows in the legend. 0 or null for unlimited.
45
+ this.numberRows = null;
46
+ // prop: numberColumns
47
+ // Maximum number of columns in the legend. 0 or null for unlimited.
48
+ this.numberColumns = null;
49
+ // prop: seriesToggle
50
+ // false to not enable series on/off toggling on the legend.
51
+ // true or a fadein/fadeout speed (number of milliseconds or 'fast', 'normal', 'slow')
52
+ // to enable show/hide of series on click of legend item.
53
+ this.seriesToggle = 'normal';
54
+ // prop: seriesToggleReplot
55
+ // True to replot the chart after toggling series on/off.
56
+ // This will set the series show property to false.
57
+ // This allows for rescaling or other maniplation of chart.
58
+ // Set to an options object (e.g. {resetAxes: true}) for replot options.
59
+ this.seriesToggleReplot = false;
60
+ // prop: disableIEFading
61
+ // true to toggle series with a show/hide method only and not allow fading in/out.
62
+ // This is to overcome poor performance of fade in some versions of IE.
63
+ this.disableIEFading = true;
64
+ $.extend(true, this, options);
65
+
66
+ if (this.seriesToggle) {
67
+ $.jqplot.postDrawHooks.push(postDraw);
68
+ }
69
+ };
70
+
71
+ // called with scope of legend
72
+ $.jqplot.EnhancedLegendRenderer.prototype.draw = function(offsets, plot) {
73
+ var legend = this;
74
+ if (this.show) {
75
+ var series = this._series;
76
+ var s;
77
+ var ss = 'position:absolute;';
78
+ ss += (this.background) ? 'background:'+this.background+';' : '';
79
+ ss += (this.border) ? 'border:'+this.border+';' : '';
80
+ ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
81
+ ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
82
+ ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
83
+ ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : '';
84
+ ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : '';
85
+ ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : '';
86
+ ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : '';
87
+ this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
88
+ if (this.seriesToggle) {
89
+ this._elem.css('z-index', '3');
90
+ }
91
+
92
+ var pad = false,
93
+ reverse = false,
94
+ nr, nc;
95
+ if (this.numberRows) {
96
+ nr = this.numberRows;
97
+ if (!this.numberColumns){
98
+ nc = Math.ceil(series.length/nr);
99
+ }
100
+ else{
101
+ nc = this.numberColumns;
102
+ }
103
+ }
104
+ else if (this.numberColumns) {
105
+ nc = this.numberColumns;
106
+ nr = Math.ceil(series.length/this.numberColumns);
107
+ }
108
+ else {
109
+ nr = series.length;
110
+ nc = 1;
111
+ }
112
+
113
+ var i, j, tr, td1, td2, lt, rs, div, div0, div1;
114
+ var idx = 0;
115
+ // check to see if we need to reverse
116
+ for (i=series.length-1; i>=0; i--) {
117
+ if (nc == 1 && series[i]._stack || series[i].renderer.constructor == $.jqplot.BezierCurveRenderer){
118
+ reverse = true;
119
+ }
120
+ }
121
+
122
+ for (i=0; i<nr; i++) {
123
+ tr = $(document.createElement('tr'));
124
+ tr.addClass('jqplot-table-legend');
125
+ if (reverse){
126
+ tr.prependTo(this._elem);
127
+ }
128
+ else{
129
+ tr.appendTo(this._elem);
130
+ }
131
+ for (j=0; j<nc; j++) {
132
+ if (idx < series.length && (series[idx].show || series[idx].showLabel)){
133
+ s = series[idx];
134
+ lt = this.labels[idx] || s.label.toString();
135
+ if (lt) {
136
+ var color = s.color;
137
+ if (!reverse){
138
+ if (i>0){
139
+ pad = true;
140
+ }
141
+ else{
142
+ pad = false;
143
+ }
144
+ }
145
+ else{
146
+ if (i == nr -1){
147
+ pad = false;
148
+ }
149
+ else{
150
+ pad = true;
151
+ }
152
+ }
153
+ rs = (pad) ? this.rowSpacing : '0';
154
+
155
+ td1 = $(document.createElement('td'));
156
+ td1.addClass('jqplot-table-legend jqplot-table-legend-swatch');
157
+ td1.css({textAlign: 'center', paddingTop: rs});
158
+
159
+ div0 = $(document.createElement('div'));
160
+ div0.addClass('jqplot-table-legend-swatch-outline');
161
+ div1 = $(document.createElement('div'));
162
+ div1.addClass('jqplot-table-legend-swatch');
163
+ div1.css({backgroundColor: color, borderColor: color});
164
+
165
+ td1.append(div0.append(div1));
166
+
167
+ td2 = $(document.createElement('td'));
168
+ td2.addClass('jqplot-table-legend jqplot-table-legend-label');
169
+ td2.css('paddingTop', rs);
170
+
171
+ // td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
172
+ // '<div><div class="jqplot-table-legend-swatch" style="background-color:'+color+';border-color:'+color+';"></div>'+
173
+ // '</div></td>');
174
+ // td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
175
+ if (this.escapeHtml){
176
+ td2.text(lt);
177
+ }
178
+ else {
179
+ td2.html(lt);
180
+ }
181
+ if (reverse) {
182
+ if (this.showLabels) {td2.prependTo(tr);}
183
+ if (this.showSwatches) {td1.prependTo(tr);}
184
+ }
185
+ else {
186
+ if (this.showSwatches) {td1.appendTo(tr);}
187
+ if (this.showLabels) {td2.appendTo(tr);}
188
+ }
189
+
190
+ if (this.seriesToggle) {
191
+
192
+ // add an overlay for clicking series on/off
193
+ // div0 = $(document.createElement('div'));
194
+ // div0.addClass('jqplot-table-legend-overlay');
195
+ // div0.css({position:'relative', left:0, top:0, height:'100%', width:'100%'});
196
+ // tr.append(div0);
197
+
198
+ var speed;
199
+ if (typeof(this.seriesToggle) === 'string' || typeof(this.seriesToggle) === 'number') {
200
+ if (!$.jqplot.use_excanvas || !this.disableIEFading) {
201
+ speed = this.seriesToggle;
202
+ }
203
+ }
204
+ if (this.showSwatches) {
205
+ td1.bind('click', {series:s, speed:speed, plot: plot, replot:this.seriesToggleReplot}, handleToggle);
206
+ td1.addClass('jqplot-seriesToggle');
207
+ }
208
+ if (this.showLabels) {
209
+ td2.bind('click', {series:s, speed:speed, plot: plot, replot:this.seriesToggleReplot}, handleToggle);
210
+ td2.addClass('jqplot-seriesToggle');
211
+ }
212
+
213
+ // for series that are already hidden, add the hidden class
214
+ if (!s.show && s.showLabel) {
215
+ td1.addClass('jqplot-series-hidden');
216
+ td2.addClass('jqplot-series-hidden');
217
+ }
218
+ }
219
+
220
+ pad = true;
221
+ }
222
+ }
223
+ idx++;
224
+ }
225
+
226
+ td1 = td2 = div0 = div1 = null;
227
+ }
228
+ }
229
+ return this._elem;
230
+ };
231
+
232
+ var handleToggle = function (ev) {
233
+ var d = ev.data,
234
+ s = d.series,
235
+ replot = d.replot,
236
+ plot = d.plot,
237
+ speed = d.speed,
238
+ sidx = s.index,
239
+ showing = false;
240
+
241
+ if (s.canvas._elem.is(':hidden') || !s.show) {
242
+ showing = true;
243
+ }
244
+
245
+ var doLegendToggle = function() {
246
+
247
+ if (replot) {
248
+ var opts = {};
249
+
250
+ if ($.isPlainObject(replot)) {
251
+ $.extend(true, opts, replot);
252
+ }
253
+
254
+ plot.replot(opts);
255
+ // if showing, there was no canvas element to fade in, so hide here
256
+ // and then do a fade in.
257
+ if (showing && speed) {
258
+ var s = plot.series[sidx];
259
+
260
+ if (s.shadowCanvas._elem) {
261
+ s.shadowCanvas._elem.hide().fadeIn(speed);
262
+ }
263
+ s.canvas._elem.hide().fadeIn(speed);
264
+ s.canvas._elem.nextAll('.jqplot-point-label.jqplot-series-'+s.index).hide().fadeIn(speed);
265
+ }
266
+
267
+ }
268
+
269
+ else {
270
+ var s = plot.series[sidx];
271
+
272
+ if (s.canvas._elem.is(':hidden') || !s.show) {
273
+ // Not sure if there is a better way to check for showSwatches and showLabels === true.
274
+ // Test for "undefined" since default values for both showSwatches and showLables is true.
275
+ if (typeof plot.options.legend.showSwatches === 'undefined' || plot.options.legend.showSwatches === true) {
276
+ plot.legend._elem.find('td').eq(sidx * 2).addClass('jqplot-series-hidden');
277
+ }
278
+ if (typeof plot.options.legend.showLabels === 'undefined' || plot.options.legend.showLabels === true) {
279
+ plot.legend._elem.find('td').eq((sidx * 2) + 1).addClass('jqplot-series-hidden');
280
+ }
281
+ }
282
+ else {
283
+ if (typeof plot.options.legend.showSwatches === 'undefined' || plot.options.legend.showSwatches === true) {
284
+ plot.legend._elem.find('td').eq(sidx * 2).removeClass('jqplot-series-hidden');
285
+ }
286
+ if (typeof plot.options.legend.showLabels === 'undefined' || plot.options.legend.showLabels === true) {
287
+ plot.legend._elem.find('td').eq((sidx * 2) + 1).removeClass('jqplot-series-hidden');
288
+ }
289
+ }
290
+
291
+ }
292
+
293
+ };
294
+
295
+ s.toggleDisplay(ev, doLegendToggle);
296
+ };
297
+
298
+ // called with scope of plot.
299
+ var postDraw = function () {
300
+ if (this.legend.renderer.constructor == $.jqplot.EnhancedLegendRenderer && this.legend.seriesToggle){
301
+ var e = this.legend._elem.detach();
302
+ this.eventCanvas._elem.after(e);
303
+ }
304
+ };
305
+ })(jQuery);