【问题标题】:Trying to Fade out all other Columns when a user selects one column当用户选择一列时尝试淡出所有其他列
【发布时间】:2015-12-09 10:48:30
【问题描述】:

当用户选择特定列时,我无法弄清楚如何淡出所有其他列。我尝试制作一个循环来遍历数据,但它仍然不起作用。

另外,我需要一旦用户单击一列然后再次单击它,所有列都会再次淡入。

此代码目前仅突出显示一个条形。

有什么建议吗?

$(function() {

    $('#container4').highcharts({
        chart: {
            type: 'column'
        },

        title: {
            text: ''
        },

        legend: {
            enabled: false
        },

        exporting: {
            enabled: false
        },

        credits: {
            enabled: false
        },

        xAxis: {
            gridLineColor: '',
            labels: {
                enabled: false
            }
        },

        yAxis: {
            title: {
                text: 'Fruit'
            },
            visible: false
        },

        credits: {
            enabled: false
        },

        plotOptions: {
            series: {
                allowPointSelect: true,
                states: {
                    select: {
                        color: 'blue',
                    }
                }
            },
            column: {
                stacking: 'normal',
            }
        },

        series: [{
            name: '',
            data: [-40, -60, -70, -80, -90, -100, -100, -100, -100, -100, -100],
            threshold: 0,
            color: '#E0E0E0 ',
            enableMouseTracking: false,
        }, {
            name: '',
            data: [-60, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50],
            threshold: 0,
            color: 'green',
            negativeColor: 'red',
        }, ]
    });
});

【问题讨论】:

  • 您使用的是 Angular 还是 jQuery?把两者混在一起是很矛盾的。有一个Angular plugin for Highcharts...
  • 你可以遍历所有点并使用point.graphic.attr({ opacity: 0.1 }); - 你试过了吗?

标签: jquery html angularjs svg highcharts


【解决方案1】:

API你没用过,你可以自己做(如果不和其他东西冲突的话)。

$(function() {
    $('#container4').highcharts({
        chart: {
            type: 'column',
            events: {
                click: function(e) {
                    console.log(e);
                },
                selection: function(e) {
                    console.log(e);
                }
            }
        },
        title: {
            text: ''
        },
        legend: {
            enabled: false
        },
        exporting: {
            enabled: false
        },
        credits: {
            enabled: false
        },
        xAxis: {
            gridLineColor: '',
            labels: {
                enabled: false
            }
        },
        yAxis: {
            title: {
                text: 'Fruit'
            },
            visible: false
        },
        credits: {
            enabled: false
        },
        plotOptions: {
            /*series: {
                allowPointSelect: true,
                states: {
                    select: {
                        color: 'blue',
                    }
                }
            },*/
            column: {
                stacking: 'normal',
            }
        },
        series: [{
            name: '',
            data: [-40, -60, -70, -80, -90, -100, -100, -100, -100, -100, -100],
            threshold: 0,
            color: '#E0E0E0 ',
            enableMouseTracking: false,
        }, {
            name: '',
            data: [-60, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50],
            threshold: 0,
            color: 'green',
            negativeColor: 'red',
        }, ]
    });
});

$(document).on('click', '.highcharts-tracker rect', function() {
    var elm = $(this);
    if (!elm.attr('class')) {
        $('.highcharts-tracker rect').removeAttr('class').css('opacity', 0.5);

        elm.attr('class', 'active').css('opacity', 1);
    } else {
        $('.highcharts-tracker rect').removeAttr('class').css('opacity', 1);
    }
});
.highcharts-series rect {
  transition:all .3s ease;
}
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container4"></div>

http://jsbin.com/jiluwimiyo

【讨论】:

  • 太棒了,谢谢,无论如何我可以通过重新单击栏取消突出显示
  • 再次感谢您的帮助,伙计,我还有一个问题要在这里发布stackoverflow.com/questions/34677801/…
  • 我现在不能回答,直到星期天(如果那时没有人回答)。你能接受这个答案,以便对其他人有所帮助吗?
猜你喜欢
  • 1970-01-01
  • 2013-11-07
  • 2014-09-08
  • 1970-01-01
  • 1970-01-01
  • 2020-02-02
  • 1970-01-01
  • 2021-06-02
  • 2017-01-29
相关资源
最近更新 更多