How can i change text of legend in c3 pie chart

前端 未结 2 1627
小鲜肉
小鲜肉 2021-02-14 10:04

How can I change the Text of legend of pie chart. I am using c3 charts in my php page. I have already read the documentation of c3 charts but no luck.

Currently i am usi

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-14 10:48

    You haven't provided the data that gets outputted from your php, so it's hard to say.

    But the first item in each of the columns array determines the name that goes in the legend. So:

    columns: [
        ['this is legend 1', 30],
        ['put your value here', 120], 
    ]
    

    would result in the legend labels being "this is legend 1" and "put your value here".

    Here's a fiddle: http://jsfiddle.net/jrdsxvys/9/

    Edit... Another option is to use the names property, as done here: http://jsfiddle.net/jrdsxvys/40/

    data: {
        columns: [
          ['d1', 30],
          ['d2', 120]
        ],
        type: 'pie',
        labels: true,
        names: {
          d1: 'some name here',
          d2: 'another name'
        }
    }
    

提交回复
热议问题