2017-12-17 1 views
1

원형 차트의 각 조각의 비율이 50 % (또는 52 % 및 48 %)에 도달하는 동안 백분율의 위치가 변경됩니다. 즉 그래프의 각 조각이 16 % 및 84 % 일 때 동일하지 않습니다. 내가 사용하는 코드는 다음과 같습니다Highcharts 변동률 위치

enter image description here

Highcharts.chart('container1', { 
    chart: { 
      plotBackgroundColor: null, 
      plotBorderWidth: null, 
      plotShadow: false, 
     type: 'pie', 
     options3d: { 
      enabled: true, 
      alpha:70, 
      beta: 0 
     } 
    }, 
    title: { 
     text: '' 
    }, 

    plotOptions: { 
     pie: { 
      allowPointSelect: false, 
      cursor: 'pointer', 
      size:100, 
      depth: 15, 


       dataLabels: { 
       textOverflow:'none', 
         enabled: true, 
        color:'black', 
        connectorColor:'transparent', 
        format:'{point.percentage:.1f}%', 
        distance:-30, 
        style:{ 
        textShadow:false} 
       }, 
       showInLegend: false 
     } 
    }, 
series: [{ 
     type: 'pie', 
     name: 'ΑΞΚΟΙ - ΑΝΘΣΤΕΣ', 

     data: [ 
      ['Παρόντες', <?php 
       while ($row2 = mysql_fetch_assoc($res2)) { 
        while($row1 = mysql_fetch_assoc($res1)){ 
        $row3['COUNT(*)']=$row2['COUNT(*)'] - $row1['COUNT(*)']; 
        echo $row3['COUNT(*)']; 

        } 
       }?>], 
      ['Απόντες', <?php 


         while($row3 = mysql_fetch_assoc($res3)){ 

        echo $row3['COUNT(*)']; 

        } 

        ?>] 
] 
    }] 
}); 

나는 비율 상수의 위치를 ​​확인하기 위해 사용할 수있는 기능이있다? 사전에 감사

+0

하이 차트에 대해 알고있는 사람의 조언이 있습니까? – teo

+0

원하는 것을 이해하기가 어렵습니다. –

+0

@teo 찾고있는 이미지를 첨부하십시오. – ewolden

답변

0

당신은 각 라벨에 Highcharts.SVGElement.attr() 함수를 호출하여 데이터 레이블의 고정 된 위치를 설정할 수 있습니다

events: { 
    load: function() { 
    var points = this.series[0].points; 
    points.forEach((p) => p.connector.destroy()); // destroy connectors 

    // set fixed position for both points 
    points[0].dataLabel.attr({ 
     x: 300, 
     y: 100 
    }); 
    points[1].dataLabel.attr({ 
     x: 75, 
     y: 100 
    }); 
    } 
} 

라이브 데모 :http://jsfiddle.net/kkulig/8z3g1LLy/

API 참조 :https://api.highcharts.com/class-reference/Highcharts.SVGElement#attr