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