简体   繁体   English

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

[英]c3js line chart all data unselected how to show tick values

I have a simple c3js line chart w/3 different lines. 我有一个简单的c3js折线图,带有3条不同的线。 When I "unselect" all 3 data sources, the x-axis tick values disappear. 当我“取消选择”所有3个数据源时,x轴刻度值消失。 I was wondering if there was anyway to reverse this behavior? 我想知道是否有任何办法可以扭转这种行为? I'd like to show the x-axis tick values even when there is no data present. 即使没有数据,我也想显示x轴刻度值。

The xaxis tick values are of a 'timeseries' type. xaxis刻度值是“时间序列”类型。 Thanks! 谢谢!

Here is my c3 config for the line chart: 这是我的折线图的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],
},

Unfortunately this functionality is baked into c3.js and the only way to change this (aside from working purely from d3) is monkey patching. 不幸的是,此功能已包含在c3.js中,并且更改此功能的唯一方法(除了从d3完全工作之外)是猴子补丁。 You will find the offender on line 6814 of c3.js: 您会在c3.js的6814行找到违法者:

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

If you change this to: 如果将其更改为:

tickExit = function() {},

The ticks are no longer removed. 刻度不再被删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM