请看一下:http://jsfiddle.net/zb443xj9/
气泡被半径拉高。 因此方法" drawPoints"如下更改(因为这"更改功能"未在框架中实现):
(function (H) {
H.wrap(H.seriesTypes.bubble.prototype, 'drawPoints', function (p) {
var series = this;
H.each(series.points, function (point, i) {
point.shapeArgs.y -= point.shapeArgs.r; //moved up by radius
});
p.call(this);
});
})(Highcharts);
如果将鼠标悬停在您看到的气泡上方,影子和工具提示仍然定位于" old"中心。 有人知道如何绘制阴影和工具提示的方法吗?
我也喜欢覆盖这两种方法。 我希望这些被称为" drawShadow"和" drawTooltip"但遗憾的是没有。
谢谢!
答案 0 :(得分:0)
你应该在point选项中包装haloPath方法。然后在点内覆盖“this”对象。
H.wrap(H.Point.prototype, 'haloPath', function (proceed) {
if(this.oldY === UNDEFINED) {
this.oldY = this.plotY;
this.plotY -= (this.shapeArgs.r);
}
return proceed.apply(this,
Array.prototype.slice.call(arguments, 1));
});
H.wrap(H.Tooltip.prototype, 'getAnchor', function (proceed, points, mouseEvent) {
var ret,
chart = this.chart,
inverted = chart.inverted,
plotTop = chart.plotTop,
plotLeft = chart.plotLeft,
plotX = 0,
plotY = 0,
yAxis,
xAxis;
points = splat(points);
// Pie uses a special tooltipPos
ret = points[0].tooltipPos;
// When tooltip follows mouse, relate the position to the mouse
if (this.followPointer && mouseEvent) {
if (mouseEvent.chartX === UNDEFINED) {
mouseEvent = chart.pointer.normalize(mouseEvent);
}
ret = [
mouseEvent.chartX - chart.plotLeft,
mouseEvent.chartY - plotTop];
}
// When shared, use the average position
if (!ret) {
each(points, function (point) {
yAxis = point.series.yAxis;
xAxis = point.series.xAxis;
plotX += point.plotX + (!inverted && xAxis ? xAxis.left - plotLeft : 0);
plotY += (point.plotLow ? (point.plotLow + point.plotHigh) / 2 : point.plotY) + (!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
});
plotX /= points.length;
plotY /= points.length;
ret = [
inverted ? chart.plotWidth - plotY : plotX,
this.shared && !inverted && points.length > 1 && mouseEvent ? mouseEvent.chartY - plotTop : // place shared tooltip next to the mouse (#424)
inverted ? chart.plotHeight - plotX : plotY];
}
if(points[0].oldY === UNDEFINED) {
ret[1] -= points[0].shapeArgs.r;
}
return map(ret, mathRound);
});