ダミアン ರ_ರ
ダミアン ರ_ರ

Reputation: 72

highcharts disable certain labels

i will like the possibility of disabled some labels of my chart

$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'bar'
            },
            title: {
                text: 'Historic World Population by Region'
            },
            subtitle: {
                text: 'Source: Wikipedia.org'
            },
            xAxis: {
                categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
                title: {
                    text: null
                }
            },
            yAxis: {
                min: 0,
                title: {
                    text: 'Population (millions)',
                    align: 'high'
                },
                labels: {
                    overflow: 'justify'
                }
            },
            tooltip: {
                formatter: function() {
                    return ''+
                        this.series.name +': '+ this.y +' millions';
                }
            },
            plotOptions: {
                bar: {
                    dataLabels: {
                        enabled: true
                    }
                }
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'top',
                x: -100,
                y: 100,
                floating: true,
                borderWidth: 1,
                backgroundColor: '#FFFFFF',
                shadow: true
            },
            credits: {
                enabled: false
            },
            series: [{
                name: 'Year 1800',
                data: [107, 31, 635, 203, 2]
            }, {
                name: 'Year 1900',
                data: [133, 156, 947, 408, 6]
            }, {
                name: 'Year 2008',
                data: [973, 914, 4054, 732, 34]
            }, {
                name: 'Year 2009',
                data: [873, 614, 4054, 732, 34]
            }, {
                name: 'Year 2010',
                data: [573, 1500, 4054, 732, 34]
            }, {
                name: 'Year 2012',
                data: [373, 1380, 4054, 732, 34]
            }]
        });
    });

});

http://jsfiddle.net/tkGFr/

for example, this chart will show all the labels and i will like the possibility of make only enabled 2 or 3 (year 1800, 1900 and 2009) of them but always maintaining the other options (year 2008, 2010 and 2012)

is this possible?

i appreciate your help and advice :D

Upvotes: 0

Views: 1897

Answers (2)

jatinder
jatinder

Reputation: 1

Even showInLegend: false; can be used; if want to hide in legends.

Upvotes: 0

Sebastian Bochan
Sebastian Bochan

Reputation: 37578

As I assume, you would like to have enabled "year 1800, 1900 and 2009" in legend and displayed in chart, but other only in legend? If yes you can use visible parameter

{
            name: 'Year 1800',
            visible: false,
            data: [107, 31, 635, 203, 2]
        }

Upvotes: 1

Related Questions