How can i bind an json data with a key and Name for display

时间:2015-07-28 16:45:23

标签: d3.js c3

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

1 个答案:

答案 0 :(得分:1)

您应该替换变量data1,而不是key。或者您可以构造名称值,如此

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

小提琴 - http://jsfiddle.net/Ld2apq0g/