app/assets/javascripts/highcharts/modules/funnel.js in highcharts-rails-4.1.9 vs app/assets/javascripts/highcharts/modules/funnel.js in highcharts-rails-4.1.10
- old
+ new
@@ -4,13 +4,18 @@
*
* (c) 2010-2014 Torstein Honsi
*
* License: www.highcharts.com/license
*/
-
-/*global Highcharts */
-(function (Highcharts) {
+/* eslint indent:0 */
+(function (factory) {
+ if (typeof module === 'object' && module.exports) {
+ module.exports = factory;
+ } else {
+ factory(Highcharts);
+ }
+}(function (Highcharts) {
'use strict';
// create shortcuts
var defaultOptions = Highcharts.getOptions(),
@@ -80,11 +85,11 @@
tempWidth,
getWidthAt,
height = getLength(options.height, plotHeight),
neckWidth = getLength(options.neckWidth, plotWidth),
neckHeight = getLength(options.neckHeight, plotHeight),
- neckY = height - neckHeight,
+ neckY = (centerY - height / 2) + height - neckHeight,
data = series.data,
path,
fraction,
half = options.dataLabels.position === 'left' ? 1 : 0,
@@ -96,16 +101,18 @@
x4,
y5;
// Return the width at a specific y coordinate
series.getWidthAt = getWidthAt = function (y) {
- return y > height - neckHeight || height === neckHeight ?
+ var top = (centerY - height / 2);
+
+ return y > neckY || height === neckHeight ?
neckWidth :
- neckWidth + (width - neckWidth) * ((height - neckHeight - y) / (height - neckHeight));
+ neckWidth + (width - neckWidth) * (1 - (y - top) / (height - neckHeight));
};
series.getX = function (y, half) {
- return centerX + (half ? -1 : 1) * ((getWidthAt(reversed ? plotHeight - y : y) / 2) + options.dataLabels.distance);
+ return centerX + (half ? -1 : 1) * ((getWidthAt(reversed ? plotHeight - y : y) / 2) + options.dataLabels.distance);
};
// Expose
series.center = [centerX, centerY, height];
series.centerX = centerX;
@@ -230,17 +237,17 @@
var pointOptions = point.options,
graphic = point.graphic,
shapeArgs = point.shapeArgs;
if (!graphic) { // Create the shapes
- point.graphic = renderer.path(shapeArgs).
- attr({
+ point.graphic = renderer.path(shapeArgs)
+ .attr({
fill: point.color,
stroke: pick(pointOptions.borderColor, options.borderColor),
'stroke-width': pick(pointOptions.borderWidth, options.borderWidth)
- }).
- add(series.group);
+ })
+ .add(series.group);
} else { // Update the shapes
graphic.animate(shapeArgs);
}
});
@@ -310,6 +317,6 @@
});
Highcharts.seriesTypes.pyramid = Highcharts.extendClass(Highcharts.seriesTypes.funnel, {
type: 'pyramid'
});
-}(Highcharts));
+}));