【问题标题】:Highcharts: how to select column (crosshairs) on mouseover xAxis labelsHighcharts:如何在鼠标悬停 xAxis 标签上选择列(十字准线)
【发布时间】:2015-05-28 18:27:30
【问题描述】:

如何在鼠标悬停 xAxis 标签上选择列(十字准线)?

我可以将鼠标悬停在标签上,但不知道如何选择列。

$(document).on('mouseover', '.highcharts-axis:eq(' + (axisCount - 1) + ') text, .highcharts-axis-labels:eq(' + (axisCount - 1) + ') text', function () {
    console.log('mouseover');
    // hover current column - crosshairs
});

http://jsfiddle.net/o355e82b/3/(想象一下它应该是什么样子 - 里面)

【问题讨论】:

  • 我认为您需要更准确地解释“选择列(十字准线)”的含义。我根本不明白你想要的结果是什么,小提琴也没有帮助澄清。

标签: highcharts mouseover axis-labels


【解决方案1】:

您可以包装十字准线功能并修改绘图元素的高度。

(function (HC) {
    HC.wrap(HC.Axis.prototype, 'drawCrosshair', function (proceed, e, point) {

        var path,
        options = this.crosshair,
            animation = options.animation,
            pos,
            attribs,
            categorized;

        if (
        // Disabled in options
        !this.crosshair ||
        // Snap
        ((defined(point) || !HC.pick(this.crosshair.snap, true)) === false)) {
            this.hideCrosshair();

        } else {

            // Get the path
            if (!HC.pick(options.snap, true)) {
                pos = (this.horiz ? e.chartX - this.pos : this.len - e.chartY + this.pos);
            } else if (defined(point)) {
                pos = this.isXAxis ? point.plotX : this.len - point.plotY; // #3834
            }

            if (this.isRadial) {
                path = this.getPlotLinePath(this.isXAxis ? point.x : pick(point.stackY, point.y)) || null; // #3189
            } else {
                path = this.getPlotLinePath(null, null, null, null, pos) || null; // #3189
            }

            if (path === null) {
                this.hideCrosshair();
                return;
            }

            // Draw the cross
            if (this.cross) {    
                //overwrite a height
                path[5] = point.series.chart.containerHeight;

                this.cross.attr({
                    visibility: VISIBLE
                })[animation ? 'animate' : 'attr']({
                    d: path
                }, animation);
            } else {
                categorized = this.categories && !this.isRadial;
                attribs = {
                    'stroke-width': options.width || (categorized ? this.transA : 1),
                    stroke: options.color || (categorized ? 'rgba(155,200,255,0.2)' : '#C0C0C0'),
                    zIndex: options.zIndex || 2
                };
                if (options.dashStyle) {
                    attribs.dashstyle = options.dashStyle;
                }

                this.cross = this.chart.renderer.path(path).attr(attribs).add();
            }

        }

    });

})(Highcharts);

示例:http://jsfiddle.net/o355e82b/5/

【讨论】:

  • 极度滞后,甚至无法使用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-20
  • 1970-01-01
  • 1970-01-01
  • 2018-09-16
  • 2012-10-27
相关资源
最近更新 更多