Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highcharts鼠标移到legend上高亮当前数据,置灰其它数据 #2

Open
natee opened this issue Aug 13, 2014 · 0 comments
Open

Comments

@natee
Copy link
Owner

natee commented Aug 13, 2014

/**
     * Highcharts plugin for setting a lower opacity for other series than the one that is hovered
     * in the legend
     */
    (function (Highcharts) {
        var each = Highcharts.each;

        Highcharts.wrap(Highcharts.Legend.prototype, 'renderItem', function (proceed, item) {

            proceed.call(this, item);
            var series = this.chart.series,
                element = item.legendGroup.element;
                type = this.chart.userOptions.chart.type;
            if(type == 'pie'){ //pie default
                return;
            }
            element.onmouseover = function () {
               each(series, function (seriesItem) {
                    if (seriesItem !== item) {
                        each(['group', 'markerGroup'], function (group) {
                            seriesItem[group].attr('opacity', 0.25);
                        });
                    }
                });
            }
            element.onmouseout = function () {
               each(series, function (seriesItem) {
                    if (seriesItem !== item) {
                        each(['group', 'markerGroup'], function (group) {
                            seriesItem[group].attr('opacity', 1);
                        });
                    }
                });
            }           

        });
    }(Highcharts));
@natee natee changed the title highcharts鼠标移到legend上高亮当前数据,置灰其它数据 Highcharts鼠标移到legend上高亮当前数据,置灰其它数据 Nov 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant