@astryxdesign/lab 0.1.4-canary.37c19d3 → 0.1.4-canary.39ffd21
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/dist/ChartV2/Chart.d.ts +32 -0
- package/dist/ChartV2/Chart.d.ts.map +1 -0
- package/dist/ChartV2/Chart.js +281 -0
- package/dist/ChartV2/ChartAxis.d.ts +36 -0
- package/dist/ChartV2/ChartAxis.d.ts.map +1 -0
- package/dist/ChartV2/ChartAxis.js +161 -0
- package/dist/ChartV2/ChartGrid.d.ts +20 -0
- package/dist/ChartV2/ChartGrid.d.ts.map +1 -0
- package/dist/ChartV2/ChartGrid.js +76 -0
- package/dist/ChartV2/ChartLegend.d.ts +14 -0
- package/dist/ChartV2/ChartLegend.d.ts.map +1 -0
- package/dist/ChartV2/ChartLegend.js +54 -0
- package/dist/ChartV2/ChartSwatch.d.ts +36 -0
- package/dist/ChartV2/ChartSwatch.d.ts.map +1 -0
- package/dist/ChartV2/ChartSwatch.js +82 -0
- package/dist/ChartV2/ChartTooltip.d.ts +46 -0
- package/dist/ChartV2/ChartTooltip.d.ts.map +1 -0
- package/dist/ChartV2/ChartTooltip.js +267 -0
- package/dist/ChartV2/ChartV2Context.d.ts +4 -0
- package/dist/ChartV2/ChartV2Context.d.ts.map +1 -0
- package/dist/ChartV2/ChartV2Context.js +12 -0
- package/dist/ChartV2/index.d.ts +13 -0
- package/dist/ChartV2/index.d.ts.map +1 -0
- package/dist/ChartV2/index.js +10 -0
- package/dist/ChartV2/layout.d.ts +25 -0
- package/dist/ChartV2/layout.d.ts.map +1 -0
- package/dist/ChartV2/layout.js +195 -0
- package/dist/ChartV2/legend.d.ts +18 -0
- package/dist/ChartV2/legend.d.ts.map +1 -0
- package/dist/ChartV2/legend.js +24 -0
- package/dist/ChartV2/marks/area.d.ts +19 -0
- package/dist/ChartV2/marks/area.d.ts.map +1 -0
- package/dist/ChartV2/marks/area.js +109 -0
- package/dist/ChartV2/marks/band.d.ts +9 -0
- package/dist/ChartV2/marks/band.d.ts.map +1 -0
- package/dist/ChartV2/marks/band.js +59 -0
- package/dist/ChartV2/marks/bar.d.ts +17 -0
- package/dist/ChartV2/marks/bar.d.ts.map +1 -0
- package/dist/ChartV2/marks/bar.js +120 -0
- package/dist/ChartV2/marks/candlestick.d.ts +15 -0
- package/dist/ChartV2/marks/candlestick.d.ts.map +1 -0
- package/dist/ChartV2/marks/candlestick.js +83 -0
- package/dist/ChartV2/marks/dot.d.ts +15 -0
- package/dist/ChartV2/marks/dot.d.ts.map +1 -0
- package/dist/ChartV2/marks/dot.js +65 -0
- package/dist/ChartV2/marks/dotGL.d.ts +16 -0
- package/dist/ChartV2/marks/dotGL.d.ts.map +1 -0
- package/dist/ChartV2/marks/dotGL.js +178 -0
- package/dist/ChartV2/marks/dotGLInteractive.d.ts +30 -0
- package/dist/ChartV2/marks/dotGLInteractive.d.ts.map +1 -0
- package/dist/ChartV2/marks/dotGLInteractive.js +464 -0
- package/dist/ChartV2/marks/errorBar.d.ts +27 -0
- package/dist/ChartV2/marks/errorBar.d.ts.map +1 -0
- package/dist/ChartV2/marks/errorBar.js +87 -0
- package/dist/ChartV2/marks/heatmapGL.d.ts +23 -0
- package/dist/ChartV2/marks/heatmapGL.d.ts.map +1 -0
- package/dist/ChartV2/marks/heatmapGL.js +242 -0
- package/dist/ChartV2/marks/index.d.ts +13 -0
- package/dist/ChartV2/marks/index.d.ts.map +1 -0
- package/dist/ChartV2/marks/index.js +14 -0
- package/dist/ChartV2/marks/line.d.ts +18 -0
- package/dist/ChartV2/marks/line.d.ts.map +1 -0
- package/dist/ChartV2/marks/line.js +76 -0
- package/dist/ChartV2/marks/referenceLine.d.ts +35 -0
- package/dist/ChartV2/marks/referenceLine.d.ts.map +1 -0
- package/dist/ChartV2/marks/referenceLine.js +186 -0
- package/dist/ChartV2/marks/streamGL.d.ts +36 -0
- package/dist/ChartV2/marks/streamGL.d.ts.map +1 -0
- package/dist/ChartV2/marks/streamGL.js +204 -0
- package/dist/ChartV2/tooltip.d.ts +38 -0
- package/dist/ChartV2/tooltip.d.ts.map +1 -0
- package/dist/ChartV2/tooltip.js +54 -0
- package/dist/ChartV2/types.d.ts +115 -0
- package/dist/ChartV2/types.d.ts.map +1 -0
- package/dist/ChartV2/types.js +35 -0
- package/dist/CodeEditor/CodeEditor.d.ts +1 -4
- package/dist/CodeEditor/CodeEditor.d.ts.map +1 -1
- package/dist/CodeEditor/CodeEditor.js +0 -3
- package/dist/Sankey/SankeyChart.d.ts.map +1 -1
- package/dist/Sankey/SankeyChart.js +0 -3
- package/dist/Schedule/ListView.d.ts.map +1 -1
- package/dist/Schedule/ListView.js +4 -7
- package/dist/Schedule/MonthlyView.js +2 -3
- package/dist/Schedule/Schedule.d.ts +1 -3
- package/dist/Schedule/Schedule.d.ts.map +1 -1
- package/dist/Schedule/Schedule.js +4 -9
- package/dist/Schedule/TimeGridView.js +2 -3
- package/dist/Schedule/context.d.ts +0 -2
- package/dist/Schedule/context.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -5
- package/dist/lab.css +15 -6
- package/package.json +2 -2
- package/src/ChartV2/Chart.tsx +348 -0
- package/src/ChartV2/ChartAxis.tsx +209 -0
- package/src/ChartV2/ChartGrid.tsx +99 -0
- package/src/ChartV2/ChartLegend.tsx +69 -0
- package/src/ChartV2/ChartSwatch.doc.mjs +17 -0
- package/src/ChartV2/ChartSwatch.tsx +86 -0
- package/src/ChartV2/ChartTooltip.tsx +382 -0
- package/src/ChartV2/ChartV2.doc.mjs +16 -0
- package/src/ChartV2/ChartV2Context.ts +15 -0
- package/src/ChartV2/index.ts +62 -0
- package/src/ChartV2/layout.ts +223 -0
- package/src/ChartV2/legend.ts +32 -0
- package/src/ChartV2/marks/area.tsx +122 -0
- package/src/ChartV2/marks/band.tsx +70 -0
- package/src/ChartV2/marks/bar.tsx +159 -0
- package/src/ChartV2/marks/candlestick.tsx +106 -0
- package/src/ChartV2/marks/dot.tsx +64 -0
- package/src/ChartV2/marks/dotGL.tsx +202 -0
- package/src/ChartV2/marks/dotGLInteractive.tsx +546 -0
- package/src/ChartV2/marks/errorBar.tsx +89 -0
- package/src/ChartV2/marks/heatmapGL.tsx +299 -0
- package/src/ChartV2/marks/index.ts +14 -0
- package/src/ChartV2/marks/line.tsx +94 -0
- package/src/ChartV2/marks/referenceLine.tsx +224 -0
- package/src/ChartV2/marks/streamGL.tsx +251 -0
- package/src/ChartV2/tooltip.ts +70 -0
- package/src/ChartV2/types.ts +129 -0
- package/src/CodeEditor/CodeEditor.tsx +0 -5
- package/src/Sankey/SankeyChart.tsx +0 -3
- package/src/Schedule/ListView.tsx +2 -5
- package/src/Schedule/MonthlyView.tsx +2 -2
- package/src/Schedule/Schedule.test.tsx +0 -39
- package/src/Schedule/Schedule.tsx +0 -8
- package/src/Schedule/TimeGridView.tsx +2 -2
- package/src/Schedule/context.tsx +0 -2
- package/src/index.ts +46 -5
- package/dist/InfoTip/InfoTip.d.ts +0 -58
- package/dist/InfoTip/InfoTip.d.ts.map +0 -1
- package/dist/InfoTip/InfoTip.js +0 -91
- package/dist/InfoTip/index.d.ts +0 -6
- package/dist/InfoTip/index.d.ts.map +0 -1
- package/dist/InfoTip/index.js +0 -8
- package/src/CodeEditor/CodeEditor.test.tsx +0 -21
- package/src/InfoTip/InfoTip.doc.mjs +0 -97
- package/src/InfoTip/InfoTip.test.tsx +0 -169
- package/src/InfoTip/InfoTip.tsx +0 -155
- package/src/InfoTip/index.ts +0 -10
- package/src/Sankey/SankeyChart.test.tsx +0 -77
|
@@ -26,8 +26,7 @@ export function TimeGridView({
|
|
|
26
26
|
hourHeight
|
|
27
27
|
}) {
|
|
28
28
|
const {
|
|
29
|
-
categories
|
|
30
|
-
headingLevel
|
|
29
|
+
categories
|
|
31
30
|
} = useScheduleContext();
|
|
32
31
|
const normalizedMinHour = Math.max(0, Math.min(23, Math.floor(minHour)));
|
|
33
32
|
const normalizedMaxHour = Math.max(normalizedMinHour + 1, Math.min(24, Math.floor(maxHour)));
|
|
@@ -61,7 +60,7 @@ export function TimeGridView({
|
|
|
61
60
|
children: days.map((day, index) => /*#__PURE__*/_jsx("div", {
|
|
62
61
|
...stylex.props(styles.timeGridHeaderCell, index === days.length - 1 && styles.timeGridHeaderCellLast),
|
|
63
62
|
children: /*#__PURE__*/_jsx(Heading, {
|
|
64
|
-
level:
|
|
63
|
+
level: 4,
|
|
65
64
|
color: "secondary",
|
|
66
65
|
display: "block",
|
|
67
66
|
xstyle: styles.timeGridHeaderHeading,
|
|
@@ -14,8 +14,6 @@ export interface ScheduleContextValue {
|
|
|
14
14
|
nextDateLabel: string;
|
|
15
15
|
view: ScheduleViewBase;
|
|
16
16
|
plugins: ReadonlyArray<SchedulePlugin>;
|
|
17
|
-
/** Heading level used for sub-headings within the schedule (day labels, weekday headers). */
|
|
18
|
-
headingLevel: 2 | 3 | 4 | 5 | 6;
|
|
19
17
|
}
|
|
20
18
|
export declare const ScheduleContext: import("react").Context<ScheduleContextValue | null>;
|
|
21
19
|
export declare function useScheduleContext(): ScheduleContextValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/Schedule/context.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IACrC,UAAU,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC5C,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/Schedule/context.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IACrC,UAAU,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC5C,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,eAAe,sDAE3B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,oBAAoB,CAMzD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
export { CodeBlock, type CodeBlockProps } from './CodeBlock';
|
|
13
13
|
export { CodeEditor, type CodeEditorProps } from './CodeEditor';
|
|
14
14
|
export { tokenize, tokenizeAsync, SYNC_TOKENIZE_THRESHOLD, type SyntaxToken, } from '@astryxdesign/core/CodeBlock';
|
|
15
|
-
export { InfoTip, type InfoTipProps, type InfoTipSize } from './InfoTip';
|
|
16
15
|
export { ChatReasoning, type ChatReasoningProps, } from './ChatReasoning/ChatReasoning';
|
|
17
16
|
export * from './Schedule';
|
|
18
17
|
export { SVGIcon, type SVGIconProps, type SVGIconVariation, type SVGIconSize, type SVGIconColor, type SVGIconDef, type IconShape, type IconShapeRole, iconVars, variations, opticalSize, xIcon, checkIcon, bellIcon, homeIcon, settingsIcon, calendarIcon, menuIcon, heartIcon, eyeIcon, starIcon, folderIcon, shieldIcon, searchIcon, mailIcon, lockIcon, starterIcons, } from './SVGIcon';
|
|
@@ -21,6 +20,7 @@ export { RadialChart, type RadialChartProps, RadialGrid, type RadialGridProps, R
|
|
|
21
20
|
export { ThreeDChart, type ThreeDChartProps, ThreeDScatter, ThreeDScatterGL, type ThreeDScatterProps, type ThreeDScatterGLProps, ThreeDBar, type ThreeDBarProps, ThreeDGrid, type ThreeDGridProps, ThreeDAxis, type ThreeDAxisProps, ThreeDSurface, type ThreeDSurfaceProps, use3D, type ThreeDContext, type Camera, type Point3D, type ProjectedPoint, } from './ThreeD';
|
|
22
21
|
export { ChartBrush, type ChartBrushProps, type BrushMode, type BrushRange, ChartZoom, type ChartZoomProps, ChartSelect, type ChartSelectProps, ChartReferenceLine, type ChartReferenceLineProps, } from './Chart';
|
|
23
22
|
export { SankeyChart, type SankeyChartProps, SankeyLink, type SankeyLinkProps, SankeyNode, type SankeyNodeProps, SankeyLabel, type SankeyLabelProps, useSankey, type SankeyNodeDatum, type SankeyLinkDatum, type SankeyColumn, type SankeyColumnDef, type SankeyNodeLayout, type SankeyLinkLayout, type SankeyColumnLayout, SankeyGrid, type SankeyGridProps, type SankeyContext, } from './Sankey';
|
|
23
|
+
export { Chart as ChartV2, type ChartProps as ChartV2Props, ChartLegend as ChartV2Legend, type ChartLegendProps as ChartV2LegendProps, type LegendItem as ChartV2LegendItem, ChartAxis as ChartV2Axis, type ChartAxisProps as ChartV2AxisProps, ChartGrid as ChartV2Grid, type ChartGridProps as ChartV2GridProps, ChartSwatch as ChartV2Swatch, swatchVariantForType as xdsChartV2SwatchVariantForType, type ChartSwatchProps as ChartV2SwatchProps, type ChartSwatchVariant as ChartV2SwatchVariant, ChartTooltip as ChartV2Tooltip, type ChartTooltipProps as ChartV2TooltipProps, type ChartTooltipPlacement as ChartV2TooltipPlacement, type TooltipSeriesValue as ChartV2TooltipSeriesValue, bar, line, dot, area, band, candlestick, errorBar, referenceLine, dotGL, dotGLInteractive, heatmapGL, streamGL, useChartV2, type SeriesDef, type ChartV2Context, type ChartPointerEvent, type ResolvedPoint, type ResolvedPositions, type SeriesContext, type ErrorBarOptions, type ReferenceLineOptions, type DotGLOptions, type DotGLInteractiveOptions, type HeatmapGLOptions, type StreamGLOptions, type StreamGLHandle, } from './ChartV2';
|
|
24
24
|
export * from './Stepper';
|
|
25
25
|
export * from './CircularProgress';
|
|
26
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAGH,OAAO,EAAC,SAAS,EAAE,KAAK,cAAc,EAAC,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAC,UAAU,EAAE,KAAK,eAAe,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,EACL,QAAQ,EACR,aAAa,EACb,uBAAuB,EACvB,KAAK,WAAW,GACjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAGH,OAAO,EAAC,SAAS,EAAE,KAAK,cAAc,EAAC,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAC,UAAU,EAAE,KAAK,eAAe,EAAC,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";
|
|
|
17
17
|
export { CodeEditor } from "./CodeEditor/index.js";
|
|
18
18
|
export { tokenize, tokenizeAsync, SYNC_TOKENIZE_THRESHOLD } from '@astryxdesign/core/CodeBlock';
|
|
19
19
|
|
|
20
|
-
// InfoTip — accessible info-icon help affordance (RFC facebook/astryx#3349)
|
|
21
|
-
export { InfoTip } from "./InfoTip/index.js";
|
|
22
|
-
|
|
23
20
|
// Chat — experimental reasoning display
|
|
24
21
|
export { ChatReasoning } from "./ChatReasoning/ChatReasoning.js";
|
|
25
22
|
|
|
@@ -44,7 +41,7 @@ export { ChartBrush, ChartZoom, ChartSelect, ChartReferenceLine } from "./Chart/
|
|
|
44
41
|
// Sankey / flow diagrams — ribbon-based flow visualization
|
|
45
42
|
export { SankeyChart, SankeyLink, SankeyNode, SankeyLabel, useSankey, SankeyGrid } from "./Sankey/index.js";
|
|
46
43
|
|
|
47
|
-
// Chart v2
|
|
48
|
-
|
|
44
|
+
// Chart v2 — config model
|
|
45
|
+
export { Chart as ChartV2, ChartLegend as ChartV2Legend, ChartAxis as ChartV2Axis, ChartGrid as ChartV2Grid, ChartSwatch as ChartV2Swatch, swatchVariantForType as xdsChartV2SwatchVariantForType, ChartTooltip as ChartV2Tooltip, bar, line, dot, area, band, candlestick, errorBar, referenceLine, dotGL, dotGLInteractive, heatmapGL, streamGL, useChartV2 } from "./ChartV2/index.js";
|
|
49
46
|
export * from "./Stepper/index.js";
|
|
50
47
|
export * from "./CircularProgress/index.js";
|
package/dist/lab.css
CHANGED
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
.x1ghz6dp:not(#\#){margin:0}
|
|
53
53
|
.x10h29id:not(#\#){margin:var(--spacing-0-5)}
|
|
54
54
|
.x1717udv:not(#\#){padding:0}
|
|
55
|
-
.x12nba7r:not(#\#){padding:var(--spacing-0-5)}
|
|
56
55
|
.x103w4nt:not(#\#):not(#\#){border-color:color-mix(in srgb,var(--color-border-blue) 48%,var(--color-border))}
|
|
57
56
|
.x14n1b0s:not(#\#):not(#\#){border-color:color-mix(in srgb,var(--color-border-cyan) 48%,var(--color-border))}
|
|
58
57
|
.x1uk4s2l:not(#\#):not(#\#){border-color:color-mix(in srgb,var(--color-border-green) 48%,var(--color-border))}
|
|
@@ -74,11 +73,12 @@
|
|
|
74
73
|
.x1r9gxr1:not(#\#):not(#\#){border-color:var(--color-border-teal)}
|
|
75
74
|
.x1kpnwn1:not(#\#):not(#\#){border-color:var(--color-border-yellow)}
|
|
76
75
|
.x14i3s5s:not(#\#):not(#\#){border-color:var(--color-border)}
|
|
76
|
+
.xbvija:not(#\#):not(#\#){border-radius:1.5px}
|
|
77
|
+
.x1cum3z5:not(#\#):not(#\#){border-radius:2px}
|
|
77
78
|
.x1hviunn:not(#\#):not(#\#){border-radius:var(--radius-container)}
|
|
78
79
|
.xh6dtrn:not(#\#):not(#\#){border-radius:var(--radius-element)}
|
|
79
80
|
.xjspbzw:not(#\#):not(#\#){border-radius:var(--radius-full)}
|
|
80
81
|
.xx3sua9:not(#\#):not(#\#){border-radius:var(--radius-inner)}
|
|
81
|
-
.xng3xce:not(#\#):not(#\#){border-style:none}
|
|
82
82
|
.x1y0btm7:not(#\#):not(#\#){border-style:solid}
|
|
83
83
|
.xc342km:not(#\#):not(#\#){border-width:0}
|
|
84
84
|
.x1litavf:not(#\#):not(#\#){border-width:var(--border-width)}
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
.x33j1x8:not(#\#):not(#\#){grid-row:var(--x-gridRow)}
|
|
101
101
|
.x17y0mx6:not(#\#):not(#\#){inset-inline:0}
|
|
102
102
|
.x1yqqeh1:not(#\#):not(#\#){margin-block:var(--spacing-0-5)}
|
|
103
|
+
.xckhbgb:not(#\#):not(#\#){margin-inline:1px}
|
|
103
104
|
.x1a2a7pz:not(#\#):not(#\#){outline:none}
|
|
104
105
|
.xysyzu8:not(#\#):not(#\#){overflow:auto}
|
|
105
106
|
.xb3r6kr:not(#\#):not(#\#){overflow:hidden}
|
|
@@ -163,6 +164,7 @@
|
|
|
163
164
|
.xwmxj5m:not(#\#):not(#\#):not(#\#){background-color:var(--color-background-muted)}
|
|
164
165
|
.x1e9xt6e:not(#\#):not(#\#):not(#\#){background-color:var(--color-background-orange)}
|
|
165
166
|
.xnpoty2:not(#\#):not(#\#):not(#\#){background-color:var(--color-background-pink)}
|
|
167
|
+
.x1prclbq:not(#\#):not(#\#):not(#\#){background-color:var(--color-background-popover)}
|
|
166
168
|
.x16i6n6f:not(#\#):not(#\#):not(#\#){background-color:var(--color-background-purple)}
|
|
167
169
|
.x1cibrc5:not(#\#):not(#\#):not(#\#){background-color:var(--color-background-red)}
|
|
168
170
|
.x1jtji5o:not(#\#):not(#\#):not(#\#){background-color:var(--color-background-teal)}
|
|
@@ -188,6 +190,7 @@
|
|
|
188
190
|
.x10w94by:not(#\#):not(#\#):not(#\#){border-inline-end-width:0}
|
|
189
191
|
.xw8tdv1:not(#\#):not(#\#):not(#\#){border-inline-end-width:var(--border-width)}
|
|
190
192
|
.x18oyj42:not(#\#):not(#\#):not(#\#){box-shadow:0 0 0 1px var(--color-accent)}
|
|
193
|
+
.x14hfi27:not(#\#):not(#\#):not(#\#){box-shadow:var(--shadow-med)}
|
|
191
194
|
.x1ftfhsn:not(#\#):not(#\#):not(#\#){caret-color:var(--color-text-primary)}
|
|
192
195
|
.xeh89do:not(#\#):not(#\#):not(#\#){clip:rect(0 0 0 0)}
|
|
193
196
|
.xzpqnlu:not(#\#):not(#\#):not(#\#){clip:rect(0,0,0,0)}
|
|
@@ -235,6 +238,7 @@
|
|
|
235
238
|
.x78zum5:not(#\#):not(#\#):not(#\#){display:flex}
|
|
236
239
|
.xrvj5dj:not(#\#):not(#\#):not(#\#){display:grid}
|
|
237
240
|
.x3nfvp2:not(#\#):not(#\#):not(#\#){display:inline-flex}
|
|
241
|
+
.x1s85apg:not(#\#):not(#\#):not(#\#){display:none}
|
|
238
242
|
.xbh8q5q:not(#\#):not(#\#):not(#\#){fill:none}
|
|
239
243
|
.xdt5ytf:not(#\#):not(#\#):not(#\#){flex-direction:column}
|
|
240
244
|
.x1q0g3np:not(#\#):not(#\#):not(#\#){flex-direction:row}
|
|
@@ -297,15 +301,19 @@
|
|
|
297
301
|
.x67bb7w:not(#\#):not(#\#):not(#\#){pointer-events:auto}
|
|
298
302
|
.x47corl:not(#\#):not(#\#):not(#\#){pointer-events:none}
|
|
299
303
|
.x10l6tqk:not(#\#):not(#\#):not(#\#){position:absolute}
|
|
304
|
+
.xixxii4:not(#\#):not(#\#):not(#\#){position:fixed}
|
|
300
305
|
.x1n2onr6:not(#\#):not(#\#):not(#\#){position:relative}
|
|
301
306
|
.x1owpc8m:not(#\#):not(#\#):not(#\#){stroke-linecap:round}
|
|
307
|
+
.xnpr05h:not(#\#):not(#\#):not(#\#){stroke-width:1}
|
|
302
308
|
.ximx5ud:not(#\#):not(#\#):not(#\#){stroke:var(--color-accent-muted)}
|
|
303
309
|
.xjsr54c:not(#\#):not(#\#):not(#\#){stroke:var(--color-accent)}
|
|
310
|
+
.x113i6qz:not(#\#):not(#\#):not(#\#){stroke:var(--color-border-emphasized)}
|
|
304
311
|
.xjswp7v:not(#\#):not(#\#):not(#\#){stroke:var(--color-error-muted)}
|
|
305
312
|
.x1vco6zm:not(#\#):not(#\#):not(#\#){stroke:var(--color-error)}
|
|
306
313
|
.x1uro670:not(#\#):not(#\#):not(#\#){stroke:var(--color-success-muted)}
|
|
307
314
|
.x8y33gb:not(#\#):not(#\#):not(#\#){stroke:var(--color-success)}
|
|
308
315
|
.xuxf9kk:not(#\#):not(#\#):not(#\#){stroke:var(--color-text-disabled)}
|
|
316
|
+
.x1lo1t26:not(#\#):not(#\#):not(#\#){stroke:var(--color-text-primary)}
|
|
309
317
|
.xpi25hw:not(#\#):not(#\#):not(#\#){stroke:var(--color-track)}
|
|
310
318
|
.x1wjzxuj:not(#\#):not(#\#):not(#\#){stroke:var(--color-warning-muted)}
|
|
311
319
|
.x9ezeq1:not(#\#):not(#\#):not(#\#){stroke:var(--color-warning)}
|
|
@@ -318,27 +326,24 @@
|
|
|
318
326
|
.x19jd1h0:not(#\#):not(#\#):not(#\#){transform:rotate(180deg)}
|
|
319
327
|
.x1cb1t30:not(#\#):not(#\#):not(#\#){transform:translateY(-50%)}
|
|
320
328
|
.xkvfbh3:not(#\#):not(#\#):not(#\#){transition-duration:var(--duration-fast-min)}
|
|
321
|
-
.xuedmi6:not(#\#):not(#\#):not(#\#){transition-duration:var(--duration-fast)}
|
|
322
329
|
.x80gvsz:not(#\#):not(#\#):not(#\#){transition-duration:var(--duration-medium)}
|
|
323
330
|
.x15406qy:not(#\#):not(#\#):not(#\#){transition-property:background-color}
|
|
324
|
-
.xt3l3uh:not(#\#):not(#\#):not(#\#){transition-property:color}
|
|
325
331
|
.xxnu56j:not(#\#):not(#\#):not(#\#){transition-property:stroke-dashoffset}
|
|
326
332
|
.xlr8y92:not(#\#):not(#\#):not(#\#){transition-timing-function:var(--ease-standard)}
|
|
327
333
|
.x87ps6o:not(#\#):not(#\#):not(#\#){user-select:none}
|
|
328
|
-
.xxymvpz:not(#\#):not(#\#):not(#\#){vertical-align:middle}
|
|
329
334
|
.xlshs6z:not(#\#):not(#\#):not(#\#){visibility:hidden}
|
|
330
335
|
.xuxw1ft:not(#\#):not(#\#):not(#\#){white-space:nowrap}
|
|
331
336
|
.x1sdyfia:not(#\#):not(#\#):not(#\#){white-space:pre}
|
|
332
337
|
.x1lldw8n:not(#\#):not(#\#):not(#\#){word-break:normal}
|
|
333
338
|
.x1vjfegm:not(#\#):not(#\#):not(#\#){z-index:1}
|
|
334
339
|
.x1355qak:not(#\#):not(#\#):not(#\#){z-index:20}
|
|
340
|
+
.x1q2oy4v:not(#\#):not(#\#):not(#\#){z-index:9999}
|
|
335
341
|
.xr3buco:not(#\#):not(#\#):not(#\#){z-index:var(--x-zIndex)}
|
|
336
342
|
.x7s97pk:focus-visible:not(#\#):not(#\#):not(#\#){outline-offset:2px}
|
|
337
343
|
.xyxi2l3:active:not(#\#):not(#\#):not(#\#){background-color:var(--color-overlay-pressed)}
|
|
338
344
|
@media (prefers-reduced-motion: reduce){.xnh0sag.xnh0sag:not(#\#):not(#\#):not(#\#){animation-duration:3s}}
|
|
339
345
|
@media (prefers-reduced-motion: reduce){.xy02sl2.xy02sl2:not(#\#):not(#\#):not(#\#){animation-duration:4s}}
|
|
340
346
|
@media (hover: hover){.xe9uy6x.xe9uy6x:hover:not(#\#):not(#\#):not(#\#){background-color:var(--color-overlay-hover)}}
|
|
341
|
-
@media (hover: hover){.xkxie9p.xkxie9p:hover:not(#\#):not(#\#):not(#\#){color:var(--color-icon-primary)}}
|
|
342
347
|
.xw8gpjh:not(#\#):not(#\#):not(#\#):not(#\#){border-bottom-color:var(--color-border)}
|
|
343
348
|
.x1q0q8m5:not(#\#):not(#\#):not(#\#):not(#\#){border-bottom-style:solid}
|
|
344
349
|
.x1qhh985:not(#\#):not(#\#):not(#\#):not(#\#){border-bottom-width:0}
|
|
@@ -352,13 +357,16 @@
|
|
|
352
357
|
.xjm9jq1:not(#\#):not(#\#):not(#\#):not(#\#){height:1px}
|
|
353
358
|
.xxk0z11:not(#\#):not(#\#):not(#\#):not(#\#){height:24px}
|
|
354
359
|
.x1gnnpzl:not(#\#):not(#\#):not(#\#):not(#\#){height:30px}
|
|
360
|
+
.xuoj239:not(#\#):not(#\#):not(#\#):not(#\#){height:3px}
|
|
355
361
|
.xqu0tyb:not(#\#):not(#\#):not(#\#):not(#\#){height:4px}
|
|
356
362
|
.x1d9x2de:not(#\#):not(#\#):not(#\#):not(#\#){height:640px}
|
|
363
|
+
.xdk7pt:not(#\#):not(#\#):not(#\#):not(#\#){height:8px}
|
|
357
364
|
.xhigkf7:not(#\#):not(#\#):not(#\#):not(#\#){height:var(--icon-size)}
|
|
358
365
|
.x6b6gus:not(#\#):not(#\#):not(#\#):not(#\#){height:var(--spacing-4)}
|
|
359
366
|
.x1grt7ep:not(#\#):not(#\#):not(#\#):not(#\#){height:var(--spacing-5)}
|
|
360
367
|
.x16ye13r:not(#\#):not(#\#):not(#\#):not(#\#){height:var(--x-height)}
|
|
361
368
|
.x1unci72:not(#\#):not(#\#):not(#\#):not(#\#){left:var(--spacing-4)}
|
|
369
|
+
.x1yztbdb:not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:16px}
|
|
362
370
|
.xlstkdb:not(#\#):not(#\#):not(#\#):not(#\#){margin-bottom:var(--spacing-0-5)}
|
|
363
371
|
.x160xvyo:not(#\#):not(#\#):not(#\#):not(#\#){margin-top:calc(var(--spacing-1) * -1)}
|
|
364
372
|
.xtbrsbv:not(#\#):not(#\#):not(#\#):not(#\#){margin-top:var(--spacing-2)}
|
|
@@ -387,6 +395,7 @@
|
|
|
387
395
|
.xvy4d1p:not(#\#):not(#\#):not(#\#):not(#\#){width:24px}
|
|
388
396
|
.x1849jeq:not(#\#):not(#\#):not(#\#):not(#\#){width:30px}
|
|
389
397
|
.x51ohtg:not(#\#):not(#\#):not(#\#):not(#\#){width:4px}
|
|
398
|
+
.x1xc55vz:not(#\#):not(#\#):not(#\#):not(#\#){width:8px}
|
|
390
399
|
.x1oai4fc:not(#\#):not(#\#):not(#\#):not(#\#){width:var(--icon-size)}
|
|
391
400
|
.x12xnipv:not(#\#):not(#\#):not(#\#):not(#\#){width:var(--spacing-4)}
|
|
392
401
|
.xfyiiit:not(#\#):not(#\#):not(#\#):not(#\#){width:var(--spacing-5)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/lab",
|
|
3
|
-
"version": "0.1.4-canary.
|
|
3
|
+
"version": "0.1.4-canary.39ffd21",
|
|
4
4
|
"description": "Experimental Astryx components — published to npm only under the @canary dist-tag for early testing; never released as a stable (latest) version.",
|
|
5
5
|
"author": "Meta Open Source",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@stylexjs/stylex": ">=0.10.0",
|
|
48
|
-
"@astryxdesign/core": "0.1.4-canary.
|
|
48
|
+
"@astryxdesign/core": "0.1.4-canary.39ffd21",
|
|
49
49
|
"react": ">=19.0.0",
|
|
50
50
|
"react-dom": ">=19.0.0"
|
|
51
51
|
},
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Chart.tsx (v2)
|
|
5
|
+
* @output Root chart — coordinates layout, rendering, and events
|
|
6
|
+
* @position Top-level; delegates everything to series configs and interaction slots
|
|
7
|
+
*
|
|
8
|
+
* The chart root has ZERO knowledge of mark types. It:
|
|
9
|
+
* 1. Runs the layout engine (scales + stacking + grouping)
|
|
10
|
+
* 2. Calls each series' resolve() and render() methods
|
|
11
|
+
* 3. Provides a single event layer for interaction children
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
type ReactNode,
|
|
16
|
+
useId,
|
|
17
|
+
useMemo,
|
|
18
|
+
useRef,
|
|
19
|
+
useState,
|
|
20
|
+
useCallback,
|
|
21
|
+
useLayoutEffect,
|
|
22
|
+
} from 'react';
|
|
23
|
+
import type {SeriesDef} from './types';
|
|
24
|
+
import type {ChartV2Context, ChartMargin, ChartPointerEvent} from './types';
|
|
25
|
+
import {computeLayout} from './layout';
|
|
26
|
+
import {ChartV2Provider} from './ChartV2Context';
|
|
27
|
+
import {ChartProvider} from '../Chart/ChartContext';
|
|
28
|
+
import {Text} from '@astryxdesign/core';
|
|
29
|
+
import {VStack, HStack} from '@astryxdesign/core';
|
|
30
|
+
import * as stylex from '@stylexjs/stylex';
|
|
31
|
+
import {ChartLegend, type ChartLegendProps} from './ChartLegend';
|
|
32
|
+
import {deriveLegendItems} from './legend';
|
|
33
|
+
import {ChartTooltip, type ChartTooltipProps} from './ChartTooltip';
|
|
34
|
+
|
|
35
|
+
export interface ChartProps {
|
|
36
|
+
data: Record<string, unknown>[];
|
|
37
|
+
xKey: string;
|
|
38
|
+
series: SeriesDef[];
|
|
39
|
+
height?: number;
|
|
40
|
+
margin?: Partial<ChartMargin>;
|
|
41
|
+
grid?: ReactNode;
|
|
42
|
+
axes?: ReactNode;
|
|
43
|
+
legend?: boolean | ChartLegendProps;
|
|
44
|
+
tooltip?: boolean | Omit<ChartTooltipProps, 'series'>;
|
|
45
|
+
interactions?: ReactNode;
|
|
46
|
+
children?: ReactNode;
|
|
47
|
+
title?: string;
|
|
48
|
+
subtitle?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const DEFAULT_MARGIN: ChartMargin = {top: 24, right: 24, bottom: 32, left: 48};
|
|
52
|
+
|
|
53
|
+
const styles = stylex.create({
|
|
54
|
+
container: {
|
|
55
|
+
width: '100%',
|
|
56
|
+
},
|
|
57
|
+
title: {
|
|
58
|
+
marginBottom: 16,
|
|
59
|
+
},
|
|
60
|
+
chartArea: {
|
|
61
|
+
flex: 1,
|
|
62
|
+
minWidth: 0,
|
|
63
|
+
overflow: 'hidden',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export function Chart({
|
|
68
|
+
data,
|
|
69
|
+
xKey,
|
|
70
|
+
series,
|
|
71
|
+
height = 300,
|
|
72
|
+
margin: marginOverride,
|
|
73
|
+
grid,
|
|
74
|
+
axes,
|
|
75
|
+
legend,
|
|
76
|
+
tooltip,
|
|
77
|
+
interactions,
|
|
78
|
+
children,
|
|
79
|
+
title,
|
|
80
|
+
subtitle,
|
|
81
|
+
}: ChartProps) {
|
|
82
|
+
const chartId = useId();
|
|
83
|
+
const descId = `${chartId}-desc`;
|
|
84
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
85
|
+
const svgRef = useRef<SVGSVGElement>(null);
|
|
86
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
87
|
+
const pointerHandlers = useRef<Set<(e: ChartPointerEvent) => void>>(
|
|
88
|
+
new Set(),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
useLayoutEffect(() => {
|
|
92
|
+
if (!containerRef.current) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const observer = new ResizeObserver(entries => {
|
|
96
|
+
const entry = entries[0];
|
|
97
|
+
if (entry) {
|
|
98
|
+
setContainerWidth(entry.contentRect.width);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
observer.observe(containerRef.current);
|
|
102
|
+
return () => observer.disconnect();
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
const margin = useMemo(
|
|
106
|
+
() => ({...DEFAULT_MARGIN, ...marginOverride}),
|
|
107
|
+
[marginOverride],
|
|
108
|
+
);
|
|
109
|
+
const innerWidth = Math.max(0, containerWidth - margin.left - margin.right);
|
|
110
|
+
const innerHeight = Math.max(0, height - margin.top - margin.bottom);
|
|
111
|
+
|
|
112
|
+
// ─── Layout pass ──────────────────────────────────────────────────────
|
|
113
|
+
const layout = useMemo(
|
|
114
|
+
() =>
|
|
115
|
+
computeLayout({
|
|
116
|
+
data,
|
|
117
|
+
xKey,
|
|
118
|
+
series,
|
|
119
|
+
width: innerWidth,
|
|
120
|
+
height: innerHeight,
|
|
121
|
+
}),
|
|
122
|
+
[data, xKey, series, innerWidth, innerHeight],
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const seriesCtx = useMemo(
|
|
126
|
+
() => ({
|
|
127
|
+
data,
|
|
128
|
+
xKey,
|
|
129
|
+
xScale: layout.xScale,
|
|
130
|
+
yScale: layout.yScale,
|
|
131
|
+
width: innerWidth,
|
|
132
|
+
height: innerHeight,
|
|
133
|
+
}),
|
|
134
|
+
[data, xKey, layout, innerWidth, innerHeight],
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// ─── Event dispatch ───────────────────────────────────────────────────
|
|
138
|
+
const onPointer = useCallback((handler: (e: ChartPointerEvent) => void) => {
|
|
139
|
+
pointerHandlers.current.add(handler);
|
|
140
|
+
return () => {
|
|
141
|
+
pointerHandlers.current.delete(handler);
|
|
142
|
+
};
|
|
143
|
+
}, []);
|
|
144
|
+
|
|
145
|
+
const dispatch = useCallback((e: ChartPointerEvent) => {
|
|
146
|
+
for (const handler of pointerHandlers.current) {
|
|
147
|
+
handler(e);
|
|
148
|
+
}
|
|
149
|
+
}, []);
|
|
150
|
+
|
|
151
|
+
const handlePointerMove = useCallback(
|
|
152
|
+
(e: React.PointerEvent<SVGRectElement>) => {
|
|
153
|
+
const svg = svgRef.current;
|
|
154
|
+
if (!svg) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const point = svg.createSVGPoint();
|
|
158
|
+
point.x = e.clientX;
|
|
159
|
+
point.y = e.clientY;
|
|
160
|
+
const ctm = e.currentTarget.getScreenCTM()?.inverse();
|
|
161
|
+
if (!ctm) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const cursor = point.matrixTransform(ctm);
|
|
165
|
+
|
|
166
|
+
// Find nearest point by x-distance only (full vertical column is the hover zone)
|
|
167
|
+
let nearest: ChartPointerEvent['nearest'] = null;
|
|
168
|
+
let bestXDist = Infinity;
|
|
169
|
+
for (const [seriesKey, points] of layout.resolved) {
|
|
170
|
+
for (const p of points) {
|
|
171
|
+
const xDist = Math.abs(p.px - cursor.x);
|
|
172
|
+
if (xDist < bestXDist) {
|
|
173
|
+
bestXDist = xDist;
|
|
174
|
+
nearest = {...p, seriesKey};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
dispatch({x: cursor.x, y: cursor.y, nearest, active: e.buttons > 0});
|
|
179
|
+
},
|
|
180
|
+
[layout.resolved, dispatch],
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const handlePointerLeave = useCallback(() => {
|
|
184
|
+
dispatch({x: -1, y: -1, nearest: null, active: false});
|
|
185
|
+
}, [dispatch]);
|
|
186
|
+
|
|
187
|
+
// ─── Context for interactions + v1 chrome ─────────────────────────────
|
|
188
|
+
const ctx: ChartV2Context = useMemo(
|
|
189
|
+
() => ({
|
|
190
|
+
width: innerWidth,
|
|
191
|
+
height: innerHeight,
|
|
192
|
+
margin,
|
|
193
|
+
data,
|
|
194
|
+
xKey,
|
|
195
|
+
xScale: layout.xScale,
|
|
196
|
+
yScale: layout.yScale,
|
|
197
|
+
resolved: layout.resolved,
|
|
198
|
+
onPointer,
|
|
199
|
+
svgRef,
|
|
200
|
+
}),
|
|
201
|
+
[innerWidth, innerHeight, margin, data, xKey, layout, onPointer],
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
// Bridge v1 context for ChartGrid/Axis compatibility
|
|
205
|
+
const v1Ctx = useMemo(
|
|
206
|
+
() => ({
|
|
207
|
+
width: innerWidth,
|
|
208
|
+
height: innerHeight,
|
|
209
|
+
margin,
|
|
210
|
+
xKey,
|
|
211
|
+
data,
|
|
212
|
+
xScale: layout.xScale,
|
|
213
|
+
yScale: layout.yScale,
|
|
214
|
+
svgRef,
|
|
215
|
+
pointerToData: () => ({
|
|
216
|
+
x: null as string | number | null,
|
|
217
|
+
y: 0,
|
|
218
|
+
px: 0,
|
|
219
|
+
py: 0,
|
|
220
|
+
}),
|
|
221
|
+
pixelToData: (px: number, py: number) => ({
|
|
222
|
+
x: null as string | number | null,
|
|
223
|
+
y: 0,
|
|
224
|
+
px,
|
|
225
|
+
py,
|
|
226
|
+
}),
|
|
227
|
+
}),
|
|
228
|
+
[innerWidth, innerHeight, margin, xKey, data, layout, svgRef],
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
// ─── Legend ────────────────────────────────────────────────────────────
|
|
232
|
+
const legendConfig = legend === true ? {} : legend || null;
|
|
233
|
+
|
|
234
|
+
const legendElement = legendConfig ? (
|
|
235
|
+
<ChartLegend
|
|
236
|
+
items={legendConfig.items ?? deriveLegendItems(series)}
|
|
237
|
+
position={legendConfig.position}
|
|
238
|
+
alignment={legendConfig.alignment}
|
|
239
|
+
/>
|
|
240
|
+
) : null;
|
|
241
|
+
|
|
242
|
+
const legendPosition = legendConfig?.position ?? 'bottom';
|
|
243
|
+
const isLegendHorizontal =
|
|
244
|
+
legendPosition === 'start' || legendPosition === 'end';
|
|
245
|
+
|
|
246
|
+
// ─── Render ───────────────────────────────────────────────────────────
|
|
247
|
+
if (containerWidth === 0) {
|
|
248
|
+
return (
|
|
249
|
+
<div
|
|
250
|
+
ref={containerRef}
|
|
251
|
+
{...stylex.props(styles.container)}
|
|
252
|
+
style={{height}}
|
|
253
|
+
/>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<div ref={containerRef} {...stylex.props(styles.container)}>
|
|
259
|
+
{(title || subtitle) && (
|
|
260
|
+
<div {...stylex.props(styles.title)}>
|
|
261
|
+
{title && (
|
|
262
|
+
<Text type="body" weight="semibold" display="block">
|
|
263
|
+
{title}
|
|
264
|
+
</Text>
|
|
265
|
+
)}
|
|
266
|
+
{subtitle && (
|
|
267
|
+
<Text type="supporting" display="block">
|
|
268
|
+
{subtitle}
|
|
269
|
+
</Text>
|
|
270
|
+
)}
|
|
271
|
+
</div>
|
|
272
|
+
)}
|
|
273
|
+
<ChartV2Provider value={ctx}>
|
|
274
|
+
<ChartProvider value={v1Ctx}>
|
|
275
|
+
{legendConfig == null ? (
|
|
276
|
+
renderSvg()
|
|
277
|
+
) : isLegendHorizontal ? (
|
|
278
|
+
<HStack gap={4}>
|
|
279
|
+
{legendPosition === 'start' && legendElement}
|
|
280
|
+
<div {...stylex.props(styles.chartArea)}>{renderSvg()}</div>
|
|
281
|
+
{legendPosition === 'end' && legendElement}
|
|
282
|
+
</HStack>
|
|
283
|
+
) : (
|
|
284
|
+
<VStack gap={4}>
|
|
285
|
+
{legendPosition === 'top' && legendElement}
|
|
286
|
+
{renderSvg()}
|
|
287
|
+
{legendPosition === 'bottom' && legendElement}
|
|
288
|
+
</VStack>
|
|
289
|
+
)}
|
|
290
|
+
</ChartProvider>
|
|
291
|
+
</ChartV2Provider>
|
|
292
|
+
</div>
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
function renderSvg() {
|
|
296
|
+
return (
|
|
297
|
+
<svg
|
|
298
|
+
ref={svgRef}
|
|
299
|
+
width="100%"
|
|
300
|
+
height={height}
|
|
301
|
+
aria-label={title ?? undefined}
|
|
302
|
+
aria-describedby={subtitle ? descId : undefined}>
|
|
303
|
+
{title && <title>{title}</title>}
|
|
304
|
+
{subtitle && <desc id={descId}>{subtitle}</desc>}
|
|
305
|
+
<g transform={`translate(${margin.left},${margin.top})`}>
|
|
306
|
+
{/* 1. Grid */}
|
|
307
|
+
{grid}
|
|
308
|
+
|
|
309
|
+
{/* 2. Marks — each series renders itself */}
|
|
310
|
+
{series.map(s => {
|
|
311
|
+
const resolved = layout.resolved.get(s.key);
|
|
312
|
+
if (!resolved) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
return <g key={s.key}>{s.render(resolved, seriesCtx)}</g>;
|
|
316
|
+
})}
|
|
317
|
+
|
|
318
|
+
{/* 3. Axes */}
|
|
319
|
+
{axes}
|
|
320
|
+
|
|
321
|
+
{/* 4. Event capture + interactions */}
|
|
322
|
+
<rect
|
|
323
|
+
x={0}
|
|
324
|
+
y={0}
|
|
325
|
+
width={innerWidth}
|
|
326
|
+
height={innerHeight}
|
|
327
|
+
fill="transparent"
|
|
328
|
+
onPointerMove={handlePointerMove}
|
|
329
|
+
onPointerLeave={handlePointerLeave}
|
|
330
|
+
/>
|
|
331
|
+
{interactions}
|
|
332
|
+
|
|
333
|
+
{/* 5. Tooltip — declarative shortcut. For full control, render
|
|
334
|
+
<ChartTooltip> directly via the `children` slot. */}
|
|
335
|
+
{tooltip && (
|
|
336
|
+
<ChartTooltip
|
|
337
|
+
series={series}
|
|
338
|
+
{...(tooltip === true ? {} : tooltip)}
|
|
339
|
+
/>
|
|
340
|
+
)}
|
|
341
|
+
|
|
342
|
+
{/* 6. Escape hatch */}
|
|
343
|
+
{children}
|
|
344
|
+
</g>
|
|
345
|
+
</svg>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
}
|