【发布时间】:2021-10-24 21:43:08
【问题描述】:
我希望使用此处的 CoreUI 文档中提供的 CChartBar 创建一个向下钻取:https://coreui.io/react/docs/3.3/components/CCharts/
我需要能够从被点击的栏中获取月份,当点击栏时,它需要将用户带到另一个页面。我如何获取信息?如何使每个栏可点击以将用户发送到表格页面?
目前这里是html
<div className="chart-container">
<CChartBar
datasets={[
{
label: "Expected Expirations",
type: "bar",
data: expectedExpirations,
backgroundColor: "#949fe8",
borderColor: "blue",
fill: true,
order: 2,
},
{
label: 'Actual Expirations',
type: "bar",
data: actualExpirations,
backgroundColor: '#556ad1',
borderColor: "blue",
fill: true,
order: 1,
},
{
label: 'Target Expirations',
backgroundColor: '#352c2c',
data: targetExpirations,
type: "line",
borderColor: "black",
fill: true,
order: 0,
borderWidth: 2,
fill: "#352c2c",
pointBackgroundColor: "#352c2c",
lineTension: 0,
}
]}
labels={dateLabels}
onClick={(event) => drillDown(event)}
options={{
maintainAspectRatio: false,
responsive: true,
tooltips: {
enabled: true,
},
scales: {
xAxes: [{
stacked: true,
scaleLabel: {
display: true,
labelString: "Month"
}
}],
yAxes: [{
ticks: {
stacked: true,
beginAtZero: true,
stepValue: 10,
max: maxOfAllExpirations
},
scaleLabel: {
display: true,
labelString: "Number of Lease Expirations"
}
}]
},
}}
/>
我希望能够点击该栏,并获取正在绘制的数据,这样我就可以将月份传递到另一个页面。
【问题讨论】: