【问题标题】:c3 graph in a dark background; how to change axis and tick value colorc3 深色背景中的图形;如何更改轴和刻度值颜色
【发布时间】:2015-07-05 16:49:30
【问题描述】:

我在深色背景上绘制了一个图表,但由于轴颜色和刻度值颜色,它很难阅读。如何将轴的颜色、刻度和轴刻度值更改为白色?

【问题讨论】:

    标签: javascript jquery d3.js c3


    【解决方案1】:

    例如,您可以使用CSS 来设置图表样式

    path.domain { stroke: white; }
    .tick text { stroke: yellow; }
    .c3-legend-item text { stroke: grey; }
    

    要使轴变为白色,刻度标签为黄色,图例文本为灰色。

    【讨论】:

    • 例如使用 CSS 选择器.c3-legend-item text
    • 虽然会创建一个笔触,但它不会改变颜色。有没有办法只更改文本颜色而不是创建笔触?
    【解决方案2】:
    .c3 path, .c3 line, .tick text { 
      stroke: white;
    }
    

    【讨论】:

      【解决方案3】:

      如果您不想使用描边,请尝试更改填充颜色:

      path.domain { fill: white; }
      .tick text { fill: yellow; }
      .c3-legend-item text { fill: grey; }
      

      【讨论】:

        【解决方案4】:

        您可以尝试调整路径和线条的 CSS 属性。请参阅下面的示例 CSS 作为帮助程序。

        .c3 .c3-axis-x path,
        .c3 .c3-axis-x line {
          stroke: red;
        }
        
        .c3 .c3-axis-y path,
        .c3 .c3-axis-y line {
          stroke: blue;
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2021-08-11
          • 1970-01-01
          • 1970-01-01
          • 2011-06-13
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多