基本条形图中的最大类别数

时间:2015-07-21 12:44:39

标签: highcharts

我想知道基本条形图中是否存在类别数量(条数)的限制。

问题是:有多少类别,一个基本条形图,可以支持?

我已经在官方文档中搜索过但我没有发现任何相关信息。

欢迎任何线索。

1 个答案:

答案 0 :(得分:0)

每个轴的类别数限制为1000。

在1001个类别下,图表会断开。

查看此小提琴进行实际测试(1000与1001类别):https://jsfiddle.net/3r2psy8u/4/

html

<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="min-width: 100%; height: 400px; margin: 10px auto"></div>
<div id="container2" style="min-width: 100%; height: 400px; margin: 0 auto"></div>

js

var thousandCategories = [];
var thousandValues = [];

for(var x = 1; x < 1001; x++) {
      thousandCategories.push('category ' + x);
      thousandValues.push(['category ' + x, x]);
}

var thousandCategoriesPlusOne = thousandCategories.concat(['category 1001'])
var thousandValuesPlusOne = thousandValues.concat([['category 1001', 1001]])

Highcharts.chart('container', {
    chart: {
        type: 'bar',
                zoomType: 'x'
    },
    title: {
        text: '1000 categories'
    },
    xAxis: {
        categories: thousandCategories
    },
    series: [{
        name: '1000 categories',
        data: thousandValues
    }]
});

Highcharts.chart('container2', {
    chart: {
        type: 'column'
    },
    title: {
        text: '1000 categories plus one'
    },
    xAxis: {
        categories: thousandCategoriesPlusOne
    },
    series: [{
        name: '1001 categories',
        data: thousandValuesPlusOne
    }]
});
相关问题