src/ztfy/myams/resources/js/myams-graphs.js
changeset 142 0201f1422bd7
parent 0 8a19e25e39e4
--- a/src/ztfy/myams/resources/js/myams-graphs.js	Tue Nov 17 12:04:26 2015 +0100
+++ b/src/ztfy/myams/resources/js/myams-graphs.js	Tue Nov 17 12:05:38 2015 +0100
@@ -3,17 +3,21 @@
  * Version 0.1.0
  * ©2014 Thierry Florac <tflorac@ulthar.net>
  */
-(function($) {
+(function($, globals) {
+
+	'use strict';
+
+	var MyAMS = globals.MyAMS;
 
 	MyAMS.graphs = {
 
 		init: function(graphs) {
 			MyAMS.ajax.check($.fn.sparkline,
 							   MyAMS.baseURL + 'ext/jquery-sparkline-2.1.1.min.js',
-							   function(first_load) {
+							   function() {
 									graphs.each(function() {
 										var graph = $(this);
-										var graph_data  =graph.data();
+										var graph_data = graph.data();
 										var sparklineType = graph_data.sparklineType || 'bar';
 										switch (sparklineType) {
 											case 'bar':
@@ -61,7 +65,6 @@
 													height : graph_data.sparklinePiesize || 90,
 													tooltipFormat : '<span style="color: {{color}}">&#9679;</span> ({{percent.1}}%)',
 													sliceColors : graph_data.sparklinePiecolor || ["#B4CAD3", "#4490B1", "#98AA56", "#da532c", "#6E9461", "#0099c6", "#990099", "#717D8A"],
-													offset : 0,
 													borderWidth : 1,
 													offset : graph_data.sparklineOffset || 0,
 													borderColor : graph_data.borderColor || '#45494C'
@@ -95,7 +98,7 @@
 													type : 'bullet',
 													height : graph_data.sparklineHeight || 'auto',
 													targetWidth : graph_data.sparklineWidth || 2,
-													targetColor : graph_data.sparklineBullet-color || '#ed1c24',
+													targetColor : graph_data.sparklineBulletColor || '#ed1c24',
 													performanceColor : graph_data.sparklinePerformanceColor || '#3030f0',
 													rangeColors : graph_data.sparklineBulletrangeColor || ["#d3dafe", "#a8b6ff", "#7f94ff"]
 												});
@@ -127,14 +130,14 @@
 												break;
 
 											case 'compositebar':
-												$this.sparkline(graph_data.sparklineBarVal, {
+												graph.sparkline(graph_data.sparklineBarVal, {
 													type : 'bar',
 													width : graph_data.sparklineWidth || '100%',
 													height : graph_data.sparklineHeight || '20px',
 													barColor : graph_data.sparklineColorBottom || '#333333',
 													barWidth : graph_data.sparklineBarwidth || 3
 												});
-												$this.sparkline(graph_data.sparklineLineVal, {
+												graph.sparkline(graph_data.sparklineLineVal, {
 													width : graph_data.sparklineWidth || '100%',
 													height : graph_data.sparklineHeight || '20px',
 													lineColor : graph_data.sparklineColorTop || '#ed1c24',
@@ -145,14 +148,14 @@
 												break;
 
 											case 'compositeline':
-												$this.sparkline(graph_data.sparklineBarVal, {
+												graph.sparkline(graph_data.sparklineBarVal, {
 													type : 'line',
 													spotRadius : graph_data.sparklineSpotradiusTop || 1.5,
 													spotColor : graph_data.sparklineSpotColor || '#f08000',
-													minSpotColor : graph_data.sparklineMinspotColorTop || '#ed1c24',
-													maxSpotColor : graph_data.sparkline-maxspotColorTop || '#f08000',
-													highlightSpotColor : graph_data.sparklineHighlightspotColorTop || '#50f050',
-													highlightLineColor : graph_data.sparklineHighlightlineColorTop || '#f02020',
+													minSpotColor : graph_data.sparklineMinSpotColorTop || '#ed1c24',
+													maxSpotColor : graph_data.sparklineMaxSpotColorTop || '#f08000',
+													highlightSpotColor : graph_data.sparklineHighlightSpotColorTop || '#50f050',
+													highlightLineColor : graph_data.sparklineHighlightLineColorTop || '#f02020',
 													valueSpots : graph_data.sparklineBarValSpotsTop || null,
 													lineWidth : graph_data.sparklineLineWidthTop || 1,
 													width : graph_data.sparklineWidth || '90px',
@@ -160,7 +163,7 @@
 													lineColor : graph_data.sparklineColorTop || '#333333',
 													fillColor : graph_data.sparklineFillcolorTop || 'transparent'
 												});
-												$this.sparkline(graph_data.sparklineLineVal, {
+												graph.sparkline(graph_data.sparklineLineVal, {
 													type : 'line',
 													spotRadius : graph_data.sparklineSpotradiusBottom || graph_data.sparklineSpotradiusTop || 1.5,
 													spotColor : graph_data.sparklineSpotColor || '#f08000',
@@ -181,6 +184,6 @@
 									});
 							   });
 		}
-	}
+	};
 
-})(jQuery);
+})(jQuery, this);