加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

从C3.js条形图中排除零值

发布时间:2020-12-16 07:15:19 所属栏目:百科 来源:网络整理
导读:我们以图表 http://c3js.org/samples/chart_bar.html为例 但用以下数据替换列数据: var chart = c3.generate({ data: { columns: [ ['data1',30,100,150,250],['data2',130,140,200,50] ],type: 'bar' },bar: { width: { ratio: 0.5 // this makes bar widt
我们以图表 http://c3js.org/samples/chart_bar.html为例
但用以下数据替换列数据:

var chart = c3.generate({
    data: {
        columns: [
            ['data1',30,100,150,250],['data2',130,140,200,50]
        ],type: 'bar'
    },bar: {
        width: {
            ratio: 0.5 // this makes bar width 50% of length between ticks
        }
        // or
        //width: 100 // this makes bar width 100px
    }
});

setTimeout(function () {
    chart.load({
        columns: [
            ['data3',-150,300,-200,100]
        ]
    });
},1000);

我们看到我们有很多空格或ZERO值条,我们如何删除它并删除空格. (不隐藏,我知道如何用CSS隐藏它)

Image example,what should be removed

解决方法

在 https://github.com/c3js/c3/issues/81用Google搜索
你需要将0替换为’null’并添加:

line: {
     connectNull: true,},var chart = c3.generate({
    data: {
        columns: [
            ['data1',null,line: {
         connectNull: true,1000);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读