@galaxy-io/dls 1.2.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/avatar/Avatar.d.ts +2 -1
- package/dist/avatar/Avatar.js +103 -14
- package/dist/buttons/Button.d.ts +6 -1
- package/dist/buttons/Button.js +8 -4
- package/dist/charts/BarChart.d.ts +30 -20
- package/dist/charts/BarChart.js +216 -250
- package/dist/charts/ChartAxis.d.ts +47 -22
- package/dist/charts/ChartAxis.js +81 -60
- package/dist/charts/ChartEmptyState.d.ts +17 -0
- package/dist/charts/ChartEmptyState.js +29 -0
- package/dist/charts/ChartFrame.d.ts +82 -0
- package/dist/charts/ChartFrame.js +86 -0
- package/dist/charts/ChartLegend.d.ts +27 -4
- package/dist/charts/ChartLegend.js +46 -23
- package/dist/charts/ChartPrimitives.d.ts +195 -0
- package/dist/charts/ChartPrimitives.js +268 -0
- package/dist/charts/ChartTooltip.d.ts +27 -6
- package/dist/charts/ChartTooltip.js +56 -50
- package/dist/charts/LineChart.d.ts +42 -20
- package/dist/charts/LineChart.js +186 -237
- package/dist/charts/PieChart.d.ts +48 -32
- package/dist/charts/PieChart.js +159 -171
- package/dist/charts/barChartGeometry.d.ts +87 -0
- package/dist/charts/barChartGeometry.js +218 -0
- package/dist/charts/chartFormat.d.ts +19 -0
- package/dist/charts/chartFormat.js +59 -0
- package/dist/charts/chartScales.d.ts +84 -0
- package/dist/charts/chartScales.js +111 -0
- package/dist/charts/chartTheme.d.ts +18 -0
- package/dist/charts/chartTheme.js +26 -0
- package/dist/charts/constants.d.ts +225 -18
- package/dist/charts/constants.js +240 -32
- package/dist/charts/lineChartGeometry.d.ts +54 -0
- package/dist/charts/lineChartGeometry.js +143 -0
- package/dist/charts/pieChartGeometry.d.ts +48 -0
- package/dist/charts/pieChartGeometry.js +89 -0
- package/dist/charts/types.d.ts +522 -54
- package/dist/charts/types.js +136 -0
- package/dist/charts/useChartDimensions.d.ts +40 -0
- package/dist/charts/useChartDimensions.js +53 -0
- package/dist/charts/useChartFormatters.d.ts +19 -0
- package/dist/charts/useChartFormatters.js +20 -0
- package/dist/charts/useChartInteraction.d.ts +71 -0
- package/dist/charts/useChartInteraction.js +130 -0
- package/dist/charts/useChartTooltipPosition.d.ts +53 -0
- package/dist/charts/useChartTooltipPosition.js +39 -0
- package/dist/hooks/useElementClientSize.d.ts +20 -0
- package/dist/hooks/useElementClientSize.js +43 -0
- package/dist/inputs/CheckboxInput.d.ts +7 -2
- package/dist/inputs/CheckboxInput.js +30 -14
- package/dist/inputs/Input.d.ts +5 -2
- package/dist/inputs/Input.js +20 -17
- package/dist/inputs/MultiSelectInput.js +1 -1
- package/dist/inputs/RadioInput.js +7 -2
- package/dist/styles.css +68 -75
- package/dist/table/InfiniteSpreadsheet.d.ts +6 -0
- package/dist/table/InfiniteSpreadsheet.js +235 -0
- package/dist/table/InfiniteTable.d.ts +7 -88
- package/dist/table/InfiniteTable.js +366 -577
- package/dist/{spreadsheet → table}/SpreadsheetCell.d.ts +6 -4
- package/dist/table/SpreadsheetCell.js +71 -0
- package/dist/{spreadsheet → table}/SpreadsheetCellEditor.js +27 -21
- package/dist/table/SpreadsheetHeaderCell.d.ts +23 -0
- package/dist/table/SpreadsheetHeaderCell.js +91 -0
- package/dist/table/SpreadsheetMenuItem.d.ts +14 -0
- package/dist/table/SpreadsheetMenuItem.js +33 -0
- package/dist/table/SpreadsheetPrimitives.d.ts +172 -0
- package/dist/table/SpreadsheetPrimitives.js +105 -0
- package/dist/table/SpreadsheetRow.d.ts +33 -0
- package/dist/table/SpreadsheetRow.js +73 -0
- package/dist/{spreadsheet → table}/SpreadsheetRowActionCell.d.ts +5 -7
- package/dist/table/SpreadsheetRowActionCell.js +51 -0
- package/dist/table/TableExpandCell.d.ts +11 -0
- package/dist/table/TableExpandCell.js +24 -0
- package/dist/table/TableExpandedRow.d.ts +16 -0
- package/dist/table/TableExpandedRow.js +77 -0
- package/dist/table/TableHeaderCellContent.d.ts +30 -0
- package/dist/table/TableHeaderCellContent.js +48 -0
- package/dist/table/TablePrimitives.d.ts +307 -0
- package/dist/table/TablePrimitives.js +298 -0
- package/dist/table/TableSelectCell.d.ts +18 -0
- package/dist/table/TableSelectCell.js +26 -0
- package/dist/table/TableStatusRow.d.ts +18 -0
- package/dist/table/TableStatusRow.js +50 -0
- package/dist/table/VirtualizedInfiniteTable.d.ts +11 -27
- package/dist/table/VirtualizedInfiniteTable.js +182 -317
- package/dist/table/types.d.ts +249 -0
- package/dist/table/types.js +51 -0
- package/dist/table/useInfiniteScrollSentinel.d.ts +24 -0
- package/dist/table/useInfiniteScrollSentinel.js +53 -0
- package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.d.ts +1 -1
- package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.js +1 -1
- package/dist/table/useTableColumnLayout.d.ts +28 -0
- package/dist/table/useTableColumnLayout.js +63 -0
- package/dist/table/useTableColumnResize.d.ts +38 -0
- package/dist/table/useTableColumnResize.js +155 -0
- package/dist/table/useTableKeyboardNavigation.d.ts +25 -0
- package/dist/table/useTableKeyboardNavigation.js +83 -0
- package/dist/table/useTableRowExpansion.d.ts +24 -0
- package/dist/table/useTableRowExpansion.js +62 -0
- package/dist/table/useTableRowSelection.d.ts +27 -0
- package/dist/table/useTableRowSelection.js +94 -0
- package/dist/table/utils.d.ts +50 -0
- package/dist/table/utils.js +78 -0
- package/dist/text/MarkdownText.js +45 -27
- package/dist/theme/variants/dark.js +1 -1
- package/dist/widget/Widget.d.ts +2 -0
- package/dist/widget/Widget.js +14 -7
- package/package.json +1 -5
- package/dist/assets/components/enrichment/PerplexityIcon.d.ts +0 -3
- package/dist/assets/components/enrichment/PerplexityIcon.js +0 -35
- package/dist/assets/components/enrichment/TavilyIcon.d.ts +0 -3
- package/dist/assets/components/enrichment/TavilyIcon.js +0 -15
- package/dist/assets/components/onboarding/TenantSetupDark.d.ts +0 -3
- package/dist/assets/components/onboarding/TenantSetupDark.js +0 -498
- package/dist/assets/components/onboarding/TenantSetupLight.d.ts +0 -3
- package/dist/assets/components/onboarding/TenantSetupLight.js +0 -482
- package/dist/assets/components/onboarding/UserSetupDark.d.ts +0 -3
- package/dist/assets/components/onboarding/UserSetupDark.js +0 -1086
- package/dist/assets/components/onboarding/UserSetupLight.d.ts +0 -3
- package/dist/assets/components/onboarding/UserSetupLight.js +0 -1024
- package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.js +0 -466
- package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.js +0 -460
- package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.js +0 -336
- package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.js +0 -336
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.js +0 -153
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.js +0 -153
- package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.js +0 -117
- package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.js +0 -117
- package/dist/assets/components/projects/MappingMethodBlankDark.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankDark.js +0 -150
- package/dist/assets/components/projects/MappingMethodBlankDarkHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankDarkHovered.js +0 -150
- package/dist/assets/components/projects/MappingMethodBlankLight.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankLight.js +0 -150
- package/dist/assets/components/projects/MappingMethodBlankLightHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankLightHovered.js +0 -150
- package/dist/assets/components/projects/MappingMethodJsonDark.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonDark.js +0 -90
- package/dist/assets/components/projects/MappingMethodJsonDarkHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonDarkHovered.js +0 -90
- package/dist/assets/components/projects/MappingMethodJsonLight.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonLight.js +0 -90
- package/dist/assets/components/projects/MappingMethodJsonLightHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonLightHovered.js +0 -90
- package/dist/assets/components/projects/ProjectsEmptyStateDark.d.ts +0 -3
- package/dist/assets/components/projects/ProjectsEmptyStateDark.js +0 -454
- package/dist/assets/components/projects/ProjectsEmptyStateLight.d.ts +0 -3
- package/dist/assets/components/projects/ProjectsEmptyStateLight.js +0 -456
- package/dist/assets/components/root/CreateProjectActionCardDark.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardDark.js +0 -1796
- package/dist/assets/components/root/CreateProjectActionCardDarkHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardDarkHovered.js +0 -1796
- package/dist/assets/components/root/CreateProjectActionCardLight.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardLight.js +0 -1786
- package/dist/assets/components/root/CreateProjectActionCardLightHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardLightHovered.js +0 -1786
- package/dist/assets/components/root/CreateSourceActionCardDark.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardDark.js +0 -879
- package/dist/assets/components/root/CreateSourceActionCardDarkHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardDarkHovered.js +0 -879
- package/dist/assets/components/root/CreateSourceActionCardLight.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardLight.js +0 -889
- package/dist/assets/components/root/CreateSourceActionCardLightHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardLightHovered.js +0 -889
- package/dist/assets/components/sources/AttioIcon.d.ts +0 -3
- package/dist/assets/components/sources/AttioIcon.js +0 -11
- package/dist/assets/components/sources/BigquerySourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/BigquerySourceIcon.js +0 -39
- package/dist/assets/components/sources/BrowserbaseSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/BrowserbaseSourceIcon.js +0 -35
- package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.d.ts +0 -3
- package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.js +0 -13
- package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.d.ts +0 -3
- package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.js +0 -13
- package/dist/assets/components/sources/ConfluenceSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/ConfluenceSourceIcon.js +0 -30
- package/dist/assets/components/sources/GithubSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/GithubSourceIcon.js +0 -27
- package/dist/assets/components/sources/GoogleDriveIcon.d.ts +0 -3
- package/dist/assets/components/sources/GoogleDriveIcon.js +0 -45
- package/dist/assets/components/sources/HubspotSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/HubspotSourceIcon.js +0 -14
- package/dist/assets/components/sources/JiraSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/JiraSourceIcon.js +0 -54
- package/dist/assets/components/sources/LinearSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/LinearSourceIcon.js +0 -14
- package/dist/assets/components/sources/MysqlLogoSourceIconDark.d.ts +0 -3
- package/dist/assets/components/sources/MysqlLogoSourceIconDark.js +0 -17
- package/dist/assets/components/sources/NetsuiteSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/NetsuiteSourceIcon.js +0 -32
- package/dist/assets/components/sources/NotionIcon.d.ts +0 -3
- package/dist/assets/components/sources/NotionIcon.js +0 -20
- package/dist/assets/components/sources/PostgresqlIcon.d.ts +0 -3
- package/dist/assets/components/sources/PostgresqlIcon.js +0 -61
- package/dist/assets/components/sources/S3Icon.d.ts +0 -3
- package/dist/assets/components/sources/S3Icon.js +0 -76
- package/dist/assets/components/sources/SalesforceSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/SalesforceSourceIcon.js +0 -23
- package/dist/assets/components/sources/SlackIcon.d.ts +0 -3
- package/dist/assets/components/sources/SlackIcon.js +0 -32
- package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.d.ts +0 -3
- package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.js +0 -14
- package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.d.ts +0 -3
- package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.js +0 -14
- package/dist/assets/components/sources/WikipediaSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/WikipediaSourceIcon.js +0 -1490
- package/dist/avatar/AvatarEmpty.d.ts +0 -7
- package/dist/avatar/AvatarEmpty.js +0 -99
- package/dist/avatar/types.d.ts +0 -5
- package/dist/avatar/types.js +0 -9
- package/dist/charts/utils.d.ts +0 -29
- package/dist/charts/utils.js +0 -62
- package/dist/icons/BackIcon.d.ts +0 -3
- package/dist/icons/BackIcon.js +0 -13
- package/dist/icons/CloseIcon.d.ts +0 -3
- package/dist/icons/CloseIcon.js +0 -13
- package/dist/icons/CreateIcon.d.ts +0 -3
- package/dist/icons/CreateIcon.js +0 -13
- package/dist/icons/ForwardIcon.d.ts +0 -3
- package/dist/icons/ForwardIcon.js +0 -13
- package/dist/icons/HelpIcon.d.ts +0 -3
- package/dist/icons/HelpIcon.js +0 -14
- package/dist/icons/ProjectsIcon.d.ts +0 -3
- package/dist/icons/ProjectsIcon.js +0 -12
- package/dist/icons/SearchIcon.d.ts +0 -3
- package/dist/icons/SearchIcon.js +0 -12
- package/dist/icons/SourcesIcon.d.ts +0 -3
- package/dist/icons/SourcesIcon.js +0 -12
- package/dist/icons/TextIcon.d.ts +0 -4
- package/dist/icons/TextIcon.js +0 -22
- package/dist/icons/WebScrapeIcon.d.ts +0 -4
- package/dist/icons/WebScrapeIcon.js +0 -22
- package/dist/icons/WebhookIcon.d.ts +0 -4
- package/dist/icons/WebhookIcon.js +0 -22
- package/dist/icons/sources/AttioLogomark.d.ts +0 -4
- package/dist/icons/sources/AttioLogomark.js +0 -8
- package/dist/icons/sources/BrowserbaseLogomark.d.ts +0 -4
- package/dist/icons/sources/BrowserbaseLogomark.js +0 -8
- package/dist/icons/sources/ClickhouseLogomark.d.ts +0 -4
- package/dist/icons/sources/ClickhouseLogomark.js +0 -16
- package/dist/icons/sources/ConfluenceLogomark.d.ts +0 -4
- package/dist/icons/sources/ConfluenceLogomark.js +0 -8
- package/dist/icons/sources/GithubLogomark.d.ts +0 -4
- package/dist/icons/sources/GithubLogomark.js +0 -8
- package/dist/icons/sources/GoogleBigqueryLogomark.d.ts +0 -4
- package/dist/icons/sources/GoogleBigqueryLogomark.js +0 -8
- package/dist/icons/sources/GoogleDriveLogomark.d.ts +0 -4
- package/dist/icons/sources/GoogleDriveLogomark.js +0 -8
- package/dist/icons/sources/HubspotLogomark.d.ts +0 -4
- package/dist/icons/sources/HubspotLogomark.js +0 -8
- package/dist/icons/sources/JiraLogomark.d.ts +0 -4
- package/dist/icons/sources/JiraLogomark.js +0 -8
- package/dist/icons/sources/LinearLogomark.d.ts +0 -4
- package/dist/icons/sources/LinearLogomark.js +0 -8
- package/dist/icons/sources/MySQLLogomark.d.ts +0 -4
- package/dist/icons/sources/MySQLLogomark.js +0 -8
- package/dist/icons/sources/NetsuiteLogomark.d.ts +0 -4
- package/dist/icons/sources/NetsuiteLogomark.js +0 -8
- package/dist/icons/sources/NotionLogomark.d.ts +0 -4
- package/dist/icons/sources/NotionLogomark.js +0 -8
- package/dist/icons/sources/PostgresLogomark.d.ts +0 -4
- package/dist/icons/sources/PostgresLogomark.js +0 -8
- package/dist/icons/sources/S3Logomark.d.ts +0 -4
- package/dist/icons/sources/S3Logomark.js +0 -8
- package/dist/icons/sources/SalesforceLogomark.d.ts +0 -4
- package/dist/icons/sources/SalesforceLogomark.js +0 -8
- package/dist/icons/sources/SlackLogoIconmark.d.ts +0 -4
- package/dist/icons/sources/SlackLogoIconmark.js +0 -8
- package/dist/icons/sources/SnowflakeLogomark.d.ts +0 -4
- package/dist/icons/sources/SnowflakeLogomark.js +0 -16
- package/dist/icons/sources/WikipediaLogomark.d.ts +0 -4
- package/dist/icons/sources/WikipediaLogomark.js +0 -8
- package/dist/spreadsheet/InfiniteSpreadsheet.d.ts +0 -3
- package/dist/spreadsheet/InfiniteSpreadsheet.js +0 -265
- package/dist/spreadsheet/SpreadsheetAddColumnButton.d.ts +0 -6
- package/dist/spreadsheet/SpreadsheetAddColumnButton.js +0 -32
- package/dist/spreadsheet/SpreadsheetCell.js +0 -115
- package/dist/spreadsheet/SpreadsheetHeaderCell.d.ts +0 -18
- package/dist/spreadsheet/SpreadsheetHeaderCell.js +0 -141
- package/dist/spreadsheet/SpreadsheetRow.d.ts +0 -21
- package/dist/spreadsheet/SpreadsheetRow.js +0 -68
- package/dist/spreadsheet/SpreadsheetRowActionCell.js +0 -78
- package/dist/spreadsheet/hooks/useColumnResize.d.ts +0 -6
- package/dist/spreadsheet/hooks/useColumnResize.js +0 -46
- package/dist/spreadsheet/types.d.ts +0 -92
- package/dist/spreadsheet/types.js +0 -21
- /package/dist/{spreadsheet → table}/SpreadsheetCellEditor.d.ts +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ChartValueUnit } from "./types.js";
|
|
2
|
+
import { match } from "ts-pattern";
|
|
3
|
+
//#region src/charts/chartFormat.ts
|
|
4
|
+
/**
|
|
5
|
+
* Value and label formatting for the chart components.
|
|
6
|
+
*
|
|
7
|
+
* Resolving the formatter once, centrally, is what keeps axis ticks, value
|
|
8
|
+
* labels and tooltip rows from drifting apart — a recurring problem when every
|
|
9
|
+
* call site writes its own one-liner.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* `Intl` formatters are comparatively expensive to construct, and the charts
|
|
13
|
+
* format every tick and tooltip row on each render, so instances are cached per
|
|
14
|
+
* unit.
|
|
15
|
+
*/
|
|
16
|
+
var FORMATTER_CACHE = /* @__PURE__ */ new Map();
|
|
17
|
+
function getIntlFormatter(unit) {
|
|
18
|
+
const cached = FORMATTER_CACHE.get(unit);
|
|
19
|
+
if (cached) return cached;
|
|
20
|
+
const formatter = match(unit).with(ChartValueUnit.PLAIN, () => new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 })).with(ChartValueUnit.CURRENCY, () => new Intl.NumberFormat(void 0, {
|
|
21
|
+
style: "currency",
|
|
22
|
+
currency: "USD",
|
|
23
|
+
maximumFractionDigits: 0
|
|
24
|
+
})).with(ChartValueUnit.PERCENT, () => new Intl.NumberFormat(void 0, { maximumFractionDigits: 1 })).with(ChartValueUnit.COMPACT, () => new Intl.NumberFormat(void 0, {
|
|
25
|
+
notation: "compact",
|
|
26
|
+
maximumFractionDigits: 1
|
|
27
|
+
})).exhaustive();
|
|
28
|
+
FORMATTER_CACHE.set(unit, formatter);
|
|
29
|
+
return formatter;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Format a value with a built-in unit.
|
|
33
|
+
*
|
|
34
|
+
* `PERCENT` takes a 0–100 value rather than a 0–1 fraction, matching how
|
|
35
|
+
* percentage data usually arrives, and appends the sign itself instead of using
|
|
36
|
+
* `style: "percent"` (which would divide by 100).
|
|
37
|
+
*/
|
|
38
|
+
function formatChartValue(value, unit) {
|
|
39
|
+
if (!Number.isFinite(value)) return "—";
|
|
40
|
+
const formatted = getIntlFormatter(unit).format(value);
|
|
41
|
+
return unit === ChartValueUnit.PERCENT ? `${formatted}%` : formatted;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Pick the effective value formatter.
|
|
45
|
+
*
|
|
46
|
+
* An explicit `valueFormatter` always wins; otherwise the unit supplies a
|
|
47
|
+
* default, and `PLAIN` is the fallback when neither is given.
|
|
48
|
+
*/
|
|
49
|
+
function resolveValueFormatter(valueFormatter, unit) {
|
|
50
|
+
if (valueFormatter) return valueFormatter;
|
|
51
|
+
const resolvedUnit = unit ?? ChartValueUnit.PLAIN;
|
|
52
|
+
return (value) => formatChartValue(value, resolvedUnit);
|
|
53
|
+
}
|
|
54
|
+
/** Pick the effective label formatter, defaulting to identity. */
|
|
55
|
+
function resolveLabelFormatter(labelFormatter) {
|
|
56
|
+
return labelFormatter ?? ((label) => label);
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { formatChartValue, resolveLabelFormatter, resolveValueFormatter };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ChartMargin, ChartValueDomain, ChartValueFormatter } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Scale construction and axis sizing for the chart components.
|
|
4
|
+
*
|
|
5
|
+
* Pure arithmetic with no React and no theme access, so it can be unit-reasoned
|
|
6
|
+
* about and stays safe for Linaria's build-time evaluation.
|
|
7
|
+
*/
|
|
8
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
9
|
+
/**
|
|
10
|
+
* Coerce a datum value into something safe to feed a scale.
|
|
11
|
+
*
|
|
12
|
+
* A single `NaN` or `Infinity` in consumer data otherwise propagates into every
|
|
13
|
+
* path's `d` attribute and blanks the entire chart rather than one mark.
|
|
14
|
+
*/
|
|
15
|
+
export declare const sanitizeValue: (value: number | undefined | null) => number;
|
|
16
|
+
/**
|
|
17
|
+
* Merge a partial margin over the defaults.
|
|
18
|
+
*
|
|
19
|
+
* Written per-field rather than as a spread: spreading an object that carries
|
|
20
|
+
* an explicit `undefined` overwrites the default with `undefined` rather than
|
|
21
|
+
* falling back to it, which is easy to trip over when the partial is assembled
|
|
22
|
+
* from separate optional values.
|
|
23
|
+
*/
|
|
24
|
+
export declare const resolveMargin: (partial?: Partial<ChartMargin>) => ChartMargin;
|
|
25
|
+
/** Inner plot dimensions, never negative. */
|
|
26
|
+
export declare const getPlotDimensions: (width: number, height: number, margin: ChartMargin) => {
|
|
27
|
+
plotWidth: number;
|
|
28
|
+
plotHeight: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Widen a margin to leave room for axis titles.
|
|
32
|
+
*
|
|
33
|
+
* The reservation has to happen here rather than inside the axis, because the
|
|
34
|
+
* margin is resolved before any axis renders — and with the root SVG set to
|
|
35
|
+
* `overflow: visible`, an unreserved title would paint outside the container and
|
|
36
|
+
* be clipped by whatever the consumer wraps the chart in.
|
|
37
|
+
*
|
|
38
|
+
* Applied to the caller's *partial* before {@link resolveMargin} fills in the
|
|
39
|
+
* defaults, so an explicit `margin.left` still governs the tick gutter and the
|
|
40
|
+
* title band is added on top of it rather than eating into it. Returns the input
|
|
41
|
+
* untouched when there are no titles, so the common case allocates nothing.
|
|
42
|
+
*/
|
|
43
|
+
export declare const addAxisTitleSpace: (partial: Partial<ChartMargin> | undefined, { hasValueTitle, hasCategoryTitle }: {
|
|
44
|
+
hasValueTitle: boolean;
|
|
45
|
+
hasCategoryTitle: boolean;
|
|
46
|
+
}) => Partial<ChartMargin> | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Build the value scale from a signed domain.
|
|
49
|
+
*
|
|
50
|
+
* Two behaviours worth knowing, both fixing defects in the V1 charts:
|
|
51
|
+
*
|
|
52
|
+
* - **Zero is always in the domain.** Bars need a baseline to grow from, and
|
|
53
|
+
* without this a negative value maps outside the range and renders as a
|
|
54
|
+
* rectangle with negative height, which paints nothing at all.
|
|
55
|
+
* - **A zero-width domain is widened to 0–1.** d3's `normalize()` returns a
|
|
56
|
+
* constant `0.5` when the domain has no extent, so empty or all-zero data
|
|
57
|
+
* would otherwise map every value to the middle of the plot and strand the
|
|
58
|
+
* baseline halfway up.
|
|
59
|
+
*/
|
|
60
|
+
export declare const buildValueScale: ([min, max]: [number, number], range: [number, number]) => import("d3-scale").ScaleLinear<number, number, never>;
|
|
61
|
+
/** Apply an explicit domain override on top of a computed domain. */
|
|
62
|
+
export declare const applyDomainOverride: (computed: [number, number], override?: Partial<ChartValueDomain>) => [number, number];
|
|
63
|
+
/** Band scale for categories, used by the bar chart. */
|
|
64
|
+
export declare const buildCategoryBandScale: (labels: string[], range: [number, number], paddingInner: number, paddingOuter: number) => import("d3-scale").ScaleBand<string>;
|
|
65
|
+
/** Point scale for categories, used by the line chart. */
|
|
66
|
+
export declare const buildCategoryPointScale: (labels: string[], range: [number, number], padding?: number) => import("d3-scale").ScalePoint<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Estimate the left margin needed to fit the widest formatted tick label.
|
|
69
|
+
*
|
|
70
|
+
* Estimated from character count rather than measured from the DOM, mirroring
|
|
71
|
+
* `estimateColumnWidth` in `table/utils.ts`, so it works during server
|
|
72
|
+
* rendering. Clamped to at least the default margin, so it can only widen a
|
|
73
|
+
* chart, never shrink one.
|
|
74
|
+
*/
|
|
75
|
+
export declare const estimateValueAxisMargin: (ticks: number[], formatter: ChartValueFormatter) => number;
|
|
76
|
+
/**
|
|
77
|
+
* How many categories to skip between rendered axis labels.
|
|
78
|
+
*
|
|
79
|
+
* Returns 1 when every label fits, so a chart that is not crowded renders
|
|
80
|
+
* exactly as it would with no skipping at all.
|
|
81
|
+
*/
|
|
82
|
+
export declare const getCategoryLabelStride: (labels: string[], step: number) => number;
|
|
83
|
+
/** Tick values for the value axis, honoring an explicit tick count. */
|
|
84
|
+
export declare const getValueTicks: (scale: ReturnType<typeof buildValueScale>, override?: Partial<ChartValueDomain>) => number[];
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { CAPTION_CHAR_WIDTH_PX, DEFAULT_CHART_MARGIN } from "./constants.js";
|
|
2
|
+
import { scaleBand, scaleLinear, scalePoint } from "d3-scale";
|
|
3
|
+
//#region src/charts/chartScales.ts
|
|
4
|
+
/**
|
|
5
|
+
* Scale construction and axis sizing for the chart components.
|
|
6
|
+
*
|
|
7
|
+
* Pure arithmetic with no React and no theme access, so it can be unit-reasoned
|
|
8
|
+
* about and stays safe for Linaria's build-time evaluation.
|
|
9
|
+
*/
|
|
10
|
+
var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
11
|
+
/**
|
|
12
|
+
* Coerce a datum value into something safe to feed a scale.
|
|
13
|
+
*
|
|
14
|
+
* A single `NaN` or `Infinity` in consumer data otherwise propagates into every
|
|
15
|
+
* path's `d` attribute and blanks the entire chart rather than one mark.
|
|
16
|
+
*/
|
|
17
|
+
var sanitizeValue = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
18
|
+
/**
|
|
19
|
+
* Merge a partial margin over the defaults.
|
|
20
|
+
*
|
|
21
|
+
* Written per-field rather than as a spread: spreading an object that carries
|
|
22
|
+
* an explicit `undefined` overwrites the default with `undefined` rather than
|
|
23
|
+
* falling back to it, which is easy to trip over when the partial is assembled
|
|
24
|
+
* from separate optional values.
|
|
25
|
+
*/
|
|
26
|
+
var resolveMargin = (partial) => ({
|
|
27
|
+
top: partial?.top ?? DEFAULT_CHART_MARGIN.top,
|
|
28
|
+
right: partial?.right ?? DEFAULT_CHART_MARGIN.right,
|
|
29
|
+
bottom: partial?.bottom ?? DEFAULT_CHART_MARGIN.bottom,
|
|
30
|
+
left: partial?.left ?? DEFAULT_CHART_MARGIN.left
|
|
31
|
+
});
|
|
32
|
+
/** Inner plot dimensions, never negative. */
|
|
33
|
+
var getPlotDimensions = (width, height, margin) => ({
|
|
34
|
+
plotWidth: Math.max(0, width - margin.left - margin.right),
|
|
35
|
+
plotHeight: Math.max(0, height - margin.top - margin.bottom)
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Widen a margin to leave room for axis titles.
|
|
39
|
+
*
|
|
40
|
+
* The reservation has to happen here rather than inside the axis, because the
|
|
41
|
+
* margin is resolved before any axis renders — and with the root SVG set to
|
|
42
|
+
* `overflow: visible`, an unreserved title would paint outside the container and
|
|
43
|
+
* be clipped by whatever the consumer wraps the chart in.
|
|
44
|
+
*
|
|
45
|
+
* Applied to the caller's *partial* before {@link resolveMargin} fills in the
|
|
46
|
+
* defaults, so an explicit `margin.left` still governs the tick gutter and the
|
|
47
|
+
* title band is added on top of it rather than eating into it. Returns the input
|
|
48
|
+
* untouched when there are no titles, so the common case allocates nothing.
|
|
49
|
+
*/
|
|
50
|
+
var addAxisTitleSpace = (partial, { hasValueTitle, hasCategoryTitle }) => {
|
|
51
|
+
if (!hasValueTitle && !hasCategoryTitle) return partial;
|
|
52
|
+
return {
|
|
53
|
+
...partial,
|
|
54
|
+
left: (partial?.left ?? DEFAULT_CHART_MARGIN.left) + (hasValueTitle ? 18 : 0),
|
|
55
|
+
bottom: (partial?.bottom ?? DEFAULT_CHART_MARGIN.bottom) + (hasCategoryTitle ? 18 : 0)
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Build the value scale from a signed domain.
|
|
60
|
+
*
|
|
61
|
+
* Two behaviours worth knowing, both fixing defects in the V1 charts:
|
|
62
|
+
*
|
|
63
|
+
* - **Zero is always in the domain.** Bars need a baseline to grow from, and
|
|
64
|
+
* without this a negative value maps outside the range and renders as a
|
|
65
|
+
* rectangle with negative height, which paints nothing at all.
|
|
66
|
+
* - **A zero-width domain is widened to 0–1.** d3's `normalize()` returns a
|
|
67
|
+
* constant `0.5` when the domain has no extent, so empty or all-zero data
|
|
68
|
+
* would otherwise map every value to the middle of the plot and strand the
|
|
69
|
+
* baseline halfway up.
|
|
70
|
+
*/
|
|
71
|
+
var buildValueScale = ([min, max], range) => {
|
|
72
|
+
const lo = Math.min(0, min);
|
|
73
|
+
const hi = Math.max(0, max);
|
|
74
|
+
return scaleLinear().domain([lo, lo === hi ? hi + 1 : hi]).nice().range(range);
|
|
75
|
+
};
|
|
76
|
+
/** Apply an explicit domain override on top of a computed domain. */
|
|
77
|
+
var applyDomainOverride = (computed, override) => [override?.min ?? computed[0], override?.max ?? computed[1]];
|
|
78
|
+
/** Band scale for categories, used by the bar chart. */
|
|
79
|
+
var buildCategoryBandScale = (labels, range, paddingInner, paddingOuter) => scaleBand().domain(labels).range(range).paddingInner(paddingInner).paddingOuter(paddingOuter);
|
|
80
|
+
/** Point scale for categories, used by the line chart. */
|
|
81
|
+
var buildCategoryPointScale = (labels, range, padding = 0) => scalePoint().domain(labels).range(range).padding(padding);
|
|
82
|
+
/**
|
|
83
|
+
* Estimate the left margin needed to fit the widest formatted tick label.
|
|
84
|
+
*
|
|
85
|
+
* Estimated from character count rather than measured from the DOM, mirroring
|
|
86
|
+
* `estimateColumnWidth` in `table/utils.ts`, so it works during server
|
|
87
|
+
* rendering. Clamped to at least the default margin, so it can only widen a
|
|
88
|
+
* chart, never shrink one.
|
|
89
|
+
*/
|
|
90
|
+
var estimateValueAxisMargin = (ticks, formatter) => {
|
|
91
|
+
let widest = 0;
|
|
92
|
+
for (const tick of ticks) widest = Math.max(widest, formatter(tick).length * CAPTION_CHAR_WIDTH_PX);
|
|
93
|
+
return clamp(Math.ceil(widest) + 12, DEFAULT_CHART_MARGIN.left, 96);
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* How many categories to skip between rendered axis labels.
|
|
97
|
+
*
|
|
98
|
+
* Returns 1 when every label fits, so a chart that is not crowded renders
|
|
99
|
+
* exactly as it would with no skipping at all.
|
|
100
|
+
*/
|
|
101
|
+
var getCategoryLabelStride = (labels, step) => {
|
|
102
|
+
if (labels.length === 0 || step <= 0) return 1;
|
|
103
|
+
let widest = 0;
|
|
104
|
+
for (const label of labels) widest = Math.max(widest, label.length * CAPTION_CHAR_WIDTH_PX);
|
|
105
|
+
const required = widest + 8;
|
|
106
|
+
return required <= step ? 1 : Math.ceil(required / step);
|
|
107
|
+
};
|
|
108
|
+
/** Tick values for the value axis, honoring an explicit tick count. */
|
|
109
|
+
var getValueTicks = (scale, override) => scale.ticks(override?.tickCount ?? 5);
|
|
110
|
+
//#endregion
|
|
111
|
+
export { addAxisTitleSpace, applyDomainOverride, buildCategoryBandScale, buildCategoryPointScale, buildValueScale, clamp, estimateValueAxisMargin, getCategoryLabelStride, getPlotDimensions, getValueTicks, resolveMargin, sanitizeValue };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Theme } from "../theme/types";
|
|
2
|
+
import { ChartPalette } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Palette resolution for the chart components.
|
|
5
|
+
*
|
|
6
|
+
* Consumer data names a {@link ChartPalette} slot; the concrete color is looked
|
|
7
|
+
* up here against the active theme. That keeps raw hex out of application data
|
|
8
|
+
* and guarantees both themes render correctly.
|
|
9
|
+
*
|
|
10
|
+
* Linaria evaluates this module at build time, so it must not import components.
|
|
11
|
+
*/
|
|
12
|
+
/** Resolve a palette slot to a concrete color for the active theme. */
|
|
13
|
+
export declare function resolveChartPaletteColor(theme: Theme, palette: ChartPalette): string;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the color for a series, honoring an explicit slot and otherwise
|
|
16
|
+
* falling back to the series' position in the default palette order.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveSeriesColor(theme: Theme, index: number, palette?: ChartPalette): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChartPalette } from "./types.js";
|
|
2
|
+
import { CHART_PALETTE_ORDER } from "./constants.js";
|
|
3
|
+
import { match } from "ts-pattern";
|
|
4
|
+
//#region src/charts/chartTheme.ts
|
|
5
|
+
/**
|
|
6
|
+
* Palette resolution for the chart components.
|
|
7
|
+
*
|
|
8
|
+
* Consumer data names a {@link ChartPalette} slot; the concrete color is looked
|
|
9
|
+
* up here against the active theme. That keeps raw hex out of application data
|
|
10
|
+
* and guarantees both themes render correctly.
|
|
11
|
+
*
|
|
12
|
+
* Linaria evaluates this module at build time, so it must not import components.
|
|
13
|
+
*/
|
|
14
|
+
/** Resolve a palette slot to a concrete color for the active theme. */
|
|
15
|
+
function resolveChartPaletteColor(theme, palette) {
|
|
16
|
+
return match(palette).with(ChartPalette.PURPLE, () => theme.color.icon.purple).with(ChartPalette.PINK, () => theme.color.icon.pink).with(ChartPalette.BLUE, () => theme.color.icon.blue).with(ChartPalette.TEAL, () => theme.color.icon.teal).with(ChartPalette.LIME, () => theme.color.icon.lime).with(ChartPalette.ORANGE, () => theme.color.icon.orange).with(ChartPalette.YELLOW, () => theme.color.icon.yellow).with(ChartPalette.GREEN, () => theme.color.icon.success).with(ChartPalette.RED, () => theme.color.icon.error).exhaustive();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the color for a series, honoring an explicit slot and otherwise
|
|
20
|
+
* falling back to the series' position in the default palette order.
|
|
21
|
+
*/
|
|
22
|
+
function resolveSeriesColor(theme, index, palette) {
|
|
23
|
+
return resolveChartPaletteColor(theme, palette ?? CHART_PALETTE_ORDER[index % CHART_PALETTE_ORDER.length]);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { resolveChartPaletteColor, resolveSeriesColor };
|
|
@@ -1,22 +1,229 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ChartPalette } from "./types";
|
|
2
2
|
import type { ChartMargin } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Layout and motion tokens for the chart components.
|
|
5
|
+
*
|
|
6
|
+
* This module is evaluated by Linaria at build time — its constants are
|
|
7
|
+
* interpolated statically into styled templates — so it must stay free of
|
|
8
|
+
* component imports. Pulling React, framer-motion or Phosphor in here would
|
|
9
|
+
* drag them into build-time evaluation.
|
|
6
10
|
*/
|
|
7
|
-
export declare const getChartPalette: (theme: Theme) => string[];
|
|
8
11
|
export declare const DEFAULT_CHART_MARGIN: ChartMargin;
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Gap between a value-axis tick label and the plot edge.
|
|
14
|
+
*
|
|
15
|
+
* The label box is `margin.left - VALUE_AXIS_TICK_GAP` wide, so the axis
|
|
16
|
+
* geometry follows the margin instead of hardcoding an offset.
|
|
17
|
+
*/
|
|
18
|
+
export declare const VALUE_AXIS_TICK_GAP = 12;
|
|
19
|
+
/** Height of a value-axis tick label box in px. */
|
|
20
|
+
export declare const VALUE_AXIS_LABEL_HEIGHT = 20;
|
|
21
|
+
/** Height of the category-axis label box in px. */
|
|
22
|
+
export declare const CATEGORY_AXIS_LABEL_HEIGHT = 24;
|
|
23
|
+
/** Gap between the plot's bottom edge and the category labels, in px. */
|
|
24
|
+
export declare const CATEGORY_AXIS_LABEL_GAP = 8;
|
|
25
|
+
/** Band reserved for an axis title, in px. Sized for one CAPTION line. */
|
|
26
|
+
export declare const AXIS_TITLE_BAND = 18;
|
|
27
|
+
/**
|
|
28
|
+
* Clear space between an axis title and its tick labels, in px.
|
|
29
|
+
*
|
|
30
|
+
* The category axis gets this for free: its labels sit in a 24px box and its
|
|
31
|
+
* title in an 18px band, and centring a CAPTION line in each leaves roughly this
|
|
32
|
+
* much air between the two. The value axis has no such slack — its title band
|
|
33
|
+
* abuts the label box exactly — so without reserving it here a wide tick number
|
|
34
|
+
* runs straight into the rotated title, and the two axes visibly disagree.
|
|
35
|
+
*/
|
|
36
|
+
export declare const AXIS_TITLE_GAP = 8;
|
|
37
|
+
/** Default approximate tick count on the value axis. */
|
|
38
|
+
export declare const DEFAULT_VALUE_TICK_COUNT = 5;
|
|
39
|
+
/** Corner radius applied to the outer end of a wide bar, in px. */
|
|
40
|
+
export declare const BAR_RADIUS = 4;
|
|
41
|
+
/** Corner radius for bars narrower than {@link NARROW_BAR_WIDTH}, in px. */
|
|
42
|
+
export declare const BAR_RADIUS_NARROW = 2;
|
|
43
|
+
/** Bars below this width use the smaller radius so the curve doesn't dominate. */
|
|
44
|
+
export declare const NARROW_BAR_WIDTH = 40;
|
|
45
|
+
/**
|
|
46
|
+
* Px shaved off a stacked segment's covered edge to separate it from its
|
|
47
|
+
* neighbour.
|
|
48
|
+
*
|
|
49
|
+
* Keep this a whole number. The geometry snaps every stack boundary to a whole
|
|
50
|
+
* pixel first, so an integer gap renders at exactly the same size at every seam;
|
|
51
|
+
* a fractional one would land differently against the device pixel grid from one
|
|
52
|
+
* boundary to the next and read as uneven.
|
|
53
|
+
*
|
|
54
|
+
* Applied to every segment except the one sitting on the baseline, so each seam
|
|
55
|
+
* gets a gap and the bar still meets the axis flush.
|
|
56
|
+
*/
|
|
57
|
+
export declare const STACK_SEGMENT_GAP = 2;
|
|
58
|
+
/** Minimum rendered height for a non-zero bar, in px. */
|
|
59
|
+
export declare const MIN_BAR_LENGTH = 2;
|
|
60
|
+
/**
|
|
61
|
+
* Target gaps in px between groups, and between bars within a group.
|
|
62
|
+
*
|
|
63
|
+
* The within-group gap must stay clearly smaller than the between-group gap —
|
|
64
|
+
* that ratio is the only thing making a group read as a group. When the two are
|
|
65
|
+
* close, the eye has nothing to bind a group's bars together and the chart reads
|
|
66
|
+
* as one long row of unrelated bars.
|
|
67
|
+
*/
|
|
68
|
+
export declare const GROUP_GAP_COMFORTABLE = 24;
|
|
69
|
+
export declare const BAR_GAP_COMFORTABLE = 6;
|
|
70
|
+
export declare const GROUP_GAP_MEDIUM = 16;
|
|
71
|
+
export declare const BAR_GAP_MEDIUM = 4;
|
|
72
|
+
export declare const GROUP_GAP_TIGHT = 12;
|
|
73
|
+
export declare const BAR_GAP_TIGHT = 3;
|
|
74
|
+
/**
|
|
75
|
+
* Fraction of its available slot a bar actually fills.
|
|
76
|
+
*
|
|
77
|
+
* Bars sized to consume every last pixel of their group read as heavy, and the
|
|
78
|
+
* chart becomes a wall of colour rather than a set of measurements. Holding them
|
|
79
|
+
* back leaves air on both sides of each group without touching the gap between
|
|
80
|
+
* neighbouring bars.
|
|
81
|
+
*/
|
|
82
|
+
export declare const BAR_WIDTH_RATIO = 0.8;
|
|
83
|
+
/**
|
|
84
|
+
* Ceiling on a single bar's thickness, in px.
|
|
85
|
+
*
|
|
86
|
+
* Without it a two- or three-category chart divides the whole plot between a
|
|
87
|
+
* handful of bars and produces slabs — the width stops carrying information the
|
|
88
|
+
* moment it exceeds what the eye needs to compare heights.
|
|
89
|
+
*/
|
|
90
|
+
export declare const MAX_BAR_WIDTH = 44;
|
|
91
|
+
/** Below this many bars the chart always uses comfortable spacing. */
|
|
92
|
+
export declare const MIN_BARS_FOR_TIGHT_SPACING = 13;
|
|
93
|
+
/**
|
|
94
|
+
* Ceiling on a gap, as a share of the space it divides.
|
|
95
|
+
*
|
|
96
|
+
* The gaps above are absolute pixel values chosen from chart-wide density, which
|
|
97
|
+
* says nothing about how much room a *single* category actually got. Forty
|
|
98
|
+
* categories in a 650px plot leave a 16px step, and a 24px gap subtracted from
|
|
99
|
+
* that goes negative — the width lands on its 1px floor and every bar renders as
|
|
100
|
+
* a hairline. Capping the gap proportionally keeps it honest at any density: it
|
|
101
|
+
* stays exactly as specified whenever there is room, and degrades smoothly when
|
|
102
|
+
* there is not.
|
|
103
|
+
*/
|
|
104
|
+
export declare const MAX_GAP_SHARE = 0.3;
|
|
105
|
+
/** Plot widths above this stay comfortable; below the tight threshold go tight. */
|
|
106
|
+
export declare const WIDTH_FOR_MEDIUM_SPACING = 650;
|
|
107
|
+
export declare const WIDTH_FOR_TIGHT_SPACING = 500;
|
|
108
|
+
/** Grid lines extend this far past both plot edges, in px. */
|
|
109
|
+
export declare const GRID_LINE_BLEED = 12;
|
|
110
|
+
export declare const DEFAULT_LINE_STROKE_WIDTH = 1.5;
|
|
111
|
+
/** Radius of the dot marking a point on a hovered category, in px. */
|
|
112
|
+
export declare const LINE_POINT_RADIUS = 3.5;
|
|
113
|
+
/** Opacity of the area fill under a line. */
|
|
114
|
+
export declare const LINE_AREA_OPACITY = 0.12;
|
|
115
|
+
/** Gap between slices, in radians. */
|
|
116
|
+
export declare const PIE_PAD_ANGLE = 0.012;
|
|
117
|
+
/** Slice corner radius in px. */
|
|
118
|
+
export declare const PIE_CORNER_RADIUS = 2;
|
|
119
|
+
/** Inner radius as a fraction of the outer radius, for donut mode. */
|
|
120
|
+
export declare const PIE_DONUT_INNER_RATIO = 0.62;
|
|
121
|
+
/**
|
|
122
|
+
* Share of the narrowest slice that its two inner pad insets may consume.
|
|
123
|
+
*
|
|
124
|
+
* d3 turns {@link PIE_PAD_ANGLE} into a *constant linear* gap, and holding that
|
|
125
|
+
* width at radius `r` costs an angular inset of `asin(gap / 2r)` — unbounded as
|
|
126
|
+
* `r` approaches zero. When the two insets no longer fit inside a slice's own
|
|
127
|
+
* span, d3 collapses that slice's inner edge rather than sweeping backwards. The
|
|
128
|
+
* collapse is what makes a hole-less pie look wrong: the gap edge stops being
|
|
129
|
+
* radial, so gaps sit at visibly different widths and lean at slight angles, and
|
|
130
|
+
* it bites hardest between the *narrowest* slices, where the span runs out
|
|
131
|
+
* first.
|
|
132
|
+
*
|
|
133
|
+
* So the inner radius is solved for rather than guessed: pick the radius that
|
|
134
|
+
* keeps both insets inside the narrowest slice, with this much of it spent. At
|
|
135
|
+
* 0.7 the measured gap spread is 1.01× (against 1.46× when the inner edge is
|
|
136
|
+
* left to collapse), and the remaining 30% is what absorbs the corner radius.
|
|
137
|
+
*/
|
|
138
|
+
export declare const PIE_MAX_INSET_SHARE = 0.7;
|
|
139
|
+
/**
|
|
140
|
+
* Ceiling on the auto-derived inner radius, as a share of the outer radius.
|
|
141
|
+
*
|
|
142
|
+
* The radius needed grows without bound as the narrowest slice shrinks, so a
|
|
143
|
+
* single sliver would otherwise turn a pie into a donut. Past this point the
|
|
144
|
+
* hole is doing more visual damage than the uneven gap it fixes, so the gap is
|
|
145
|
+
* allowed to degrade instead — never worse than it renders today.
|
|
146
|
+
*/
|
|
147
|
+
export declare const PIE_MAX_AUTO_INNER_RATIO = 0.06;
|
|
148
|
+
/** How far outside the arc the tooltip anchors, in px. */
|
|
149
|
+
export declare const PIE_TOOLTIP_ANCHOR_INSET = 8;
|
|
150
|
+
/**
|
|
151
|
+
* Default share below which a slice is folded into an "Other" bucket.
|
|
152
|
+
*
|
|
153
|
+
* Slivers this thin are unreadable and effectively unhoverable, so grouping
|
|
154
|
+
* them communicates more than rendering each faithfully.
|
|
155
|
+
*/
|
|
156
|
+
export declare const PIE_MIN_SLICE_SHARE = 0.02;
|
|
157
|
+
/** Margin around a pie, which needs no axis gutters. */
|
|
158
|
+
export declare const PIE_CHART_MARGIN: {
|
|
159
|
+
top: number;
|
|
160
|
+
right: number;
|
|
161
|
+
bottom: number;
|
|
162
|
+
left: number;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Duration in ms for hover, dim and tooltip transitions.
|
|
166
|
+
*
|
|
167
|
+
* Sits inside the 75–150ms band the DLS uses everywhere else. Hover feedback is
|
|
168
|
+
* a response, not an animation — anything long enough to *watch* reads as the
|
|
169
|
+
* chart being slow rather than the chart being smooth.
|
|
170
|
+
*/
|
|
171
|
+
export declare const CHART_TRANSITION_MS = 100;
|
|
172
|
+
/**
|
|
173
|
+
* Delay in ms before marks return to full strength after the pointer leaves.
|
|
174
|
+
*
|
|
175
|
+
* Restoring immediately makes the whole chart flash while the pointer sweeps
|
|
176
|
+
* across categories. Highlighting stays instant (no delay) — only the
|
|
177
|
+
* *un*-highlight waits, so a sweep reads as one continuous gesture.
|
|
178
|
+
*
|
|
179
|
+
* Kept short because it does less work than it looks: while the pointer is
|
|
180
|
+
* anywhere in the plot the chart is still engaged, so `ChartPlotGroup` and
|
|
181
|
+
* `ChartLegendRow` zero this out and category-to-category sweeping is already
|
|
182
|
+
* instant. All this actually covers is the moment the pointer leaves entirely,
|
|
183
|
+
* where a long delay just feels like lag.
|
|
184
|
+
*/
|
|
185
|
+
export declare const CHART_RESTORE_DELAY_MS = 200;
|
|
186
|
+
/**
|
|
187
|
+
* Opacity ramp for the mark states.
|
|
188
|
+
*
|
|
189
|
+
* The grammar is inherited from the reference charts and is the opposite of the
|
|
190
|
+
* obvious one: hovering does not brighten the hovered mark, it *softens*
|
|
191
|
+
* everything else. `MUTED` applies to marks outside the hovered category;
|
|
192
|
+
* `FADED` to marks outside a *pinned* one.
|
|
193
|
+
*
|
|
194
|
+
* The step down from ACTIVE is deliberately steep. These are large filled areas
|
|
195
|
+
* — bars and arcs — and a filled shape still reads as present at an opacity
|
|
196
|
+
* where a hairline would have vanished, so a timid step barely registers as a
|
|
197
|
+
* highlight at all.
|
|
198
|
+
*
|
|
199
|
+
* Keep `FADED` below `MUTED`, or pinning becomes visually indistinguishable
|
|
200
|
+
* from hovering — the pin exists to say "I am holding this one", which only
|
|
201
|
+
* reads if the rest recede further than they do on hover.
|
|
202
|
+
*/
|
|
203
|
+
export declare const CHART_MARK_OPACITY_ACTIVE = 1;
|
|
204
|
+
export declare const CHART_MARK_OPACITY_MUTED = 0.1;
|
|
205
|
+
export declare const CHART_MARK_OPACITY_FADED = 0.04;
|
|
206
|
+
/** Distance in px between the tooltip and its anchor. */
|
|
207
|
+
export declare const CHART_TOOLTIP_OFFSET = 10;
|
|
208
|
+
/** Minimum width of the tooltip, in px. */
|
|
209
|
+
export declare const CHART_TOOLTIP_MIN_WIDTH = 168;
|
|
210
|
+
/** Maximum width of the tooltip, in px. */
|
|
211
|
+
export declare const CHART_TOOLTIP_MAX_WIDTH = 320;
|
|
212
|
+
/**
|
|
213
|
+
* Approximate width of one CAPTION-size character.
|
|
214
|
+
*
|
|
215
|
+
* Axis sizing estimates label widths arithmetically rather than measuring the
|
|
216
|
+
* DOM, so it stays correct during build-time evaluation and server rendering.
|
|
217
|
+
*/
|
|
218
|
+
export declare const CAPTION_CHAR_WIDTH_PX = 6.2;
|
|
219
|
+
/** Ceiling for an auto-sized left margin, so a wide formatter can't eat the plot. */
|
|
220
|
+
export declare const MAX_AUTO_MARGIN_LEFT = 96;
|
|
221
|
+
/** Minimum px between category labels before AUTO mode starts skipping them. */
|
|
222
|
+
export declare const MIN_CATEGORY_LABEL_GAP = 8;
|
|
223
|
+
/**
|
|
224
|
+
* Default assignment order for series colors.
|
|
225
|
+
*
|
|
226
|
+
* Purple leads to match the Galaxy brand. Galaxy blue is deliberately absent —
|
|
227
|
+
* it is structural only, reserved for primary actions and selection.
|
|
228
|
+
*/
|
|
229
|
+
export declare const CHART_PALETTE_ORDER: ChartPalette[];
|