【发布时间】:2017-09-07 15:12:31
【问题描述】:
我正在使用 highcharts,我想获得您可以在下面看到的相同图表(负条)。你可以看到我所拥有的代码。如何在最后一个栏的一侧添加灰色文本? (浅绿色条)。我也想摆脱我在第二个栏中得到的 0%。提前致谢。
$(function () {
$('#emmisions2015_2050').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
xAxis: {
opposite: true,
categories: ['Transport', 'Purchased Electricity', 'Direct Emissions']
},
tooltip: {
formatter: function () {
return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;
}
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
rotation: 0,
align: 'right',
style: {
textOutline: false
},
borderWidth: 1,
formatter: function() {
if (this.point.isInside == true) {
return '<span style="color: white">' + this.y + '%</span>';
} else {
return '<span style="color: black">' + this.y + '%</span>';
}
}
}
},
column: {
stacking: 'normal',
format: '{point.x:.1f} Billion Euro'
}
},
series: [{
name: 'Emerging & Breakthrough',
data: [0, 0, { y: -5, color: '#8cc640'}]
},{
name: 'Demand-side Flexibility',
data: [0, 0, { y: -2, color: '#8cc640'}]
},{
name: 'Fuel Switch',
data: [0, 0, { y: -8, color: '#8cc640'}]
},{
name: 'Energy Efficiency',
data: [{ y: -4, color: '#51a332'},{ y: -11, color: '#26b6cc'},{ y: -7, color: '#8cc640'}]
}]
});
});
#emmisions2015_2050 .highcharts-legend{
display: none;
}
.highcharts-button, .highcharts-axis, .highcharts-credits{
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div class="emisions" id="emmisions2015_2050"></div>
【问题讨论】:
标签: jquery highcharts