flot饼图标签

Smi*_*ith 4 javascript formatting flot pie-chart

flot饼图默认以百分比显示项目的标签,但我需要显示构成百分比而不是百分比的数字.下面的代码是我的数据和

var pieOptions={
    series: {
        pie: {
            show: true,
            radius: 1,
            label: {
                show: true,
                radius: 3/4,
                formatter: labelFormatter,
                background: {
                    opacity: 0.5,
                    color: '#000'
                }
            }
        }
    },
    grid: {
        hoverable: true,
        clickable: true
    },
    legend: {
        container: '#pieLegend'
    }
}
Run Code Online (Sandbox Code Playgroud)

标签格式化程序

function labelFormatter(label, series) {
    return "<div style='font-size:8pt; text-align:center; padding:2px; color:white;'>"
+ label + "<br/>" + Math.round(series.percent) + "%</div>";
}
Run Code Online (Sandbox Code Playgroud)

我的数据

[["ebbok1","1"],["ebook2","4"],["ebook3","4"],["something","3"]]
Run Code Online (Sandbox Code Playgroud)

所以我需要1,4,4,3来显示饼图而不是计算的百分比

编辑

我刚试过series.data[0][1],但它在图表中显示为空白

Mar*_*ark 8

将labelFormatter更改为:

function labelFormatter(label, series) {
    return "<div style='font-size:8pt; text-align:center; padding:2px; color:white;'>"    + label + "<br/>" + series.data[0][1] + "%</div>";
}
Run Code Online (Sandbox Code Playgroud)

即系列中第一个(唯一)点的y数据.