mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-02-23 12:20:12 +08:00
Make barchart clickable
This commit is contained in:
parent
93ef083abc
commit
50b7af8421
@ -9,6 +9,8 @@ import {
|
||||
Legend,
|
||||
ResponsiveContainer,
|
||||
} from "recharts";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { queueDetailsPath } from "../paths";
|
||||
|
||||
interface Props {
|
||||
data: TaskBreakdown[];
|
||||
@ -24,9 +26,25 @@ interface TaskBreakdown {
|
||||
}
|
||||
|
||||
function QueueSizeChart(props: Props) {
|
||||
const handleClick = (params: { activeLabel?: string } | null) => {
|
||||
const allQueues = props.data.map((b) => b.queue);
|
||||
if (
|
||||
params &&
|
||||
params.activeLabel &&
|
||||
allQueues.includes(params.activeLabel)
|
||||
) {
|
||||
history.push(queueDetailsPath(params.activeLabel));
|
||||
}
|
||||
};
|
||||
const history = useHistory();
|
||||
return (
|
||||
<ResponsiveContainer>
|
||||
<BarChart data={props.data} maxBarSize={120}>
|
||||
<BarChart
|
||||
data={props.data}
|
||||
maxBarSize={120}
|
||||
onClick={handleClick}
|
||||
style={{ cursor: "pointer" }}
|
||||
>
|
||||
<CartesianGrid strokeDasharray="3 3" />
|
||||
<XAxis dataKey="queue" />
|
||||
<YAxis />
|
||||
|
@ -196,6 +196,7 @@ export default function QueuesOverviewTable(props: Props) {
|
||||
<TableBody>
|
||||
{sortQueues(props.queues, cmpFunc).map((q) => (
|
||||
<Row
|
||||
key={q.queue}
|
||||
queue={q}
|
||||
onPauseClick={() => props.onPauseClick(q.queue)}
|
||||
onResumeClick={() => props.onResumeClick(q.queue)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user