【问题标题】:Fusion Charts Show Percentage as centerLabel in Doughnut Chart融合图表在圆环图中将百分比显示为 centerLabel
【发布时间】:2017-09-24 08:41:34
【问题描述】:

使用 Fusion Charts 脚本,我可以轻松地将图表标签显示为百分比。但是,我需要在标签上显示值并在圆环图的中心显示百分比。

Fusion Charts API 似乎并未涵盖此选项。看来 $value 和 $label 是唯一可用的变量。

可以这样做吗?

如果看起来我遗漏了一些明显的东西,这里是一些用于设置的 jquery:

$.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();

【问题讨论】:

    标签: jquery fusioncharts


    【解决方案1】:

    我通过浏览 fusioncharts.js 源代码偶然发现了这个问题的答案。该值为 $percentValue。

    只需设置 "centerLabel" : "$percentValue

    "centerLabel" : "$percentValue
    

    这个值是在 fusioncharts.js 的“_parseValues”函数中设置的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-08
      • 2016-07-24
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多