我们正在从基于Flash的图表库(FusionCharts)迁移到基于JavaScript的图表库(HighCharts)。
这就是我们目前的flash图表
这就是我迄今为止使用HighCharts所获得的。
如何删除绘图边框与实际图表数据之间的空格(标有大哑红色箭头)?
这是我的代码:http://jsfiddle.net/ChrisMBarr/7JAcN/1/
var chart = new Highcharts.Chart({
chart:{
renderTo: 'container',
type: 'areaspline',
plotBorderWidth: 1,
spacingTop:2,
spacingRight:5,
spacingBottom:5,
spacingLeft:2,
borderWidth:1,
borderRadius:0,
borderColor:'#999'
},
credits: {
enabled: false
},
title: {
text: 'Total spam in the last 7 days'
},
legend: {
verticalAlign: 'bottom',
borderWidth: 1,
backgroundColor: '#FFFFFF'
},
xAxis: {
allowDecimals:false,
categories: [
'Thu 2/14',
'Fri 2/15',
'Sat 2/16',
'Sun 2/17',
'Mon 2/18',
'Tue 2/19',
'Wed 2/20'
],
labels: {
staggerLines: 2
},
tickmarkPlacement: 'on',
},
yAxis: {
allowDecimals:false,
alternateGridColor: '#F7F7F7',
title: {
text: 'Number of Emails',
margin:5
}
},
tooltip: {
formatter: function() {
var isSpam = this.series.name === _chartOptions.series[1].name
return ''+this.x +': <strong>'+ this.y +(isSpam ? " Spam" : "") +' Emails</strong>';
}
},
plotOptions: {
areaspline: {
fillOpacity: 0.5
}
},
series: [{
"name": "Total Mail",
"color":"#339999",
"data": [2,3,4,7,8,8,8]
},{
"name": "Spam",
"color":"#003399",
"data": [2,2,4,4,4,6,8]
}]
});
答案 0 :(得分:13)
这可能会有所帮助:
xAxis: {
min: 0.5, max: 5.5
...
其中max =数据点数减去1.5
答案 1 :(得分:7)
您应该使用minPadding / maxPadding参数,但它不适用于类别。所以我建议删除Categoreis,使用min值和tickInterval
http://jsfiddle.net/7JAcN/3/ http://api.highcharts.com/highcharts#xAxis.minPadding
xAxis: {
allowDecimals:false,
minPadding:0,
maxPadding:0,
/*categories: [
'Thu 2/14',
'Fri 2/15',
'Sat 2/16',
'Sun 2/17',
'Mon 2/18',
'Tue 2/19',
'Wed 2/20'
],*/
labels: {
staggerLines: 2
},
tickmarkPlacement: 'on',
},
答案 2 :(得分:0)
选项“tickmarkplacement”设置为“on”,xAxis“ startontick ”选项可能对您有所帮助:
xAxis: {
startOnTick: false,
tickmarkplacement:"on",
...
见 this jsfiddle, forked from the Highcharts API documentation
答案 3 :(得分:0)
删除填充的最佳方法是在&#39;
上添加 pointPlacement:&#39;plotOptions: {
areaspline: {
pointPlacement: 'on'
}
}