我想创建高图表。
这是 FIDDLE LINK 我的代码。
我给出了两个值 a 和 b 。 a 代表 x 轴 b 代表 y 轴。问题是当我给出 a 和 b 的值时。当 a 和 b 之间的差异较小时,则不会出现图形 IE。 a= -9 , b= -9 。否则它会起作用
$(function () {
var a, b, x, j;
a = -9;
b = -9;
if (a > b) {
x = a;
j = b
} else {
x = b;
j = a
}
alert("X is " + x);
alert("Y is" + j);
$('#container').highcharts({
chart: {
type: 'bar',
backgroundColor: null
},
credits: {
enabled: false
},
tooltip: {
enabled: false,
},
title: {
text: ''
},
xAxis: {
categories: ["", "", ""],
//minTickInterval:20000,
},
yAxis: {
min: j - (j * 5 / 100),
max: x + (x * 5 / 100),
//min: -50,
//max: -50,
//minTickInterval:20000,
endOnTick: true,
tickPixelInterval: 340,
maxPadding: 0.25,
title: {
text: ''
},
labels: {
formatter: function () {
if (j - (j * 5 / 100) > 1000000) {
return Highcharts.numberFormat((this.value) / 1000000, 0, '', ',') + 'M';
} else if (j - (j * 5 / 100) > 1000) {
return Highcharts.numberFormat((this.value) / 1000, 0, '', ',') + 'K';
} else {
return Highcharts.numberFormat((this.value), 0, '', ',');
}
},
x: 6
}
},
legend: {
backgroundColor: '#FFFFFF',
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
name: ' ',
data: [a]
},
{
name: ' ',
data: [0, b]
}, ]
});
});
最佳答案
这是一个有效的 fiddle
只需删除:
min: j-(j*5/100),
max: x+(x*5/100)
来自 yAxis:{ --- 一些选项 --- }
也尝试使用一个值 positive
和其他 negative
为 a
和 b
。
希望这对您有所帮助。
关于javascript - 使用 JavaScript 创建 Highchart 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25912328/