简体   繁体   English

高图深化图表:深化或深化显示/隐藏绘图带和线

[英]Highcharts drilldown chart: Display/Hide Plot Bands and Lines on drilldown or drillup

I have a drill-down chart in Highcharts where I want the plot bands and plot lines to be hidden when a drill-down occurs. 我在Highcharts中有一个向下钻取图表,在该图表中,当发生向下钻取时,我想隐藏绘图带和绘图线。

I used the drill-down event to successfully hide the plot bands, but it seems the Plot band label reappears when the drill-down is shown. 我使用向下钻取事件成功隐藏了绘图带,但是当显示向下钻取时,似乎重新出现了绘图带标签。

See this fiddle: http://jsfiddle.net/jmunger/KFpJC/ 看到这个小提琴: http : //jsfiddle.net/jmunger/KFpJC/

The code to hide or display the bands and lines is as follows: 隐藏或显示带和线的代码如下:

    events: {
        drilldown: function () {
            var myAxis = this.xAxis[0];
            var myPlotBands = myAxis.plotLinesAndBands;
            $.each(myPlotBands, function (i, linesAndBands) {
                if (linesAndBands.label) {
                    linesAndBands.label.hide();
                    linesAndBands.label.opacity = 0;
                }
                linesAndBands.svgElem.hide();
            });
        },
        drillup: function () {
            $.each(this.xAxis[0].plotLinesAndBands, function (i, linesAndBands) {
                linesAndBands.svgElem.show();
                if (linesAndBands.label) {
                    linesAndBands.label.show();
                }
            });
        }
    }

Is there a way to make sure the label is hidden on a drill-down, and reappears on a drill-up? 是否有办法确保标签在向下钻取时隐藏,并在向上钻取时重新出现? The line: 该行:

linesAndBands.label.hide();

effectively hides the label but it reappears when the drill-down chart appears. 有效地隐藏了标签,但在向下钻取图出现时重新出现。

Instead of .hide() you can usee .css() instead: http://jsfiddle.net/KFpJC/2/ 取而代之的.hide()可以USEE .css()代替: http://jsfiddle.net/KFpJC/2/

        events: {
            drilldown: function () {
                var myAxis = this.xAxis[0];
                var myPlotBands = myAxis.plotLinesAndBands;
                $.each(myPlotBands, function (i, linesAndBands) {
                    linesAndBands.svgElem.hide();
                    if (linesAndBands.label) {
                        linesAndBands.label.css({
                            display: 'none'   
                        });
                    }
                });
            },
            drillup: function () {
                $.each(this.xAxis[0].plotLinesAndBands, function (i, linesAndBands) {
                    linesAndBands.svgElem.show();
                    if (linesAndBands.label) {
                        linesAndBands.label.css({
                            display: 'block'   
                        });
                    }
                });
            }
        }

Most probably, label returns because it's positioned (x/y position and visibility) after other graphics are placed on a plotting area. 标签很可能会返回,因为标签在其他图形放置在绘图区域后已定位(x / y位置和可见性)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM