Javascript HighChart中y轴的起始值
我最近添加到我的项目中,我想用它来创建图表。我编写了以下代码来创建一些城市每月的温度图表:Javascript HighChart中y轴的起始值,javascript,jquery,charts,highcharts,Javascript,Jquery,Charts,Highcharts,我最近添加到我的项目中,我想用它来创建图表。我编写了以下代码来创建一些城市每月的温度图表: function CreateChart() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', ype: 'line', //type: 'column', s
function CreateChart() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
ype: 'line',
//type: 'column',
shadow: true,
zoomType: 'x',
style: {
fontFamily: 'Tahoma'
}
},
title: {
text: 'Nima Report',
x: -20 //center
},
labels: {
items: {
style: {
fontFamily: 'Tahoma'
}
},
style: {
fontFamily: 'Tahoma'
}
},
subtitle: {
text: 'Source: --',
x: -20
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
labels: {
rotation: -45,
align: 'right',
formatter: function () {
return '<span style="font-size: 18px;">' + this.value + '</span>';
}
}
},
yAxis: {
title: {
text: 'Temp'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}],
labels: {
align: 'right',
formatter: function () {
return '<span style="font-size: 18px;font-weight: bold">' + this.value + '</span>';
}
}
},
tooltip: {
crosshairs: [true, true],
enabled: true,
style: {
fontFamily: "Tahoma",
textAlign: "right"
},
formatter: function () {
return '<b>' + this.series.name + '</b><br/>' +
this.x + ': ' + this.y + '°C';
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0,
labelFormatter: function () { return '<span style="font-family: Tahoma">' + this.name + '</span>'; }
},
series: [{
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
name: 'New York',
data: [0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}, {
name: 'Berlin',
data: [0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
}, {
name: 'London',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}]
});
}
函数CreateChart(){
图表=新的高点图表。图表({
图表:{
renderTo:'容器',
类型:'行',
//键入:“列”,
影子:没错,
zoomType:'x',
风格:{
丰特家族:“塔荷马”
}
},
标题:{
文本:“尼玛报告”,
x:-20/中心
},
标签:{
项目:{
风格:{
丰特家族:“塔荷马”
}
},
风格:{
丰特家族:“塔荷马”
}
},
副标题:{
文本:“源:——”,
x:-20
},
xAxis:{
类别:[一月、二月、三月、四月、五月、六月、七月、八月、九月、十月、十一月、十二月],
标签:{
轮调:-45,
对齐:“右”,
格式化程序:函数(){
返回“”+this.value+“”;
}
}
},
亚克斯:{
标题:{
文本:“临时”
},
绘图线:[{
值:0,
宽度:1,
颜色:'#808080'
}],
标签:{
对齐:“右”,
格式化程序:函数(){
返回“”+this.value+“”;
}
}
},
工具提示:{
十字准星:[对,对],
启用:对,
风格:{
丰特家族:“塔荷马”,
text对齐:“右”
},
格式化程序:函数(){
返回“+this.series.name+”
+
这个.x+':'+这个.y+'°C';
}
},
图例:{
布局:“垂直”,
对齐:“右”,
垂直排列:“顶部”,
x:-10,
y:100,
边框宽度:0,
labelFormatter:函数(){return'+this.name+'';}
},
系列:[{
名称:"东京",,
数据:[7.0,6.9,9.5,14.5,18.2,21.5,25.2,26.5,23.3,18.3,13.9,9.6]
}, {
名称:'纽约',
数据:[0.2,0.8,5.7,11.3,17.0,22.0,24.8,24.1,20.1,14.1,8.6,2.5]
}, {
名称:“柏林”,
数据:[0.9,0.6,3.5,8.4,13.5,17.0,18.6,17.9,14.3,9.0,3.9,1.0]
}, {
名称:“伦敦”,
数据:[3.9,4.2,5.7,8.5,11.9,15.2,17.0,16.6,14.2,10.3,6.6,4.8]
}]
});
}
问题是当图表创建时,Y轴的起始值是
-25
,尽管我没有任何负值。我希望它从零开始
如何设置?谢谢将min
添加到y轴:
yAxis: {
title: {
text: 'Temp'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}],
labels: {
align: 'right',
formatter: function () {
return '<span style="font-size: 18px;font-weight: bold">' + this.value + '</span>';
}
},
min:0,
},
yAxis:{
标题:{
文本:“临时”
},
绘图线:[{
值:0,
宽度:1,
颜色:'#808080'
}],
标签:{
对齐:“右”,
格式化程序:函数(){
返回“”+this.value+“”;
}
},
分:0,,
},
这种方法的问题是,如果有负值,则行会被截断,如图所示。问题是如何避免在所有数据点均为正值的情况下,从负值开始y轴的高图表。