在具有 [x, y] 格式的数据系列的堆叠图表中,左侧和右侧的边距较大。我用示例数据创建了以下 jsfiddle:
图表代码如下:
$(function () {
var chart = new Highcharts.Chart({
chart: {"renderTo": "container", "type": "column"},
colors: ["#2f7ed8", "#0d233a", "#8bbc21", "#910000", "#1aadce", "#492970", "#f28f43", "#77a1e5", "#c42525", "#a6c96a", "#4572A7", "#AA4643", "#89A54E", "#80699B", "#3D96AE", "#DB843D", "#92A8CD", "#A47D7C", "#B5CA92"],
credits: {"enabled": false},
plotOptions: {"column": {"stacking": "normal"}},
series: [
{"name": "Muster1", "data": [
[11, 1],
[32, 1]
]},
{"name": "Muster2", "data": [
[11, 7],
[12, 4],
[14, 4],
[15, 1],
[16, 1],
[17, 4],
[18, 6],
[19, 2],
[20, 1],
[21, 1],
[22, 1],
[25, 3],
[26, 2],
[28, 1],
[29, 1],
[30, 1]
]},
{"name": "Muster 3", "data": [
[11, 2],
[13, 2],
[15, 1],
[16, 3],
[18, 5],
[19, 11],
[20, 8],
[21, 1],
[23, 3],
[24, 12],
[27, 3],
[28, 4],
[30, 3],
[31, 3],
[33, 3],
[34, 3]
]}
],
title: {"text": null},
xAxis: {"title": {"text": "Week"}},
yAxis: {"title": {"text": "Count"}}
});
});
我尝试过使用最小值和最大值、类别等,但没有任何结果。如何调整图表以全尺寸显示?
我已经用正确的排序更新了代码和 jsfiddle。我使用的是 3.0 而不是 3.05,因此控制台中没有错误。使用最新版本,我必须解决剩余的问题。一个是上面提到的左右两侧的大余量,另一个是我无法(即使使用 tickInterval)每个日历周都有一个刻度。根据上述示例,整个图表应具有从 x=11 到 x=34 的范围,每个 x 上都有一个刻度。