谢谢你的时间。对此,我真的非常感激。但我想通了。这是我发布的原始 jsFiddle 链接的一个分支。它正是我想做的。基本上,我删除了 xAxis 中的类别选项,然后使用了 xAxis 的自定义标签格式化程序;它对我有用。下边是
我的 Highcharts JavaScript 代码可以做到这一点:
var x_labels = ["$60.00","$70.00","$80.00","$90.00","$100.00"];
var chart2 = new Highcharts.Chart({
chart: {
renderTo: 'discount_chart',
type: 'line'
},
title: {
text: "Big Wells 2 Economic Sensitivity Plot"
},
xAxis: {
title: {
text: 'Price Range - $'
},
labels: {
formatter: function() {
return x_labels[this.value];
}
},
showLastLabel: true,
},
yAxis: [{
min: 0,
type: 'linear',
title: {
text: 'Rate of Return - %'
}},
{
min: 0,
type: 'linear',
title: {
text: 'Disc. N.Rev./Invest.(ROI)'
},
opposite: true}],
tooltip: {
formatter: function() {
var seriesName = {
'Rate of Return': 'ROR',
'Return on Investment': 'ROI'
}[this.series.name];
return '<b>' + this.series.name + '</b><br/>Price = ' + x_labels[this.x] + ', ' + seriesName + ' = ' + (Math.round(this.y * 1000) / 1000);
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -20,
y: 100,
borderWidth: 0
},
plotOptions: {
series: {
marker: {
enabled: false,
states: {
hover: {
enabled: true
}
}
}
}
},
series: [{
name: 'Rate of Return',
color: 'red',
data: [-4.608072102337354, -0.738803860865155, 4.653294970652549, 8.92228974293352, 14.025752639875485],
pointStart: 0},
{
name: 'Return on Investment',
color: 'blue',
data: [0.5863077142857144, 0.7098245714285715, 0.8340802857142857, 0.9587922857142858, 1.083803],
pointStart: 0,
yAxis: 1}]
});
上述代码的 jSFiddle Demo fork: