使用动态值创建c3图形

Below is the code I'm using to generate a line graph using c3.js. In the variable 'value' I'll get the values to be plotted as comma separated values. I've hard coded the values now. With this code, the graph generated has only one value - '0'.

This code doesn't work :

       var name = "Graph Values";
        var value = "120,150,120,120,120";
          var obj = { 
           "data1": [value]
            }
          var chart = c3.generate({
              bindto: '#chart1',
              data: {
                columns: [
                 [name].concat(obj.data1)
                ]
              }
          });

This code works :

       var name = "Graph Values";
        var value = "120,150,120,120,120";
          var obj = { 
           "data1": [120,150,120,120,120]
            }
          var chart = c3.generate({
              bindto: '#chart1',
              data: {
                columns: [
                 [name].concat(obj.data1)
                ]
              }
          });

The problem was the value you declared was not in the proper way Try this

 var value = [120,150,120,120,120];
  var obj = { 
       "data1": value
        } ;

you can put your data in an array.

var Array=[]; //Store your dynamic values here 
var chart = c3.generate({
              bindto: '#chart1',
              data: {

                            columns:[Array],
                             type : 'bar',


                    }
      });