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

c3js line chart all data unselected how to show tick values

我有一个简单的 c3js 折线图 w/3 不同的线。当我 "unselect" 所有 3 个数据源时,x 轴刻度值消失。我想知道是否有办法扭转这种行为?即使没有数据,我也想显示 x 轴刻度值。

x 轴刻度值属于 '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],
},

不幸的是,此功能已集成到 c3.js 中,更改此功能的唯一方法(除了纯粹从 d3 工作之外)是猴子修补。您会在 c3.js:

的第 6814 行找到违规者
tickExit = tick.exit().remove(),

如果将其更改为:

tickExit = function() {},

刻度不再被删除。