Chartjs-Plotting multiple JSON subobjects in Chart.js Line chart ( with Time as x-axis)

0👍

Update:
I found a way to prepare the data in a way I need.
By cycling through the JSON object and building an array based on that.
async function prepData(){

  var chartLabel = [];
  var data_points = [];
  var dataset = [];
  var entry = [];
  var data_point = [];
  for (var channel in json_data){
    data_points = [];
    dataset = [];
    entry = [];
    chartLabel = [];

    chartLabels.push(channel);
    for(entry in json_data[channel]){
      data_point = {
        y:json_data[channel][entry].Value,
        t:json_data[channel][entry].Timestamp
      };
      data_points.push(data_point);
    };

    dataset = {
      label: channel,
      data: data_points
    };
    //console.log(dataset);
    chartData.push(dataset)
  };
  console.log(chartData);
  console.log(chartLabels)
}

Leave a comment