resolveUsageChartXAxisMaxTicks (usage/chart-axis.ts)

appwrite · apps/console/src/lib/usage/chart-axis.ts · typescript · BSD-3-Clause
ui, tag:embed-classified

Utility functions for calculating chart X‑axis ticks and labels.

// Source: https://github.com/appwrite/appwrite | License: BSD-3-Clause | Copyright 2019 Appwrite (https://appwrite.io) and individual contributors
// Provided via justclaw.it.com; keep this notice with the code.
import { format, isSameDay } from 'date-fns'
import { formatLocalizedDate } from '@/lib/i18n/date-format'
import type { UsageChartInterval } from '@/lib/usage/chart-interval'

/** Target tick count for overview charts (narrow chart column beside breakdown). */
export const OVERVIEW_USAGE_CHART_X_AXIS_MAX_TICKS = 6

/** Target tick count for full-width usage page charts. */
export const USAGE_CHART_X_AXIS_MAX_TICKS = 7

type UsageChartXAxisVariant = 'overview' | 'full'

type UsageChartXAxisPoint = {
  date: string
  day: Date
}

function spansMultipleDays(rangeFrom: Date, rangeTo: 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key