ngx-charts-bar-水平数据标签格式

问题描述 投票:0回答:1

我正在使用ngx-charts更准确的横向。我要做的是格式化数据标签并在最后添加%。我曾尝试使用[xAxisTickFormatting],但它不起作用,因为从我注意到,我的值不是在ngx-charts-x-axis而是在ngx-charts-series-horizo​​ntal上。

ngx-charts用作如下:

<ngx-charts-bar-horizontal 
*ngIf='givesEnergyChartData && givesEnergyDataColorScheme'  
[scheme]="givesEnergyDataColorScheme"
[results]="givesEnergyChartData"
[gradient]="gradient"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[legend]="showLegend"
[view]="viewGiveEnergy"
[showXAxisLabel]="showXAxisLabel"
[showYAxisLabel]="showYAxisLabel"
[showDataLabel]="showDataLabel">
</ngx-charts-bar-horizontal>

此外,我试图格式化数据阵列(我知道它是愚蠢的,但我已经尝试:))

this.givesEnergyChartData = this.statistic.givesEnergyData.map(
 s => {
   return { name: s.name, value: s.count } 
 });

通过添加值:s.count +'%'。

那么,我该怎么做才能格式化数据标签并在值之后添加'%'?

here is my chart

angular typescript charts ngx-bootstrap ngx-charts
1个回答
0
投票

我找到了一个使用querySelector和innerHTML的解决方案:

 document.querySelectorAll(text.textDataLabel).innerHTML += '%';
© www.soinside.com 2019 - 2024. All rights reserved.