如何在ApexChart polar area极区图中移除或设置数值的小数位数
极区图上显示的数值属于数据标签,通过修改配置项中的plotOptions字段即可实现你的两种需求:
方案1:直接移除所有显示的数值
在配置对象中新增plotOptions字段,关闭极区图的数据标签开关:
this.duChartOptions2 = { series: [1,2,4], chart: { type: "polarArea" }, // 新增配置段 plotOptions: { polarArea: { dataLabels: { enabled: false // 关闭数据标签即可隐藏所有显示的数值 } } }, labels: ["a","b","c"], stroke: { colors: ["#fff"] }, fill: { opacity: 0.8 }, responsive: [ { breakpoint: 480, options: { chart: { width: 200 }, legend: { position: "bottom" } } } ] };
方案2:数值保留2位小数
不关闭数据标签,添加formatter回调函数格式化输出的数值即可:
this.duChartOptions2 = { series: [1,2,4], chart: { type: "polarArea" }, // 新增配置段 plotOptions: { polarArea: { dataLabels: { enabled: true, formatter: function(val) { return val.toFixed(2) // 格式化数值为保留2位小数 } } } }, labels: ["a","b","c"], stroke: { colors: ["#fff"] }, fill: { opacity: 0.8 }, responsive: [ { breakpoint: 480, options: { chart: { width: 200 }, legend: { position: "bottom" } } } ] };
内容的提问来源于stack exchange,提问作者Rimuru
相关产品推荐
相关产品推荐

