我们在使用 Highchart 柱形图时遇到问题,显示的 y 轴标签不一致。生成的柱形条位于两个 y 轴标签之间。这给出了没有 y 轴刻度并且条形是浮动的外观。
而且它也没有生成 0 yaxis 刻度,该条始终从该刻度开始。我们有负值和正值,因此条形图应显示在 0 y 轴的上方和下方。
我们无法发布样本,因为行为是随机的,它在大多数情况下都能正常工作,只是在某些情况下它不起作用(尽管很正常,但可以忽略)。
请在柱形图设置选项下方找到:
{
chart: {
type: 'column',
height: response.ChartHeight ? response.ChartHeight : ChartDefaults.Height
},
xAxis: {
categories: response.TimePeriodTranslated,
labels: {
style: {
fontSize: (response.ChartFontSize ? response.ChartFontSize + 'pt' : ChartDefaults.FontSize)
}
}
},
yAxis: {
startOnTick: true,
title: {
text: ''
},
labels: {
style: {
fontSize: (response.ChartFontSize ? response.ChartFontSize + 'pt' : ChartDefaults.FontSize)
}
}
},
tooltip: {
useHTML: true,
formatter: function () {
return this.series.name + "<br>" + this.x + " </b> : <b> " + this.y.toFixed(response.NumberOfDecimal ? 2 : response.NumberOfDecimal);
}
},
title: {
text: response.ShowAsAtDate == 1 ? modelContents.GetTranslation('AsAt') + ' ' + response.AsAtDate : '',
align: 'left',
//x: 70,
style: {
fontSize: (response.ChartFontSize ? response.ChartFontSize + 'pt' : ChartDefaults.FontSize)
}
},
subtitle: {
text: '',
style: {
fontSize: (response.ChartFontSize ? response.ChartFontSize + 'pt' : ChartDefaults.FontSize)
}
},
legend: {
enabled: true,
itemStyle: {
fontSize: (response.ChartFontSize ? response.ChartFontSize + 'pt' : ChartDefaults.FontSize)
}
},
credits: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: response.ShowDataLabels == 1 ? true : false,
formatter: function () {
return this.y ? this.y.toFixed(response.NumberOfDecimal ? 2 : response.NumberOfDecimal) : this.y;
},
style: {
fontSize: (response.ChartFontSize ? response.ChartFontSize + 'pt' : ChartDefaults.FontSize)
}
},
//To set the bar width.
//pointWidth: GetBarSettings(dataToPlot)
},
column: {
cursor: 'pointer',
point: {
events: {
click: function (e) {
// This can be handled in the drilldown event but our requirements with drilldown need this event implementation
SetChart(e, data, divId, dataId);
}
}
}
}
},
series: dataToPlot
};
谢谢,萨拉特