Skip to content

Commit c0dc01b

Browse files
authored
Merge pull request #62 from tinybirdco/canyon02
use tinybird charts
2 parents 407dad7 + cf39c76 commit c0dc01b

18 files changed

+446
-920
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
.tmp
55
.tb_error*
66
tinybird/fixtures
7-
7+
tinybird/tests

apps/web/package-lock.json

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@radix-ui/react-separator": "^1.1.1",
2323
"@radix-ui/react-slot": "^1.1.1",
2424
"@radix-ui/react-tooltip": "^1.1.6",
25+
"@tinybirdco/charts": "^0.2.4",
2526
"ai": "^4.0.22",
2627
"class-variance-authority": "^0.7.1",
2728
"clsx": "^2.1.1",

apps/web/pnpm-lock.yaml

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,36 @@
1-
"use client"
1+
'use client'
22

3-
import {
4-
Card,
5-
CardContent,
6-
CardHeader,
7-
CardTitle,
8-
} from "@/components/ui/card"
9-
import {
10-
ChartContainer,
11-
ChartTooltip,
12-
ChartConfig,
13-
ChartTooltipContent
14-
} from "@/components/ui/chart"
15-
import { Bar, BarChart, XAxis, YAxis } from "recharts"
3+
import { BarList } from '@tinybirdco/charts'
164

17-
export interface AuthMechDataPoint {
18-
mech: string
19-
logins: number
20-
}
21-
22-
export interface AuthMechChartData {
23-
data: AuthMechDataPoint[]
24-
className?: string
25-
}
26-
27-
const chartConfig = {
28-
logins: {
29-
color: "hsl(var(--chart-1))",
30-
label: "Logins",
31-
},
32-
} satisfies ChartConfig
33-
34-
function transformData(data: AuthMechDataPoint[]): (AuthMechDataPoint & { fill: string })[] {
35-
return data.map((item, index) => ({
36-
...item,
37-
fill: `hsl(var(--chart-${(index % 12) + 1}))`
38-
}));
39-
}
40-
41-
export function AuthMechChart({ data, className }: AuthMechChartData) {
42-
const sortedData = transformData([...data].sort((a, b) => b.logins - a.logins))
43-
44-
return (
45-
<Card>
46-
<CardHeader>
47-
<CardTitle>Authentication Methods</CardTitle>
48-
</CardHeader>
49-
<CardContent>
50-
<ChartContainer config={chartConfig} className={`w-full ${className}`}>
51-
<BarChart
52-
data={sortedData}
53-
layout="vertical"
54-
margin={{
55-
left: 24,
56-
right: 12,
57-
top: 12,
58-
bottom: 12,
59-
}}
60-
>
61-
<XAxis
62-
type="number"
63-
tickLine={false}
64-
axisLine={false}
65-
tickMargin={8}
66-
/>
67-
<YAxis
68-
type="category"
69-
dataKey="mech"
70-
tickLine={false}
71-
axisLine={false}
72-
tickMargin={8}
73-
width={70}
74-
/>
75-
<ChartTooltip
76-
content={<ChartTooltipContent />}
77-
cursor={{ fill: "hsl(var(--muted))", opacity: 0.2 }}
78-
/>
79-
<Bar
80-
dataKey="logins"
81-
radius={[4, 4, 4, 4]}
82-
/>
83-
</BarChart>
84-
</ChartContainer>
85-
</CardContent>
86-
</Card>
87-
)
88-
}
5+
export function Auth0TopAuth(params: {
6+
client_id?: string
7+
connection_id?: string
8+
tenant_name?: string
9+
token?: string
10+
date_from?: string
11+
date_to?: string
12+
}) {
13+
return <BarList
14+
endpoint={`${process.env.NEXT_PUBLIC_TINYBIRD_API_HOST}/v0/pipes/auth0_mech_usage.json`}
15+
token={params.token ?? ''}
16+
index="mech"
17+
categories={['logins']}
18+
colorPalette={['#000000']}
19+
height="250px"
20+
params={params}
21+
indexConfig={{
22+
label: 'AUTH',
23+
renderBarContent: ({ label }) => (
24+
<span className="font-normal text-white [text-shadow:2px_1px_0px_#000]">{label}</span>
25+
)
26+
}}
27+
options={{
28+
tooltip: {
29+
backgroundColor: '#fff',
30+
textStyle: {
31+
color: '#333'
32+
}
33+
}
34+
}}
35+
/>
36+
}

0 commit comments

Comments
 (0)