sunrise-votes 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -4
- data/Rakefile +0 -22
- data/app/controllers/manage/ballot_box/votes_controller.rb +4 -0
- data/app/views/manage/ballot_box/votes/show.html.erb +211 -81
- data/lib/generators/sunrise/votes/install_generator.rb +1 -1
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.js +170 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/highcharts.src.js +11428 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.js +22 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/modules/exporting.src.js +711 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-blue.js +263 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/dark-green.js +263 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/gray.js +262 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/grid.js +96 -0
- data/lib/generators/sunrise/votes/templates/javascripts/highcharts/themes/skies.js +89 -0
- data/lib/sunrise/votes/version.rb +1 -1
- metadata +33 -79
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/excanvas.min.js +0 -35
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.css +0 -226
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/jquery.jqplot.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.js +0 -312
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.BezierCurveRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.js +0 -702
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.barRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.js +0 -234
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.blockRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.js +0 -748
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.bubbleRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.js +0 -199
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisLabelRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.js +0 -238
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasAxisTickRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.js +0 -614
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasOverlay.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.js +0 -420
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.canvasTextRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.js +0 -634
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.categoryAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.js +0 -115
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ciParser.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.js +0 -1002
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.cursor.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.js +0 -439
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dateAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.js +0 -904
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.donutRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.js +0 -218
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.dragable.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.js +0 -199
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.enhancedLegendRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.js +0 -932
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.funnelRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.js +0 -406
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.highlighter.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.js +0 -475
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.json2.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.js +0 -446
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.logAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.js +0 -607
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoAxisRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.js +0 -432
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.mekkoRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.js +0 -1142
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.meterGaugeRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.js +0 -372
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.ohlcRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.js +0 -797
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pieRenderer.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.js +0 -337
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.pointLabels.min.js +0 -30
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.js +0 -220
- data/lib/generators/sunrise/votes/templates/javascripts/ballot_box/plugins/jqplot.trendline.min.js +0 -30
@@ -1,30 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b1_r746
|
6
|
-
*
|
7
|
-
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
-
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
-
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
-
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
-
* choose the license that best suits your project and use it accordingly.
|
12
|
-
*
|
13
|
-
* Although not required, the author would appreciate an email letting him
|
14
|
-
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
-
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
-
*
|
17
|
-
* If you are feeling kind and generous, consider supporting the project by
|
18
|
-
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
-
*
|
20
|
-
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
-
*
|
22
|
-
* version 2007.04.27
|
23
|
-
* author Ash Searle
|
24
|
-
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
-
* http://hexmen.com/js/sprintf.js
|
26
|
-
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
-
* "This code is unrestricted: you are free to use it however you like."
|
28
|
-
*
|
29
|
-
*/
|
30
|
-
(function(b){b.jqplot.MekkoRenderer=function(){this.shapeRenderer=new b.jqplot.ShapeRenderer();this.borderColor=null;this.showBorders=true};b.jqplot.MekkoRenderer.prototype.init=function(c,e){this.fill=false;this.fillRect=true;this.strokeRect=true;this.shadow=false;this._xwidth=0;this._xstart=0;b.extend(true,this.renderer,c);var d={lineJoin:"miter",lineCap:"butt",isarc:false,fillRect:this.fillRect,strokeRect:this.strokeRect};this.renderer.shapeRenderer.init(d);e.axes.x2axis._series.push(this);this._type="mekko"};b.jqplot.MekkoRenderer.prototype.setGridData=function(h){var e=this._xaxis.series_u2p;var c=this._yaxis.series_u2p;var g=this._plotData;this.gridData=[];this._xwidth=e(this._sumy)-e(0);if(this.index>0){this._xstart=h.series[this.index-1]._xstart+h.series[this.index-1]._xwidth}var l=this.canvas.getHeight();var d=0;var k;var j;for(var f=0;f<g.length;f++){if(g[f]!=null){d+=g[f][1];k=l-(d/this._sumy*l);j=g[f][1]/this._sumy*l;this.gridData.push([this._xstart,k,this._xwidth,j])}}};b.jqplot.MekkoRenderer.prototype.makeGridData=function(f,g){var d=this._xaxis.series_u2p;var l=this.canvas.getHeight();var c=0;var j;var h;var k=[];for(var e=0;e<f.length;e++){if(f[e]!=null){c+=f[e][1];j=l-(c/this._sumy*l);h=f[e][1]/this._sumy*l;k.push([this._xstart,j,this._xwidth,h])}}return k};b.jqplot.MekkoRenderer.prototype.draw=function(c,h,d){var e;var g=(d!=undefined)?d:{};var f=(g.showLine!=undefined)?g.showLine:this.showLine;var j=new b.jqplot.ColorGenerator(this.seriesColors);c.save();if(h.length){if(f){for(e=0;e<h.length;e++){g.fillStyle=j.next();if(this.renderer.showBorders){g.strokeStyle=this.renderer.borderColor}else{g.strokeStyle=g.fillStyle}this.renderer.shapeRenderer.draw(c,h[e],g)}}}c.restore()};b.jqplot.MekkoRenderer.prototype.drawShadow=function(c,e,d){};b.jqplot.MekkoLegendRenderer=function(){};b.jqplot.MekkoLegendRenderer.prototype.init=function(c){this.numberRows=null;this.numberColumns=null;this.placement="outside";b.extend(true,this,c)};b.jqplot.MekkoLegendRenderer.prototype.draw=function(){var f=this;if(this.show){var o=this._series;var r="position:absolute;";r+=(this.background)?"background:"+this.background+";":"";r+=(this.border)?"border:"+this.border+";":"";r+=(this.fontSize)?"font-size:"+this.fontSize+";":"";r+=(this.fontFamily)?"font-family:"+this.fontFamily+";":"";r+=(this.textColor)?"color:"+this.textColor+";":"";this._elem=b('<table class="jqplot-table-legend" style="'+r+'"></table>');var w=false,n=true,c,l;var p=o[0];var d=new b.jqplot.ColorGenerator(p.seriesColors);if(p.show){var x=p.data;if(this.numberRows){c=this.numberRows;if(!this.numberColumns){l=Math.ceil(x.length/c)}else{l=this.numberColumns}}else{if(this.numberColumns){l=this.numberColumns;c=Math.ceil(x.length/this.numberColumns)}else{c=x.length;l=1}}var v,u,e,h,g,k,m,t;var q=0;for(v=0;v<c;v++){if(n){e=b('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem)}else{e=b('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem)}for(u=0;u<l;u++){if(q<x.length){k=this.labels[q]||x[q][0].toString();t=d.next();if(!n){if(v>0){w=true}else{w=false}}else{if(v==c-1){w=false}else{w=true}}m=(w)?this.rowSpacing:"0";h=b('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+m+';"><div><div class="jqplot-table-legend-swatch" style="border-color:'+t+';"></div></div></td>');g=b('<td class="jqplot-table-legend" style="padding-top:'+m+';"></td>');if(this.escapeHtml){g.text(k)}else{g.html(k)}if(n){g.prependTo(e);h.prependTo(e)}else{h.appendTo(e);g.appendTo(e)}w=true}q++}}}}return this._elem};b.jqplot.MekkoLegendRenderer.prototype.pack=function(f){if(this.show){var e={_top:f.top,_left:f.left,_right:f.right,_bottom:this._plotDimensions.height-f.bottom};if(this.placement=="insideGrid"){switch(this.location){case"nw":var d=e._left+this.xoffset;var c=e._top+this.yoffset;this._elem.css("left",d);this._elem.css("top",c);break;case"n":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=e._top+this.yoffset;this._elem.css("left",d);this._elem.css("top",c);break;case"ne":var d=f.right+this.xoffset;var c=e._top+this.yoffset;this._elem.css({right:d,top:c});break;case"e":var d=f.right+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;case"se":var d=f.right+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({right:d,bottom:c});break;case"s":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"sw":var d=e._left+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"w":var d=e._left+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;default:var d=e._right-this.xoffset;var c=e._bottom+this.yoffset;this._elem.css({right:d,bottom:c});break}}else{switch(this.location){case"nw":var d=this._plotDimensions.width-e._left+this.xoffset;var c=e._top+this.yoffset;this._elem.css("right",d);this._elem.css("top",c);break;case"n":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-e._top+this.yoffset;this._elem.css("left",d);this._elem.css("bottom",c);break;case"ne":var d=this._plotDimensions.width-f.right+this.xoffset;var c=e._top+this.yoffset;this._elem.css({left:d,top:c});break;case"e":var d=this._plotDimensions.width-f.right+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({left:d,top:c});break;case"se":var d=this._plotDimensions.width-f.right+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({left:d,bottom:c});break;case"s":var d=(f.left+(this._plotDimensions.width-f.right))/2-this.getWidth()/2;var c=this._plotDimensions.height-f.bottom+this.yoffset;this._elem.css({left:d,top:c});break;case"sw":var d=this._plotDimensions.width-e._left+this.xoffset;var c=f.bottom+this.yoffset;this._elem.css({right:d,bottom:c});break;case"w":var d=this._plotDimensions.width-e._left+this.xoffset;var c=(f.top+(this._plotDimensions.height-f.bottom))/2-this.getHeight()/2;this._elem.css({right:d,top:c});break;default:var d=e._right-this.xoffset;var c=e._bottom+this.yoffset;this._elem.css({right:d,bottom:c});break}}}};function a(g,f,d){d=d||{};d.axesDefaults=d.axesDefaults||{};d.legend=d.legend||{};d.seriesDefaults=d.seriesDefaults||{};var c=false;if(d.seriesDefaults.renderer==b.jqplot.MekkoRenderer){c=true}else{if(d.series){for(var e=0;e<d.series.length;e++){if(d.series[e].renderer==b.jqplot.MekkoRenderer){c=true}}}}if(c){d.axesDefaults.renderer=b.jqplot.MekkoAxisRenderer;d.legend.renderer=b.jqplot.MekkoLegendRenderer;d.legend.preDraw=true}}b.jqplot.preInitHooks.push(a)})(jQuery);
|
@@ -1,1142 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* jqPlot
|
3
|
-
* Pure JavaScript plotting plugin using jQuery
|
4
|
-
*
|
5
|
-
* Version: 1.0.0b1_r746
|
6
|
-
*
|
7
|
-
* Copyright (c) 2009-2011 Chris Leonello
|
8
|
-
* jqPlot is currently available for use in all personal or commercial projects
|
9
|
-
* under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL
|
10
|
-
* version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can
|
11
|
-
* choose the license that best suits your project and use it accordingly.
|
12
|
-
*
|
13
|
-
* Although not required, the author would appreciate an email letting him
|
14
|
-
* know of any substantial use of jqPlot. You can reach the author at:
|
15
|
-
* chris at jqplot dot com or see http://www.jqplot.com/info.php .
|
16
|
-
*
|
17
|
-
* If you are feeling kind and generous, consider supporting the project by
|
18
|
-
* making a donation at: http://www.jqplot.com/donate.php .
|
19
|
-
*
|
20
|
-
* sprintf functions contained in jqplot.sprintf.js by Ash Searle:
|
21
|
-
*
|
22
|
-
* version 2007.04.27
|
23
|
-
* author Ash Searle
|
24
|
-
* http://hexmen.com/blog/2007/03/printf-sprintf/
|
25
|
-
* http://hexmen.com/js/sprintf.js
|
26
|
-
* The author (Ash Searle) has placed this code in the public domain:
|
27
|
-
* "This code is unrestricted: you are free to use it however you like."
|
28
|
-
*
|
29
|
-
*/
|
30
|
-
(function($) {
|
31
|
-
/**
|
32
|
-
* Class: $.jqplot.MeterGaugeRenderer
|
33
|
-
* Plugin renderer to draw a meter gauge chart.
|
34
|
-
*
|
35
|
-
* Data consists of a single series with 1 data point to position the gauge needle.
|
36
|
-
*
|
37
|
-
* To use this renderer, you need to include the
|
38
|
-
* meter gauge renderer plugin, for example:
|
39
|
-
*
|
40
|
-
* > <script type="text/javascript" src="plugins/jqplot.meterGaugeRenderer.js"></script>
|
41
|
-
*
|
42
|
-
* Properties described here are passed into the $.jqplot function
|
43
|
-
* as options on the series renderer. For example:
|
44
|
-
*
|
45
|
-
* > plot0 = $.jqplot('chart0',[[18]],{
|
46
|
-
* > title: 'Network Speed',
|
47
|
-
* > seriesDefaults: {
|
48
|
-
* > renderer: $.jqplot.MeterGaugeRenderer,
|
49
|
-
* > rendererOptions: {
|
50
|
-
* > label: 'MB/s'
|
51
|
-
* > }
|
52
|
-
* > }
|
53
|
-
* > });
|
54
|
-
*
|
55
|
-
* A meterGauge plot does not support events.
|
56
|
-
*/
|
57
|
-
$.jqplot.MeterGaugeRenderer = function(){
|
58
|
-
$.jqplot.LineRenderer.call(this);
|
59
|
-
};
|
60
|
-
|
61
|
-
$.jqplot.MeterGaugeRenderer.prototype = new $.jqplot.LineRenderer();
|
62
|
-
$.jqplot.MeterGaugeRenderer.prototype.constructor = $.jqplot.MeterGaugeRenderer;
|
63
|
-
|
64
|
-
// called with scope of a series
|
65
|
-
$.jqplot.MeterGaugeRenderer.prototype.init = function(options) {
|
66
|
-
// Group: Properties
|
67
|
-
//
|
68
|
-
// prop: diameter
|
69
|
-
// Outer diameter of the meterGauge, auto computed by default
|
70
|
-
this.diameter = null;
|
71
|
-
// prop: padding
|
72
|
-
// padding between the meterGauge and plot edges, auto
|
73
|
-
// calculated by default.
|
74
|
-
this.padding = null;
|
75
|
-
// prop: shadowOffset
|
76
|
-
// offset of the shadow from the gauge ring and offset of
|
77
|
-
// each succesive stroke of the shadow from the last.
|
78
|
-
this.shadowOffset = 2;
|
79
|
-
// prop: shadowAlpha
|
80
|
-
// transparency of the shadow (0 = transparent, 1 = opaque)
|
81
|
-
this.shadowAlpha = 0.07;
|
82
|
-
// prop: shadowDepth
|
83
|
-
// number of strokes to apply to the shadow,
|
84
|
-
// each stroke offset shadowOffset from the last.
|
85
|
-
this.shadowDepth = 4;
|
86
|
-
// prop: background
|
87
|
-
// background color of the inside of the gauge.
|
88
|
-
this.background = "#efefef";
|
89
|
-
// prop: ringColor
|
90
|
-
// color of the outer ring, hub, and needle of the gauge.
|
91
|
-
this.ringColor = "#BBC6D0";
|
92
|
-
// needle color not implemented yet.
|
93
|
-
this.needleColor = "#C3D3E5";
|
94
|
-
// prop: tickColor
|
95
|
-
// color of the tick marks around the gauge.
|
96
|
-
this.tickColor = "989898";
|
97
|
-
// prop: ringWidth
|
98
|
-
// width of the ring around the gauge. Auto computed by default.
|
99
|
-
this.ringWidth = null;
|
100
|
-
// prop: min
|
101
|
-
// Minimum value on the gauge. Auto computed by default
|
102
|
-
this.min;
|
103
|
-
// prop: max
|
104
|
-
// Maximum value on the gauge. Auto computed by default
|
105
|
-
this.max;
|
106
|
-
// prop: ticks
|
107
|
-
// Array of tick values. Auto computed by default.
|
108
|
-
this.ticks = [];
|
109
|
-
// prop: showTicks
|
110
|
-
// true to show ticks around gauge.
|
111
|
-
this.showTicks = true;
|
112
|
-
// prop: showTickLabels
|
113
|
-
// true to show tick labels next to ticks.
|
114
|
-
this.showTickLabels = true;
|
115
|
-
// prop: label
|
116
|
-
// A gauge label like 'kph' or 'Volts'
|
117
|
-
this.label = null;
|
118
|
-
// prop: labelHeightAdjust
|
119
|
-
// Number of Pixels to offset the label up (-) or down (+) from its default position.
|
120
|
-
this.labelHeightAdjust = 0;
|
121
|
-
// prop: labelPosition
|
122
|
-
// Where to position the label, either 'inside' or 'bottom'.
|
123
|
-
this.labelPosition = 'inside';
|
124
|
-
// prop: intervals
|
125
|
-
// Array of ranges to be drawn around the gauge.
|
126
|
-
// Array of form:
|
127
|
-
// > [value1, value2, ...]
|
128
|
-
// indicating the values for the first, second, ... intervals.
|
129
|
-
this.intervals = [];
|
130
|
-
// prop: intervalColors
|
131
|
-
// Array of colors to use for the intervals.
|
132
|
-
this.intervalColors = [ "#4bb2c5", "#EAA228", "#c5b47f", "#579575", "#839557", "#958c12", "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc", "#c747a3", "#cddf54", "#FBD178", "#26B4E3", "#bd70c7"];
|
133
|
-
// prop: intervalInnerRadius
|
134
|
-
// Radius of the inner circle of the interval ring.
|
135
|
-
this.intervalInnerRadius = null;
|
136
|
-
// prop: intervalOuterRadius
|
137
|
-
// Radius of the outer circle of the interval ring.
|
138
|
-
this.intervalOuterRadius = null;
|
139
|
-
this.tickRenderer = $.jqplot.MeterGaugeTickRenderer;
|
140
|
-
// ticks spaced every 1, 2, 2.5, 5, 10, 20, .1, .2, .25, .5, etc.
|
141
|
-
this.tickPositions = [1, 2, 2.5, 5, 10];
|
142
|
-
// prop: tickSpacing
|
143
|
-
// Degrees between ticks. This is a target number, if
|
144
|
-
// incompatible span and ticks are supplied, a suitable
|
145
|
-
// spacing close to this value will be computed.
|
146
|
-
this.tickSpacing = 30;
|
147
|
-
this.numberMinorTicks = null;
|
148
|
-
// prop: hubRadius
|
149
|
-
// Radius of the hub at the bottom center of gauge which the needle attaches to.
|
150
|
-
// Auto computed by default
|
151
|
-
this.hubRadius = null;
|
152
|
-
// prop: tickPadding
|
153
|
-
// padding of the tick marks to the outer ring and the tick labels to marks.
|
154
|
-
// Auto computed by default.
|
155
|
-
this.tickPadding = null;
|
156
|
-
// prop: needleThickness
|
157
|
-
// Maximum thickness the needle. Auto computed by default.
|
158
|
-
this.needleThickness = null;
|
159
|
-
// prop: needlePad
|
160
|
-
// Padding between needle and inner edge of the ring when the needle is at the min or max gauge value.
|
161
|
-
this.needlePad = 6;
|
162
|
-
// prop: pegNeedle
|
163
|
-
// True will stop needle just below/above the min/max values if data is below/above min/max,
|
164
|
-
// as if the meter is "pegged".
|
165
|
-
this.pegNeedle = true;
|
166
|
-
this._type = 'meterGauge';
|
167
|
-
|
168
|
-
$.extend(true, this, options);
|
169
|
-
this.type = null;
|
170
|
-
this.numberTicks = null;
|
171
|
-
this.tickInterval = null;
|
172
|
-
// span, the sweep (in degrees) from min to max. This gauge is
|
173
|
-
// a semi-circle.
|
174
|
-
this.span = 180;
|
175
|
-
// get rid of this nonsense
|
176
|
-
// this.innerSpan = this.span;
|
177
|
-
if (this.type == 'circular') {
|
178
|
-
this.semiCircular = false;
|
179
|
-
}
|
180
|
-
else if (this.type != 'circular') {
|
181
|
-
this.semiCircular = true;
|
182
|
-
}
|
183
|
-
else {
|
184
|
-
this.semiCircular = (this.span <= 180) ? true : false;
|
185
|
-
}
|
186
|
-
this._tickPoints = [];
|
187
|
-
// reference to label element.
|
188
|
-
this._labelElm = null;
|
189
|
-
|
190
|
-
// start the gauge at the beginning of the span
|
191
|
-
this.startAngle = (90 + (360 - this.span)/2) * Math.PI/180;
|
192
|
-
this.endAngle = (90 - (360 - this.span)/2) * Math.PI/180;
|
193
|
-
|
194
|
-
this.setmin = !!(this.min == null);
|
195
|
-
this.setmax = !!(this.max == null);
|
196
|
-
|
197
|
-
// if given intervals and is an array of values, create labels and colors.
|
198
|
-
if (this.intervals.length) {
|
199
|
-
if (this.intervals[0].length == null || this.intervals.length == 1) {
|
200
|
-
for (var i=0; i<this.intervals.length; i++) {
|
201
|
-
this.intervals[i] = [this.intervals[i], this.intervals[i], this.intervalColors[i]];
|
202
|
-
}
|
203
|
-
}
|
204
|
-
else if (this.intervals[0].length == 2) {
|
205
|
-
for (i=0; i<this.intervals.length; i++) {
|
206
|
-
this.intervals[i] = [this.intervals[i][0], this.intervals[i][1], this.intervalColors[i]];
|
207
|
-
}
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
// compute min, max and ticks if not supplied:
|
212
|
-
if (this.ticks.length) {
|
213
|
-
if (this.ticks[0].length == null || this.ticks[0].length == 1) {
|
214
|
-
for (var i=0; i<this.ticks.length; i++) {
|
215
|
-
this.ticks[i] = [this.ticks[i], this.ticks[i]];
|
216
|
-
}
|
217
|
-
}
|
218
|
-
this.min = (this.min == null) ? this.ticks[0][0] : this.min;
|
219
|
-
this.max = (this.max == null) ? this.ticks[this.ticks.length-1][0] : this.max;
|
220
|
-
this.setmin = false;
|
221
|
-
this.setmax = false;
|
222
|
-
this.numberTicks = this.ticks.length;
|
223
|
-
this.tickInterval = this.ticks[1][0] - this.ticks[0][0];
|
224
|
-
this.tickFactor = Math.floor(parseFloat((Math.log(this.tickInterval)/Math.log(10)).toFixed(11)));
|
225
|
-
// use the first interal to calculate minor ticks;
|
226
|
-
this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor);
|
227
|
-
if (!this.numberMinorTicks) {
|
228
|
-
this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1);
|
229
|
-
}
|
230
|
-
if (!this.numberMinorTicks) {
|
231
|
-
this.numberMinorTicks = 1;
|
232
|
-
}
|
233
|
-
}
|
234
|
-
|
235
|
-
else if (this.intervals.length) {
|
236
|
-
this.min = (this.min == null) ? 0 : this.min;
|
237
|
-
this.setmin = false;
|
238
|
-
if (this.max == null) {
|
239
|
-
if (this.intervals[this.intervals.length-1][0] >= this.data[0][1]) {
|
240
|
-
this.max = this.intervals[this.intervals.length-1][0];
|
241
|
-
this.setmax = false;
|
242
|
-
}
|
243
|
-
}
|
244
|
-
else {
|
245
|
-
this.setmax = false;
|
246
|
-
}
|
247
|
-
}
|
248
|
-
|
249
|
-
else {
|
250
|
-
// no ticks and no intervals supplied, put needle in middle
|
251
|
-
this.min = (this.min == null) ? 0 : this.min;
|
252
|
-
this.setmin = false;
|
253
|
-
if (this.max == null) {
|
254
|
-
this.max = this.data[0][1] * 1.25;
|
255
|
-
this.setmax = true;
|
256
|
-
}
|
257
|
-
else {
|
258
|
-
this.setmax = false;
|
259
|
-
}
|
260
|
-
}
|
261
|
-
};
|
262
|
-
|
263
|
-
$.jqplot.MeterGaugeRenderer.prototype.setGridData = function(plot) {
|
264
|
-
// set gridData property. This will hold angle in radians of each data point.
|
265
|
-
var stack = [];
|
266
|
-
var td = [];
|
267
|
-
var sa = this.startAngle;
|
268
|
-
for (var i=0; i<this.data.length; i++){
|
269
|
-
stack.push(this.data[i][1]);
|
270
|
-
td.push([this.data[i][0]]);
|
271
|
-
if (i>0) {
|
272
|
-
stack[i] += stack[i-1];
|
273
|
-
}
|
274
|
-
}
|
275
|
-
var fact = Math.PI*2/stack[stack.length - 1];
|
276
|
-
|
277
|
-
for (var i=0; i<stack.length; i++) {
|
278
|
-
td[i][1] = stack[i] * fact;
|
279
|
-
}
|
280
|
-
this.gridData = td;
|
281
|
-
};
|
282
|
-
|
283
|
-
$.jqplot.MeterGaugeRenderer.prototype.makeGridData = function(data, plot) {
|
284
|
-
var stack = [];
|
285
|
-
var td = [];
|
286
|
-
var sa = this.startAngle;
|
287
|
-
for (var i=0; i<data.length; i++){
|
288
|
-
stack.push(data[i][1]);
|
289
|
-
td.push([data[i][0]]);
|
290
|
-
if (i>0) {
|
291
|
-
stack[i] += stack[i-1];
|
292
|
-
}
|
293
|
-
}
|
294
|
-
var fact = Math.PI*2/stack[stack.length - 1];
|
295
|
-
|
296
|
-
for (var i=0; i<stack.length; i++) {
|
297
|
-
td[i][1] = stack[i] * fact;
|
298
|
-
}
|
299
|
-
return td;
|
300
|
-
};
|
301
|
-
|
302
|
-
|
303
|
-
function getnmt(pos, interval, fact) {
|
304
|
-
var temp;
|
305
|
-
for (var i=pos.length-1; i>=0; i--) {
|
306
|
-
temp = interval/(pos[i] * Math.pow(10, fact));
|
307
|
-
if (temp == 4 || temp == 5) {
|
308
|
-
return temp - 1;
|
309
|
-
}
|
310
|
-
}
|
311
|
-
return null;
|
312
|
-
}
|
313
|
-
|
314
|
-
// called with scope of series
|
315
|
-
$.jqplot.MeterGaugeRenderer.prototype.draw = function (ctx, gd, options) {
|
316
|
-
var i;
|
317
|
-
var opts = (options != undefined) ? options : {};
|
318
|
-
// offset and direction of offset due to legend placement
|
319
|
-
var offx = 0;
|
320
|
-
var offy = 0;
|
321
|
-
var trans = 1;
|
322
|
-
if (options.legendInfo && options.legendInfo.placement == 'inside') {
|
323
|
-
var li = options.legendInfo;
|
324
|
-
switch (li.location) {
|
325
|
-
case 'nw':
|
326
|
-
offx = li.width + li.xoffset;
|
327
|
-
break;
|
328
|
-
case 'w':
|
329
|
-
offx = li.width + li.xoffset;
|
330
|
-
break;
|
331
|
-
case 'sw':
|
332
|
-
offx = li.width + li.xoffset;
|
333
|
-
break;
|
334
|
-
case 'ne':
|
335
|
-
offx = li.width + li.xoffset;
|
336
|
-
trans = -1;
|
337
|
-
break;
|
338
|
-
case 'e':
|
339
|
-
offx = li.width + li.xoffset;
|
340
|
-
trans = -1;
|
341
|
-
break;
|
342
|
-
case 'se':
|
343
|
-
offx = li.width + li.xoffset;
|
344
|
-
trans = -1;
|
345
|
-
break;
|
346
|
-
case 'n':
|
347
|
-
offy = li.height + li.yoffset;
|
348
|
-
break;
|
349
|
-
case 's':
|
350
|
-
offy = li.height + li.yoffset;
|
351
|
-
trans = -1;
|
352
|
-
break;
|
353
|
-
default:
|
354
|
-
break;
|
355
|
-
}
|
356
|
-
}
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
// pre-draw so can get it's dimensions.
|
361
|
-
if (this.label) {
|
362
|
-
this._labelElem = $('<div class="jqplot-meterGauge-label" style="position:absolute;">'+this.label+'</div>');
|
363
|
-
this.canvas._elem.after(this._labelElem);
|
364
|
-
}
|
365
|
-
|
366
|
-
var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
|
367
|
-
var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
|
368
|
-
var fill = (opts.fill != undefined) ? opts.fill : this.fill;
|
369
|
-
var cw = ctx.canvas.width;
|
370
|
-
var ch = ctx.canvas.height;
|
371
|
-
if (this.padding == null) {
|
372
|
-
this.padding = Math.round(Math.min(cw, ch)/30);
|
373
|
-
}
|
374
|
-
var w = cw - offx - 2 * this.padding;
|
375
|
-
var h = ch - offy - 2 * this.padding;
|
376
|
-
if (this.labelPosition == 'bottom' && this.label) {
|
377
|
-
h -= this._labelElem.outerHeight(true);
|
378
|
-
}
|
379
|
-
var mindim = Math.min(w,h);
|
380
|
-
var d = mindim;
|
381
|
-
|
382
|
-
if (!this.diameter) {
|
383
|
-
if (this.semiCircular) {
|
384
|
-
if ( w >= 2*h) {
|
385
|
-
if (!this.ringWidth) {
|
386
|
-
this.ringWidth = 2*h/35;
|
387
|
-
}
|
388
|
-
this.needleThickness = this.needleThickness || 2+Math.pow(this.ringWidth, 0.8);
|
389
|
-
this.innerPad = this.ringWidth/2 + this.needleThickness/2 + this.needlePad;
|
390
|
-
this.diameter = 2 * (h - 2*this.innerPad);
|
391
|
-
}
|
392
|
-
else {
|
393
|
-
if (!this.ringWidth) {
|
394
|
-
this.ringWidth = w/35;
|
395
|
-
}
|
396
|
-
this.needleThickness = this.needleThickness || 2+Math.pow(this.ringWidth, 0.8);
|
397
|
-
this.innerPad = this.ringWidth/2 + this.needleThickness/2 + this.needlePad;
|
398
|
-
this.diameter = w - 2*this.innerPad;
|
399
|
-
}
|
400
|
-
// center taking into account legend and over draw for gauge bottom below hub.
|
401
|
-
// this will be center of hub.
|
402
|
-
this._center = [(cw - trans * offx)/2 + trans * offx, (ch + trans*offy - this.padding - this.ringWidth - this.innerPad)];
|
403
|
-
}
|
404
|
-
else {
|
405
|
-
if (!this.ringWidth) {
|
406
|
-
this.ringWidth = d/35;
|
407
|
-
}
|
408
|
-
this.needleThickness = this.needleThickness || 2+Math.pow(this.ringWidth, 0.8);
|
409
|
-
this.innerPad = 0;
|
410
|
-
this.diameter = d - this.ringWidth;
|
411
|
-
// center in middle of canvas taking into account legend.
|
412
|
-
// will be center of hub.
|
413
|
-
this._center = [(cw-trans*offx)/2 + trans * offx, (ch-trans*offy)/2 + trans * offy];
|
414
|
-
}
|
415
|
-
}
|
416
|
-
|
417
|
-
if (this._labelElem && this.labelPosition == 'bottom') {
|
418
|
-
this._center[1] -= this._labelElem.outerHeight(true);
|
419
|
-
}
|
420
|
-
|
421
|
-
this._radius = this.diameter/2;
|
422
|
-
|
423
|
-
this.tickSpacing = 6000/this.diameter;
|
424
|
-
|
425
|
-
if (!this.hubRadius) {
|
426
|
-
this.hubRadius = this.diameter/18;
|
427
|
-
}
|
428
|
-
|
429
|
-
this.shadowOffset = 0.5 + this.ringWidth/9;
|
430
|
-
this.shadowWidth = this.ringWidth*1;
|
431
|
-
|
432
|
-
this.tickPadding = 3 + Math.pow(this.diameter/20, 0.7);
|
433
|
-
this.tickOuterRadius = this._radius - this.ringWidth/2 - this.tickPadding;
|
434
|
-
this.tickLength = (this.showTicks) ? this._radius/13 : 0;
|
435
|
-
|
436
|
-
if (this.ticks.length == 0) {
|
437
|
-
// no ticks, lets make some.
|
438
|
-
var max = this.max,
|
439
|
-
min = this.min,
|
440
|
-
setmax = this.setmax,
|
441
|
-
setmin = this.setmin,
|
442
|
-
ti = (max - min) * this.tickSpacing / this.span;
|
443
|
-
var tf = Math.floor(parseFloat((Math.log(ti)/Math.log(10)).toFixed(11)));
|
444
|
-
var tp = (ti/Math.pow(10, tf));
|
445
|
-
(tp > 2 && tp <= 2.5) ? tp = 2.5 : tp = Math.ceil(tp);
|
446
|
-
var t = this.tickPositions;
|
447
|
-
var tpindex, nt;
|
448
|
-
|
449
|
-
for (i=0; i<t.length; i++) {
|
450
|
-
if (tp == t[i] || i && t[i-1] < tp && tp < t[i]) {
|
451
|
-
ti = t[i]*Math.pow(10, tf);
|
452
|
-
tpindex = i;
|
453
|
-
}
|
454
|
-
}
|
455
|
-
|
456
|
-
for (i=0; i<t.length; i++) {
|
457
|
-
if (tp == t[i] || i && t[i-1] < tp && tp < t[i]) {
|
458
|
-
ti = t[i]*Math.pow(10, tf);
|
459
|
-
nt = Math.ceil((max - min) / ti);
|
460
|
-
}
|
461
|
-
}
|
462
|
-
|
463
|
-
// both max and min are free
|
464
|
-
if (setmax && setmin) {
|
465
|
-
var tmin = (min > 0) ? min - min % ti : min - min % ti - ti;
|
466
|
-
if (!this.forceZero) {
|
467
|
-
var diff = Math.min(min - tmin, 0.8*ti);
|
468
|
-
var ntp = Math.floor(diff/t[tpindex]);
|
469
|
-
if (ntp > 1) {
|
470
|
-
tmin = tmin + t[tpindex] * (ntp-1);
|
471
|
-
if (parseInt(tmin, 10) != tmin && parseInt(tmin-t[tpindex], 10) == tmin-t[tpindex]) {
|
472
|
-
tmin = tmin - t[tpindex];
|
473
|
-
}
|
474
|
-
}
|
475
|
-
}
|
476
|
-
if (min == tmin) {
|
477
|
-
min -= ti;
|
478
|
-
}
|
479
|
-
else {
|
480
|
-
// tmin should always be lower than dataMin
|
481
|
-
if (min - tmin > 0.23*ti) {
|
482
|
-
min = tmin;
|
483
|
-
}
|
484
|
-
else {
|
485
|
-
min = tmin -ti;
|
486
|
-
nt += 1;
|
487
|
-
}
|
488
|
-
}
|
489
|
-
nt += 1;
|
490
|
-
var tmax = min + (nt - 1) * ti;
|
491
|
-
if (max >= tmax) {
|
492
|
-
tmax += ti;
|
493
|
-
nt += 1;
|
494
|
-
}
|
495
|
-
// now tmax should always be mroe than dataMax
|
496
|
-
if (tmax - max < 0.23*ti) {
|
497
|
-
tmax += ti;
|
498
|
-
nt += 1;
|
499
|
-
}
|
500
|
-
this.max = max = tmax;
|
501
|
-
this.min = min;
|
502
|
-
|
503
|
-
this.tickInterval = ti;
|
504
|
-
this.numberTicks = nt;
|
505
|
-
var it;
|
506
|
-
for (i=0; i<nt; i++) {
|
507
|
-
it = parseFloat((min+i*ti).toFixed(11));
|
508
|
-
this.ticks.push([it, it]);
|
509
|
-
}
|
510
|
-
this.max = this.ticks[nt-1][1];
|
511
|
-
|
512
|
-
this.tickFactor = tf;
|
513
|
-
// determine number of minor ticks
|
514
|
-
|
515
|
-
this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor);
|
516
|
-
|
517
|
-
if (!this.numberMinorTicks) {
|
518
|
-
this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1);
|
519
|
-
}
|
520
|
-
}
|
521
|
-
// max is free, min is fixed
|
522
|
-
else if (setmax) {
|
523
|
-
var tmax = min + (nt - 1) * ti;
|
524
|
-
if (max >= tmax) {
|
525
|
-
max = tmax + ti;
|
526
|
-
nt += 1;
|
527
|
-
}
|
528
|
-
else {
|
529
|
-
max = tmax;
|
530
|
-
}
|
531
|
-
|
532
|
-
this.tickInterval = this.tickInterval || ti;
|
533
|
-
this.numberTicks = this.numberTicks || nt;
|
534
|
-
var it;
|
535
|
-
for (i=0; i<this.numberTicks; i++) {
|
536
|
-
it = parseFloat((min+i*this.tickInterval).toFixed(11));
|
537
|
-
this.ticks.push([it, it]);
|
538
|
-
}
|
539
|
-
this.max = this.ticks[this.numberTicks-1][1];
|
540
|
-
|
541
|
-
this.tickFactor = tf;
|
542
|
-
// determine number of minor ticks
|
543
|
-
this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor);
|
544
|
-
|
545
|
-
if (!this.numberMinorTicks) {
|
546
|
-
this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1);
|
547
|
-
}
|
548
|
-
}
|
549
|
-
|
550
|
-
// not setting max or min
|
551
|
-
if (!setmax && !setmin) {
|
552
|
-
var range = this.max - this.min;
|
553
|
-
tf = Math.floor(parseFloat((Math.log(range)/Math.log(10)).toFixed(11))) - 1;
|
554
|
-
var nticks = [5,6,4,7,3,8,9,10,2], res, numticks, nonSigDigits=0, sigRange;
|
555
|
-
// check to see how many zeros are at the end of the range
|
556
|
-
if (range > 1) {
|
557
|
-
var rstr = String(range);
|
558
|
-
if (rstr.search(/\./) == -1) {
|
559
|
-
var pos = rstr.search(/0+$/);
|
560
|
-
nonSigDigits = (pos > 0) ? rstr.length - pos - 1 : 0;
|
561
|
-
}
|
562
|
-
}
|
563
|
-
sigRange = range/Math.pow(10, nonSigDigits);
|
564
|
-
for (i=0; i<nticks.length; i++) {
|
565
|
-
res = sigRange/(nticks[i]-1);
|
566
|
-
if (res == parseInt(res, 10)) {
|
567
|
-
this.numberTicks = nticks[i];
|
568
|
-
this.tickInterval = range/(this.numberTicks-1);
|
569
|
-
this.tickFactor = tf+1;
|
570
|
-
break;
|
571
|
-
}
|
572
|
-
}
|
573
|
-
var it;
|
574
|
-
for (i=0; i<this.numberTicks; i++) {
|
575
|
-
it = parseFloat((this.min+i*this.tickInterval).toFixed(11));
|
576
|
-
this.ticks.push([it, it]);
|
577
|
-
}
|
578
|
-
// determine number of minor ticks
|
579
|
-
this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor);
|
580
|
-
|
581
|
-
if (!this.numberMinorTicks) {
|
582
|
-
this.numberMinorTicks = getnmt(this.tickPositions, this.tickInterval, this.tickFactor-1);
|
583
|
-
}
|
584
|
-
|
585
|
-
if (!this.numberMinorTicks) {
|
586
|
-
this.numberMinorTicks = 1;
|
587
|
-
var nums = [4, 5, 3, 6, 2];
|
588
|
-
for (i=0; i<5; i++) {
|
589
|
-
var temp = this.tickInterval/nums[i];
|
590
|
-
if (temp == parseInt(temp, 10)) {
|
591
|
-
this.numberMinorTicks = nums[i]-1;
|
592
|
-
break;
|
593
|
-
}
|
594
|
-
}
|
595
|
-
}
|
596
|
-
}
|
597
|
-
}
|
598
|
-
|
599
|
-
|
600
|
-
var r = this._radius,
|
601
|
-
sa = this.startAngle,
|
602
|
-
ea = this.endAngle,
|
603
|
-
pi = Math.PI,
|
604
|
-
hpi = Math.PI/2;
|
605
|
-
|
606
|
-
if (this.semiCircular) {
|
607
|
-
var overAngle = Math.atan(this.innerPad/r),
|
608
|
-
outersa = this.outerStartAngle = sa - overAngle,
|
609
|
-
outerea = this.outerEndAngle = ea + overAngle,
|
610
|
-
hubsa = this.hubStartAngle = sa - Math.atan(this.innerPad/this.hubRadius*2),
|
611
|
-
hubea = this.hubEndAngle = ea + Math.atan(this.innerPad/this.hubRadius*2);
|
612
|
-
|
613
|
-
ctx.save();
|
614
|
-
|
615
|
-
ctx.translate(this._center[0], this._center[1]);
|
616
|
-
ctx.lineJoin = "round";
|
617
|
-
ctx.lineCap = "round";
|
618
|
-
|
619
|
-
// draw the innerbackground
|
620
|
-
ctx.save();
|
621
|
-
ctx.beginPath();
|
622
|
-
ctx.fillStyle = this.background;
|
623
|
-
ctx.arc(0, 0, r, outersa, outerea, false);
|
624
|
-
ctx.closePath();
|
625
|
-
ctx.fill();
|
626
|
-
ctx.restore();
|
627
|
-
|
628
|
-
// draw the shadow
|
629
|
-
// the outer ring.
|
630
|
-
var shadowColor = 'rgba(0,0,0,'+this.shadowAlpha+')';
|
631
|
-
ctx.save();
|
632
|
-
for (var i=0; i<this.shadowDepth; i++) {
|
633
|
-
ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
|
634
|
-
ctx.beginPath();
|
635
|
-
ctx.strokeStyle = shadowColor;
|
636
|
-
ctx.lineWidth = this.shadowWidth;
|
637
|
-
ctx.arc(0 ,0, r, outersa, outerea, false);
|
638
|
-
ctx.closePath();
|
639
|
-
ctx.stroke();
|
640
|
-
}
|
641
|
-
ctx.restore();
|
642
|
-
|
643
|
-
// the inner hub.
|
644
|
-
ctx.save();
|
645
|
-
var tempd = parseInt((this.shadowDepth+1)/2, 10);
|
646
|
-
for (var i=0; i<tempd; i++) {
|
647
|
-
ctx.translate(this.shadowOffset*Math.cos(this.shadowAngle/180*Math.PI), this.shadowOffset*Math.sin(this.shadowAngle/180*Math.PI));
|
648
|
-
ctx.beginPath();
|
649
|
-
ctx.fillStyle = shadowColor;
|
650
|
-
ctx.arc(0 ,0, this.hubRadius, hubsa, hubea, false);
|
651
|
-
ctx.closePath();
|
652
|
-
ctx.fill();
|
653
|
-
}
|
654
|
-
ctx.restore();
|
655
|
-
|
656
|
-
// draw the outer ring.
|
657
|
-
ctx.save();
|
658
|
-
ctx.beginPath();
|
659
|
-
ctx.strokeStyle = this.ringColor;
|
660
|
-
ctx.lineWidth = this.ringWidth;
|
661
|
-
ctx.arc(0 ,0, r, outersa, outerea, false);
|
662
|
-
ctx.closePath();
|
663
|
-
ctx.stroke();
|
664
|
-
ctx.restore();
|
665
|
-
|
666
|
-
// draw the hub
|
667
|
-
|
668
|
-
ctx.save();
|
669
|
-
ctx.beginPath();
|
670
|
-
ctx.fillStyle = this.ringColor;
|
671
|
-
ctx.arc(0 ,0, this.hubRadius,hubsa, hubea, false);
|
672
|
-
ctx.closePath();
|
673
|
-
ctx.fill();
|
674
|
-
ctx.restore();
|
675
|
-
|
676
|
-
// draw the ticks
|
677
|
-
if (this.showTicks) {
|
678
|
-
ctx.save();
|
679
|
-
var orad = this.tickOuterRadius,
|
680
|
-
tl = this.tickLength,
|
681
|
-
mtl = tl/2,
|
682
|
-
nmt = this.numberMinorTicks,
|
683
|
-
ts = this.span * Math.PI / 180 / (this.ticks.length-1),
|
684
|
-
mts = ts/(nmt + 1);
|
685
|
-
|
686
|
-
for (i = 0; i<this.ticks.length; i++) {
|
687
|
-
ctx.beginPath();
|
688
|
-
ctx.lineWidth = 1.5 + this.diameter/360;
|
689
|
-
ctx.strokeStyle = this.ringColor;
|
690
|
-
var wps = ts*i+sa;
|
691
|
-
ctx.moveTo(-orad * Math.cos(ts*i+sa), orad * Math.sin(ts*i+sa));
|
692
|
-
ctx.lineTo(-(orad-tl) * Math.cos(ts*i+sa), (orad - tl) * Math.sin(ts*i+sa));
|
693
|
-
this._tickPoints.push([(orad-tl) * Math.cos(ts*i+sa) + this._center[0] + this.canvas._offsets.left, (orad - tl) * Math.sin(ts*i+sa) + this._center[1] + this.canvas._offsets.top, ts*i+sa]);
|
694
|
-
ctx.stroke();
|
695
|
-
ctx.lineWidth = 1.0 + this.diameter/440;
|
696
|
-
if (i<this.ticks.length-1) {
|
697
|
-
for (var j=1; j<=nmt; j++) {
|
698
|
-
ctx.beginPath();
|
699
|
-
ctx.moveTo(-orad * Math.cos(ts*i+mts*j+sa), orad * Math.sin(ts*i+mts*j+sa));
|
700
|
-
ctx.lineTo(-(orad-mtl) * Math.cos(ts*i+mts*j+sa), (orad-mtl) * Math.sin(ts*i+mts*j+sa));
|
701
|
-
ctx.stroke();
|
702
|
-
}
|
703
|
-
}
|
704
|
-
}
|
705
|
-
ctx.restore();
|
706
|
-
}
|
707
|
-
|
708
|
-
// draw the tick labels
|
709
|
-
if (this.showTickLabels) {
|
710
|
-
var elem, l, t, ew, eh, dim, maxdim=0;
|
711
|
-
var tp = this.tickPadding * (1 - 1/(this.diameter/80+1));
|
712
|
-
for (i=0; i<this.ticks.length; i++) {
|
713
|
-
elem = $('<div class="jqplot-meterGauge-tick" style="position:absolute;">'+this.ticks[i][1]+'</div>');
|
714
|
-
this.canvas._elem.after(elem);
|
715
|
-
ew = elem.outerWidth(true);
|
716
|
-
eh = elem.outerHeight(true);
|
717
|
-
l = this._tickPoints[i][0] - ew * (this._tickPoints[i][2]-Math.PI)/Math.PI - tp * Math.cos(this._tickPoints[i][2]);
|
718
|
-
t = this._tickPoints[i][1] - eh/2 + eh/2 * Math.pow(Math.abs((Math.sin(this._tickPoints[i][2]))), 0.5) + tp/3 * Math.pow(Math.abs((Math.sin(this._tickPoints[i][2]))), 0.5) ;
|
719
|
-
// t = this._tickPoints[i][1] - eh/2 - eh/2 * Math.sin(this._tickPoints[i][2]) - tp/2 * Math.sin(this._tickPoints[i][2]);
|
720
|
-
elem.css({left:l, top:t});
|
721
|
-
dim = ew*Math.cos(this._tickPoints[i][2]) + eh*Math.sin(Math.PI/2+this._tickPoints[i][2]/2);
|
722
|
-
maxdim = (dim > maxdim) ? dim : maxdim;
|
723
|
-
}
|
724
|
-
}
|
725
|
-
|
726
|
-
// draw the gauge label
|
727
|
-
if (this.label && this.labelPosition == 'inside') {
|
728
|
-
var l = this._center[0] + this.canvas._offsets.left;
|
729
|
-
var tp = this.tickPadding * (1 - 1/(this.diameter/80+1));
|
730
|
-
var t = 0.5*(this._center[1] + this.canvas._offsets.top - this.hubRadius) + 0.5*(this._center[1] + this.canvas._offsets.top - this.tickOuterRadius + this.tickLength + tp) + this.labelHeightAdjust;
|
731
|
-
// this._labelElem = $('<div class="jqplot-meterGauge-label" style="position:absolute;">'+this.label+'</div>');
|
732
|
-
// this.canvas._elem.after(this._labelElem);
|
733
|
-
l -= this._labelElem.outerWidth(true)/2;
|
734
|
-
t -= this._labelElem.outerHeight(true)/2;
|
735
|
-
this._labelElem.css({left:l, top:t});
|
736
|
-
}
|
737
|
-
|
738
|
-
else if (this.label && this.labelPosition == 'bottom') {
|
739
|
-
var l = this._center[0] + this.canvas._offsets.left - this._labelElem.outerWidth(true)/2;
|
740
|
-
var t = this._center[1] + this.canvas._offsets.top + this.innerPad + + this.ringWidth + this.padding + this.labelHeightAdjust;
|
741
|
-
this._labelElem.css({left:l, top:t});
|
742
|
-
|
743
|
-
}
|
744
|
-
|
745
|
-
// draw the intervals
|
746
|
-
|
747
|
-
ctx.save();
|
748
|
-
var inner = this.intervalInnerRadius || this.hubRadius * 1.5;
|
749
|
-
if (this.intervalOuterRadius == null) {
|
750
|
-
if (this.showTickLabels) {
|
751
|
-
var outer = (this.tickOuterRadius - this.tickLength - this.tickPadding - this.diameter/8);
|
752
|
-
}
|
753
|
-
else {
|
754
|
-
var outer = (this.tickOuterRadius - this.tickLength - this.diameter/16);
|
755
|
-
}
|
756
|
-
}
|
757
|
-
else {
|
758
|
-
var outer = this.intervalOuterRadius;
|
759
|
-
}
|
760
|
-
var range = this.max - this.min;
|
761
|
-
var intrange = this.intervals[this.intervals.length-1] - this.min;
|
762
|
-
var start, end, span = this.span*Math.PI/180;
|
763
|
-
for (i=0; i<this.intervals.length; i++) {
|
764
|
-
start = (i == 0) ? sa : sa + (this.intervals[i-1][0] - this.min)*span/range;
|
765
|
-
if (start < 0) {
|
766
|
-
start = 0;
|
767
|
-
}
|
768
|
-
end = sa + (this.intervals[i][0] - this.min)*span/range;
|
769
|
-
if (end < 0) {
|
770
|
-
end = 0;
|
771
|
-
}
|
772
|
-
ctx.beginPath();
|
773
|
-
ctx.fillStyle = this.intervals[i][2];
|
774
|
-
ctx.arc(0, 0, inner, start, end, false);
|
775
|
-
ctx.lineTo(outer*Math.cos(end), outer*Math.sin(end));
|
776
|
-
ctx.arc(0, 0, outer, end, start, true);
|
777
|
-
ctx.lineTo(inner*Math.cos(start), inner*Math.sin(start));
|
778
|
-
ctx.closePath();
|
779
|
-
ctx.fill();
|
780
|
-
}
|
781
|
-
ctx.restore();
|
782
|
-
|
783
|
-
// draw the needle
|
784
|
-
var datapoint = this.data[0][1];
|
785
|
-
var dataspan = this.max - this.min;
|
786
|
-
if (this.pegNeedle) {
|
787
|
-
if (this.data[0][1] > this.max + dataspan*3/this.span) {
|
788
|
-
datapoint = this.max + dataspan*3/this.span;
|
789
|
-
}
|
790
|
-
if (this.data[0][1] < this.min - dataspan*3/this.span) {
|
791
|
-
datapoint = this.min - dataspan*3/this.span;
|
792
|
-
}
|
793
|
-
}
|
794
|
-
var dataang = (datapoint - this.min)/dataspan * this.span * Math.PI/180 + this.startAngle;
|
795
|
-
|
796
|
-
|
797
|
-
ctx.save();
|
798
|
-
ctx.beginPath();
|
799
|
-
ctx.fillStyle = this.ringColor;
|
800
|
-
ctx.strokeStyle = this.ringColor;
|
801
|
-
this.needleLength = (this.tickOuterRadius - this.tickLength) * 0.85;
|
802
|
-
this.needleThickness = (this.needleThickness < 2) ? 2 : this.needleThickness;
|
803
|
-
var endwidth = this.needleThickness * 0.4;
|
804
|
-
|
805
|
-
|
806
|
-
var dl = this.needleLength/10;
|
807
|
-
var dt = (this.needleThickness - endwidth)/10;
|
808
|
-
var templ;
|
809
|
-
for (var i=0; i<10; i++) {
|
810
|
-
templ = this.needleThickness - i*dt;
|
811
|
-
ctx.moveTo(dl*i*Math.cos(dataang), dl*i*Math.sin(dataang));
|
812
|
-
ctx.lineWidth = templ;
|
813
|
-
ctx.lineTo(dl*(i+1)*Math.cos(dataang), dl*(i+1)*Math.sin(dataang));
|
814
|
-
ctx.stroke();
|
815
|
-
}
|
816
|
-
|
817
|
-
ctx.restore();
|
818
|
-
}
|
819
|
-
else {
|
820
|
-
this._center = [(cw - trans * offx)/2 + trans * offx, (ch - trans*offy)/2 + trans * offy];
|
821
|
-
}
|
822
|
-
};
|
823
|
-
|
824
|
-
$.jqplot.MeterGaugeAxisRenderer = function() {
|
825
|
-
$.jqplot.LinearAxisRenderer.call(this);
|
826
|
-
};
|
827
|
-
|
828
|
-
$.jqplot.MeterGaugeAxisRenderer.prototype = new $.jqplot.LinearAxisRenderer();
|
829
|
-
$.jqplot.MeterGaugeAxisRenderer.prototype.constructor = $.jqplot.MeterGaugeAxisRenderer;
|
830
|
-
|
831
|
-
|
832
|
-
// There are no traditional axes on a gauge chart. We just need to provide
|
833
|
-
// dummy objects with properties so the plot will render.
|
834
|
-
// called with scope of axis object.
|
835
|
-
$.jqplot.MeterGaugeAxisRenderer.prototype.init = function(options){
|
836
|
-
//
|
837
|
-
this.tickRenderer = $.jqplot.MeterGaugeTickRenderer;
|
838
|
-
$.extend(true, this, options);
|
839
|
-
// I don't think I'm going to need _dataBounds here.
|
840
|
-
// have to go Axis scaling in a way to fit chart onto plot area
|
841
|
-
// and provide u2p and p2u functionality for mouse cursor, etc.
|
842
|
-
// for convienence set _dataBounds to 0 and 100 and
|
843
|
-
// set min/max to 0 and 100.
|
844
|
-
this._dataBounds = {min:0, max:100};
|
845
|
-
this.min = 0;
|
846
|
-
this.max = 100;
|
847
|
-
this.showTicks = false;
|
848
|
-
this.ticks = [];
|
849
|
-
this.showMark = false;
|
850
|
-
this.show = false;
|
851
|
-
};
|
852
|
-
|
853
|
-
$.jqplot.MeterGaugeLegendRenderer = function(){
|
854
|
-
$.jqplot.TableLegendRenderer.call(this);
|
855
|
-
};
|
856
|
-
|
857
|
-
$.jqplot.MeterGaugeLegendRenderer.prototype = new $.jqplot.TableLegendRenderer();
|
858
|
-
$.jqplot.MeterGaugeLegendRenderer.prototype.constructor = $.jqplot.MeterGaugeLegendRenderer;
|
859
|
-
|
860
|
-
/**
|
861
|
-
* Class: $.jqplot.MeterGaugeLegendRenderer
|
862
|
-
*Meter gauges don't typically have a legend, this overrides the default legend renderer.
|
863
|
-
*/
|
864
|
-
$.jqplot.MeterGaugeLegendRenderer.prototype.init = function(options) {
|
865
|
-
|
866
|
-
// Maximum number of rows in the legend. 0 or null for unlimited.
|
867
|
-
this.numberRows = null;
|
868
|
-
// Maximum number of columns in the legend. 0 or null for unlimited.
|
869
|
-
this.numberColumns = null;
|
870
|
-
$.extend(true, this, options);
|
871
|
-
};
|
872
|
-
|
873
|
-
// called with context of legend
|
874
|
-
$.jqplot.MeterGaugeLegendRenderer.prototype.draw = function() {
|
875
|
-
var legend = this;
|
876
|
-
if (this.show) {
|
877
|
-
var series = this._series;
|
878
|
-
var ss = 'position:absolute;';
|
879
|
-
ss += (this.background) ? 'background:'+this.background+';' : '';
|
880
|
-
ss += (this.border) ? 'border:'+this.border+';' : '';
|
881
|
-
ss += (this.fontSize) ? 'font-size:'+this.fontSize+';' : '';
|
882
|
-
ss += (this.fontFamily) ? 'font-family:'+this.fontFamily+';' : '';
|
883
|
-
ss += (this.textColor) ? 'color:'+this.textColor+';' : '';
|
884
|
-
ss += (this.marginTop != null) ? 'margin-top:'+this.marginTop+';' : '';
|
885
|
-
ss += (this.marginBottom != null) ? 'margin-bottom:'+this.marginBottom+';' : '';
|
886
|
-
ss += (this.marginLeft != null) ? 'margin-left:'+this.marginLeft+';' : '';
|
887
|
-
ss += (this.marginRight != null) ? 'margin-right:'+this.marginRight+';' : '';
|
888
|
-
this._elem = $('<table class="jqplot-table-legend" style="'+ss+'"></table>');
|
889
|
-
// MeterGauge charts legends don't go by number of series, but by number of data points
|
890
|
-
// in the series. Refactor things here for that.
|
891
|
-
|
892
|
-
var pad = false,
|
893
|
-
reverse = false,
|
894
|
-
nr, nc;
|
895
|
-
var s = series[0];
|
896
|
-
|
897
|
-
if (s.show) {
|
898
|
-
var pd = s.data;
|
899
|
-
if (this.numberRows) {
|
900
|
-
nr = this.numberRows;
|
901
|
-
if (!this.numberColumns){
|
902
|
-
nc = Math.ceil(pd.length/nr);
|
903
|
-
}
|
904
|
-
else{
|
905
|
-
nc = this.numberColumns;
|
906
|
-
}
|
907
|
-
}
|
908
|
-
else if (this.numberColumns) {
|
909
|
-
nc = this.numberColumns;
|
910
|
-
nr = Math.ceil(pd.length/this.numberColumns);
|
911
|
-
}
|
912
|
-
else {
|
913
|
-
nr = pd.length;
|
914
|
-
nc = 1;
|
915
|
-
}
|
916
|
-
|
917
|
-
var i, j, tr, td1, td2, lt, rs, color;
|
918
|
-
var idx = 0;
|
919
|
-
|
920
|
-
for (i=0; i<nr; i++) {
|
921
|
-
if (reverse){
|
922
|
-
tr = $('<tr class="jqplot-table-legend"></tr>').prependTo(this._elem);
|
923
|
-
}
|
924
|
-
else{
|
925
|
-
tr = $('<tr class="jqplot-table-legend"></tr>').appendTo(this._elem);
|
926
|
-
}
|
927
|
-
for (j=0; j<nc; j++) {
|
928
|
-
if (idx < pd.length){
|
929
|
-
lt = this.labels[idx] || pd[idx][0].toString();
|
930
|
-
color = colorGenerator.next();
|
931
|
-
if (!reverse){
|
932
|
-
if (i>0){
|
933
|
-
pad = true;
|
934
|
-
}
|
935
|
-
else{
|
936
|
-
pad = false;
|
937
|
-
}
|
938
|
-
}
|
939
|
-
else{
|
940
|
-
if (i == nr -1){
|
941
|
-
pad = false;
|
942
|
-
}
|
943
|
-
else{
|
944
|
-
pad = true;
|
945
|
-
}
|
946
|
-
}
|
947
|
-
rs = (pad) ? this.rowSpacing : '0';
|
948
|
-
|
949
|
-
td1 = $('<td class="jqplot-table-legend" style="text-align:center;padding-top:'+rs+';">'+
|
950
|
-
'<div><div class="jqplot-table-legend-swatch" style="border-color:'+color+';"></div>'+
|
951
|
-
'</div></td>');
|
952
|
-
td2 = $('<td class="jqplot-table-legend" style="padding-top:'+rs+';"></td>');
|
953
|
-
if (this.escapeHtml){
|
954
|
-
td2.text(lt);
|
955
|
-
}
|
956
|
-
else {
|
957
|
-
td2.html(lt);
|
958
|
-
}
|
959
|
-
if (reverse) {
|
960
|
-
td2.prependTo(tr);
|
961
|
-
td1.prependTo(tr);
|
962
|
-
}
|
963
|
-
else {
|
964
|
-
td1.appendTo(tr);
|
965
|
-
td2.appendTo(tr);
|
966
|
-
}
|
967
|
-
pad = true;
|
968
|
-
}
|
969
|
-
idx++;
|
970
|
-
}
|
971
|
-
}
|
972
|
-
}
|
973
|
-
}
|
974
|
-
return this._elem;
|
975
|
-
};
|
976
|
-
|
977
|
-
// $.jqplot.MeterGaugeLegendRenderer.prototype.pack = function(offsets) {
|
978
|
-
// if (this.show) {
|
979
|
-
// // fake a grid for positioning
|
980
|
-
// var grid = {_top:offsets.top, _left:offsets.left, _right:offsets.right, _bottom:this._plotDimensions.height - offsets.bottom};
|
981
|
-
// if (this.placement == 'insideGrid') {
|
982
|
-
// switch (this.location) {
|
983
|
-
// case 'nw':
|
984
|
-
// var a = grid._left + this.xoffset;
|
985
|
-
// var b = grid._top + this.yoffset;
|
986
|
-
// this._elem.css('left', a);
|
987
|
-
// this._elem.css('top', b);
|
988
|
-
// break;
|
989
|
-
// case 'n':
|
990
|
-
// var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
|
991
|
-
// var b = grid._top + this.yoffset;
|
992
|
-
// this._elem.css('left', a);
|
993
|
-
// this._elem.css('top', b);
|
994
|
-
// break;
|
995
|
-
// case 'ne':
|
996
|
-
// var a = offsets.right + this.xoffset;
|
997
|
-
// var b = grid._top + this.yoffset;
|
998
|
-
// this._elem.css({right:a, top:b});
|
999
|
-
// break;
|
1000
|
-
// case 'e':
|
1001
|
-
// var a = offsets.right + this.xoffset;
|
1002
|
-
// var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
|
1003
|
-
// this._elem.css({right:a, top:b});
|
1004
|
-
// break;
|
1005
|
-
// case 'se':
|
1006
|
-
// var a = offsets.right + this.xoffset;
|
1007
|
-
// var b = offsets.bottom + this.yoffset;
|
1008
|
-
// this._elem.css({right:a, bottom:b});
|
1009
|
-
// break;
|
1010
|
-
// case 's':
|
1011
|
-
// var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
|
1012
|
-
// var b = offsets.bottom + this.yoffset;
|
1013
|
-
// this._elem.css({left:a, bottom:b});
|
1014
|
-
// break;
|
1015
|
-
// case 'sw':
|
1016
|
-
// var a = grid._left + this.xoffset;
|
1017
|
-
// var b = offsets.bottom + this.yoffset;
|
1018
|
-
// this._elem.css({left:a, bottom:b});
|
1019
|
-
// break;
|
1020
|
-
// case 'w':
|
1021
|
-
// var a = grid._left + this.xoffset;
|
1022
|
-
// var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
|
1023
|
-
// this._elem.css({left:a, top:b});
|
1024
|
-
// break;
|
1025
|
-
// default: // same as 'se'
|
1026
|
-
// var a = grid._right - this.xoffset;
|
1027
|
-
// var b = grid._bottom + this.yoffset;
|
1028
|
-
// this._elem.css({right:a, bottom:b});
|
1029
|
-
// break;
|
1030
|
-
// }
|
1031
|
-
//
|
1032
|
-
// }
|
1033
|
-
// else {
|
1034
|
-
// switch (this.location) {
|
1035
|
-
// case 'nw':
|
1036
|
-
// var a = this._plotDimensions.width - grid._left + this.xoffset;
|
1037
|
-
// var b = grid._top + this.yoffset;
|
1038
|
-
// this._elem.css('right', a);
|
1039
|
-
// this._elem.css('top', b);
|
1040
|
-
// break;
|
1041
|
-
// case 'n':
|
1042
|
-
// var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
|
1043
|
-
// var b = this._plotDimensions.height - grid._top + this.yoffset;
|
1044
|
-
// this._elem.css('left', a);
|
1045
|
-
// this._elem.css('bottom', b);
|
1046
|
-
// break;
|
1047
|
-
// case 'ne':
|
1048
|
-
// var a = this._plotDimensions.width - offsets.right + this.xoffset;
|
1049
|
-
// var b = grid._top + this.yoffset;
|
1050
|
-
// this._elem.css({left:a, top:b});
|
1051
|
-
// break;
|
1052
|
-
// case 'e':
|
1053
|
-
// var a = this._plotDimensions.width - offsets.right + this.xoffset;
|
1054
|
-
// var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
|
1055
|
-
// this._elem.css({left:a, top:b});
|
1056
|
-
// break;
|
1057
|
-
// case 'se':
|
1058
|
-
// var a = this._plotDimensions.width - offsets.right + this.xoffset;
|
1059
|
-
// var b = offsets.bottom + this.yoffset;
|
1060
|
-
// this._elem.css({left:a, bottom:b});
|
1061
|
-
// break;
|
1062
|
-
// case 's':
|
1063
|
-
// var a = (offsets.left + (this._plotDimensions.width - offsets.right))/2 - this.getWidth()/2;
|
1064
|
-
// var b = this._plotDimensions.height - offsets.bottom + this.yoffset;
|
1065
|
-
// this._elem.css({left:a, top:b});
|
1066
|
-
// break;
|
1067
|
-
// case 'sw':
|
1068
|
-
// var a = this._plotDimensions.width - grid._left + this.xoffset;
|
1069
|
-
// var b = offsets.bottom + this.yoffset;
|
1070
|
-
// this._elem.css({right:a, bottom:b});
|
1071
|
-
// break;
|
1072
|
-
// case 'w':
|
1073
|
-
// var a = this._plotDimensions.width - grid._left + this.xoffset;
|
1074
|
-
// var b = (offsets.top + (this._plotDimensions.height - offsets.bottom))/2 - this.getHeight()/2;
|
1075
|
-
// this._elem.css({right:a, top:b});
|
1076
|
-
// break;
|
1077
|
-
// default: // same as 'se'
|
1078
|
-
// var a = grid._right - this.xoffset;
|
1079
|
-
// var b = grid._bottom + this.yoffset;
|
1080
|
-
// this._elem.css({right:a, bottom:b});
|
1081
|
-
// break;
|
1082
|
-
// }
|
1083
|
-
// }
|
1084
|
-
// }
|
1085
|
-
// };
|
1086
|
-
|
1087
|
-
// setup default renderers for axes and legend so user doesn't have to
|
1088
|
-
// called with scope of plot
|
1089
|
-
function preInit(target, data, options) {
|
1090
|
-
options = options || {};
|
1091
|
-
options.axesDefaults = options.axesDefaults || {};
|
1092
|
-
options.legend = options.legend || {};
|
1093
|
-
options.seriesDefaults = options.seriesDefaults || {};
|
1094
|
-
options.grid = options.grid || {};
|
1095
|
-
options.gridPadding = options.gridPadding || {};
|
1096
|
-
|
1097
|
-
// only set these if there is a gauge series
|
1098
|
-
var setopts = false;
|
1099
|
-
if (options.seriesDefaults.renderer == $.jqplot.MeterGaugeRenderer) {
|
1100
|
-
setopts = true;
|
1101
|
-
}
|
1102
|
-
else if (options.series) {
|
1103
|
-
for (var i=0; i < options.series.length; i++) {
|
1104
|
-
if (options.series[i].renderer == $.jqplot.MeterGaugeRenderer) {
|
1105
|
-
setopts = true;
|
1106
|
-
}
|
1107
|
-
}
|
1108
|
-
}
|
1109
|
-
|
1110
|
-
if (setopts) {
|
1111
|
-
options.axesDefaults.renderer = $.jqplot.MeterGaugeAxisRenderer;
|
1112
|
-
options.legend.renderer = $.jqplot.MeterGaugeLegendRenderer;
|
1113
|
-
options.legend.preDraw = true;
|
1114
|
-
options.grid.background = options.grid.background || 'white';
|
1115
|
-
options.grid.drawGridlines = false;
|
1116
|
-
options.grid.borderWidth = (options.grid.borderWidth != null) ? options.grid.borderWidth : 0;
|
1117
|
-
options.grid.shadow = (options.grid.shadow != null) ? options.grid.shadow : false;
|
1118
|
-
options.gridPadding.top = (options.gridPadding.top != null) ? options.gridPadding.top : 0;
|
1119
|
-
options.gridPadding.bottom = (options.gridPadding.bottom != null) ? options.gridPadding.bottom : 0;
|
1120
|
-
options.gridPadding.left = (options.gridPadding.left != null) ? options.gridPadding.left : 0;
|
1121
|
-
options.gridPadding.right = (options.gridPadding.right != null) ? options.gridPadding.right : 0;
|
1122
|
-
}
|
1123
|
-
}
|
1124
|
-
|
1125
|
-
// called with scope of plot
|
1126
|
-
function postParseOptions(options) {
|
1127
|
-
//
|
1128
|
-
}
|
1129
|
-
|
1130
|
-
$.jqplot.preInitHooks.push(preInit);
|
1131
|
-
$.jqplot.postParseOptionsHooks.push(postParseOptions);
|
1132
|
-
|
1133
|
-
$.jqplot.MeterGaugeTickRenderer = function() {
|
1134
|
-
$.jqplot.AxisTickRenderer.call(this);
|
1135
|
-
};
|
1136
|
-
|
1137
|
-
$.jqplot.MeterGaugeTickRenderer.prototype = new $.jqplot.AxisTickRenderer();
|
1138
|
-
$.jqplot.MeterGaugeTickRenderer.prototype.constructor = $.jqplot.MeterGaugeTickRenderer;
|
1139
|
-
|
1140
|
-
})(jQuery);
|
1141
|
-
|
1142
|
-
|