Permalink
Browse files

Added support for polar columnrange series.

  • Loading branch information...
TorsteinHonsi committed Mar 30, 2016
1 parent f615069 commit d2b1113bd030a325b41ecc15bccc933e30ae0e83
Showing with 108 additions and 66 deletions.
  1. +55 −34 js/highcharts-more.src.js
  2. +33 −16 js/parts-more/ColumnRangeSeries.js
  3. +20 −16 js/parts-more/Polar.js
View
@@ -2,7 +2,7 @@
// @compilation_level SIMPLE_OPTIMIZATIONS
/**
* @license Highcharts JS v4.2.3-modified (2016-02-26)
* @license Highcharts JS v4.2.3-modified (2016-03-30)
*
* (c) 2009-2016 Torstein Honsi
*
@@ -968,11 +968,14 @@ var arrayMin = Highcharts.arrayMin,
/**
* Translate data points from raw values x and y to plotX and plotY
*/
translate: function () {
translate: function () {console.log('@colrange.translate')
var series = this,
yAxis = series.yAxis,
xAxis = series.xAxis,
startAngleRad = xAxis.startAngleRad,
chart = series.chart,
renderer = chart.renderer,
isRadial = series.xAxis.isRadial,
plotHigh;
colProto.translate.apply(series);
@@ -990,7 +993,7 @@ var arrayMin = Highcharts.arrayMin,
// adjust shape
y = plotHigh;
height = point.plotY - plotHigh;
height = pick(point.rectPlotY, point.plotY) - plotHigh;
// Adjust for minPointLength
if (Math.abs(height) < minPointLength) {
@@ -1004,19 +1007,28 @@ var arrayMin = Highcharts.arrayMin,
y -= height;
}
shapeArgs.height = height;
shapeArgs.y = y;
point.tooltipPos = chart.inverted ?
[
yAxis.len + yAxis.pos - chart.plotLeft - y - height / 2,
xAxis.len + xAxis.pos - chart.plotTop - shapeArgs.x - shapeArgs.width / 2,
height
] : [
xAxis.left - chart.plotLeft + shapeArgs.x + shapeArgs.width / 2,
yAxis.pos - chart.plotTop + y + height / 2,
height
]; // don't inherit from column tooltip position - #3372
if (isRadial) {
start = point.barX + startAngleRad;
point.shapeType = 'path';
point.shapeArgs = {
d: series.polarArc(y + height, y, start, start + point.pointWidth)
};
} else {
shapeArgs.height = height;
shapeArgs.y = y;
point.tooltipPos = chart.inverted ?
[
yAxis.len + yAxis.pos - chart.plotLeft - y - height / 2,
xAxis.len + xAxis.pos - chart.plotTop - shapeArgs.x - shapeArgs.width / 2,
height
] : [
xAxis.left - chart.plotLeft + shapeArgs.x + shapeArgs.width / 2,
yAxis.pos - chart.plotTop + y + height / 2,
height
]; // don't inherit from column tooltip position - #3372
}
});
},
directTouch: true,
@@ -1026,8 +1038,13 @@ var arrayMin = Highcharts.arrayMin,
pointAttrToOptions: colProto.pointAttrToOptions,
drawPoints: colProto.drawPoints,
drawTracker: colProto.drawTracker,
animate: colProto.animate,
getColumnMetrics: colProto.getColumnMetrics
getColumnMetrics: colProto.getColumnMetrics,
animate: function () {
return colProto.animate.apply(this, arguments);
},
polarArc: function () {
return colProto.polarArc.apply(this, arguments);
}
});
}());
@@ -2531,6 +2548,24 @@ var arrayMin = Highcharts.arrayMin,
if (seriesTypes.column) {
colProto = seriesTypes.column.prototype;
colProto.polarArc = function (low, high, start, end) {
var center = this.xAxis.center,
len = this.yAxis.len;
return this.chart.renderer.symbols.arc(
center[0],
center[1],
len - high,
null,
{
start: start,
end: end,
innerR: len - pick(low, len)
}
);
};
/**
* Define the animate method for columnseries
*/
@@ -2543,8 +2578,6 @@ var arrayMin = Highcharts.arrayMin,
wrap(colProto, 'translate', function (proceed) {
var xAxis = this.xAxis,
len = this.yAxis.len,
center = xAxis.center,
startAngleRad = xAxis.startAngleRad,
renderer = this.chart.renderer,
start,
@@ -2565,23 +2598,11 @@ var arrayMin = Highcharts.arrayMin,
point = points[i];
start = point.barX + startAngleRad;
point.shapeType = 'path';
point.shapeArgs = {
d: renderer.symbols.arc(
center[0],
center[1],
len - point.plotY,
null,
{
start: start,
end: start + point.pointWidth,
innerR: len - pick(point.yBottom, len)
}
)
};
point.shapeArgs = this.polarArc(point.yBottom, point.plotY, start, start + point.pointWidth);
// Provide correct plotX, plotY for tooltip
this.toXY(point);
point.tooltipPos = [point.plotX, point.plotY];
point.ttBelow = point.plotY > center[1];
point.ttBelow = point.plotY > xAxis.center[1];
}
}
});
@@ -18,11 +18,14 @@
/**
* Translate data points from raw values x and y to plotX and plotY
*/
translate: function () {
translate: function () {console.log('@colrange.translate')
var series = this,
yAxis = series.yAxis,
xAxis = series.xAxis,
startAngleRad = xAxis.startAngleRad,
chart = series.chart,
renderer = chart.renderer,
isRadial = series.xAxis.isRadial,
plotHigh;
colProto.translate.apply(series);
@@ -40,7 +43,7 @@
// adjust shape
y = plotHigh;
height = point.plotY - plotHigh;
height = pick(point.rectPlotY, point.plotY) - plotHigh;
// Adjust for minPointLength
if (Math.abs(height) < minPointLength) {
@@ -54,19 +57,28 @@
y -= height;
}
shapeArgs.height = height;
shapeArgs.y = y;
if (isRadial) {
point.tooltipPos = chart.inverted ?
[
yAxis.len + yAxis.pos - chart.plotLeft - y - height / 2,
xAxis.len + xAxis.pos - chart.plotTop - shapeArgs.x - shapeArgs.width / 2,
height
] : [
xAxis.left - chart.plotLeft + shapeArgs.x + shapeArgs.width / 2,
yAxis.pos - chart.plotTop + y + height / 2,
height
]; // don't inherit from column tooltip position - #3372
start = point.barX + startAngleRad;
point.shapeType = 'path';
point.shapeArgs = {
d: series.polarArc(y + height, y, start, start + point.pointWidth)
};
} else {
shapeArgs.height = height;
shapeArgs.y = y;
point.tooltipPos = chart.inverted ?
[
yAxis.len + yAxis.pos - chart.plotLeft - y - height / 2,
xAxis.len + xAxis.pos - chart.plotTop - shapeArgs.x - shapeArgs.width / 2,
height
] : [
xAxis.left - chart.plotLeft + shapeArgs.x + shapeArgs.width / 2,
yAxis.pos - chart.plotTop + y + height / 2,
height
]; // don't inherit from column tooltip position - #3372
}
});
},
directTouch: true,
@@ -76,8 +88,13 @@
pointAttrToOptions: colProto.pointAttrToOptions,
drawPoints: colProto.drawPoints,
drawTracker: colProto.drawTracker,
animate: colProto.animate,
getColumnMetrics: colProto.getColumnMetrics
getColumnMetrics: colProto.getColumnMetrics,
animate: function () {
return colProto.animate.apply(this, arguments);
},
polarArc: function () {
return colProto.polarArc.apply(this, arguments);
}
});
}());
View
@@ -309,6 +309,24 @@
if (seriesTypes.column) {
colProto = seriesTypes.column.prototype;
colProto.polarArc = function (low, high, start, end) {
var center = this.xAxis.center,
len = this.yAxis.len;
return this.chart.renderer.symbols.arc(
center[0],
center[1],
len - high,
null,
{
start: start,
end: end,
innerR: len - pick(low, len)
}
);
};
/**
* Define the animate method for columnseries
*/
@@ -321,8 +339,6 @@
wrap(colProto, 'translate', function (proceed) {
var xAxis = this.xAxis,
len = this.yAxis.len,
center = xAxis.center,
startAngleRad = xAxis.startAngleRad,
renderer = this.chart.renderer,
start,
@@ -343,23 +359,11 @@
point = points[i];
start = point.barX + startAngleRad;
point.shapeType = 'path';
point.shapeArgs = {
d: renderer.symbols.arc(
center[0],
center[1],
len - point.plotY,
null,
{
start: start,
end: start + point.pointWidth,
innerR: len - pick(point.yBottom, len)
}
)
};
point.shapeArgs = this.polarArc(point.yBottom, point.plotY, start, start + point.pointWidth);
// Provide correct plotX, plotY for tooltip
this.toXY(point);
point.tooltipPos = [point.plotX, point.plotY];
point.ttBelow = point.plotY > center[1];
point.ttBelow = point.plotY > xAxis.center[1];
}
}
});

0 comments on commit d2b1113

Please sign in to comment.