gpt4 book ai didi

javascript - Highcharts 值(value)百分比

转载 作者:行者123 更新时间:2023-11-28 05:04:09 25 4
gpt4 key购买 nike

我正在尝试使用高级图表 API 重新创建此图表。有什么想法如何构建这个吗?尝试使用数字和百分比列对年份类别进行分组,请参阅随附的示例图片。谢谢!

1

到目前为止,我已经尝试过此操作,但无法像所附图片那样同时获得值和百分比:

  Highcharts.chart('ContainerMonthToDate', {
chart: {
type: 'column'
},
title: {
text: null
},
subtitle: {
text: null
},
xAxis: {
categories: [
'Jan 2017',
'Jan 2016'

],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: '# Patients'
}
},


labels: {
formatter: function(){
return 100*this.value / $(this.axis.tickPositions).last()[0] + '%';
}

},


tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} </b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
dataLabels: {
enabled: true,
crop: false,
overflow: 'none'
}
}
},


colors: [
'#ff0000',
'#ff0000',
'#ff0000',
'#ff0000'
],

series: [{
name: 'Cumulative',
data: [8657, 7824]

}, {
name: 'Admissions',
data: [2025, 1898]

}, {
name: 'Budgeted',
data: [8018, 7913]

}, {
showInLegend: false,
name: '',
data: [1956, 1889]


}]



});

最佳答案

要组合两种类型的数据,请使用 yAxis 的定义:

    yAxis: [{
title: {
text: '# Pts'
}
}, {
opposite: true,
max: 100,
title: {
text: '% Pts'
},
labels: {
format: '{value} %',
style: {
color: Highcharts.getOptions().colors[2]
}
}
}],

example on jsfiddle

关于javascript - Highcharts 值(value)百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41883865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com