Я не уверен, правильно ли я понимаю ваш вопрос или нет, но приведенный выше ответ от @ppotaczek мне кажется нормальным.
Пожалуйста, ознакомьтесь с этим рабочим примером. fiddle .
Здесь я добавил gridLineWidth: 1
и tickmarkPlacement: "between"
, чтобы продемонстрировать, что тик фактически проходит от середины.
И как сказал @ppotaczek: Вы можете изменить расстояние между точками, изменив свойства pointPadding
и groupPadding
.
Пожалуйста, дайте мне знать, если это работает для вас!:)
Поскольку ссылка на fiddle.net должна сопровождаться кодом, который я включил здесь:
$(function() {
$('#container').highcharts({
chart: {
type: 'column',
inverted: true,
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['2018-06', '2018-07', '2018-08', '2018-09', '2018-10'],
tickWidth: 1,
tickmarkPlacement: "between",
gridLineWidth: 1
},
yAxis: {
min: -10,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold'
}
}
},
legend: {
enabled :false,
align: 'right',
x: -70,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function() {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;
}
},
plotOptions: {
series: {
groupPadding: 0.99,
pointPadding: 0.99
}
},
series: [{
name: 'Q1',
data: [
[0, -5],
[1, 3],
[2, 4],
[3, 7],
[4, -2]
]
}, {
name: 'Q2',
data: [
[0, 5],
[1, -3],
[2, 4],
[3, -7],
[4, 2]
]
}, {
name: 'Q3',
data: [
[1, 3],
[1, -4],
[2, 7],
[4, 2]
]
}]
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/broken-axis.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>