我想在 y 轴上显示带有特定货币符号的数据,如工具提示中的突出显示区域。我已经自定义了工具提示,但提供给图形的动态数据不受我控制。
这是我尝试过的代码
<Line
ref="chart"
data={ {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
datasets: [
{
label: "",
fill: false,
lineTension: 0,
backgroundColor: "rgba(75,192,192,0.4)",
borderColor: "#71C898",
borderCapStyle: "butt",
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: "miter",
pointBorderColor: "#71C898",
pointBackgroundColor: "#2D9A5E",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#71C898",
pointHoverBorderColor: "rgba(220,220,220,1)",
pointHoverBorderWidth: 2,
pointRadius: 5,
pointHitRadius: 10,
data: this.props.data.length > 0 ? this.props.data : [],
}],
}}
height={ 200 }
options={ {
tooltips: {
callbacks: {
label: (tooltipItems, data) => {
return `${currencyFormatter(tooltipItems.value)}`
}
}
}
}}
/>