0

I have the following data

firstData = [  
["2019-11-24", "12:38:54"],
 ["2019-11-21", "07:06:29"],
 ["2019-11-20", "19:26:37"],
 ["2019-09-26", "19:56:00"] ]

secondData = [ 
["2019-09-26", "10:26:00"],
 ["2019-11-20", "06:52:34"],
 ["2019-11-21", "07:06:19"],
 ["2019-11-24", "07:38:54"] ]

I would like to display graph like this. date and time graph

4

1 回答 1

0

所以正如我在评论中提到的,y 值必须是一个数字。如果要将其呈现为时间格式,则需要将此字符串转换为正确的数字,请检查下面的函数和演示:https ://jsfiddle.net/BlackLabel/2vc7aphd/1/

function parseToNumber(string) {
  return Date.parse("1-1-1 " + string) - Date.parse('1-1-1 00:00:00')
}

function parseData(data) {
  let output = [];
  data.forEach(d => {
    let x = d[0],
      y = d[1];

    output.push({
      name: x,
      y: parseToNumber(y),
      label: y
    });
  })
  return output;
}
于 2019-12-31T11:47:03.603 回答