将axisX日期转换为Html5 5折线图中的文本

时间:2016-10-21 12:52:40

标签: javascript html5

将x轴日期转换为Html5 5折线图中的文本,当前在x轴'jan,feb ....'出现。想要显示主题名称等文本。这里的参考网站是http://canvasjs.com/html5-javascript-line-chart/

/Contents/Java/lib

1 个答案:

答案 0 :(得分:1)

您需要将label键和值放在对象上。这是jsFiddle

dataPoints: [{
      x: new Date(2012, 00, 1),
      y: 450,
      label: '2012-00-01'
    }, {
      x: new Date(2012, 01, 1),
      y: 414,
      label: '2012-01-01'
    }, {
      x: new Date(2012, 02, 1),
      y: 520,
      label: '2012-02-01',
      indexLabel: "highest",
      markerColor: "red",
      markerType: "triangle"
    }, {
      x: new Date(2012, 08, 1),
      y: 410,
      label: '2012-08-01',
      indexLabel: "lowest",
      markerColor: "DarkSlateGrey",
      markerType: "cross"
    }, {
      x: new Date(2012, 09, 1),
      y: 500,
      label: '2012-09-01'
    },