2

I have a situation to bind a json data with a key to plot a graph. But graph is plotting correctly but the name of the data is showing the same key. i need to avoid it .

How can i supply a name for my data. I have tried as follows but its seems not working. Can any guys help one this.

data: {
                    //                        columns: [chartData],
                    json: data,
                    keys: {
                        value: [key]
                    },
                    type: chartType,
                    labels: true,                        
                    selection: {
                        enabled: false
                    },
                    names: {
                        data1: 'Some Name'                            
                    }
                }

Thanks in Advance :) Kiran Gopal

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204
kiran Gopal
  • 450
  • 5
  • 17

1 Answers1

1

Instead of data1, you should substitute the value of the variable key. Or you could construct the names value, like so

var names = {}
names[key] = 'Some Name'; 
var chart = c3.generate({
    ...
    names: names
  },
});

Fiddle - http://jsfiddle.net/Ld2apq0g/

potatopeelings
  • 40,709
  • 7
  • 95
  • 119