xiaolin3303 / wx-charts

微信小程序图表库,Charts for WeChat Mini Program
MIT License
4.9k stars 1.68k forks source link

Pie图的 dataLabel 能否显示除百分比外数据本身的数值? #211

Closed green-dalii closed 6 years ago

green-dalii commented 6 years ago

使用 Pie 图时,设置dataLabel:true只能显示百分比,我想显示原始数据的数值,如何操作?

green-dalii commented 6 years ago

已解决,查阅 #56 中数据列表定义:

dateItem.format Function 自定义显示数据内容

通过以下方式定义 format ,return回 this.data便可实现显示原始数据数值:

format: function () {
    return this.data;
}
AmoSunsh1ne commented 5 years ago

具体应该怎么写呢,我照着该怎么不对呢

voidmain90 commented 2 years ago

具体数值可以通过下面的文字进行显示 ,希望对您有所帮助 pieChart = new wxCharts({ animation: true, canvasId: 'pieCanvas', type: 'pie', series: [{ name: '正常 : '+this.data.normal+'台' , data: this.data.normal, color:'rgb(116, 240, 59)',

        }, {
            **name: '离线 : '+this.data.offline+'台'**,
            data: this.data.offline,
            color:'orange'
        }],
        width: windowWidth,
        height: 300,
        dataLabel: true,
        animation:true,
        format: function () {
          return this.data;
      }
    });