diff --git a/docs/docs/api/appkit-ui/data/AreaChart.mdx b/docs/docs/api/appkit-ui/data/AreaChart.mdx index 59ce64da1..60596e002 100644 --- a/docs/docs/api/appkit-ui/data/AreaChart.mdx +++ b/docs/docs/api/appkit-ui/data/AreaChart.mdx @@ -6,25 +6,40 @@ Area Chart component for trend visualization with filled areas. ## Example ```tsx -"use client"; - import { AreaChart } from "@databricks/appkit-ui/react"; +// Long rows as `config/queries/revenue_by_channel.sql` returns them, one row +// per month and channel; `seriesKey` turns each channel into a stacked band. +// SELECT DATE_TRUNC('MONTH', order_date) AS month, channel, +// CAST(SUM(amount) AS DOUBLE) AS revenue +// FROM orders GROUP BY 1, 2 ORDER BY 1 +const rows = [ + { month: "2026-01-01", channel: "Online", revenue: 412000 }, + { month: "2026-01-01", channel: "Retail", revenue: 268000 }, + { month: "2026-02-01", channel: "Online", revenue: 451000 }, + { month: "2026-02-01", channel: "Retail", revenue: 259000 }, + { month: "2026-03-01", channel: "Online", revenue: 498000 }, + { month: "2026-03-01", channel: "Retail", revenue: 281000 }, + { month: "2026-04-01", channel: "Online", revenue: 530000 }, + { month: "2026-04-01", channel: "Retail", revenue: 274000 }, +]; + +const usd = (value: string | number) => + new Intl.NumberFormat("en-US", { + style: "currency", + currency: "USD", + notation: "compact", + }).format(Number(value)); + export default function AreaChartExample() { return ( ); @@ -37,11 +52,19 @@ export default function AreaChartExample() { Area Chart component for trend visualization with filled areas. -**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. +**Use when:** the split of a total changes over time (stacked), or for a running total. + +**Not when:** up to 12 periods (stacked BarChart); over 5 parts (top 4 plus "Other" in SQL); values of mixed sign. -**Best Practice:** Use the built-in data fetching by passing `queryKey` and `parameters` props instead of pre-fetching data with `useAnalyticsQuery`. +**Rows:** one per period and part: long rows plus `seriesKey`, or one column per part. + +**Gotchas:** pass `stacked` for composition; unstacked areas overlap. A stack of mixed-sign values logs a warning. + +**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. -Supports both query mode (queryKey + parameters) and data mode (static data). +**Data:** pass `queryKey` (and `parameters`) when the chart owns its query. Pass `data={rows}` when several +elements share one result (a KPI, a chart and a table fed by one `useAnalyticsQuery`), or for stub rows while +the UI is built first; add `loading` and `error` so the chart shows those states in its box. **Source:** [`packages/appkit-ui/src/react/charts/area/index.tsx`](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/charts/area/index.tsx) @@ -54,33 +77,43 @@ Supports both query mode (queryKey + parameters) and data mode (static data). | `queryKey` | `string` | | - | Analytics query key registered with analytics plugin | | `parameters` | `Record` | | - | Query parameters passed to the analytics endpoint | | `format` | `"auto" \| "json_array" \| "arrow_stream" \| "json" \| "arrow"` | | `"auto"` | Data format to use - "json_array": Use JSON format (smaller payloads, simpler) - "arrow_stream": Use Arrow format (faster for large datasets) - "auto": Automatically select based on expected data size | -| `transformer` | `((data: T) => T)` | | - | Transform raw data before rendering | +| `transformer` | `ChartTransformer` | | - | Reshape the fetched rows before rendering. See ChartTransformer. | | `data` | `ChartDataInput` | | - | Arrow Table or an array of row objects (interfaces and `as const` arrays too). | +| `loading` | `boolean` | | - | Show the loading state instead of the chart, in the chart's box. Use it while the rows are being fetched (`data={rows ?? []} loading={!rows}`). | +| `error` | `string \| Error \| null` | | - | Show this error instead of the chart, in the chart's box. | | `title` | `string` | | - | Chart title | -| `showLegend` | `boolean` | | - | Show legend | +| `showLegend` | `boolean` | | `true` | Show the legend. Series charts draw it only when there are two or more series; pie and donut always; on a heatmap it is the color scale. | | `colorPalette` | `"categorical" \| "sequential" \| "diverging"` | | - | Color palette to use. Auto-selected based on chart type if not specified. - "categorical": Distinct colors for different categories (bar, pie, line) - "sequential": Gradient for magnitude/intensity (heatmap) - "diverging": Two-tone for positive/negative values | -| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes), held to the same formats. | -| `height` | `number` | | - | Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). | +| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette): hex, `rgb()` or `hsl()` strings, or theme tokens such as `var(--chart-cat-1)`, which are resolved against the root element before drawing (and again on theme change). Without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes). ECharts can't parse `oklch()`, so the variables must hold hex, rgb or hsl values. | +| `height` | `number` | | - | Chart height in pixels. Without it the chart fills its parent, at least 160 px (300 px with `defaults="v3"`). A className height such as `h-[400px]` also works. | | `className` | `string` | | - | Additional CSS classes | | `xKey` | `string` | | - | X-axis field key. Auto-detected from schema if not provided. | | `yKey` | `string \| string[]` | | - | Y-axis field key(s). Auto-detected from schema if not provided. | +| `seriesKey` | `string` | | - | Column that names the series in long rows (one row per x, series and value, as SQL returns them). With it, `yKey` is the single value column and each distinct value of `seriesKey` becomes a series. | +| `xType` | `"time" \| "value" \| "category"` | | - | X axis type (cartesian charts). Inferred from the `xKey` values only, never from column names: all dates gives `"time"`, otherwise `"category"`. | +| `defaults` | `"v3"` | | - | Opt into the v3 defaults. See ChartDefaults. Bug fixes apply with or without it; only defaults that change the look of a correct chart are gated. | | `ariaLabel` | `string` | | - | Accessibility label for screen readers | | `testId` | `string` | | - | Test ID for automated testing | -| `options` | `Record` | | - | Additional ECharts options to merge | +| `options` | `Record \| ((built: Record) => Record)` | | - | Additional ECharts options. An object is deep-merged into the built option (`series`, `xAxis`, `yAxis` and `grid` entry by entry, so a patch for the first series keeps its data). A function receives the built option and returns the option to render. | | `valueFormatter` | `ChartValueFormatter` | | - | `(value: string \| number, field: string) => string`. Formats measure values in the chart's built-in value axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different format for each series. | | `onDataClick` | `((datum: ChartClickDatum) => void)` | | - | Pointer-only: charts render to <canvas>, so this does not fire for keyboard users. Provide a keyboard-accessible equivalent (e.g. a table row action) for the same action. | | `selected` | `string \| string[]` | | - | Controlled selection by category name. Matching data element(s) render at full prominence while the rest are dimmed. Drive it from your own state to reflect a cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis; other chart types ignore it. | -| `orientation` | `"horizontal" \| "vertical"` | | `"vertical"` | Chart orientation | +| `sparkline` | `boolean` | | - | A KPI-tile sparkline: no axes, legend or margins, the y range fitted to the data, a gap at missing values, and a dot when there is one point. Height defaults to 48 px. | +| `symbolSize` | `number` | | `8` | Size of the data point symbols | | `showSymbol` | `boolean` | | `false` | Show data point symbols | -| `smooth` | `boolean` | | `true` | Smooth line curves | +| `smooth` | `boolean` | | `true (false with `defaults="v3"`)` | Smooth line curves. | +| `connectNulls` | `boolean` | | `false` | Draw the line across missing values instead of leaving a gap. Only applies with `defaults="v3"`, where missing values stay missing. | | `stacked` | `boolean` | | `false` | Stack areas | +| `referenceLines` | `ChartReferenceLine[]` | | - | Target or reference lines across the plot, at values of the value axis (`[{ value: 100, label: "Target" }]`). | +| `zoom` | `boolean` | | `false` | Zoom along the category or time axis: mouse wheel and drag in the plot, plus a slider. Use it for long series. | +| `series` | `Record` | | - | Per-`yKey` series type and value axis, for combo charts and a second y axis: `series={{ margin_pct: { type: "line", axis: "right" } }}` on a BarChart draws `margin_pct` as a line against its own axis. | ### Usage ```tsx -import { AreaChart } from '@databricks/appkit-ui'; +import { AreaChart } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/data/BarChart.mdx b/docs/docs/api/appkit-ui/data/BarChart.mdx index c016e9add..0e17b1aba 100644 --- a/docs/docs/api/appkit-ui/data/BarChart.mdx +++ b/docs/docs/api/appkit-ui/data/BarChart.mdx @@ -6,22 +6,35 @@ Bar Chart component for categorical comparisons. ## Example ```tsx -"use client"; - import { BarChart } from "@databricks/appkit-ui/react"; +// Rows as `config/queries/revenue_by_segment.sql` returns them: +// SELECT segment, CAST(SUM(amount) AS DOUBLE) AS revenue +// FROM orders GROUP BY segment ORDER BY revenue DESC LIMIT 10 +// In an app, pass the query instead of the rows: +// +const rows = [ + { segment: "Enterprise", revenue: 1840500 }, + { segment: "Mid-market", revenue: 1215300 }, + { segment: "SMB", revenue: 864200 }, + { segment: "Public sector", revenue: 512900 }, + { segment: "Education", revenue: 301750 }, +]; + +const usd = (value: string | number) => + new Intl.NumberFormat("en-US", { + style: "currency", + currency: "USD", + notation: "compact", + }).format(Number(value)); + export default function BarChartExample() { return ( ); @@ -34,11 +47,19 @@ export default function BarChartExample() { Bar Chart component for categorical comparisons. -**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. +**Use when:** comparing one measure across 3 to 15 categories, or across up to 12 periods. + +**Not when:** more than 15 categories (DataTable); more than 12 periods (LineChart); 2 to 5 parts of one whole (DonutChart); one category (a KPI tile). -**Best Practice:** Use the built-in data fetching by passing `queryKey` and `parameters` props instead of pre-fetching data with `useAnalyticsQuery`. +**Rows:** one per category, already sorted in SQL; a category column (text) and a measure column (number). Several series: one measure column each, or long rows plus `seriesKey`. + +**Gotchas:** categories keep their row order, numbers and years included (`xType="value"` sorts them). Pass `orientation` if the automatic rule picks the wrong one. Cast DECIMAL to DOUBLE in SQL, or pass the strings: both parse. + +**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. -Supports both query mode (queryKey + parameters) and data mode (static data). +**Data:** pass `queryKey` (and `parameters`) when the chart owns its query. Pass `data={rows}` when several +elements share one result (a KPI, a chart and a table fed by one `useAnalyticsQuery`), or for stub rows while +the UI is built first; add `loading` and `error` so the chart shows those states in its box. **Source:** [`packages/appkit-ui/src/react/charts/bar/index.tsx`](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/charts/bar/index.tsx) @@ -51,31 +72,40 @@ Supports both query mode (queryKey + parameters) and data mode (static data). | `queryKey` | `string` | | - | Analytics query key registered with analytics plugin | | `parameters` | `Record` | | - | Query parameters passed to the analytics endpoint | | `format` | `"auto" \| "json_array" \| "arrow_stream" \| "json" \| "arrow"` | | `"auto"` | Data format to use - "json_array": Use JSON format (smaller payloads, simpler) - "arrow_stream": Use Arrow format (faster for large datasets) - "auto": Automatically select based on expected data size | -| `transformer` | `((data: T) => T)` | | - | Transform raw data before rendering | +| `transformer` | `ChartTransformer` | | - | Reshape the fetched rows before rendering. See ChartTransformer. | | `data` | `ChartDataInput` | | - | Arrow Table or an array of row objects (interfaces and `as const` arrays too). | +| `loading` | `boolean` | | - | Show the loading state instead of the chart, in the chart's box. Use it while the rows are being fetched (`data={rows ?? []} loading={!rows}`). | +| `error` | `string \| Error \| null` | | - | Show this error instead of the chart, in the chart's box. | | `title` | `string` | | - | Chart title | -| `showLegend` | `boolean` | | - | Show legend | +| `showLegend` | `boolean` | | `true` | Show the legend. Series charts draw it only when there are two or more series; pie and donut always; on a heatmap it is the color scale. | | `colorPalette` | `"categorical" \| "sequential" \| "diverging"` | | - | Color palette to use. Auto-selected based on chart type if not specified. - "categorical": Distinct colors for different categories (bar, pie, line) - "sequential": Gradient for magnitude/intensity (heatmap) - "diverging": Two-tone for positive/negative values | -| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes), held to the same formats. | -| `height` | `number` | | - | Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). | +| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette): hex, `rgb()` or `hsl()` strings, or theme tokens such as `var(--chart-cat-1)`, which are resolved against the root element before drawing (and again on theme change). Without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes). ECharts can't parse `oklch()`, so the variables must hold hex, rgb or hsl values. | +| `height` | `number` | | - | Chart height in pixels. Without it the chart fills its parent, at least 160 px (300 px with `defaults="v3"`). A className height such as `h-[400px]` also works. | | `className` | `string` | | - | Additional CSS classes | | `xKey` | `string` | | - | X-axis field key. Auto-detected from schema if not provided. | | `yKey` | `string \| string[]` | | - | Y-axis field key(s). Auto-detected from schema if not provided. | +| `seriesKey` | `string` | | - | Column that names the series in long rows (one row per x, series and value, as SQL returns them). With it, `yKey` is the single value column and each distinct value of `seriesKey` becomes a series. | +| `xType` | `"time" \| "value" \| "category"` | | - | X axis type (cartesian charts). Inferred from the `xKey` values only, never from column names: all dates gives `"time"`, otherwise `"category"`. | +| `defaults` | `"v3"` | | - | Opt into the v3 defaults. See ChartDefaults. Bug fixes apply with or without it; only defaults that change the look of a correct chart are gated. | | `ariaLabel` | `string` | | - | Accessibility label for screen readers | | `testId` | `string` | | - | Test ID for automated testing | -| `options` | `Record` | | - | Additional ECharts options to merge | +| `options` | `Record \| ((built: Record) => Record)` | | - | Additional ECharts options. An object is deep-merged into the built option (`series`, `xAxis`, `yAxis` and `grid` entry by entry, so a patch for the first series keeps its data). A function receives the built option and returns the option to render. | | `valueFormatter` | `ChartValueFormatter` | | - | `(value: string \| number, field: string) => string`. Formats measure values in the chart's built-in value axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different format for each series. | | `onDataClick` | `((datum: ChartClickDatum) => void)` | | - | Pointer-only: charts render to <canvas>, so this does not fire for keyboard users. Provide a keyboard-accessible equivalent (e.g. a table row action) for the same action. | | `selected` | `string \| string[]` | | - | Controlled selection by category name. Matching data element(s) render at full prominence while the rest are dimmed. Drive it from your own state to reflect a cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis; other chart types ignore it. | -| `orientation` | `"horizontal" \| "vertical"` | | `"vertical"` | Chart orientation | -| `stacked` | `boolean` | | - | Stack bars | +| `orientation` | `"horizontal" \| "vertical"` | | - | Bar orientation. When unset, dates are vertical and category labels are horizontal. With `defaults="v3"`: dates, numbers (such as years) and up to 7 labels of at most 10 characters are vertical; anything else is horizontal. | +| `stacked` | `boolean` | | `false` | Stack the series, on vertical and horizontal bars. | +| `referenceLines` | `ChartReferenceLine[]` | | - | Target or reference lines across the plot, at values of the value axis (`[{ value: 100, label: "Target" }]`). | +| `zoom` | `boolean` | | `false` | Zoom along the category or time axis: mouse wheel and drag in the plot, plus a slider. Use it for long series. | +| `showValues` | `boolean` | | `false` | Print each bar's (or point's) value next to it. | +| `series` | `Record` | | - | Per-`yKey` series type and value axis, for combo charts and a second y axis: `series={{ margin_pct: { type: "line", axis: "right" } }}` on a BarChart draws `margin_pct` as a line against its own axis. | ### Usage ```tsx -import { BarChart } from '@databricks/appkit-ui'; +import { BarChart } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/data/DataTable.mdx b/docs/docs/api/appkit-ui/data/DataTable.mdx index 00c4fb15f..95216b096 100644 --- a/docs/docs/api/appkit-ui/data/DataTable.mdx +++ b/docs/docs/api/appkit-ui/data/DataTable.mdx @@ -6,17 +6,37 @@ Production-ready data table with automatic data fetching and state management ## Example ```tsx -"use client"; - import { DataTable } from "@databricks/appkit-ui/react"; +// Detail rows with typed columns. In an app, pass the query instead of rows: +// +const rows = [ + { order_id: "00412", customer: "Acme", amount: 1840.5, shipped: true }, + { order_id: "00413", customer: "Globex", amount: 215.0, shipped: false }, + { order_id: "00414", customer: "Initech", amount: 9310.25, shipped: true }, + { order_id: "00415", customer: "Hooli", amount: null, shipped: false }, +]; + +const usd = new Intl.NumberFormat("en-US", { + style: "currency", + currency: "USD", +}); + export default function DataTableExample() { return ( (value == null ? "—" : usd.format(Number(value))), + align: "right", + }, + { key: "shipped" }, + ]} + defaultSort={{ key: "amount", desc: true }} pageSize={10} /> ); @@ -29,6 +49,15 @@ export default function DataTableExample() { Production-ready data table with automatic data fetching and state management +**Use when:** readers need the exact records (detail rows, a top N with a link column). + +**Not when:** one number (a KPI tile) or a trend (a chart). On a dashboard, pick at most 8 columns with `columns`. + +**Rows:** detail rows with aliased snake_case columns; pass `queryKey` or `data`. + +**Gotchas:** formats come from the values, so cast in SQL what should read as a number, and use `columns` for +labels, money and percent formats, widths and link cells. + Features: - Automatic column generation from data structure - Integrated with useAnalyticsQuery for data fetching @@ -38,11 +67,11 @@ Features: - Responsive design - Supports opinionated mode (auto columns) and full-control mode (`children(table)`) -In opinionated mode the columns are the keys of the first row that match `/^[a-zA-Z_][a-zA-Z0-9_]*$/` (other -keys are dropped), headed by the key in Title Case. Every cell whose value parses as a number, numeric strings -included, is right-aligned and formatted: a key containing `cost`, `price`, `spend`, `revenue` or `usd` shows as -USD, and any other value of 1000 or more is abbreviated (10021 shows as 10K). For ids, zip codes or years, render -a `Table` from `useAnalyticsQuery` rows instead. +In opinionated mode the columns are `columns` when given, otherwise every key of the first row, headed by the key +in Title Case (a key such as `count(1)` is shown as written). Cells are formatted by the column's type, inferred from all +of its values and never from its name: numbers (and numeric text such as DECIMAL strings) are right-aligned at full +precision, with separators above four digits; text with a leading zero ("02134") stays text; booleans show as +true/false; timestamps as `YYYY-MM-DD HH:MM:SS`; objects as JSON; null and empty values as a dash. **Source:** [`packages/appkit-ui/src/react/table/data-table.tsx`](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/table/data-table.tsx) @@ -52,19 +81,29 @@ a `Table` from `useAnalyticsQuery` rows instead. | Prop | Type | Required | Default | Description | |------|------|----------|---------|-------------| -| `queryKey` | `string` | ✓ | - | The query key to fetch the data | -| `parameters` | `Record` | ✓ | - | The parameters to pass to the query | -| `filterColumn` | `string` | | - | The column to filter by | +| `queryKey` | `string` | | - | The query key to fetch the data | +| `parameters` | `Record` | | - | The parameters to pass to the query. Optional, as on charts. | +| `data` | `ChartDataInput` | | - | Rows to show, or an Arrow Table: the same contract as a chart's `data`. Use it for stub rows while building the UI, Lakebase rows, or a result already fetched with `useAnalyticsQuery` for a chart on the same screen. | +| `loading` | `boolean` | | - | Show the loading state (data mode). | +| `error` | `string \| Error \| null` | | - | Show an error state (data mode). | +| `defaultSort` | `DataTableSort` | | - | Initial sort, e.g. `{ key: "revenue", desc: true }`. Headers show the direction and set `aria-sort`. | +| `columns` | `DataTableColumn[]` | | - | Columns to show, in order, with label, format, alignment, width and custom cell content. Defaults to every key of the first row with the format inferred from the values. | +| `toolbar` | `boolean \| { search?: boolean; columns?: boolean; } \| undefined` | | `true` | The toolbar above the table: a search box and a Columns menu. `false` hides it; an object hides either part. | +| `filterColumn` | `string` | | - | Filter only this column. Without it, the search box matches any column. | | `filterPlaceholder` | `string` | | - | Optional placeholder for the filter input | -| `transform` | `((data: any[]) => any[])` | | - | Optional function to transform data before creating table. A new function reference re-runs it and resets the table to the first page, so keep it stable: define it outside the component, or rely on the React Compiler (enabled in the AppKit template); without the compiler, wrap it in `useCallback`. | +| `transform` | `((data: any[]) => any[])` | | - | Optional function to transform data before creating table (rows in, rows out). An inline function is fine: when it returns the same rows the table keeps its page and columns. | +| `transformer` | `((data: any[]) => any[])` | | - | Same as `transform`, under the name charts use. | | `labels` | `DataTableLabels` | | - | Optional labels for the DataTable component | | `ariaLabel` | `string` | | - | Optional accessibility label for the DataTable component | | `testId` | `string` | | - | Optional test ID for the DataTable component | | `className` | `string` | | - | Optional CSS class name for the DataTable component | | `enableRowSelection` | `boolean` | | - | Enable row selection with checkboxes | -| `onRowSelectionChange` | `((rowSelection: RowSelectionState) => void)` | | - | Callback function to handle row selection changes | +| `onRowSelectionChange` | `((rowSelection: RowSelectionState) => void)` | | - | Callback function to handle row selection changes (TanStack index map; prefer `onSelectionChange`) | +| `onSelectionChange` | `((rows: any[]) => void)` | | - | Called with the selected rows themselves whenever the selection changes. Needs `enableRowSelection`. Rows are selected by position, so a new `data` array clears the selection. Memoize `data` to keep it across renders. | +| `onRowClick` | `((row: any) => void)` | | - | Called with the row when a row is clicked, or activated with Enter. Rows become focusable. | | `children` | `((table: Table) => ReactNode)` | | - | Optional children for full control mode | | `pageSize` | `number` | | - | Number of rows to display per page | +| `maxHeight` | `string \| number` | | `600` | Height at which the table body scrolls (pixels or a CSS length), with the header kept in view. | | `pageSizeOptions` | `number[]` | | - | Options for the page size selector | @@ -72,7 +111,7 @@ a `Table` from `useAnalyticsQuery` rows instead. ### Usage ```tsx -import { DataTable } from '@databricks/appkit-ui'; +import { DataTable } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/data/DonutChart.mdx b/docs/docs/api/appkit-ui/data/DonutChart.mdx index 42bed7fb6..f1e577b3d 100644 --- a/docs/docs/api/appkit-ui/data/DonutChart.mdx +++ b/docs/docs/api/appkit-ui/data/DonutChart.mdx @@ -6,19 +6,25 @@ Donut Chart component (Pie chart with inner radius). ## Example ```tsx -"use client"; - import { DonutChart } from "@databricks/appkit-ui/react"; +// Headcount by department, with the total in the hole. +// SELECT department, COUNT(*) AS headcount FROM employees +// GROUP BY department ORDER BY headcount DESC +const rows = [ + { department: "Engineering", headcount: 450 }, + { department: "Sales", headcount: 300 }, + { department: "Marketing", headcount: 250 }, + { department: "Operations", headcount: 200 }, +]; + export default function DonutChartExample() { return ( ); @@ -31,11 +37,19 @@ export default function DonutChartExample() { Donut Chart component (Pie chart with inner radius). -**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. +**Use when:** 2 to 5 parts of one whole, with the total in the hole (`centerLabel`). + +**Not when:** 6 or more parts, or parts of similar size (horizontal BarChart); negative values (BarChart). -**Best Practice:** Use the built-in data fetching by passing `queryKey` and `parameters` props instead of pre-fetching data with `useAnalyticsQuery`. +**Rows:** one per part, sorted descending: a name column and a value column. Pass both keys. + +**Gotchas:** `innerRadius` is clamped to 63; `innerRadius={0}` draws a pie. + +**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. -Supports both query mode (queryKey + parameters) and data mode (static data). +**Data:** pass `queryKey` (and `parameters`) when the chart owns its query. Pass `data={rows}` when several +elements share one result (a KPI, a chart and a table fed by one `useAnalyticsQuery`), or for stub rows while +the UI is built first; add `loading` and `error` so the chart shows those states in its box. **Source:** [`packages/appkit-ui/src/react/charts/pie/index.tsx`](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/charts/pie/index.tsx) @@ -48,32 +62,38 @@ Supports both query mode (queryKey + parameters) and data mode (static data). | `queryKey` | `string` | | - | Analytics query key registered with analytics plugin | | `parameters` | `Record` | | - | Query parameters passed to the analytics endpoint | | `format` | `"auto" \| "json_array" \| "arrow_stream" \| "json" \| "arrow"` | | `"auto"` | Data format to use - "json_array": Use JSON format (smaller payloads, simpler) - "arrow_stream": Use Arrow format (faster for large datasets) - "auto": Automatically select based on expected data size | -| `transformer` | `((data: T) => T)` | | - | Transform raw data before rendering | +| `transformer` | `ChartTransformer` | | - | Reshape the fetched rows before rendering. See ChartTransformer. | | `data` | `ChartDataInput` | | - | Arrow Table or an array of row objects (interfaces and `as const` arrays too). | +| `loading` | `boolean` | | - | Show the loading state instead of the chart, in the chart's box. Use it while the rows are being fetched (`data={rows ?? []} loading={!rows}`). | +| `error` | `string \| Error \| null` | | - | Show this error instead of the chart, in the chart's box. | | `title` | `string` | | - | Chart title | -| `showLegend` | `boolean` | | - | Show legend | +| `showLegend` | `boolean` | | `true` | Show the legend. Series charts draw it only when there are two or more series; pie and donut always; on a heatmap it is the color scale. | | `colorPalette` | `"categorical" \| "sequential" \| "diverging"` | | - | Color palette to use. Auto-selected based on chart type if not specified. - "categorical": Distinct colors for different categories (bar, pie, line) - "sequential": Gradient for magnitude/intensity (heatmap) - "diverging": Two-tone for positive/negative values | -| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes), held to the same formats. | -| `height` | `number` | | - | Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). | +| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette): hex, `rgb()` or `hsl()` strings, or theme tokens such as `var(--chart-cat-1)`, which are resolved against the root element before drawing (and again on theme change). Without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes). ECharts can't parse `oklch()`, so the variables must hold hex, rgb or hsl values. | +| `height` | `number` | | - | Chart height in pixels. Without it the chart fills its parent, at least 160 px (300 px with `defaults="v3"`). A className height such as `h-[400px]` also works. | | `className` | `string` | | - | Additional CSS classes | | `xKey` | `string` | | - | X-axis field key. Auto-detected from schema if not provided. | | `yKey` | `string \| string[]` | | - | Y-axis field key(s). Auto-detected from schema if not provided. | +| `seriesKey` | `string` | | - | Column that names the series in long rows (one row per x, series and value, as SQL returns them). With it, `yKey` is the single value column and each distinct value of `seriesKey` becomes a series. | +| `xType` | `"time" \| "value" \| "category"` | | - | X axis type (cartesian charts). Inferred from the `xKey` values only, never from column names: all dates gives `"time"`, otherwise `"category"`. | +| `defaults` | `"v3"` | | - | Opt into the v3 defaults. See ChartDefaults. Bug fixes apply with or without it; only defaults that change the look of a correct chart are gated. | | `ariaLabel` | `string` | | - | Accessibility label for screen readers | | `testId` | `string` | | - | Test ID for automated testing | -| `options` | `Record` | | - | Additional ECharts options to merge | +| `options` | `Record \| ((built: Record) => Record)` | | - | Additional ECharts options. An object is deep-merged into the built option (`series`, `xAxis`, `yAxis` and `grid` entry by entry, so a patch for the first series keeps its data). A function receives the built option and returns the option to render. | | `valueFormatter` | `ChartValueFormatter` | | - | `(value: string \| number, field: string) => string`. Formats measure values in the chart's built-in value axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different format for each series. | | `onDataClick` | `((datum: ChartClickDatum) => void)` | | - | Pointer-only: charts render to <canvas>, so this does not fire for keyboard users. Provide a keyboard-accessible equivalent (e.g. a table row action) for the same action. | | `selected` | `string \| string[]` | | - | Controlled selection by category name. Matching data element(s) render at full prominence while the rest are dimmed. Drive it from your own state to reflect a cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis; other chart types ignore it. | -| `innerRadius` | `number` | | `0` | Inner radius for donut charts (0-100%) | -| `showLabels` | `boolean` | | `true` | Show labels on slices | +| `innerRadius` | `number` | | `0 (40 on DonutChart)` | Hole radius in percent of the chart, clamped to 0 to 63 (90% of the outer radius). `0` draws a plain pie, also on DonutChart. | +| `showLabels` | `boolean` | | `true (false with `defaults="v3"`, where the legend shows name, value and share)` | Show labels on slices. | | `labelPosition` | `"center" \| "outside" \| "inside"` | | `"outside"` | Label position | +| `centerLabel` | `string \| boolean` | | `true on a v3 DonutChart` | Text in the donut hole, sized to fit it. `true` shows the formatted total (compacted, e.g. "9.7M", when the full number doesn't fit). Ignored on a pie without a hole. | ### Usage ```tsx -import { DonutChart } from '@databricks/appkit-ui'; +import { DonutChart } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/data/HeatmapChart.mdx b/docs/docs/api/appkit-ui/data/HeatmapChart.mdx index 48a959935..e9c424681 100644 --- a/docs/docs/api/appkit-ui/data/HeatmapChart.mdx +++ b/docs/docs/api/appkit-ui/data/HeatmapChart.mdx @@ -6,31 +6,31 @@ Heatmap Chart component for matrix-style data visualization. ## Example ```tsx -"use client"; - import { HeatmapChart } from "@databricks/appkit-ui/react"; -export default function HeatmapChartExample() { - const data = []; - const days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; - const hours = ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00"]; - - for (const day of days) { - for (const hour of hours) { - data.push({ - day, - hour, - count: Math.floor(Math.random() * 100), - }); - } - } +// One row per cell, as `config/queries/orders_by_hour.sql` returns them. +// Weekdays are put in calendar order whatever the row order. +// SELECT DATE_FORMAT(created_at, 'E') AS weekday, HOUR(created_at) AS hour, +// COUNT(*) AS orders +// FROM orders GROUP BY 1, 2 +const weekdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; +const hours = [8, 10, 12, 14, 16, 18]; +const rows = weekdays.flatMap((weekday, d) => + hours.map((hour, h) => ({ + weekday, + hour, + // Busy at lunch and on weekdays: a fixed pattern, not random data. + orders: (d < 5 ? 60 : 25) + (h === 2 ? 40 : 0) + ((d * 7 + h * 3) % 11), + })), +); +export default function HeatmapChartExample() { return ( ); @@ -43,16 +43,24 @@ export default function HeatmapChartExample() { Heatmap Chart component for matrix-style data visualization. +**Use when:** finding where a measure is high or low across two dimensions (weekday by hour, cohort by period). + +**Not when:** under 3 by 3 cells (grouped BarChart); over 30 columns (aggregate in SQL). + +**Rows:** one per cell; name the roles with `columnKey`, `rowKey` and `valueKey`. + +**Gotchas:** repeated cells are summed with a warning; weekdays, months, numbers and dates are put in order (`xOrder`/`yOrder` override). Use `colorPalette="diverging"` for values around 0. + **Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. -**Best Practice:** Use the built-in data fetching by passing `queryKey` and `parameters` props instead of pre-fetching data with `useAnalyticsQuery`. +**Data:** pass `queryKey` (and `parameters`) when the chart owns its query. Pass `data={rows}` when several +elements share one result (a KPI, a chart and a table fed by one `useAnalyticsQuery`), or for stub rows while +the UI is built first; add `loading` and `error` so the chart shows those states in its box. Data should be in "long format" with three fields: -- xKey: X-axis category (columns) -- yAxisKey: Y-axis category (rows) -- yKey: The numeric value for each cell - -Supports both query mode (queryKey + parameters) and data mode (static data). +- columnKey (or xKey): X-axis category (columns) +- rowKey (or yAxisKey): Y-axis category (rows) +- valueKey (or yKey): The numeric value for each cell **Source:** [`packages/appkit-ui/src/react/charts/heatmap/index.tsx`](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/charts/heatmap/index.tsx) @@ -65,33 +73,43 @@ Supports both query mode (queryKey + parameters) and data mode (static data). | `queryKey` | `string` | | - | Analytics query key registered with analytics plugin | | `parameters` | `Record` | | - | Query parameters passed to the analytics endpoint | | `format` | `"auto" \| "json_array" \| "arrow_stream" \| "json" \| "arrow"` | | `"auto"` | Data format to use - "json_array": Use JSON format (smaller payloads, simpler) - "arrow_stream": Use Arrow format (faster for large datasets) - "auto": Automatically select based on expected data size | -| `transformer` | `((data: T) => T)` | | - | Transform raw data before rendering | +| `transformer` | `ChartTransformer` | | - | Reshape the fetched rows before rendering. See ChartTransformer. | | `data` | `ChartDataInput` | | - | Arrow Table or an array of row objects (interfaces and `as const` arrays too). | +| `loading` | `boolean` | | - | Show the loading state instead of the chart, in the chart's box. Use it while the rows are being fetched (`data={rows ?? []} loading={!rows}`). | +| `error` | `string \| Error \| null` | | - | Show this error instead of the chart, in the chart's box. | | `title` | `string` | | - | Chart title | -| `showLegend` | `boolean` | | - | Show legend | +| `showLegend` | `boolean` | | `true` | Show the legend. Series charts draw it only when there are two or more series; pie and donut always; on a heatmap it is the color scale. | | `colorPalette` | `"categorical" \| "sequential" \| "diverging"` | | - | Color palette to use. Auto-selected based on chart type if not specified. - "categorical": Distinct colors for different categories (bar, pie, line) - "sequential": Gradient for magnitude/intensity (heatmap) - "diverging": Two-tone for positive/negative values | -| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes), held to the same formats. | -| `height` | `number` | | - | Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). | +| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette): hex, `rgb()` or `hsl()` strings, or theme tokens such as `var(--chart-cat-1)`, which are resolved against the root element before drawing (and again on theme change). Without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes). ECharts can't parse `oklch()`, so the variables must hold hex, rgb or hsl values. | +| `height` | `number` | | - | Chart height in pixels. Without it the chart fills its parent, at least 160 px (300 px with `defaults="v3"`). A className height such as `h-[400px]` also works. | | `className` | `string` | | - | Additional CSS classes | | `xKey` | `string` | | - | X-axis field key. Auto-detected from schema if not provided. | | `yKey` | `string \| string[]` | | - | Y-axis field key(s). Auto-detected from schema if not provided. | +| `seriesKey` | `string` | | - | Column that names the series in long rows (one row per x, series and value, as SQL returns them). With it, `yKey` is the single value column and each distinct value of `seriesKey` becomes a series. | +| `xType` | `"time" \| "value" \| "category"` | | - | X axis type (cartesian charts). Inferred from the `xKey` values only, never from column names: all dates gives `"time"`, otherwise `"category"`. | +| `defaults` | `"v3"` | | - | Opt into the v3 defaults. See ChartDefaults. Bug fixes apply with or without it; only defaults that change the look of a correct chart are gated. | | `ariaLabel` | `string` | | - | Accessibility label for screen readers | | `testId` | `string` | | - | Test ID for automated testing | -| `options` | `Record` | | - | Additional ECharts options to merge | +| `options` | `Record \| ((built: Record) => Record)` | | - | Additional ECharts options. An object is deep-merged into the built option (`series`, `xAxis`, `yAxis` and `grid` entry by entry, so a patch for the first series keeps its data). A function receives the built option and returns the option to render. | | `valueFormatter` | `ChartValueFormatter` | | - | `(value: string \| number, field: string) => string`. Formats measure values in the chart's built-in value axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different format for each series. | | `onDataClick` | `((datum: ChartClickDatum) => void)` | | - | Pointer-only: charts render to <canvas>, so this does not fire for keyboard users. Provide a keyboard-accessible equivalent (e.g. a table row action) for the same action. | | `selected` | `string \| string[]` | | - | Controlled selection by category name. Matching data element(s) render at full prominence while the rest are dimmed. Drive it from your own state to reflect a cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis; other chart types ignore it. | | `yAxisKey` | `string` | | - | Field key for the Y-axis categories. For heatmaps, data should have: xKey (column), yAxisKey (row), and yKey (value). | | `min` | `number` | | - | Min value for color scale (auto-detected if not provided) | | `max` | `number` | | - | Max value for color scale (auto-detected if not provided) | -| `showLabels` | `boolean` | | `false` | Show value labels on cells | +| `showLabels` | `boolean` | | - | Show value labels on cells. Unset: on for up to 100 cells when each cell is wide enough for a label. | +| `xOrder` | `readonly (string \| number)[]` | | - | Column order: these values first, in this order. Unset: weekdays and months in calendar order, numbers ascending, dates chronologically, other text in row order. | +| `yOrder` | `readonly (string \| number)[]` | | - | Row order, as HeatmapChartSpecificProps.xOrder. | +| `columnKey` | `string` | | - | The column dimension; same as `xKey`. | +| `rowKey` | `string` | | - | The row dimension; same as `yAxisKey`. | +| `valueKey` | `string` | | - | The numeric cell value; same as `yKey`. | ### Usage ```tsx -import { HeatmapChart } from '@databricks/appkit-ui'; +import { HeatmapChart } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/data/LineChart.mdx b/docs/docs/api/appkit-ui/data/LineChart.mdx index eaa662d00..dd61f4c16 100644 --- a/docs/docs/api/appkit-ui/data/LineChart.mdx +++ b/docs/docs/api/appkit-ui/data/LineChart.mdx @@ -6,24 +6,31 @@ Line Chart component for time-series and trend visualization. ## Example ```tsx -"use client"; - import { LineChart } from "@databricks/appkit-ui/react"; +// Rows as `config/queries/daily_orders.sql` returns them: a DATE column and a +// count, one row per day. A day with no data is null and shows as a gap with +// `defaults="v3"`. +// SELECT order_date, COUNT(*) AS orders FROM orders +// WHERE order_date >= :start_date GROUP BY order_date ORDER BY order_date +// In an app: +const rows = [ + { order_date: "2026-03-01", orders: 182 }, + { order_date: "2026-03-02", orders: 205 }, + { order_date: "2026-03-03", orders: 198 }, + { order_date: "2026-03-04", orders: null }, + { order_date: "2026-03-05", orders: 231 }, + { order_date: "2026-03-06", orders: 264 }, + { order_date: "2026-03-07", orders: 249 }, +]; + export default function LineChartExample() { return ( ); @@ -36,11 +43,19 @@ export default function LineChartExample() { Line Chart component for time-series and trend visualization. -**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. +**Use when:** a measure changes over time. + +**Not when:** under 4 periods (vertical BarChart); over 5 series (top 4 plus "Other" in SQL). -**Best Practice:** Use the built-in data fetching by passing `queryKey` and `parameters` props instead of pre-fetching data with `useAnalyticsQuery`. +**Rows:** one per period, a DATE or TIMESTAMP column and a measure; several series as one column each or long rows plus `seriesKey`. + +**Gotchas:** the x axis is a time axis only when every `xKey` value is a date. Missing values draw as 0 unless `defaults="v3"`, which leaves a gap. Lines are smoothed unless `smooth={false}` or `defaults="v3"`. For a KPI tile use `sparkline`. + +**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. -Supports both query mode (queryKey + parameters) and data mode (static data). +**Data:** pass `queryKey` (and `parameters`) when the chart owns its query. Pass `data={rows}` when several +elements share one result (a KPI, a chart and a table fed by one `useAnalyticsQuery`), or for stub rows while +the UI is built first; add `loading` and `error` so the chart shows those states in its box. **Source:** [`packages/appkit-ui/src/react/charts/line/index.tsx`](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/charts/line/index.tsx) @@ -53,32 +68,42 @@ Supports both query mode (queryKey + parameters) and data mode (static data). | `queryKey` | `string` | | - | Analytics query key registered with analytics plugin | | `parameters` | `Record` | | - | Query parameters passed to the analytics endpoint | | `format` | `"auto" \| "json_array" \| "arrow_stream" \| "json" \| "arrow"` | | `"auto"` | Data format to use - "json_array": Use JSON format (smaller payloads, simpler) - "arrow_stream": Use Arrow format (faster for large datasets) - "auto": Automatically select based on expected data size | -| `transformer` | `((data: T) => T)` | | - | Transform raw data before rendering | +| `transformer` | `ChartTransformer` | | - | Reshape the fetched rows before rendering. See ChartTransformer. | | `data` | `ChartDataInput` | | - | Arrow Table or an array of row objects (interfaces and `as const` arrays too). | +| `loading` | `boolean` | | - | Show the loading state instead of the chart, in the chart's box. Use it while the rows are being fetched (`data={rows ?? []} loading={!rows}`). | +| `error` | `string \| Error \| null` | | - | Show this error instead of the chart, in the chart's box. | | `title` | `string` | | - | Chart title | -| `showLegend` | `boolean` | | - | Show legend | +| `showLegend` | `boolean` | | `true` | Show the legend. Series charts draw it only when there are two or more series; pie and donut always; on a heatmap it is the color scale. | | `colorPalette` | `"categorical" \| "sequential" \| "diverging"` | | - | Color palette to use. Auto-selected based on chart type if not specified. - "categorical": Distinct colors for different categories (bar, pie, line) - "sequential": Gradient for magnitude/intensity (heatmap) - "diverging": Two-tone for positive/negative values | -| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes), held to the same formats. | -| `height` | `number` | | - | Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). | +| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette): hex, `rgb()` or `hsl()` strings, or theme tokens such as `var(--chart-cat-1)`, which are resolved against the root element before drawing (and again on theme change). Without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes). ECharts can't parse `oklch()`, so the variables must hold hex, rgb or hsl values. | +| `height` | `number` | | - | Chart height in pixels. Without it the chart fills its parent, at least 160 px (300 px with `defaults="v3"`). A className height such as `h-[400px]` also works. | | `className` | `string` | | - | Additional CSS classes | | `xKey` | `string` | | - | X-axis field key. Auto-detected from schema if not provided. | | `yKey` | `string \| string[]` | | - | Y-axis field key(s). Auto-detected from schema if not provided. | +| `seriesKey` | `string` | | - | Column that names the series in long rows (one row per x, series and value, as SQL returns them). With it, `yKey` is the single value column and each distinct value of `seriesKey` becomes a series. | +| `xType` | `"time" \| "value" \| "category"` | | - | X axis type (cartesian charts). Inferred from the `xKey` values only, never from column names: all dates gives `"time"`, otherwise `"category"`. | +| `defaults` | `"v3"` | | - | Opt into the v3 defaults. See ChartDefaults. Bug fixes apply with or without it; only defaults that change the look of a correct chart are gated. | | `ariaLabel` | `string` | | - | Accessibility label for screen readers | | `testId` | `string` | | - | Test ID for automated testing | -| `options` | `Record` | | - | Additional ECharts options to merge | +| `options` | `Record \| ((built: Record) => Record)` | | - | Additional ECharts options. An object is deep-merged into the built option (`series`, `xAxis`, `yAxis` and `grid` entry by entry, so a patch for the first series keeps its data). A function receives the built option and returns the option to render. | | `valueFormatter` | `ChartValueFormatter` | | - | `(value: string \| number, field: string) => string`. Formats measure values in the chart's built-in value axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different format for each series. | | `onDataClick` | `((datum: ChartClickDatum) => void)` | | - | Pointer-only: charts render to <canvas>, so this does not fire for keyboard users. Provide a keyboard-accessible equivalent (e.g. a table row action) for the same action. | | `selected` | `string \| string[]` | | - | Controlled selection by category name. Matching data element(s) render at full prominence while the rest are dimmed. Drive it from your own state to reflect a cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis; other chart types ignore it. | -| `orientation` | `"horizontal" \| "vertical"` | | `"vertical"` | Chart orientation | +| `sparkline` | `boolean` | | - | A KPI-tile sparkline: no axes, legend or margins, the y range fitted to the data, a gap at missing values, and a dot when there is one point. Height defaults to 48 px. | +| `symbolSize` | `number` | | `8` | Size of the data point symbols | | `showSymbol` | `boolean` | | `false` | Show data point symbols | -| `smooth` | `boolean` | | `true` | Smooth line curves | +| `smooth` | `boolean` | | `true (false with `defaults="v3"`)` | Smooth line curves. | +| `connectNulls` | `boolean` | | `false` | Draw the line across missing values instead of leaving a gap. Only applies with `defaults="v3"`, where missing values stay missing. | +| `referenceLines` | `ChartReferenceLine[]` | | - | Target or reference lines across the plot, at values of the value axis (`[{ value: 100, label: "Target" }]`). | +| `zoom` | `boolean` | | `false` | Zoom along the category or time axis: mouse wheel and drag in the plot, plus a slider. Use it for long series. | +| `series` | `Record` | | - | Per-`yKey` series type and value axis, for combo charts and a second y axis: `series={{ margin_pct: { type: "line", axis: "right" } }}` on a BarChart draws `margin_pct` as a line against its own axis. | ### Usage ```tsx -import { LineChart } from '@databricks/appkit-ui'; +import { LineChart } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/data/PieChart.mdx b/docs/docs/api/appkit-ui/data/PieChart.mdx index 60def78b4..05b8e617a 100644 --- a/docs/docs/api/appkit-ui/data/PieChart.mdx +++ b/docs/docs/api/appkit-ui/data/PieChart.mdx @@ -6,22 +6,20 @@ Pie Chart component for proportional data visualization. ## Example ```tsx -"use client"; - import { PieChart } from "@databricks/appkit-ui/react"; +// Two to five parts of one whole, as `config/queries/tickets_by_priority.sql` +// returns them. More parts, or parts of similar size, read better as a bar chart. +// SELECT priority, COUNT(*) AS tickets FROM tickets GROUP BY priority ORDER BY tickets DESC +const rows = [ + { priority: "Low", tickets: 412 }, + { priority: "Medium", tickets: 268 }, + { priority: "High", tickets: 121 }, + { priority: "Urgent", tickets: 37 }, +]; + export default function PieChartExample() { - return ( - - ); + return ; } ``` @@ -31,11 +29,19 @@ export default function PieChartExample() { Pie Chart component for proportional data visualization. -**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. +**Use when:** 2 to 5 parts of one whole. + +**Not when:** 6 or more parts, or parts of similar size (horizontal BarChart); negative values (BarChart); change over time (AreaChart). -**Best Practice:** Use the built-in data fetching by passing `queryKey` and `parameters` props instead of pre-fetching data with `useAnalyticsQuery`. +**Rows:** one per part, sorted descending: a name column and a value column. Pass both keys. + +**Gotchas:** a negative value shows an error and an all-zero result the empty state. Zero and missing slices are left out. + +**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. -Supports both query mode (queryKey + parameters) and data mode (static data). +**Data:** pass `queryKey` (and `parameters`) when the chart owns its query. Pass `data={rows}` when several +elements share one result (a KPI, a chart and a table fed by one `useAnalyticsQuery`), or for stub rows while +the UI is built first; add `loading` and `error` so the chart shows those states in its box. **Source:** [`packages/appkit-ui/src/react/charts/pie/index.tsx`](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/charts/pie/index.tsx) @@ -48,32 +54,38 @@ Supports both query mode (queryKey + parameters) and data mode (static data). | `queryKey` | `string` | | - | Analytics query key registered with analytics plugin | | `parameters` | `Record` | | - | Query parameters passed to the analytics endpoint | | `format` | `"auto" \| "json_array" \| "arrow_stream" \| "json" \| "arrow"` | | `"auto"` | Data format to use - "json_array": Use JSON format (smaller payloads, simpler) - "arrow_stream": Use Arrow format (faster for large datasets) - "auto": Automatically select based on expected data size | -| `transformer` | `((data: T) => T)` | | - | Transform raw data before rendering | +| `transformer` | `ChartTransformer` | | - | Reshape the fetched rows before rendering. See ChartTransformer. | | `data` | `ChartDataInput` | | - | Arrow Table or an array of row objects (interfaces and `as const` arrays too). | +| `loading` | `boolean` | | - | Show the loading state instead of the chart, in the chart's box. Use it while the rows are being fetched (`data={rows ?? []} loading={!rows}`). | +| `error` | `string \| Error \| null` | | - | Show this error instead of the chart, in the chart's box. | | `title` | `string` | | - | Chart title | -| `showLegend` | `boolean` | | - | Show legend | +| `showLegend` | `boolean` | | `true` | Show the legend. Series charts draw it only when there are two or more series; pie and donut always; on a heatmap it is the color scale. | | `colorPalette` | `"categorical" \| "sequential" \| "diverging"` | | - | Color palette to use. Auto-selected based on chart type if not specified. - "categorical": Distinct colors for different categories (bar, pie, line) - "sequential": Gradient for magnitude/intensity (heatmap) - "diverging": Two-tone for positive/negative values | -| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes), held to the same formats. | -| `height` | `number` | | - | Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). | +| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette): hex, `rgb()` or `hsl()` strings, or theme tokens such as `var(--chart-cat-1)`, which are resolved against the root element before drawing (and again on theme change). Without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes). ECharts can't parse `oklch()`, so the variables must hold hex, rgb or hsl values. | +| `height` | `number` | | - | Chart height in pixels. Without it the chart fills its parent, at least 160 px (300 px with `defaults="v3"`). A className height such as `h-[400px]` also works. | | `className` | `string` | | - | Additional CSS classes | | `xKey` | `string` | | - | X-axis field key. Auto-detected from schema if not provided. | | `yKey` | `string \| string[]` | | - | Y-axis field key(s). Auto-detected from schema if not provided. | +| `seriesKey` | `string` | | - | Column that names the series in long rows (one row per x, series and value, as SQL returns them). With it, `yKey` is the single value column and each distinct value of `seriesKey` becomes a series. | +| `xType` | `"time" \| "value" \| "category"` | | - | X axis type (cartesian charts). Inferred from the `xKey` values only, never from column names: all dates gives `"time"`, otherwise `"category"`. | +| `defaults` | `"v3"` | | - | Opt into the v3 defaults. See ChartDefaults. Bug fixes apply with or without it; only defaults that change the look of a correct chart are gated. | | `ariaLabel` | `string` | | - | Accessibility label for screen readers | | `testId` | `string` | | - | Test ID for automated testing | -| `options` | `Record` | | - | Additional ECharts options to merge | +| `options` | `Record \| ((built: Record) => Record)` | | - | Additional ECharts options. An object is deep-merged into the built option (`series`, `xAxis`, `yAxis` and `grid` entry by entry, so a patch for the first series keeps its data). A function receives the built option and returns the option to render. | | `valueFormatter` | `ChartValueFormatter` | | - | `(value: string \| number, field: string) => string`. Formats measure values in the chart's built-in value axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different format for each series. | | `onDataClick` | `((datum: ChartClickDatum) => void)` | | - | Pointer-only: charts render to <canvas>, so this does not fire for keyboard users. Provide a keyboard-accessible equivalent (e.g. a table row action) for the same action. | | `selected` | `string \| string[]` | | - | Controlled selection by category name. Matching data element(s) render at full prominence while the rest are dimmed. Drive it from your own state to reflect a cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis; other chart types ignore it. | -| `innerRadius` | `number` | | `0` | Inner radius for donut charts (0-100%) | -| `showLabels` | `boolean` | | `true` | Show labels on slices | +| `innerRadius` | `number` | | `0 (40 on DonutChart)` | Hole radius in percent of the chart, clamped to 0 to 63 (90% of the outer radius). `0` draws a plain pie, also on DonutChart. | +| `showLabels` | `boolean` | | `true (false with `defaults="v3"`, where the legend shows name, value and share)` | Show labels on slices. | | `labelPosition` | `"center" \| "outside" \| "inside"` | | `"outside"` | Label position | +| `centerLabel` | `string \| boolean` | | `true on a v3 DonutChart` | Text in the donut hole, sized to fit it. `true` shows the formatted total (compacted, e.g. "9.7M", when the full number doesn't fit). Ignored on a pie without a hole. | ### Usage ```tsx -import { PieChart } from '@databricks/appkit-ui'; +import { PieChart } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/data/RadarChart.mdx b/docs/docs/api/appkit-ui/data/RadarChart.mdx index 9bb102b65..4a61b6b3a 100644 --- a/docs/docs/api/appkit-ui/data/RadarChart.mdx +++ b/docs/docs/api/appkit-ui/data/RadarChart.mdx @@ -6,23 +6,36 @@ Radar Chart component for multi-dimensional data comparison. ## Example ```tsx -"use client"; - import { RadarChart } from "@databricks/appkit-ui/react"; +// One row per entity, on one 0-100 scale, as a SQL query returns it. +// `metrics` names the spokes; `max` fixes the rim at 100. +// SELECT region, availability, latency_score, error_score, cost_score +// FROM region_scores +const rows = [ + { + region: "us-east", + availability: 98, + latency_score: 82, + error_score: 91, + cost_score: 64, + }, + { + region: "eu-west", + availability: 95, + latency_score: 88, + error_score: 79, + cost_score: 72, + }, +]; + export default function RadarChartExample() { return ( ); @@ -35,11 +48,19 @@ export default function RadarChartExample() { Radar Chart component for multi-dimensional data comparison. -**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. +**Use when:** asked to show how one or two entities score on 4 to 8 metrics on one scale. + +**Not when:** metrics in different units (DataTable); more than 3 entities (grouped BarChart). -**Best Practice:** Use the built-in data fetching by passing `queryKey` and `parameters` props instead of pre-fetching data with `useAnalyticsQuery`. +**Rows:** one per entity as SQL returns them, with `metrics` naming the spokes; or one row per metric with a `yKey` per entity. + +**Gotchas:** pass `max` when the scale is known (`max={100}` for scores). Negative values show an error. + +**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. -Supports both query mode (queryKey + parameters) and data mode (static data). +**Data:** pass `queryKey` (and `parameters`) when the chart owns its query. Pass `data={rows}` when several +elements share one result (a KPI, a chart and a table fed by one `useAnalyticsQuery`), or for stub rows while +the UI is built first; add `loading` and `error` so the chart shows those states in its box. **Source:** [`packages/appkit-ui/src/react/charts/radar/index.tsx`](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/charts/radar/index.tsx) @@ -52,30 +73,37 @@ Supports both query mode (queryKey + parameters) and data mode (static data). | `queryKey` | `string` | | - | Analytics query key registered with analytics plugin | | `parameters` | `Record` | | - | Query parameters passed to the analytics endpoint | | `format` | `"auto" \| "json_array" \| "arrow_stream" \| "json" \| "arrow"` | | `"auto"` | Data format to use - "json_array": Use JSON format (smaller payloads, simpler) - "arrow_stream": Use Arrow format (faster for large datasets) - "auto": Automatically select based on expected data size | -| `transformer` | `((data: T) => T)` | | - | Transform raw data before rendering | +| `transformer` | `ChartTransformer` | | - | Reshape the fetched rows before rendering. See ChartTransformer. | | `data` | `ChartDataInput` | | - | Arrow Table or an array of row objects (interfaces and `as const` arrays too). | +| `loading` | `boolean` | | - | Show the loading state instead of the chart, in the chart's box. Use it while the rows are being fetched (`data={rows ?? []} loading={!rows}`). | +| `error` | `string \| Error \| null` | | - | Show this error instead of the chart, in the chart's box. | | `title` | `string` | | - | Chart title | -| `showLegend` | `boolean` | | - | Show legend | +| `showLegend` | `boolean` | | `true` | Show the legend. Series charts draw it only when there are two or more series; pie and donut always; on a heatmap it is the color scale. | | `colorPalette` | `"categorical" \| "sequential" \| "diverging"` | | - | Color palette to use. Auto-selected based on chart type if not specified. - "categorical": Distinct colors for different categories (bar, pie, line) - "sequential": Gradient for magnitude/intensity (heatmap) - "diverging": Two-tone for positive/negative values | -| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes), held to the same formats. | -| `height` | `number` | | - | Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). | +| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette): hex, `rgb()` or `hsl()` strings, or theme tokens such as `var(--chart-cat-1)`, which are resolved against the root element before drawing (and again on theme change). Without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes). ECharts can't parse `oklch()`, so the variables must hold hex, rgb or hsl values. | +| `height` | `number` | | - | Chart height in pixels. Without it the chart fills its parent, at least 160 px (300 px with `defaults="v3"`). A className height such as `h-[400px]` also works. | | `className` | `string` | | - | Additional CSS classes | | `xKey` | `string` | | - | X-axis field key. Auto-detected from schema if not provided. | | `yKey` | `string \| string[]` | | - | Y-axis field key(s). Auto-detected from schema if not provided. | +| `seriesKey` | `string` | | - | Column that names the series in long rows (one row per x, series and value, as SQL returns them). With it, `yKey` is the single value column and each distinct value of `seriesKey` becomes a series. | +| `xType` | `"time" \| "value" \| "category"` | | - | X axis type (cartesian charts). Inferred from the `xKey` values only, never from column names: all dates gives `"time"`, otherwise `"category"`. | +| `defaults` | `"v3"` | | - | Opt into the v3 defaults. See ChartDefaults. Bug fixes apply with or without it; only defaults that change the look of a correct chart are gated. | | `ariaLabel` | `string` | | - | Accessibility label for screen readers | | `testId` | `string` | | - | Test ID for automated testing | -| `options` | `Record` | | - | Additional ECharts options to merge | +| `options` | `Record \| ((built: Record) => Record)` | | - | Additional ECharts options. An object is deep-merged into the built option (`series`, `xAxis`, `yAxis` and `grid` entry by entry, so a patch for the first series keeps its data). A function receives the built option and returns the option to render. | | `valueFormatter` | `ChartValueFormatter` | | - | `(value: string \| number, field: string) => string`. Formats measure values in the chart's built-in value axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different format for each series. | | `onDataClick` | `((datum: ChartClickDatum) => void)` | | - | Pointer-only: charts render to <canvas>, so this does not fire for keyboard users. Provide a keyboard-accessible equivalent (e.g. a table row action) for the same action. | | `selected` | `string \| string[]` | | - | Controlled selection by category name. Matching data element(s) render at full prominence while the rest are dimmed. Drive it from your own state to reflect a cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis; other chart types ignore it. | | `showArea` | `boolean` | | `true` | Show area fill | +| `max` | `number \| readonly number[]` | | - | The rim value: one number for every metric (e.g. `100` for scores), or one per metric in row order. Unset: the data's largest value rounded up. | +| `metrics` | `readonly string[]` | | - | Metric columns, for data with one row per entity (the shape a SQL query returns: `name, speed, power, range`). Each listed column becomes a spoke and each row a polygon named by `xKey` (or the first text column). Without it, rows are metrics and `yKey` columns are the series. | ### Usage ```tsx -import { RadarChart } from '@databricks/appkit-ui'; +import { RadarChart } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/data/ScatterChart.mdx b/docs/docs/api/appkit-ui/data/ScatterChart.mdx index 0e395190a..6c9378f51 100644 --- a/docs/docs/api/appkit-ui/data/ScatterChart.mdx +++ b/docs/docs/api/appkit-ui/data/ScatterChart.mdx @@ -6,25 +6,28 @@ Scatter Chart component for correlation and distribution visualization. ## Example ```tsx -"use client"; - import { ScatterChart } from "@databricks/appkit-ui/react"; +// Two measures per entity, as `config/queries/customer_health.sql` returns them. +// Pass both keys: a scatter needs a numeric x and y. +// SELECT customer, CAST(monthly_spend AS DOUBLE) AS monthly_spend, uptime_pct +// FROM customer_health +const rows = [ + { customer: "Acme", monthly_spend: 5200, uptime_pct: 99.1 }, + { customer: "Globex", monthly_spend: 5850, uptime_pct: 98.4 }, + { customer: "Initech", monthly_spend: 5400, uptime_pct: 97.2 }, + { customer: "Umbrella", monthly_spend: 6000, uptime_pct: 99.5 }, + { customer: "Hooli", monthly_spend: 5050, uptime_pct: 98.9 }, + { customer: "Stark", monthly_spend: 5600, uptime_pct: 97.8 }, +]; + export default function ScatterChartExample() { return ( `${value}%`} height={300} /> ); @@ -37,11 +40,19 @@ export default function ScatterChartExample() { Scatter Chart component for correlation and distribution visualization. -**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. +**Use when:** checking whether two measures are related, one point per entity. + +**Not when:** under 10 points (DataTable); over 2,000 points (aggregate in SQL first). -**Best Practice:** Use the built-in data fetching by passing `queryKey` and `parameters` props instead of pre-fetching data with `useAnalyticsQuery`. +**Rows:** one per entity: two numeric measures and a label column. Pass both `xKey` and `yKey`. + +**Gotchas:** a text x shows an error; DATE values on x give a time axis. A point with a missing x or y is left out. + +**Important:** This component uses Apache ECharts architecture. Configure it via props, not by passing child components. -Supports both query mode (queryKey + parameters) and data mode (static data). +**Data:** pass `queryKey` (and `parameters`) when the chart owns its query. Pass `data={rows}` when several +elements share one result (a KPI, a chart and a table fed by one `useAnalyticsQuery`), or for stub rows while +the UI is built first; add `loading` and `error` so the chart shows those states in its box. **Source:** [`packages/appkit-ui/src/react/charts/scatter/index.tsx`](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/charts/scatter/index.tsx) @@ -54,30 +65,37 @@ Supports both query mode (queryKey + parameters) and data mode (static data). | `queryKey` | `string` | | - | Analytics query key registered with analytics plugin | | `parameters` | `Record` | | - | Query parameters passed to the analytics endpoint | | `format` | `"auto" \| "json_array" \| "arrow_stream" \| "json" \| "arrow"` | | `"auto"` | Data format to use - "json_array": Use JSON format (smaller payloads, simpler) - "arrow_stream": Use Arrow format (faster for large datasets) - "auto": Automatically select based on expected data size | -| `transformer` | `((data: T) => T)` | | - | Transform raw data before rendering | +| `transformer` | `ChartTransformer` | | - | Reshape the fetched rows before rendering. See ChartTransformer. | | `data` | `ChartDataInput` | | - | Arrow Table or an array of row objects (interfaces and `as const` arrays too). | +| `loading` | `boolean` | | - | Show the loading state instead of the chart, in the chart's box. Use it while the rows are being fetched (`data={rows ?? []} loading={!rows}`). | +| `error` | `string \| Error \| null` | | - | Show this error instead of the chart, in the chart's box. | | `title` | `string` | | - | Chart title | -| `showLegend` | `boolean` | | - | Show legend | +| `showLegend` | `boolean` | | `true` | Show the legend. Series charts draw it only when there are two or more series; pie and donut always; on a heatmap it is the color scale. | | `colorPalette` | `"categorical" \| "sequential" \| "diverging"` | | - | Color palette to use. Auto-selected based on chart type if not specified. - "categorical": Distinct colors for different categories (bar, pie, line) - "sequential": Gradient for magnitude/intensity (heatmap) - "diverging": Two-tone for positive/negative values | -| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette) as hex, `rgb()` or `hsl()` strings, since ECharts draws on a canvas and cannot resolve `var()` or parse `oklch()` (those draw gray); without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes), held to the same formats. | -| `height` | `number` | | - | Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). | +| `colors` | `string[]` | | - | Custom colors for series (overrides colorPalette): hex, `rgb()` or `hsl()` strings, or theme tokens such as `var(--chart-cat-1)`, which are resolved against the root element before drawing (and again on theme change). Without it, series colors are the CSS variables `--chart-cat-1` to `--chart-cat-8` on `:root` (`--chart-seq-*` and `--chart-div-*` for the sequential and diverging palettes). ECharts can't parse `oklch()`, so the variables must hold hex, rgb or hsl values. | +| `height` | `number` | | - | Chart height in pixels. Without it the chart fills its parent, at least 160 px (300 px with `defaults="v3"`). A className height such as `h-[400px]` also works. | | `className` | `string` | | - | Additional CSS classes | | `xKey` | `string` | | - | X-axis field key. Auto-detected from schema if not provided. | | `yKey` | `string \| string[]` | | - | Y-axis field key(s). Auto-detected from schema if not provided. | +| `seriesKey` | `string` | | - | Column that names the series in long rows (one row per x, series and value, as SQL returns them). With it, `yKey` is the single value column and each distinct value of `seriesKey` becomes a series. | +| `xType` | `"time" \| "value" \| "category"` | | - | X axis type (cartesian charts). Inferred from the `xKey` values only, never from column names: all dates gives `"time"`, otherwise `"category"`. | +| `defaults` | `"v3"` | | - | Opt into the v3 defaults. See ChartDefaults. Bug fixes apply with or without it; only defaults that change the look of a correct chart are gated. | | `ariaLabel` | `string` | | - | Accessibility label for screen readers | | `testId` | `string` | | - | Test ID for automated testing | -| `options` | `Record` | | - | Additional ECharts options to merge | +| `options` | `Record \| ((built: Record) => Record)` | | - | Additional ECharts options. An object is deep-merged into the built option (`series`, `xAxis`, `yAxis` and `grid` entry by entry, so a patch for the first series keeps its data). A function receives the built option and returns the option to render. | | `valueFormatter` | `ChartValueFormatter` | | - | `(value: string \| number, field: string) => string`. Formats measure values in the chart's built-in value axes, tooltips, and value labels. `field` is the corresponding `yKey`, so one formatter can select a different format for each series. | | `onDataClick` | `((datum: ChartClickDatum) => void)` | | - | Pointer-only: charts render to <canvas>, so this does not fire for keyboard users. Provide a keyboard-accessible equivalent (e.g. a table row action) for the same action. | | `selected` | `string \| string[]` | | - | Controlled selection by category name. Matching data element(s) render at full prominence while the rest are dimmed. Drive it from your own state to reflect a cross-filter or selection. Categorical charts (bar, pie/donut) show emphasis; other chart types ignore it. | | `symbolSize` | `number` | | `8` | Symbol size | +| `referenceLines` | `ChartReferenceLine[]` | | - | Target or reference lines across the plot, at values of the value axis (`[{ value: 100, label: "Target" }]`). | +| `showValues` | `boolean` | | `false` | Print each bar's (or point's) value next to it. | ### Usage ```tsx -import { ScatterChart } from '@databricks/appkit-ui'; +import { ScatterChart } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/files/DirectoryList.mdx b/docs/docs/api/appkit-ui/files/DirectoryList.mdx index d73e97ca3..46cad416a 100644 --- a/docs/docs/api/appkit-ui/files/DirectoryList.mdx +++ b/docs/docs/api/appkit-ui/files/DirectoryList.mdx @@ -34,7 +34,7 @@ Card-wrapped directory listing with loading, error, and empty states ### Usage ```tsx -import { DirectoryList } from '@databricks/appkit-ui'; +import { DirectoryList } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/files/FileBreadcrumb.mdx b/docs/docs/api/appkit-ui/files/FileBreadcrumb.mdx index e4b6bf5c5..b0cc17186 100644 --- a/docs/docs/api/appkit-ui/files/FileBreadcrumb.mdx +++ b/docs/docs/api/appkit-ui/files/FileBreadcrumb.mdx @@ -25,7 +25,7 @@ Path-aware breadcrumb navigation built on top of Breadcrumb primitives ### Usage ```tsx -import { FileBreadcrumb } from '@databricks/appkit-ui'; +import { FileBreadcrumb } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/files/FileEntry.mdx b/docs/docs/api/appkit-ui/files/FileEntry.mdx index 6b8e2ba15..deb640a1d 100644 --- a/docs/docs/api/appkit-ui/files/FileEntry.mdx +++ b/docs/docs/api/appkit-ui/files/FileEntry.mdx @@ -25,7 +25,7 @@ Single file or directory row with icon, name, size, and selection state ### Usage ```tsx -import { FileEntry } from '@databricks/appkit-ui'; +import { FileEntry } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/files/FilePreviewPanel.mdx b/docs/docs/api/appkit-ui/files/FilePreviewPanel.mdx index 2c594781f..0e453318e 100644 --- a/docs/docs/api/appkit-ui/files/FilePreviewPanel.mdx +++ b/docs/docs/api/appkit-ui/files/FilePreviewPanel.mdx @@ -30,7 +30,7 @@ Preview panel displaying file metadata, image/text preview, and download/delete ### Usage ```tsx -import { FilePreviewPanel } from '@databricks/appkit-ui'; +import { FilePreviewPanel } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/files/NewFolderInput.mdx b/docs/docs/api/appkit-ui/files/NewFolderInput.mdx index 56768e4a3..59fd688df 100644 --- a/docs/docs/api/appkit-ui/files/NewFolderInput.mdx +++ b/docs/docs/api/appkit-ui/files/NewFolderInput.mdx @@ -28,7 +28,7 @@ Inline folder-name input with create/cancel actions ### Usage ```tsx -import { NewFolderInput } from '@databricks/appkit-ui'; +import { NewFolderInput } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/genie/GenieChat.mdx b/docs/docs/api/appkit-ui/genie/GenieChat.mdx index 22e76deb6..40adb73d6 100644 --- a/docs/docs/api/appkit-ui/genie/GenieChat.mdx +++ b/docs/docs/api/appkit-ui/genie/GenieChat.mdx @@ -41,7 +41,7 @@ Full-featured chat interface for a single Databricks AI/BI Genie space. Handles ### Usage ```tsx -import { GenieChat } from '@databricks/appkit-ui'; +import { GenieChat } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/genie/GenieChatInput.mdx b/docs/docs/api/appkit-ui/genie/GenieChatInput.mdx index 79a6e6ab5..1f859d589 100644 --- a/docs/docs/api/appkit-ui/genie/GenieChatInput.mdx +++ b/docs/docs/api/appkit-ui/genie/GenieChatInput.mdx @@ -25,7 +25,7 @@ Auto-expanding textarea input with a send button for chat messages. Submits on E ### Usage ```tsx -import { GenieChatInput } from '@databricks/appkit-ui'; +import { GenieChatInput } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/genie/GenieChatMessage.mdx b/docs/docs/api/appkit-ui/genie/GenieChatMessage.mdx index 1092051c3..c2dbc541f 100644 --- a/docs/docs/api/appkit-ui/genie/GenieChatMessage.mdx +++ b/docs/docs/api/appkit-ui/genie/GenieChatMessage.mdx @@ -23,7 +23,7 @@ Renders a single Genie message bubble with optional expandable SQL query attachm ### Usage ```tsx -import { GenieChatMessage } from '@databricks/appkit-ui'; +import { GenieChatMessage } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/genie/GenieChatMessageList.mdx b/docs/docs/api/appkit-ui/genie/GenieChatMessageList.mdx index cb8d6d4b3..99f6742b7 100644 --- a/docs/docs/api/appkit-ui/genie/GenieChatMessageList.mdx +++ b/docs/docs/api/appkit-ui/genie/GenieChatMessageList.mdx @@ -26,7 +26,7 @@ Scrollable message list that renders Genie chat messages with auto-scroll, skele ### Usage ```tsx -import { GenieChatMessageList } from '@databricks/appkit-ui'; +import { GenieChatMessageList } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/genie/GenieQueryVisualization.mdx b/docs/docs/api/appkit-ui/genie/GenieQueryVisualization.mdx index 44dd3cd33..6e6a82cb5 100644 --- a/docs/docs/api/appkit-ui/genie/GenieQueryVisualization.mdx +++ b/docs/docs/api/appkit-ui/genie/GenieQueryVisualization.mdx @@ -30,7 +30,7 @@ Renders a chart + data table for a Genie query result. ### Usage ```tsx -import { GenieQueryVisualization } from '@databricks/appkit-ui'; +import { GenieQueryVisualization } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/ui/Accordion.mdx b/docs/docs/api/appkit-ui/ui/Accordion.mdx index 91620c343..f00d0ae14 100644 --- a/docs/docs/api/appkit-ui/ui/Accordion.mdx +++ b/docs/docs/api/appkit-ui/ui/Accordion.mdx @@ -37,7 +37,7 @@ Collapsible content sections organized in a vertical stack ### Usage ```tsx -import { Accordion } from '@databricks/appkit-ui'; +import { Accordion } from '@databricks/appkit-ui/react'; ``` @@ -63,7 +63,7 @@ Content area that expands and collapses within an accordion item ### Usage ```tsx -import { AccordionContent } from '@databricks/appkit-ui'; +import { AccordionContent } from '@databricks/appkit-ui/react'; ``` @@ -90,7 +90,7 @@ Individual collapsible section within an accordion ### Usage ```tsx -import { AccordionItem } from '@databricks/appkit-ui'; +import { AccordionItem } from '@databricks/appkit-ui/react'; ``` @@ -115,7 +115,7 @@ Clickable button that triggers accordion content visibility ### Usage ```tsx -import { AccordionTrigger } from '@databricks/appkit-ui'; +import { AccordionTrigger } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/ui/Alert.mdx b/docs/docs/api/appkit-ui/ui/Alert.mdx index 01772655f..620ed3362 100644 --- a/docs/docs/api/appkit-ui/ui/Alert.mdx +++ b/docs/docs/api/appkit-ui/ui/Alert.mdx @@ -29,7 +29,7 @@ Displays important information with optional icon and multiple variants ### Usage ```tsx -import { Alert } from '@databricks/appkit-ui'; +import { Alert } from '@databricks/appkit-ui/react'; ``` @@ -52,7 +52,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { AlertDescription } from '@databricks/appkit-ui'; +import { AlertDescription } from '@databricks/appkit-ui/react'; ``` @@ -75,7 +75,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { AlertTitle } from '@databricks/appkit-ui'; +import { AlertTitle } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/ui/AlertDialog.mdx b/docs/docs/api/appkit-ui/ui/AlertDialog.mdx index 79f54905d..148b220bc 100644 --- a/docs/docs/api/appkit-ui/ui/AlertDialog.mdx +++ b/docs/docs/api/appkit-ui/ui/AlertDialog.mdx @@ -31,7 +31,7 @@ Modal dialog that interrupts the user with critical information requiring immedi ### Usage ```tsx -import { AlertDialog } from '@databricks/appkit-ui'; +import { AlertDialog } from '@databricks/appkit-ui/react'; ``` @@ -56,7 +56,7 @@ Primary action button that confirms the alert ### Usage ```tsx -import { AlertDialogAction } from '@databricks/appkit-ui'; +import { AlertDialogAction } from '@databricks/appkit-ui/react'; ``` @@ -81,7 +81,7 @@ Cancel button that dismisses the alert dialog ### Usage ```tsx -import { AlertDialogCancel } from '@databricks/appkit-ui'; +import { AlertDialogCancel } from '@databricks/appkit-ui/react'; ``` @@ -111,7 +111,7 @@ Main content container for the alert dialog ### Usage ```tsx -import { AlertDialogContent } from '@databricks/appkit-ui'; +import { AlertDialogContent } from '@databricks/appkit-ui/react'; ``` @@ -136,7 +136,7 @@ Descriptive text explaining the alert ### Usage ```tsx -import { AlertDialogDescription } from '@databricks/appkit-ui'; +import { AlertDialogDescription } from '@databricks/appkit-ui/react'; ``` @@ -159,7 +159,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { AlertDialogFooter } from '@databricks/appkit-ui'; +import { AlertDialogFooter } from '@databricks/appkit-ui/react'; ``` @@ -182,7 +182,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { AlertDialogHeader } from '@databricks/appkit-ui'; +import { AlertDialogHeader } from '@databricks/appkit-ui/react'; ``` @@ -208,7 +208,7 @@ Background overlay that dims content behind the alert dialog ### Usage ```tsx -import { AlertDialogOverlay } from '@databricks/appkit-ui'; +import { AlertDialogOverlay } from '@databricks/appkit-ui/react'; ``` @@ -234,7 +234,7 @@ Portal container for rendering alert dialog content outside the DOM hierarchy ### Usage ```tsx -import { AlertDialogPortal } from '@databricks/appkit-ui'; +import { AlertDialogPortal } from '@databricks/appkit-ui/react'; ``` @@ -259,7 +259,7 @@ Title heading for the alert dialog ### Usage ```tsx -import { AlertDialogTitle } from '@databricks/appkit-ui'; +import { AlertDialogTitle } from '@databricks/appkit-ui/react'; ``` @@ -284,7 +284,7 @@ Button that triggers the alert dialog to open ### Usage ```tsx -import { AlertDialogTrigger } from '@databricks/appkit-ui'; +import { AlertDialogTrigger } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/ui/AspectRatio.mdx b/docs/docs/api/appkit-ui/ui/AspectRatio.mdx index f601d239d..ee9197872 100644 --- a/docs/docs/api/appkit-ui/ui/AspectRatio.mdx +++ b/docs/docs/api/appkit-ui/ui/AspectRatio.mdx @@ -30,7 +30,7 @@ Container that maintains a specific aspect ratio for its content ### Usage ```tsx -import { AspectRatio } from '@databricks/appkit-ui'; +import { AspectRatio } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/ui/Avatar.mdx b/docs/docs/api/appkit-ui/ui/Avatar.mdx index 656858b26..4aabccc8c 100644 --- a/docs/docs/api/appkit-ui/ui/Avatar.mdx +++ b/docs/docs/api/appkit-ui/ui/Avatar.mdx @@ -29,7 +29,7 @@ Displays user profile picture or initials in a circular container ### Usage ```tsx -import { Avatar } from '@databricks/appkit-ui'; +import { Avatar } from '@databricks/appkit-ui/react'; ``` @@ -55,7 +55,7 @@ Fallback content displayed when avatar image fails to load ### Usage ```tsx -import { AvatarFallback } from '@databricks/appkit-ui'; +import { AvatarFallback } from '@databricks/appkit-ui/react'; ``` @@ -81,7 +81,7 @@ Image element for the avatar ### Usage ```tsx -import { AvatarImage } from '@databricks/appkit-ui'; +import { AvatarImage } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/ui/Badge.mdx b/docs/docs/api/appkit-ui/ui/Badge.mdx index ce2862fcd..37b52c339 100644 --- a/docs/docs/api/appkit-ui/ui/Badge.mdx +++ b/docs/docs/api/appkit-ui/ui/Badge.mdx @@ -30,7 +30,7 @@ Small label for displaying status, categories, or counts ### Usage ```tsx -import { Badge } from '@databricks/appkit-ui'; +import { Badge } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/ui/Breadcrumb.mdx b/docs/docs/api/appkit-ui/ui/Breadcrumb.mdx index c480562cb..6c0b19375 100644 --- a/docs/docs/api/appkit-ui/ui/Breadcrumb.mdx +++ b/docs/docs/api/appkit-ui/ui/Breadcrumb.mdx @@ -27,7 +27,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { Breadcrumb } from '@databricks/appkit-ui'; +import { Breadcrumb } from '@databricks/appkit-ui/react'; ``` @@ -50,7 +50,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { BreadcrumbEllipsis } from '@databricks/appkit-ui'; +import { BreadcrumbEllipsis } from '@databricks/appkit-ui/react'; ``` @@ -73,7 +73,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { BreadcrumbItem } from '@databricks/appkit-ui'; +import { BreadcrumbItem } from '@databricks/appkit-ui/react'; ``` @@ -98,7 +98,7 @@ Clickable link within a breadcrumb item ### Usage ```tsx -import { BreadcrumbLink } from '@databricks/appkit-ui'; +import { BreadcrumbLink } from '@databricks/appkit-ui/react'; ``` @@ -121,7 +121,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { BreadcrumbList } from '@databricks/appkit-ui'; +import { BreadcrumbList } from '@databricks/appkit-ui/react'; ``` @@ -144,7 +144,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { BreadcrumbPage } from '@databricks/appkit-ui'; +import { BreadcrumbPage } from '@databricks/appkit-ui/react'; ``` @@ -167,7 +167,7 @@ This component extends standard HTML element attributes. ### Usage ```tsx -import { BreadcrumbSeparator } from '@databricks/appkit-ui'; +import { BreadcrumbSeparator } from '@databricks/appkit-ui/react'; ``` diff --git a/docs/docs/api/appkit-ui/ui/Button.mdx b/docs/docs/api/appkit-ui/ui/Button.mdx index 46835d345..0c47b4542 100644 --- a/docs/docs/api/appkit-ui/ui/Button.mdx +++ b/docs/docs/api/appkit-ui/ui/Button.mdx @@ -31,7 +31,7 @@ Clickable button with multiple variants and sizes ### Usage ```tsx -import { Button } from '@databricks/appkit-ui'; +import { Button } from '@databricks/appkit-ui/react';