在c3js图表中重叠类别轴标签文本

时间:2015-01-19 06:28:42

标签: javascript d3.js charts c3.js

如果类别轴标签文本很长或c3js图表中有多个单词,它们会重叠并使其无法读取,是否有任何配置或黑客来解决此问题?

c3js category axis label text overlapping

c3js category axis example

复制并粘贴以下代码以重现此错误。

var chart = c3.generate({
  data: {
    columns: [
        ['data1',40, 30, 200, 100, 400, 150, 250, 50, 100, 250,67,190,48,123,76,54,254]
    ]
  },
  axis: {
    rotated: true,
    x: {
        type: 'category',
        categories: ['Travel and Hospitality','Life Science and Pharma', 'Saas and Cloud', 'Hi-tech Manufacturing', 'Software', 'Business Services', 'Govt/Public Sector', 'Energy', 'Manufacturing', 'Healthcare','Media','Internet','Retail','Biotech','Automobile','Consumer Goods','Financial Services']
    }
  }
});

1 个答案:

答案 0 :(得分:4)

我在axis_x_tick下的'multiline'配置中找到了解决方案,如下所示: -

axis: {
    rotated: true,
    x: {
        tick: {
            multiline: false,
        },
        type: 'category',
    }
 }

Working example- multiline axis label disabled