Эх сурвалжийг харах

HUE-487. Including the point value in HueChart.Box selection event parameter object.

Marcus McLaughlin 14 жил өмнө
parent
commit
74df5894d3

+ 3 - 2
desktop/core/static/js/Source/Hue/HueChart.Area.js

@@ -45,9 +45,10 @@ HueChart.Area = new Class({
 				};
 				};
 		},
 		},
 
 
-		getYRange: function(y) {
-				return this.parent(y, this.yScaleTicks);
+		invertYValue: function(y) {
+			return this.yScaleTicks.invert(y);
 		},
 		},
+
 		getDataSeriesFromPointAndY: function(dataPoint, y) {
 		getDataSeriesFromPointAndY: function(dataPoint, y) {
 				var yRange = this.getYRange(y);
 				var yRange = this.getYRange(y);
 				var yCenter = (yRange[0] + yRange[1])/2;
 				var yCenter = (yRange[0] + yRange[1])/2;

+ 19 - 4
desktop/core/static/js/Source/Hue/HueChart.Box.js

@@ -356,13 +356,16 @@ HueChart.Box = new Class({
 				}
 				}
 		},
 		},
 
 
+		invertYValue: function(y) {
+			return this.yScale.invert(y);
+		},
+
 		getYRange: function(y, inversionScale) {
 		getYRange: function(y, inversionScale) {
-				var scale = inversionScale || this.yScale;
 				var yBuffer = 5; //Pixel buffer for usability.
 				var yBuffer = 5; //Pixel buffer for usability.
 				//Must use yValueReverse to reverse the mouse value because drawing happens from the bottom up.  Mouse position is from the top down.
 				//Must use yValueReverse to reverse the mouse value because drawing happens from the bottom up.  Mouse position is from the top down.
-				var invertedYValue = scale.invert(y);
+				var invertedYValue = this.invertYValue(y);
 				//Since range will be inverted, the array goes from greatest to least initially.
 				//Since range will be inverted, the array goes from greatest to least initially.
-				var invertedYRange = [scale.invert(y + yBuffer), scale.invert(y - yBuffer)];
+				var invertedYRange = [this.invertYValue(y + yBuffer), this.invertYValue(y - yBuffer)];
 				var yValue = this.yValueReverse(invertedYValue);
 				var yValue = this.yValueReverse(invertedYValue);
 				//Convert the inverted yRange to a non-inverted yRange.
 				//Convert the inverted yRange to a non-inverted yRange.
 				var yRange = invertedYRange.map(function(value) { return this.yValueReverse(value); }.bind(this));
 				var yRange = invertedYRange.map(function(value) { return this.yValueReverse(value); }.bind(this));
@@ -426,11 +429,23 @@ HueChart.Box = new Class({
 				return argArray.map(function(point) {
 				return argArray.map(function(point) {
 						var toGraph = this.adjustToGraph(axis, point);
 						var toGraph = this.adjustToGraph(axis, point);
 						var index = this.getDataIndexFromPoint(axis, toGraph);
 						var index = this.getDataIndexFromPoint(axis, toGraph);
-						return { index: index, data: this.getData(true).getObjects()[index] };
+						var pointValue = this.getValueFromPoint(axis, point);
+						return { index: index, data: this.getData(true).getObjects()[index], pointValue: pointValue };
 				}.bind(this));
 				}.bind(this));
 				
 				
 		},
 		},
 		
 		
+		getValueFromPoint: function(axis, point) {
+			switch (axis) {
+				case 'x':
+					return this.xScale.invert(point);
+					break;
+				case 'y':
+					return this.invertYValue(point);
+					break;
+			}
+		},
+		
 		//Make selection in graph draggable
 		//Make selection in graph draggable
 		makeSelectionDraggable: function() {
 		makeSelectionDraggable: function() {
 				//Attach the ProtoVis drag behavior to the select bar and attach events for drag occurrences
 				//Attach the ProtoVis drag behavior to the select bar and attach events for drag occurrences