Skip to content

Commit f2ead22

Browse files
authored
fix(insights): keep paused calendars visible and chart scales finite (#9274)
1 parent daca837 commit f2ead22

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎apps/sim/ee/organization-usage/components/usage-calendar.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function UsageCalendar({ organizationId, timezone, workspaceId }: UsageCa
2222
{calendar.isError || !calendar.data ? (
2323
<ChartFrame
2424
height={172}
25-
loading={calendar.isLoading}
25+
loading={calendar.isPending}
2626
error={calendar.isError ? 'Could not load daily usage' : undefined}
2727
onRetry={() => void calendar.refetch()}
2828
>

‎apps/sim/ee/organization-usage/components/usage-consumers.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ export function UsageConsumers({
299299
row={row}
300300
info={
301301
dimension === 'workspace' && !row.id
302-
? 'Usage without a workspace link, including organization-level activity and permanently deleted workspaces.'
302+
? 'Usage without a workspace link, including organization-level activity and retained charges from permanently deleted workspaces. This view cannot distinguish between them.'
303303
: undefined
304304
}
305305
isMember={dimension === 'member'}

‎packages/emcn/src/components/charts/geometry.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ describe('resolveBarTickValues', () => {
1515
expect(resolveBarTickValues(peak)).toEqual(expected)
1616
})
1717

18+
it.each([Number.MIN_VALUE, 1e-323, 2e-323, 1.5e308, Number.MAX_VALUE])(
19+
'keeps a finite, increasing scale covering an extreme finite peak of %s',
20+
(peak) => {
21+
const ticks = resolveBarTickValues(peak)
22+
expect(ticks.length).toBeGreaterThanOrEqual(2)
23+
expect(ticks.length).toBeLessThanOrEqual(6)
24+
expect(ticks[0]).toBe(0)
25+
expect(ticks[ticks.length - 1]).toBeGreaterThanOrEqual(peak)
26+
expect(ticks.every(Number.isFinite)).toBe(true)
27+
expect(ticks.every((tick, index) => index === 0 || tick > ticks[index - 1])).toBe(true)
28+
}
29+
)
30+
1831
it.each([0, -1, Number.NaN, Number.POSITIVE_INFINITY])(
1932
'provides a finite, nonzero scale for an empty or invalid peak of %s',
2033
(peak) => {

‎packages/emcn/src/components/charts/geometry.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ export function resolveBarTickValues(peak: number): number[] {
4747
const magnitude = 10 ** Math.floor(Math.log10(roughStep))
4848
const multiple = [1, 2, 5, 10].find((candidate) => candidate * magnitude >= roughStep) ?? 10
4949
const step = Math.max(peak >= 1 ? 1 : 0, multiple * magnitude)
50+
if (!Number.isFinite(ceiling) || !Number.isFinite(step) || step <= 0) return [0, peak]
5051
const intervals = Math.ceil(ceiling / step)
51-
return Array.from({ length: intervals + 1 }, (_, index) => Number((index * step).toPrecision(12)))
52+
const ticks = Array.from({ length: intervals + 1 }, (_, index) =>
53+
Number((index * step).toPrecision(12))
54+
)
55+
return ticks.every(Number.isFinite) ? ticks : [0, peak]
5256
}
5357

5458
/** Vertical clamp for plotted geometry, keeping strokes off the axis rules. */

0 commit comments

Comments
 (0)