Index: trunk/extensions/SemanticResultFormats/RELEASE-NOTES |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | * Added warning icon with tooltip to jqplotpie shown when there are no results instead of a non-working chart. |
11 | 11 | * Added value distribution support to jqplotpie and jqplotbar. |
12 | 12 | * Added min parameter to jqplotbar to set the minimun value for the Y-axis. |
| 13 | +* Added pointlabel parameter to jqplotbar, based on a patch by James Hong Kong. |
13 | 14 | |
14 | 15 | New formats in this version are: |
15 | 16 | * valuerank (written by DaSch) |
Index: trunk/extensions/SemanticResultFormats/SRF_Messages.php |
— | — | @@ -78,6 +78,7 @@ |
79 | 79 | 'srf_paramdesc_bardirection'=> 'The direction of the bar chart', |
80 | 80 | 'srf_paramdesc_barnumbersaxislabel' => 'The label for the numbers axis', |
81 | 81 | 'srf-paramdesc-minvalue' => 'The minimum value to show on the Y-axis', |
| 82 | + 'srf-paramdesc-pointlabels' => 'Display of individual data points', |
82 | 83 | |
83 | 84 | // "gallery" format |
84 | 85 | 'srf_printername_gallery' => 'Gallery', |
Index: trunk/extensions/SemanticResultFormats/jqPlot/jqplot.pointLabels.min.js |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +/** |
| 3 | + * jqPlot |
| 4 | + * Pure JavaScript plotting plugin using jQuery |
| 5 | + * |
| 6 | + * Version: 1.0.0b2_r947 |
| 7 | + * |
| 8 | + * Copyright (c) 2009-2011 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 | + * included jsDate library by Chris Leonello: |
| 31 | + * |
| 32 | + * Copyright (c) 2010-2011 Chris Leonello |
| 33 | + * |
| 34 | + * jsDate is currently available for use in all personal or commercial projects |
| 35 | + * under both the MIT and GPL version 2.0 licenses. This means that you can |
| 36 | + * choose the license that best suits your project and use it accordingly. |
| 37 | + * |
| 38 | + * jsDate borrows many concepts and ideas from the Date Instance |
| 39 | + * Methods by Ken Snyder along with some parts of Ken's actual code. |
| 40 | + * |
| 41 | + * Ken's origianl Date Instance Methods and copyright notice: |
| 42 | + * |
| 43 | + * Ken Snyder (ken d snyder at gmail dot com) |
| 44 | + * 2008-09-10 |
| 45 | + * version 2.0.2 (http://kendsnyder.com/sandbox/date/) |
| 46 | + * Creative Commons Attribution License 3.0 (http://creativecommons.org/licenses/by/3.0/) |
| 47 | + * |
| 48 | + * jqplotToImage function based on Larry Siden's export-jqplot-to-png.js. |
| 49 | + * Larry has generously given permission to adapt his code for inclusion |
| 50 | + * into jqPlot. |
| 51 | + * |
| 52 | + * Larry's original code can be found here: |
| 53 | + * |
| 54 | + * https://github.com/lsiden/export-jqplot-to-png |
| 55 | + * |
| 56 | + * |
| 57 | + */ |
| 58 | +(function(c){c.jqplot.PointLabels=function(e){this.show=c.jqplot.config.enablePlugins;this.location="n";this.labelsFromSeries=false;this.seriesLabelIndex=null;this.labels=[];this._labels=[];this.stackedValue=false;this.ypadding=6;this.xpadding=6;this.escapeHTML=true;this.edgeTolerance=-5;this.formatter=c.jqplot.DefaultTickFormatter;this.formatString="";this.hideZeros=false;this._elems=[];c.extend(true,this,e)};var a=["nw","n","ne","e","se","s","sw","w"];var d={nw:0,n:1,ne:2,e:3,se:4,s:5,sw:6,w:7};var b=["se","s","sw","w","nw","n","ne","e"];c.jqplot.PointLabels.init=function(i,h,f,g){var e=c.extend(true,{},f,g);e.pointLabels=e.pointLabels||{};if(this.renderer.constructor===c.jqplot.BarRenderer&&this.barDirection==="horizontal"&&!e.pointLabels.location){e.pointLabels.location="e"}this.plugins.pointLabels=new c.jqplot.PointLabels(e.pointLabels);this.plugins.pointLabels.setLabels.call(this)};c.jqplot.PointLabels.prototype.setLabels=function(){var f=this.plugins.pointLabels;var h;if(f.seriesLabelIndex!=null){h=f.seriesLabelIndex}else{if(this.renderer.constructor===c.jqplot.BarRenderer&&this.barDirection==="horizontal"){h=0}else{h=(this._plotData.length===0)?0:this._plotData[0].length-1}}f._labels=[];if(f.labels.length===0||f.labelsFromSeries){if(f.stackedValue){if(this._plotData.length&&this._plotData[0].length){for(var e=0;e<this._plotData.length;e++){f._labels.push(this._plotData[e][h])}}}else{var g=this._plotData;if(this.renderer.constructor===c.jqplot.BarRenderer&&this.waterfall){g=this._data}if(g.length&&g[0].length){for(var e=0;e<g.length;e++){f._labels.push(g[e][h])}}g=null}}else{if(f.labels.length){f._labels=f.labels}}};c.jqplot.PointLabels.prototype.xOffset=function(f,e,g){e=e||this.location;g=g||this.xpadding;var h;switch(e){case"nw":h=-f.outerWidth(true)-this.xpadding;break;case"n":h=-f.outerWidth(true)/2;break;case"ne":h=this.xpadding;break;case"e":h=this.xpadding;break;case"se":h=this.xpadding;break;case"s":h=-f.outerWidth(true)/2;break;case"sw":h=-f.outerWidth(true)-this.xpadding;break;case"w":h=-f.outerWidth(true)-this.xpadding;break;default:h=-f.outerWidth(true)-this.xpadding;break}return h};c.jqplot.PointLabels.prototype.yOffset=function(f,e,g){e=e||this.location;g=g||this.xpadding;var h;switch(e){case"nw":h=-f.outerHeight(true)-this.ypadding;break;case"n":h=-f.outerHeight(true)-this.ypadding;break;case"ne":h=-f.outerHeight(true)-this.ypadding;break;case"e":h=-f.outerHeight(true)/2;break;case"se":h=this.ypadding;break;case"s":h=this.ypadding;break;case"sw":h=this.ypadding;break;case"w":h=-f.outerHeight(true)/2;break;default:h=-f.outerHeight(true)-this.ypadding;break}return h};c.jqplot.PointLabels.draw=function(w,j){var t=this.plugins.pointLabels;t.setLabels.call(this);for(var v=0;v<t._elems.length;v++){t._elems[v].emptyForce()}t._elems.splice(0,t._elems.length);if(t.show){var r="_"+this._stackAxis+"axis";if(!t.formatString){t.formatString=this[r]._ticks[0].formatString;t.formatter=this[r]._ticks[0].formatter}var C=this._plotData;var z=this._xaxis;var q=this._yaxis;var y,f;for(var v=0,u=t._labels.length;v<u;v++){var o=t._labels[v];if(t.hideZeros&&parseInt(t._labels[v],10)==0){o=""}if(o!=null){o=t.formatter(t.formatString,o)}f=document.createElement("div");t._elems[v]=c(f);y=t._elems[v];y.addClass("jqplot-point-label jqplot-series-"+this.index+" jqplot-point-"+v);y.css("position","absolute");y.insertAfter(w.canvas);if(t.escapeHTML){y.text(o)}else{y.html(o)}var g=t.location;if((this.fillToZero&&C[v][1]<0)||(this.fillToZero&&this._type==="bar"&&this.barDirection==="horizontal"&&C[v][0]<0)||(this.waterfall&&parseInt(o,10))<0){g=b[d[g]]}var n=z.u2p(C[v][0])+t.xOffset(y,g);var h=q.u2p(C[v][1])+t.yOffset(y,g);if(this.renderer.constructor==c.jqplot.BarRenderer){if(this.barDirection=="vertical"){n+=this._barNudge}else{h-=this._barNudge}}y.css("left",n);y.css("top",h);var k=n+y.width();var s=h+y.height();var B=t.edgeTolerance;var e=c(w.canvas).position().left;var x=c(w.canvas).position().top;var A=w.canvas.width+e;var m=w.canvas.height+x;if(n-B<e||h-B<x||k+B>A||s+B>m){y.remove()}y=null;f=null}}};c.jqplot.postSeriesInitHooks.push(c.jqplot.PointLabels.init);c.jqplot.postDrawSeriesHooks.push(c.jqplot.PointLabels.draw)})(jQuery); |
\ No newline at end of file |
Property changes on: trunk/extensions/SemanticResultFormats/jqPlot/jqplot.pointLabels.min.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 59 | + native |
Index: trunk/extensions/SemanticResultFormats/jqPlot/SRF_jqPlotBar.php |
— | — | @@ -51,9 +51,8 @@ |
52 | 52 | 'styles' => array( |
53 | 53 | 'jquery.jqplot.css', |
54 | 54 | ), |
55 | | - 'dependencies' => array( |
56 | | - ), |
57 | 55 | ); |
| 56 | + |
58 | 57 | $wgResourceModules['ext.srf.jqplotbar'] = $resourceTemplate + array( |
59 | 58 | 'scripts' => array( |
60 | 59 | 'jqplot.categoryAxisRenderer.js', |
— | — | @@ -61,19 +60,30 @@ |
62 | 61 | 'jqplot.canvasAxisTickRenderer.js', |
63 | 62 | 'jqplot.canvasTextRenderer.js', |
64 | 63 | 'excanvas.js', |
| 64 | + 'jqplot.pointLabels.js', |
65 | 65 | ), |
66 | | - 'styles' => array( |
67 | | - ), |
68 | 66 | 'dependencies' => array( |
69 | 67 | 'ext.srf.jqplot', |
70 | 68 | ), |
71 | 69 | ); |
| 70 | + |
| 71 | + $wgResourceModules['ext.srf.jqplotpointlabels'] = $resourceTemplate + array( |
| 72 | + 'scripts' => array( |
| 73 | + 'jqplot.pointLabels.min.js', |
| 74 | + ), |
| 75 | + 'dependencies' => array( |
| 76 | + 'ext.srf.jqplotbar', |
| 77 | + ), |
| 78 | + ); |
72 | 79 | } |
73 | 80 | |
74 | | - protected static function loadJavascriptAndCSS() { |
| 81 | + protected function loadJavascriptAndCSS() { |
75 | 82 | global $wgOut; |
76 | | - $wgOut->addModules( 'ext.srf.jqplot' ); |
77 | 83 | $wgOut->addModules( 'ext.srf.jqplotbar' ); |
| 84 | + |
| 85 | + if ( $this->params['pointlabels'] ) { |
| 86 | + $wgOut->addModules( 'ext.srf.jqplotpointlabels' ); |
| 87 | + } |
78 | 88 | } |
79 | 89 | |
80 | 90 | /** |
— | — | @@ -88,7 +98,7 @@ |
89 | 99 | |
90 | 100 | // MW 1.17 + |
91 | 101 | if ( class_exists( 'ResourceLoader' ) ) { |
92 | | - self::loadJavascriptAndCSS(); |
| 102 | + $this->loadJavascriptAndCSS(); |
93 | 103 | return; |
94 | 104 | } |
95 | 105 | |
— | — | @@ -109,6 +119,10 @@ |
110 | 120 | $scripts[] = "$srfgScriptPath/jqPlot/jqplot.canvasAxisTickRenderer.js"; |
111 | 121 | $scripts[] = "$srfgScriptPath/jqPlot/jqplot.canvasTextRenderer.js"; |
112 | 122 | |
| 123 | + if ( $this->params['pointlabels'] ) { |
| 124 | + $scripts[] = "$srfgScriptPath/jqPlot/jqplot.pointLabels.js"; |
| 125 | + } |
| 126 | + |
113 | 127 | foreach ( $scripts as $script ) { |
114 | 128 | $wgOut->addScriptFile( $script ); |
115 | 129 | } |
— | — | @@ -205,6 +219,8 @@ |
206 | 220 | $numbers_ticks .= ($i * $biggerMultipleOf10) . ', '; |
207 | 221 | } |
208 | 222 | |
| 223 | + $pointlabels = FormatJson::encode( $this->params['pointlabels'] ); |
| 224 | + |
209 | 225 | $js_bar =<<<END |
210 | 226 | <script type="text/javascript"> |
211 | 227 | jQuery(document).ready(function(){ |
— | — | @@ -220,7 +236,8 @@ |
221 | 237 | barDirection: '{$this->m_bardirection}', |
222 | 238 | barPadding: 6, |
223 | 239 | barMargin: $barmargin |
224 | | - } |
| 240 | + }, |
| 241 | + pointLabels: {show: $pointlabels} |
225 | 242 | }], |
226 | 243 | axes: { |
227 | 244 | $labels_axis: { |
— | — | @@ -284,6 +301,9 @@ |
285 | 302 | $params['min']->setMessage( 'srf-paramdesc-minvalue' ); |
286 | 303 | $params['min']->setDefault( false, false ); |
287 | 304 | |
| 305 | + $params['pointlabels'] = new Parameter( 'pointlabels', Parameter::TYPE_BOOLEAN, false ); |
| 306 | + $params['pointlabels']->setMessage( 'srf-paramdesc-pointlabels' ); |
| 307 | + |
288 | 308 | return $params; |
289 | 309 | } |
290 | 310 | |