-
Notifications
You must be signed in to change notification settings - Fork 609
fix: WIP Chart and tooltips are not informative #3915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
012b154
f1d51fc
d3fbe99
bc45baf
fe8061f
4244b92
a1add6d
f9e4616
1343ec4
d039e99
ff8fbb0
27299c8
4860cb0
c0dbd09
038238c
f09ae5b
105c8a4
a611f0c
ec30287
bd59fff
519e83d
cb0425d
379a093
0f2d2d0
138d1ed
d703d6b
38d4239
d02bab9
4bb804e
d2db157
e035f3b
eca153c
3e1bb17
a48344d
e654219
a8fcd5b
84088f5
08b213b
5a7ec4b
16dd808
1fa0ccc
e1c40dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,18 +8,25 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ChartTooltipContent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "@/components/ui/chart"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { formatNumber } from "@/lib/fmt"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { CompoundTimeseriesGranularity } from "@/lib/trpc/routers/utils/granularity"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Grid } from "@unkey/icons"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useEffect, useRef, useState } from "react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Bar, BarChart, ReferenceArea, ResponsiveContainer, YAxis } from "recharts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bar, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BarChart, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ReferenceArea, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ResponsiveContainer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| YAxis, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "recharts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { createTimeIntervalFormatter } from "../overview-charts/utils"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { LogsChartError } from "./components/logs-chart-error"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { LogsChartLoading } from "./components/logs-chart-loading"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { calculateTimePoints } from "./utils/calculate-timepoints"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { formatTimestampLabel } from "./utils/format-timestamp"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type Selection = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start: string | number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end: string | number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start: number | undefined; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end: number | undefined; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| startTimestamp?: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| endTimestamp?: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -30,6 +37,13 @@ type TimeseriesData = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [key: string]: unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type ChartMouseEvent = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activeLabel?: string | number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activePayload?: ReadonlyArray<{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payload: TimeseriesData; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type LogsTimeseriesBarChartProps = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data?: TimeseriesData[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config: ChartConfig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -39,6 +53,7 @@ type LogsTimeseriesBarChartProps = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isLoading?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isError?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enableSelection?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| granularity?: CompoundTimeseriesGranularity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function LogsTimeseriesBarChart({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -50,9 +65,13 @@ export function LogsTimeseriesBarChart({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isLoading, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isError, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enableSelection = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| granularity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: LogsTimeseriesBarChartProps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const chartRef = useRef<HTMLDivElement>(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [selection, setSelection] = useState<Selection>({ start: "", end: "" }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [selection, setSelection] = useState<Selection>({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start: undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end: undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // biome-ignore lint/correctness/useExhaustiveDependencies: We need this to re-trigger distanceToTop calculation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -62,31 +81,42 @@ export function LogsTimeseriesBarChart({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, [onMount, isLoading, isError]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // biome-ignore lint/suspicious/noExplicitAny: those are safe to leave | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleMouseDown = (e: any) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!enableSelection) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleMouseDown = (e: ChartMouseEvent) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!enableSelection || e.activeLabel === undefined) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const timestamp = e.activePayload?.[0]?.payload?.originalTimestamp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const numericLabel = Number(e.activeLabel); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!Number.isFinite(numericLabel) || !timestamp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setSelection({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start: e.activeLabel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end: e.activeLabel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start: numericLabel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end: numericLabel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| startTimestamp: timestamp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| endTimestamp: timestamp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+84
to
102
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard against non-numeric activeLabel to avoid NaN selection. Add a finite-number check before setting state. const handleMouseDown = (e: ChartMouseEvent) => {
if (!enableSelection || e.activeLabel === undefined) {
return;
}
- const timestamp = e.activePayload?.[0]?.payload?.originalTimestamp;
- const numericLabel = Number(e.activeLabel);
+ const timestamp = e.activePayload?.[0]?.payload?.originalTimestamp;
+ const numericLabel = Number(e.activeLabel);
+ if (!Number.isFinite(numericLabel)) {
+ return;
+ }
+ if (timestamp === undefined) {
+ return;
+ }
setSelection({
start: numericLabel,
end: numericLabel,
startTimestamp: timestamp,
endTimestamp: timestamp,
});
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // biome-ignore lint/suspicious/noExplicitAny: those are safe to leave | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleMouseMove = (e: any) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!enableSelection) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleMouseMove = (e: ChartMouseEvent) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!enableSelection || e.activeLabel === undefined) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (selection.start) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (selection.start !== undefined) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const timestamp = e.activePayload?.[0]?.payload?.originalTimestamp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const numericLabel = Number(e.activeLabel); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!Number.isFinite(numericLabel) || !timestamp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setSelection((prev) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...prev, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end: e.activeLabel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| startTimestamp: timestamp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end: numericLabel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| endTimestamp: timestamp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+104
to
122
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same NaN guard needed during drag. const handleMouseMove = (e: ChartMouseEvent) => {
if (!enableSelection || e.activeLabel === undefined) {
return;
}
if (selection.start !== undefined) {
- const timestamp = e.activePayload?.[0]?.payload?.originalTimestamp;
+ const timestamp = e.activePayload?.[0]?.payload?.originalTimestamp;
+ const numericLabel = Number(e.activeLabel);
+ if (!Number.isFinite(numericLabel)) {
+ return;
+ }
+ if (timestamp === undefined) {
+ return;
+ }
setSelection((prev) => ({
...prev,
- end: Number(e.activeLabel),
+ end: numericLabel,
endTimestamp: timestamp,
}));
}
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -95,17 +125,27 @@ export function LogsTimeseriesBarChart({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!enableSelection) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (selection.start && selection.end && onSelectionChange) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!selection.startTimestamp || !selection.endTimestamp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selection.start !== undefined && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selection.end !== undefined && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSelectionChange | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selection.startTimestamp === undefined || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selection.endTimestamp === undefined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [start, end] = [selection.startTimestamp, selection.endTimestamp].sort((a, b) => a - b); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [start, end] = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selection.startTimestamp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selection.endTimestamp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ].sort((a, b) => a - b); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSelectionChange({ start, end }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setSelection({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start: "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end: "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start: undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end: undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| startTimestamp: undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| endTimestamp: undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -125,16 +165,19 @@ export function LogsTimeseriesBarChart({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? calculateTimePoints( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data[0]?.originalTimestamp ?? Date.now(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data.at(-1)?.originalTimestamp ?? Date.now(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).map((time, i) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // biome-ignore lint/suspicious/noArrayIndexKey: <explanation> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div key={i} className="z-10"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data.at(-1)?.originalTimestamp ?? Date.now() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).map((time) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div key={time.getTime()} className="z-10"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {formatTimestampLabel(time)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : null} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ResponsiveContainer width="100%" height={height} className="border-b border-gray-4"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ResponsiveContainer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width="100%" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| height={height} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="border-b border-gray-4" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ChartContainer config={config}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <BarChart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data={data} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -157,7 +200,11 @@ export function LogsTimeseriesBarChart({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strokeOpacity: 0.7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content={({ active, payload, label }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!active || !payload?.length || payload?.[0]?.payload.total === 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !active || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !payload?.length || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payload?.[0]?.payload.total === 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -175,7 +222,9 @@ export function LogsTimeseriesBarChart({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="capitalize text-accent-9 text-xs w-[2ch] inline-block"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| All | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="capitalize text-accent-12 text-xs">Total</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="capitalize text-accent-12 text-xs"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Total | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="ml-auto"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="font-mono tabular-nums text-accent-12"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -188,25 +237,39 @@ export function LogsTimeseriesBarChart({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="rounded-lg shadow-lg border border-gray-4" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| labelFormatter={(_, payload) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //@ts-expect-error This is okay to ignore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createTimeIntervalFormatter(data, "HH:mm")(payload) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createTimeIntervalFormatter( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| granularity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (payload ?? []).map( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (p) => (p as { payload: TimeseriesData }).payload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {Object.keys(config).map((key) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Bar key={key} dataKey={key} stackId="a" fill={config[key].color} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {enableSelection && selection.start && selection.end && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ReferenceArea | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isAnimationActive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x1={Math.min(Number(selection.start), Number(selection.end))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x2={Math.max(Number(selection.start), Number(selection.end))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fill="hsl(var(--chart-selection))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| radius={[4, 4, 0, 0]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Bar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key={key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dataKey={key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stackId="a" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fill={config[key].color} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {enableSelection && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selection.start !== undefined && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selection.end !== undefined && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ReferenceArea | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isAnimationActive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x1={Math.min(selection.start, selection.end)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x2={Math.max(selection.start, selection.end)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fill="hsl(var(--chart-selection))" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| radius={[4, 4, 0, 0]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </BarChart> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </ChartContainer> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </ResponsiveContainer> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.