【问题标题】:C3JS not correctly binding y2 axis json dataC3JS 未正确绑定 y2 轴 json 数据
【发布时间】:2016-07-28 20:16:10
【问题描述】:

我有一个图表,它是一个带有两个 y 轴的时间序列。左侧 y 轴以毫秒为单位显示延迟,右侧 y 轴 (y2) 显示吞吐量。但是,似乎 json 数据没有正确绑定到 y2,因为它的行为就像没有数据提供给它一样。 这是我正在使用的 json 的一小部分:

 json: [{
        latency: 59,
        datestamp: "20160712",
        throughput: 46
      }, {
        latency: 272,
        datestamp: "20160713",
        throughput: 30
      }]

另请注意,我覆盖了 documentation 中所述的轴

axes: {
  'latency': 'y',
  'throughput': 'y2'
}

这里是 JS 小提琴:

https://jsfiddle.net/Lz8nx8dc/3/

如您所见,吞吐量的值远高于 1.0,但 y2 刻度值并未更新。

【问题讨论】:

    标签: javascript json d3.js c3.js


    【解决方案1】:

    我最终在这里修复了它:https://jsfiddle.net/Lz8nx8dc/5/

    解决方案是将轴移动为数据的属性:

    data: {
        axes: {
          'latency': 'y',
          'throughput': 'y2'
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2011-11-13
      • 1970-01-01
      • 2014-09-15
      • 1970-01-01
      • 1970-01-01
      • 2016-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多