본문 바로가기

Web/Highcharts

[Highcharts] 사용자 버튼

  • 내보내기 버튼 숨기기
  • 사용자 버튼 활성화 여부
chart= Highcharts.chart('container', {
    chart: {
        type: 'pie',
        events: {
            //load: function () { console.log(this) },
            drilldown: function() {          
                if (this.series[0].options._levelNumber != 1 ) {
                    /* hide thirdbutton  */
                    this.exportSVGElements[4].hide();
                }
                //chart.redraw(); // 차트 다시 그리기
            },
            drillup: function(u) {
          		if (this.series[0].options._levelNumber == 1 ) {
                    /* show thirdbutton  */
                    this.exportSVGElements[4].show();
                }
                //chart.redraw(); // 차트 다시 그리기
            }
        }
    },
    title: {
        text: ''
    },
    xAxis: {
        type: 'category'
    },
	exporting: {
     	buttons: {
            contextButton: {
                enabled: false // 내보내기 버튼 활성화 여부
            },
            firstButton: {
                text: 'Download',
                menuItems: [
                    'downloadCSV'
                ]
            },
           secondButton: {
              text: 'Table',
              onclick: function () {
                  this.viewData();
              }
          },
          thirdButton:{
              text:'Hide-at-drilldown',
              menuItems: [
                  'downloadXLS'
              ]
		  },
       }
    },
      
    legend: {
        enabled: false
    },

    plotOptions: {
        series: {
            borderWidth: 0,
            dataLabels: {
                enabled: true
            }
        }
    },

    series: [{
        name: 'Things',
        colorByPoint: true,
        data: [{
            name: 'Dieren',
            y: 5,
            drilldown: 'animals'
        }, {
            name: 'Fruit',
            y: 3,
            drilldown: 'fruits'
        }]
    }],
    drilldown: {      
        series: [{
            id: 'animals',
            data: [
                ['Katten', 4],
                ['Honden', 2],
                ['Koeien', 1],
                ['Schapen', 2],
                ['Varkens', 1]
            ]
        }, {
            id: 'fruits',
            data: [
                ['Appels', 4],
                ['Sinaasappels', 2]
            ]
        }]
    }
});

https://jsfiddle.net/BlackLabel/dz29Lham/

 

Highcharts Demo - JSFiddle - Code Playground

 

jsfiddle.net

 

'Web > Highcharts' 카테고리의 다른 글

[Highcharts] credits 링크 제거  (0) 2022.03.13