【问题标题】:Highcharts: make tooltip's arrow (anchor) always visibleHighcharts:使工具提示的箭头(锚)始终可见
【发布时间】:2019-02-12 12:36:51
【问题描述】:

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

请看示例: https://jsfiddle.net/jezusro6/

【问题讨论】:

    标签: javascript charts highcharts data-visualization angular2-highcharts


    【解决方案1】:

    您应该覆盖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;
    }
    

    现场演示:https://jsfiddle.net/BlackLabel/g5h27mfx/

    文档:https://www.highcharts.com/docs/extending-highcharts

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    • 1970-01-01
    • 1970-01-01
    • 2019-11-06
    相关资源
    最近更新 更多