2013-02-07 3 views
-1

Highcharts를 사용하여 원형 차트를 구현하려고했지만 매우 낮은 해상도에서 데이터 레이블이 잘리는 문제가 발생했습니다.Windows에서 Highchart 데이터 레이블 제거

formatter : function()을 사용하여 windows.resize를 추가하려고 시도했지만 실패했습니다.

  // Radialize the colors 
      Highcharts.getOptions().colors = $.map(Highcharts.getOptions().colors, function(color) { 
       return { 
        radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 }, 
        stops: [ 
         [0, color], 
         [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken 
        ] 
       }; 
      }); 

      // Build the chart 
      chart = new Highcharts.Chart({ 
       chart: { 
        renderTo: 'container', 
        plotBackgroundColor: null, 
        plotBorderWidth: null, 
        plotShadow: false, 
        backgroundColor: { 
        linearGradient: [0, 0, 500, 500], 
        stops: [ 

        ] 
        },       
       }, 
       title: { 
        text: 'Header Here' 
       }, 
       tooltip: { 
        pointFormat: '{series.name}: <b>{point.percentage}%</b>', 
        percentageDecimals: 0 
       }, 
       plotOptions: { 
        pie: { 
         allowPointSelect: false, 
         cursor: 'pointer', 
         dataLabels: { 
          enabled: true, 
          color: '#000000', 
          connectorColor: '#000000', 
          formatter: function() { 
           return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +'%'; 
          } 
         } 
        } 
       }, 
       series: [{ 
        type: 'pie', 
        name: 'Votes', 
        data: [ 
         ['Vote One', 50],     
         ['Vote Two', 50], 
         ['Vote three', 2] 
        ] 
       }] 
      }); 

어쨌든 라벨이 false/숨김으로 설정할 수 있습니다 크기 조정에 새 차트를 만드는 것보다 다른 거기 : 여기

내가 현재 사용하고있는 코드? 특정 해상도 이상으로 다시 표시됩니까?

많은 감사

답변

3

당신은 datalabels 및 포맷터에서 사실로 useHTML을 설정할 수 있습니다 자신의 div의를 정의합니다. 그런 다음 크기 조정 이벤트를 잡을 때 functons 표시/숨기기를 사용하십시오. 클릭 버튼 후/숨기기 datalabels을 보여

간단한 예는 여기에 있습니다 :

http://jsfiddle.net/VYGEW/

chart = new Highcharts.Chart({ 
     chart: { 
      renderTo: 'container', 
      type: 'line' 
     }, 
     title: { 
      text: 'Monthly Average Temperature' 
     }, 
     plotOptions: { 
      series: { 
       dataLabels: { 
        enabled: true, 
        useHTML: true, 
        formatter: function() { 
         return '<div class="datalabel">' + this.y + '</div>'; 
        } 
       } 
      } 
     }, 
     series: [{ 
      data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6] 
     }] 
    }, function (chart) { 

     $('#btn').toggle(function() { 

      $('.datalabel').hide(); 
     }, function() { 
      $('.datalabel').show(); 
     }); 

    }); 
+0

브릴리언트, 아주 간단 수정! 당신의 도움을 주셔서 감사합니다 :) – Andross