如何自定义c3js中Y轴网格线的CSS属性?

huangapple go评论55阅读模式
英文:

How to coustomise the Y-axis grid line css properties in c3js

问题

我已创建了一个包含时间序列数据的折线图。我使用自定义的X轴网格线,并通过编辑它们的CSS来增加它们的间距。我想要增加Y轴上网格线的间距。这是我所做的:

// 增加X轴网格线间距
.c3-xgrid-line{
    stroke-dasharray: 10,5;
}

// 增加Y轴网格线间距
.c3-ygrid-line {
    stroke-dasharray: 10,5;
}

以上代码只能改变X轴网格线的属性。

这是目前图表的外观

英文:

I have created a line chart with time series data. I used custom X-axis grid lines and increased their spacing by editing their CSS. I would like to increase the spacing between the grid lines on the Yaxis. Here's what I did:

`// to increase the X grid line spacing
.c3-xgrid-line{
    stroke-dasharray: 10,5;
    }
// to increase the Y grig line spacing
.c3-ygrid-line {
    stroke-dasharray: 10,5;``
}`

The X grid line property was the only one I could change with the above

This is how the graph looks now

答案1

得分: 1

自定义网格线最终使用类名.c3-(x或y)grid-lines,这就是它适用于x轴的原因。

如果它们只是标准的,即通过grid: { y: { show: true }}设置,
那么它们位于不同的组元素中,并具有类名.c3-(x或y)grid。

简而言之:在您的CSS中将.c3-ygrid-line更改为.c3-ygrid。

英文:

Custom grid lines end up with the class .c3-(x or y)grid-lines which is why it works for x

If they're just standard i.e. set with grid: { y: { show: true }}
then they're in a different group element and given the .c3(x or y)grid class

Long story short: change .c3-ygrid-line to .c3-ygrid in your css

huangapple
  • 本文由 发表于 2023年7月13日 13:06:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76676091.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定