feat(ui): improve chart spacing and labels; format hours <1h as minutes; unify date format to dd/MM (ticks) and dd/MM/yyyy (tooltips); fix tooltips labels ('Total', 'Resolvidos')
This commit is contained in:
parent
4b4c0d8e69
commit
f255a4c780
6 changed files with 133 additions and 50 deletions
|
|
@ -1,6 +1,34 @@
|
|||
import { clsx, type ClassValue } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
// Format hours so that values under 1h are shown in minutes.
|
||||
// Examples: 0.06 -> "4 min"; 0.5 -> "30 min"; 1.25 -> "1,25 h" (pt-BR)
|
||||
export function formatHoursCompact(value: number, locale: string = "pt-BR"): string {
|
||||
const hours = Number(value) || 0
|
||||
if (hours < 1 && hours > 0) {
|
||||
const mins = Math.round(hours * 60)
|
||||
return `${mins} min`
|
||||
}
|
||||
const nf = new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
return `${nf.format(hours)} h`
|
||||
}
|
||||
|
||||
// Format date to dd/MM or dd/MM/yyyy. Accepts Date or ISO-like string (YYYY-MM-DD).
|
||||
export function formatDateDM(value: Date | string | number): string {
|
||||
const d = typeof value === "string" || typeof value === "number" ? new Date(value) : value
|
||||
const dd = String(d.getDate()).padStart(2, "0")
|
||||
const mm = String(d.getMonth() + 1).padStart(2, "0")
|
||||
return `${dd}/${mm}`
|
||||
}
|
||||
|
||||
export function formatDateDMY(value: Date | string | number): string {
|
||||
const d = typeof value === "string" || typeof value === "number" ? new Date(value) : value
|
||||
const dd = String(d.getDate()).padStart(2, "0")
|
||||
const mm = String(d.getMonth() + 1).padStart(2, "0")
|
||||
const yyyy = d.getFullYear()
|
||||
return `${dd}/${mm}/${yyyy}`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue