You can easily echo your json data into C3.js by doing:
var dataset = <?php echo $lineChartData; ?>;
data: {
json: dataset
}
I am using the same pipeline you are using for my web project (mySQL-PHP-C3.js). It is important that your json data is exactly in the format that C3 needs for imput. As you can read in the C3.js documentation (https://c3js.org/samples/timeseries.html), data format for time series should be as follows:
data: {
x: 'x',
// xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
columns: [
['x', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06'],
// ['x', '20130101', '20130102', '20130103', '20130104', '20130105', '20130106'],
['data1', 30, 200, 100, 400, 150, 250],
['data2', 130, 340, 200, 500, 250, 350]
]
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%Y-%m-%d'
}
}
}
For my data (not time series data), json object looks as follows:
{"data1": [0.23, 0.29, 0.19, 0.14, 0.7], "data2": [0, 0.25, 0.61, 0.4, 0.52]}
If you follow this structure and add your time data (date) as third dimension to it, you should be able to achive what you want.