c3js折线图所有数据未选中如何显示刻度值

时间:2015-05-18 18:29:55

标签: javascript d3.js data-visualization c3

我有一个简单的c3js折线图,有3条不同的线条。当我“取消选择”所有3个数据源时,x轴刻度值消失。我想知道是否有反转这种行为?即使没有数据,我也想显示x轴刻度值。

xaxis刻度值属于'timeseries'类型。谢谢!

以下是折线图的c3配置:

bindto: '#test',
data: {
  x: 'date',
  xFormat: '%m%d',
  columns: [],
},
legend: {
  position: 'bottom',
},
axis: {
  y: {
    tick: {
      format: function (d) { return d + '%'; },
      count: 5,
    },
    max: 100,
    padding: {
      top: 0,
      bottom: 0,
    },
  },
  x: {
    type: 'timeseries',
    tick: {
      culling: false,
    },
  },
},
color: {
  pattern: [testRateColor, firstRateColor, secRateColor],
},

1 个答案:

答案 0 :(得分:1)

不幸的是,这个功能被包含在c3.js中,改变它的唯一方法(除了纯粹从d3开始工作)是猴子修补。你会在c3.js的第6814行找到罪犯:

tickExit = tick.exit().remove(),

如果您将其更改为:

tickExit = function() {},

不再删除刻度线。