How to pass data to c3 graph


Here is my JS code:

var abc = JSON.stringify(dataObject); var chart = c3.generate({ bindto: '#container', data: { json: abc, keys: { x:'_id', value: ['a', 'b','c','d'], }, axis: { x: { type: 'timeseries', } } } });

The above code gives error:undefined is not a function.

However if I directly give the same data directly without storing in a variable, the code works.<br /> Please let me know what the mistake is.


i got the Answer , it works fine with me . Remove JSON.stringify(dataObject).

it will already Stringify by the c3.js it self


Remove JSON.stringify(dataObject).

It will already Stringify by the <strong>c3.js</strong> itself


According to c3js documentation here : <a href="http://c3js.org/reference.html#data-json" rel="nofollow">http://c3js.org/reference.html#data-json</a>

You don't need to convert, You are getting undefined error because your keys are already in double quotes. Your data is already JSON, therefore you don't need to convert it, C3js automatically parse it unless there is syntax error.

If your data is valid JSON/Javascript object then C3js will parse it for you.

[{ "_id": 1404412200000, "a": 6, "b": 10, "c": 6, "d": 20 }]


[{ _id: 1404412200000, a: 6, b: 10, c: 6, d: 20 }]

Notice the difference first one is JSON and second one is Javascript Object


I stopped in the same error. I think stringify adds characters c3js no interpret


  • Turning the second timeseries in a TimeseriesChart to a barchart
  • Keras: How to shape inputs for CNN and LSTM layers?
  • overlapping the predicted time series on the original series in R
  • Compute EWMA over sparse/irregular TimeSeries in Pandas
  • Android CalendarContract, deleting a recurring event causes all events to disappear on calendar?
  • FindAndModify, return array of Objects
  • How to increase the python speed over loops?
  • Mongodb exception, “ MongoCursorException' with message '$ operator made object too large”
  • Back press fragments issue in android
  • Keep same scale in different graphs ggplot2
  • Safari PHP form submission -file upload hangs
  • JFreechart X and Y axis scaling
  • Is a .txt file created in VB different than one I'd randomly create?
  • Best practice for switching iPhone views?
  • Getting error 'Cannot read property 'document' of undefined' while importing exp
  • Breaking out column by groups in Pandas
  • Array with custom indexes in Ionic2
  • MongoError: Incorrect arguments
  • Accessing IRQ description array within a module and displaying action names
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Check if a string to interpolate provides expected placeholders
  • Javascript Callbacks with Object constructor
  • ILMerge & Keep Assembly Name
  • Where to put my custom functions in Wordpress?
  • Javascript + PHP Encryption with pidCrypt
  • Large data - storage and query
  • Jquery - Jquery Wysiwyg return html as a string
  • WOWZA + RTMP + HTML5 Playback?
  • Arrays break string types in Julia
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • WPF Applying a trigger on binding failure
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How do I configure my settings file to work with unit tests?
  • Java static initializers and reflection
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Binding checkboxes to object values in AngularJs