C3.js制作线显示为虚线

时间:2015-03-19 17:08:09

标签: css charts c3

我使用两个Y轴使用C3.js。我有2个数据系列:

data: {
        rows: [
        ['data1', 'data2', 'data3'],
        [90, 120, 300],
        [40, 160, 240],
        [50, 200, 290],
        [120, null, 230],
        [80, null, 300],
        [90, null, 320],
    ],
        regions: {
            'data1': [{'start':0, 'style':'dashed'},],
        }
    }

当我运行它时,我得到一条虚线,然后它沿着x轴作为虚线绘制为null。这不是我想要的。我希望它在数据集为空时停止绘图。如果我删除该区域,我会得到我想要的功能,但我没有得到虚线。

有没有办法在不绘制空值的情况下获取虚线?

1 个答案:

答案 0 :(得分:12)

由于C3使用SVG,您可以使用CSS选择器来修改其元素的外观。

C3图表中的所有行都有.c3-line类,请看一下:1

所以,我们可能只是将它添加到我们的CSS:

.c3-line{
  stroke-dasharray: 5,5;
}

以下是stroke-dasharray的一些文档。

Note the classes in the path. We can use them to target the element with CSS

相关问题