React ApexChart将工具提示格式点调换为逗号
我正在开发一个德国应用程序,他们不使用数量(20.00),而是使用逗号(20,00)。使用React-Apexcharts
,如何替换图表和工具中的点。任何方向都将不胜感激,我已经被卡住了几天:(
import { ApexOptions } from 'apexcharts';
import { FC } from 'react';
import ReactApexChart from 'react-apexcharts';
interface IGraphProps extends ApexOptions {
className?: string;
label: string[];
values: number[] | string[];
legendPosition?: 'top' | 'right' | 'bottom' | 'left';
colorHexCodes?: string[];
}
export const DonutChart: FC<IGraphProps> = ({
className,
label,
values,
legendPosition = 'bottom',
colorHexCodes
}) => {
const options = {
labels: ['Energie', 'Abfall', 'Verbrauchsgüter', 'Geschäftsreisen', 'Arbeitsweg'],
legend: {
position: legendPosition
},
colors: colorHexCodes,
dataLabels: {
enabled: true
formatter: function (val: number) {
return val.toString().replace('.', ',');
}
}
};
const x = values;
return (
<div className={className}>
<ReactApexChart type="donut" options={options} series={x} height={400} width={350} />
</div>
);
};
I am developing a German app and they do not use dots (20.00) in numbers, they use commas (20,00). Using react-apexcharts
, how do I replace the dots in my chart and tools. Any direction will be appreciated, I have been stuck for days now :(
import { ApexOptions } from 'apexcharts';
import { FC } from 'react';
import ReactApexChart from 'react-apexcharts';
interface IGraphProps extends ApexOptions {
className?: string;
label: string[];
values: number[] | string[];
legendPosition?: 'top' | 'right' | 'bottom' | 'left';
colorHexCodes?: string[];
}
export const DonutChart: FC<IGraphProps> = ({
className,
label,
values,
legendPosition = 'bottom',
colorHexCodes
}) => {
const options = {
labels: ['Energie', 'Abfall', 'Verbrauchsgüter', 'Geschäftsreisen', 'Arbeitsweg'],
legend: {
position: legendPosition
},
colors: colorHexCodes,
dataLabels: {
enabled: true
formatter: function (val: number) {
return val.toString().replace('.', ',');
}
}
};
const x = values;
return (
<div className={className}>
<ReactApexChart type="donut" options={options} series={x} height={400} width={350} />
</div>
);
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
datalabels
使用此格式化:和
tooltip
y
使用此( https://apexcharts.com/docs/options/tooltip/#yformatter ):In
dataLabels
use this formatter:And in
tooltip
y
use this (https://apexcharts.com/docs/options/tooltip/#yformatter):