Jot*_*vel 5 html javascript css jquery highcharts
我正在使用 Highcharts 并遇到了一个我正在努力克服的小问题。
我创建了一个 jsfiddle,所以你可以看到我的问题:
http://jsfiddle.net/jo_pappi/0e5h8sts/3/ [A]
如你看到的

我可以在 highcharts 中实现上述格式,因为此图表是基于动态数据呈现的 我在这里附上图片
和代码
$('#container-one').highcharts({
chart: {
type: 'bar',
events: {
click: function (event) {
console.log(event.pageX + ',' + event.pageY);
}
}
},
credits: {
enabled: false
},
title: {
text: 'Total fruit consumtion, grouped by gender'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'],
minPadding: 1.1,
maxPadding: 1.1
},
yAxis: {
allowDecimals: false,
min: 0,
title: {
text: 'Number of fruits'
}
},
tooltip: {
enabled: false,
formatter: function () {
return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;
}
},
plotOptions: {
// column: {
// stacking: 'normal'
// }
series: {
pointWidth: 20,
stacking: 'normal',
borderWidth: 0,
events: {
click: function (event) {
//reloadFlash();
//$('#report').html('click on yAxis title');
console.log(event.pageX + ',' + event.pageY);
}
}
}
},
series: [{
name: 'John',
color: 'rgba(89,89,89,1)',
data: [5], // data: [5, 3, 4, 7, 4],
stack: 'male',
pointPadding: -0.0,
pointPlacement: -0.0
}, {
name: 'Joe',
color: 'rgba(255,95,215,1)',
data: [3], // data: [3, 4, 4, 2, 2],
stack: 'male',
pointPadding: -0.0,
pointPlacement: -0.0
}, {
name: 'Jane',
color: 'rgba(217,116,0,1)',
data: [2], // data: [2, 5, 6, 2, 1],
stack: 'female',
pointPadding: -0.0,
pointPlacement: -0.0
}, {
name: 'Janet',
color: 'rgba(155,215,255,1)',
data: [3], // data: [3, 0, 4, 4, 3],
stack: 'female',
pointPadding: -0.0,
pointPlacement: -0.0
}]
});
Run Code Online (Sandbox Code Playgroud)

我怎样才能减少酒吧之间的空间?
如果更改图表的高度是一种解决方案,则意味着我如何动态实现这一点?
删除“pointWidth”解决了条形之间的空白。但我需要在所有可能的情况下,酒吧应该保持相同的高度。我通过根据类别计数动态设置高度解决了这个问题。例如,如果我只有一个类别,我将图表的高度设置为“210”,将 2 个类别的高度设置为“270”。并删除了 pointWidth。
$('#container-one').highcharts({
chart: {
type: 'bar',
height: 210,
...
.
.
plotOptions: {
bar: {
pointPadding: 0,
borderWidth: 0
},
series: {
//pointWidth: 20,
stacking: 'normal',
.
.
});
Run Code Online (Sandbox Code Playgroud)
当我有两个类别时,我将图表高度设置为270
$('#container-two').highcharts({
chart: {
type: 'bar',
height: 270,
...
.
.
plotOptions: {
bar: {
pointPadding: 0,
borderWidth: 0
},
series: {
//pointWidth: 20,
stacking: 'normal',
.
.
});
Run Code Online (Sandbox Code Playgroud)
也许我做的是错的。但它解决了我的问题。如果我错了请纠正我。
谢谢大家
| 归档时间: |
|
| 查看次数: |
3408 次 |
| 最近记录: |