const maxValue = Math.max(...column_data.map((d) => d.rate));
const averageValue = column_data.map((d, index) => ({ key: index, rate: d.rate })).reduce((a, b) => a + b.rate, 0) / column_data.length;
const roundedAverage = Math.round(averageValue * 100) / 100;
const formattedAverage = roundedAverage.toFixed(2);
const column_config = {
data: column_data,
xField: 'service_user_name',
yField: 'rate',
seriesField: "service_user_name",
color: ['#7262fd'],
padding: [10, 10, 20, 40],
legend: {
visible: false,
},
tooltip: {
visible: true,
formatter: (column_data: any) => {
return { name: '归档率', value: `${column_data.rate}%` };
},
},
label: {
position: 'middle',
style: {
fill: '#FFFFFF',
opacity: 1,
},
formatter: (column_data: any) => {
return ` ${column_data.rate}%`;
},
},
xAxis: {
label: {
autoHide: true,
autoRotate: false,
},
},
meta: {
type: {
alias: '类别',
},
sales: {
alias: '销售额',
},
},
smooth: true,
annotations: [
{
type: 'line',
start: ['min', averageValue],
end: ['max', averageValue],
text: {
content: `均值${formattedAverage}`,
position: ['max'],
style: {
textAlign: 'right',
fill: 'red',
},
},
style: {
lineDash: [1, 1],
stroke: 'red',
},
},
],
};
<Spin spinning={loadContract}>
<div className="desktop_overdue_con" style={{ height: `${scrollHeightchart}px` }}>
<div style={{height:'100%'}}>
<Column {...column_config} />
</div>
</div>
</Spin>