当前位置: 代码迷 >> JavaScript >> 高图:使工具提示的箭头(锚)始终可见
  详细解决方案

高图:使工具提示的箭头(锚)始终可见

热度:118   发布时间:2023-06-03 18:15:58.0

我正在尝试使用Highcharts构建具有自定义工具提示位置的柱形图。 我想使工具提示的箭头(锚)始终在工具提示的底部可见。 目前,它仅在我删除自定义工具提示定位器功能时可见。 我试图覆盖Tooltip类的move方法,并在那里将skipAnchor设置为false 。 但是,它没有用。

请参见示例: :

您应该覆盖callout符号方法:

H.SVGRenderer.prototype.symbols.callout = function(x, y, w, h, options) {
    var arrowLength = 6,
        halfDistance = 6,
        r = Math.min((options && options.r) || 0, w, h),
        safeDistance = r + halfDistance,
        anchorX = options && options.anchorX,
        anchorY = options && options.anchorY,
        path;

    path = [
        'M', x + r, y,
        'L', x + w - r, y, // top side
        'C', x + w, y, x + w, y, x + w, y + r, // top-right corner
        'L', x + w, y + h - r, // right side
        'C', x + w, y + h, x + w, y + h, x + w - r, y + h, // bottom-rgt
        'L', x + r, y + h, // bottom side
        'C', x, y + h, x, y + h, x, y + h - r, // bottom-left corner
        'L', x, y + r, // left side
        'C', x, y, x, y, x + r, y // top-left corner
    ];

    path.splice(
        23,
        3,
        'L', anchorX + halfDistance, y + h,
        anchorX, y + h + arrowLength,
        anchorX - halfDistance, y + h,
        x + r, y + h
    );

    return path;
}

现场演示: :

文件: :

  相关解决方案