How can i change text of legend in c3 pie chart How can i change text of legend in c3 pie chart php php

How can i change text of legend in c3 pie chart


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'    }}


@agpt Yes. The names property is a good way to go generally because the first property of the columns data array eg 'd1' above is used when doing things like having multiple types on charts. eg for a bar and line combination using types instead of type: 'pie':

columns: [   ['bar_1', 3, 8, 6],   ['bar_2', 4, 0, 7],   ['bar_3', 2, 3, 0] ],types: {  bar_1: 'bar',  bar_2: 'line',  bar_3: 'bar'},names : {      bar_1: 'Initial',      bar_2: '3 month',      bar_3: '6 month'                }

So, using the names property allows you to use more 'dynamic' property names and be consistent throughout the config.