Morris.js,线图显示错误的数据

时间:2015-06-03 09:15:43

标签: javascript morris.js

我正在使用morris.js和javascript创建折线图。这是我的代码:

// get the testCase
def tc = testRunner.testCase
// get testStep by its name
def ts = tc.getTestStepByName('TestStepName')
// property values
def propertyValueArray = ['firstValue','anotherValue','moreValues','lastOne']

// for each property value
propertyValueArray.each { value ->
    // set the value for your property
    tc.setPropertyValue('yourProperty',value)
    // invoke testStep 
    ts.run(testRunner,context)
}

我将这个数组传递给js,我得到了这个图:

请查看星期二图表。兑换的价值在数组中是2,但在图表中它显示3,这是错误的。我犯了什么错误吗?

1 个答案:

答案 0 :(得分:4)

您的代码中没有错误,这是默认行为。区域堆叠在彼此之上,因此值为3,因为奖励+兑换= 3。 如果要覆盖它们,可以使用behaveLikeLine选项。将它设置为true,你就会得到你想要的东西。

Morris.Area({
  element: 'hero-area',
  data: [{
    day: "Thu",
    Reward: 0,
    Redeem: 0
  }, {
    day: "Fri",
    Reward: 2,
    Redeem: 0
  }, {
    day: "Sat",
    Reward: 1,
    Redeem: 0
  }, {
    day: "Sun",
    Reward: 0,
    Redeem: 0
  }, {
    day: "Mon",
    Reward: 0,
    Redeem: 0
  }, {
    day: "Tue",
    Reward: 1,
    Redeem: 2
  }, {
    day: "Wed",
    Reward: 0,
    Redeem: 0
  }],
  xkey: 'day',
  ykeys: ['Reward', 'Redeem'],
  labels: ['Reward', 'Redeem'],
  // later on
  parseTime: false,
  hideHover: 'auto',
  lineWidth: 1,
  pointSize: 5,
  lineColors: ['#4a8bc2', '#ff6c60'],
  fillOpacity: 0.5,
  smooth: false,
  behaveLikeLine: true
});