2017-04-26 4 views
0

퓨전 차트 스크립트를 사용하면 차트 레이블을 백분율로 쉽게 표시 할 수 있습니다. 그러나 레이블에 값을 표시하고 도넛 형 차트 가운데에 백분율을 표시해야합니다.퓨전 차트 도너츠 차트의 centerLabel로 백분율 표시

Fusion Charts API는이 옵션을 다루지 않습니다. 사용할 수있는 변수는 $ value와 $ label뿐입니다.

가능합니까?

$.each(jsonDataPoints, function (index, obj) { 
     var hoverText = obj.label + " (" + obj.value + ")"; 
     //obj.toolText = hoverText; //This sets the text to display when a pie chart is hovered. 
     //obj.displayValue = hoverText; //This sets the chart labels. 
     obj.displayValue = obj.value; //This sets the chart labels. 
     obj.centerLabel = obj.percentValue;//percentValue is not an object. Just a guess 
    }); 

    var doughnutChart = new FusionCharts({ 
     type: 'doughnut2D', 
     renderAt: containerId, 
     registerWithJS: '1', 
     dataFormat: 'json', 
     "width": "100%", 
     "height": "100%", 
     dataSource: { 
      "chart": { 
       "paletteColors": "#0075c2,#1aaf5d,#f2c500,#f45b00,#8e0000", 
       "bgColor": "#ffffff", 
       "showBorder": "0", 
       "use3DLighting": "0", 
       "showShadow": "0", 
       "enableSmartLabels": "0", 
       "startingAngle": "310", 
       "showLabels": "0", 
       "showPercentValues": "1", 
       "showLegend": "1", 
       "legendShadow": "0", 
       "legendBorderAlpha": "0", 
       "defaultCenterLabel": "...", 
       "centerLabel": "$value", 
       "centerLabelBold": "1", 
       "showTooltip": "1", 
       "decimals": "0", 
       "captionFontSize": "14", 
       "subcaptionFontSize": "14", 
       "subcaptionFontBold": "0", 
       "useDataPlotColorForLabels": "1", 
       "labelDistance": "-20", 
       "baseFontSize": "13", 
      }, 
      "data": jsonDataPoints 
     } 
    }); 

    doughnutChart.render(); 

답변

0

내가 fusioncharts.js의 소스 코드를 스캔하여이에 대한 답변 우연히 : 나는 분명 뭔가 빠진 것 같은 보이는 경우 여기

은 설정에 대한 몇 가지 JQuery와있다. 값은 $ percentValue입니다. 필요했다

모두 "centerLabel"로 설정했다 : "$ percentValue

"centerLabel" : "$percentValue 

이 값은 내부 설정"fusioncharts.js

에 _parseValues ​​"기능
관련 문제