@surfaces-ui/components 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/NOTICE +50 -0
  2. package/dist/appComponents.d.ts +9 -0
  3. package/dist/appComponents.js +105 -1
  4. package/dist/appComponents.js.map +1 -1
  5. package/dist/brand/MovingMark.d.ts +15 -0
  6. package/dist/brand/MovingMark.js +52 -0
  7. package/dist/brand/MovingMark.js.map +1 -0
  8. package/dist/brand/SurfacesMark.d.ts +9 -0
  9. package/dist/brand/SurfacesMark.js +12 -0
  10. package/dist/brand/SurfacesMark.js.map +1 -0
  11. package/dist/brand/index.d.ts +3 -0
  12. package/dist/brand/index.js +3 -0
  13. package/dist/brand/index.js.map +1 -0
  14. package/dist/brand/markMotion.d.ts +29 -0
  15. package/dist/brand/markMotion.js +89 -0
  16. package/dist/brand/markMotion.js.map +1 -0
  17. package/dist/chart/Chart.d.ts +8 -4
  18. package/dist/chart/Chart.js +28 -9
  19. package/dist/chart/Chart.js.map +1 -1
  20. package/dist/chart/advice.d.ts +4 -2
  21. package/dist/chart/advice.js +14 -1
  22. package/dist/chart/advice.js.map +1 -1
  23. package/dist/chart/labels.d.ts +23 -0
  24. package/dist/chart/labels.js +82 -0
  25. package/dist/chart/labels.js.map +1 -0
  26. package/dist/chart/option.d.ts +17 -2
  27. package/dist/chart/option.js +146 -3
  28. package/dist/chart/option.js.map +1 -1
  29. package/dist/controls/ItemControls.d.ts +6 -2
  30. package/dist/controls/ItemControls.js +8 -3
  31. package/dist/controls/ItemControls.js.map +1 -1
  32. package/dist/controls/OutlineIcon.d.ts +9 -0
  33. package/dist/controls/OutlineIcon.js +12 -0
  34. package/dist/controls/OutlineIcon.js.map +1 -0
  35. package/dist/feedback/ErrorPage.d.ts +27 -0
  36. package/dist/feedback/ErrorPage.js +12 -0
  37. package/dist/feedback/ErrorPage.js.map +1 -0
  38. package/dist/index.d.ts +4 -0
  39. package/dist/index.js +4 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/loading/ChartArt.d.ts +8 -0
  42. package/dist/loading/ChartArt.js +29 -0
  43. package/dist/loading/ChartArt.js.map +1 -0
  44. package/dist/loading/DraftCard.d.ts +10 -0
  45. package/dist/loading/DraftCard.js +38 -0
  46. package/dist/loading/DraftCard.js.map +1 -0
  47. package/dist/loading/Loading.d.ts +49 -0
  48. package/dist/loading/Loading.js +38 -0
  49. package/dist/loading/Loading.js.map +1 -0
  50. package/dist/locale/locale.d.ts +1 -0
  51. package/dist/locale/locale.js +1 -0
  52. package/dist/locale/locale.js.map +1 -1
  53. package/dist/result/QueryResult.js +2 -1
  54. package/dist/result/QueryResult.js.map +1 -1
  55. package/dist/schema/SchemaExplorer.d.ts +4 -0
  56. package/dist/schema/SchemaExplorer.js +46 -28
  57. package/dist/schema/SchemaExplorer.js.map +1 -1
  58. package/dist/styles.css +812 -67
  59. package/dist/styles.layer.css +812 -67
  60. package/dist/text/Markdown.js +21 -8
  61. package/dist/text/Markdown.js.map +1 -1
  62. package/dist/workspace/icons.js +2 -1
  63. package/dist/workspace/icons.js.map +1 -1
  64. package/package.json +11 -6
@@ -1 +1 @@
1
- {"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../src/chart/Chart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAmB,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGnG,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,SAAS,EAAwB,MAAM,oBAAoB,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,MAAM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AAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAClB,CACd,EACA,KAAK,CAAC,MAAM,EAAE,GAAG,IAAI,CACpB,qBAAY,SAAS,EAAC,eAAe,YAClC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,QAAQ;oBAC5B,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,GAC/G,CACd,IACM,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { type DataSource, collect, parseMeasureExpression, writeMeasure } from \"@surfaces-ui/data\";\nimport type { MessageInitShape } from \"@bufbuild/protobuf\";\nimport type { DataType } from \"apache-arrow\";\nimport { AggregateFunction, SortDirection, TimeGrain, type ViewQuerySchema } from \"@surfaces-ui/proto\";\nimport { defaultTheme, echartsTheme, resolveColors } from \"@surfaces-ui/tokens\";\nimport { BarChart, LineChart, PieChart, ScatterChart } from \"echarts/charts\";\nimport {\n AriaComponent,\n DataZoomComponent,\n DatasetComponent,\n GridComponent,\n LegendComponent,\n TooltipComponent,\n} from \"echarts/components\";\nimport * as echarts from \"echarts/core\";\nimport { CanvasRenderer } from \"echarts/renderers\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useDataSource } from \"../data/DataSourceProvider.js\";\nimport { dataNotes } from \"../data/DataNotes.js\";\nimport type { DataMessages } from \"../data/messages.js\";\nimport { chartValue, numericValue } from \"../data/format.js\";\nimport { label as text, numberFormat } from \"../locale/locale.js\";\nimport { type FilterInit, type TimeTravelInit, type ValueInit, messageOf } from \"../data/useRowWindow.js\";\nimport { useOptionalTheme } from \"../theme/ThemeProvider.js\";\nimport { type ChartShape, chartAdvice } from \"./advice.js\";\nimport { wheelScrollsThePage } from \"./wheel.js\";\nimport { type AxisFormat, type ChartOptionInput, type ChartType, type LegendPlacement, type SeriesType, buildChartOption, isOrdered, niceBinWidth, rowsWithoutX } from \"./option.js\";\n\necharts.use([\n BarChart,\n LineChart,\n PieChart,\n ScatterChart,\n AriaComponent,\n DataZoomComponent,\n DatasetComponent,\n GridComponent,\n LegendComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\nexport type ChartAggregate =\n | \"sum\"\n | \"avg\"\n | \"count\"\n | \"count_distinct\"\n | \"min\"\n | \"max\"\n | \"median\"\n | \"stddev\"\n | \"variance\"\n | \"percentile\";\n\nexport type ChartGrain = \"minute\" | \"hour\" | \"day\" | \"week\" | \"month\" | \"quarter\" | \"year\";\n\nexport interface ChartMeasure {\n /** Column to plot. Optional only for `count`, which then counts rows. */\n column?: string;\n /**\n * Summarise the column per x value in the engine. Without it the chart\n * plots raw rows: all of them when the result is small, otherwise a random\n * sample.\n */\n aggregate?: ChartAggregate;\n /** For `percentile`: a fraction from 0 to 1. Defaults to 0.9. */\n percentile?: number;\n /**\n * A calculation instead of a column: arithmetic over the measures named in\n * `terms`, such as `refunded / revenue`. The engine works it out after\n * summarising, so it is right for any number of rows and can be sorted by.\n */\n expression?: string;\n /** The measures an `expression` names, by the name it uses for them. */\n terms?: Record<string, { column?: string; aggregate: ChartAggregate; percentile?: number }>;\n /** Name for the legend. Defaults to e.g. \"sum of amount\". */\n label?: string;\n /** Draw this series differently from the chart's `type`, e.g. a line over bars. */\n type?: SeriesType;\n /** The y axis this series is measured on. Use \"right\" for a measure on another scale. Defaults to \"left\". */\n axis?: \"left\" | \"right\";\n /** Series with the same stack name are stacked on each other. */\n stack?: string;\n /**\n * Which of the theme's series colours to use, counting from 1. Give a\n * measure the same slot wherever it appears and it keeps its colour across\n * charts. Without it, series take the theme's colours in order.\n */\n slot?: number;\n}\n\nexport interface ChartProps extends DataMessages {\n sourceId: string;\n /** The base SQL. Grouping and aggregation are applied around it by the backend. */\n sql: string;\n /** How series are drawn unless a measure sets its own `type`. */\n type: ChartType;\n /** Column for the x axis, or the slices of a pie. */\n x: string;\n /** Group a date or time x column into buckets of this size, so a time series has one point per bucket. */\n xGrain?: ChartGrain;\n /** Group a numeric x column into bins of this width (a histogram). */\n xBinWidth?: number;\n /** Group a numeric x column into about this many bins; the width is chosen from the column's range. */\n xBins?: number;\n /** One entry per series. */\n y: ChartMeasure[];\n /** Split each measure into one series per distinct value of this column. */\n splitBy?: string;\n /**\n * The theme colour slot for particular values of `splitBy`, by value, e.g.\n * `{ Europe: 1, \"Asia Pacific\": 2 }`. A value then keeps its colour when a\n * filter removes other values.\n */\n splitSlots?: Record<string, number>;\n /** Stack the series. */\n stacked?: boolean;\n /**\n * The order of bars. \"value\" (the default for a bar chart over categories)\n * puts the largest first, and with a row limit keeps the largest. \"x\" keeps\n * the order of the x column. Dates, bins and numbers always keep their own order.\n */\n sort?: \"value\" | \"x\";\n /** Show advice when the chart's shape is one that misleads or cannot be read. Defaults to true. */\n advice?: boolean;\n /** Where the legend goes. Defaults to \"top\" when there is more than one series. */\n legend?: LegendPlacement;\n /** Axis titles. */\n xTitle?: string;\n yTitle?: string;\n yRightTitle?: string;\n /**\n * Turn the bars on their side: categories down the left, largest at the\n * top, values along the bottom. Easier to read with long category names or\n * many of them. Only for bars on one scale; ignored otherwise.\n */\n horizontal?: boolean;\n /** How the left axis writes its numbers: \"percent\" for a rate (6%, not 0.06), \"currency\" for money. Labels only; the values are untouched. */\n yFormat?: AxisFormat;\n filters?: FilterInit[];\n parameters?: ValueInit[];\n timeTravel?: TimeTravelInit;\n /** ISO 8601 time of the run this chart belongs to; see `RowWindowQuery.notBefore`. */\n notBefore?: string;\n /** Most points fetched. Defaults to 5,000; the chart says when it was cut off or sampled. */\n limit?: number;\n /** Height in px. Defaults to 320. */\n height?: number;\n /**\n * Called when a point, bar or slice is clicked, with its x value and\n * series name. Use it to filter other views (cross-filtering).\n */\n onPointClick?(point: { x: string | number | null; series: string; value: number | null }): void;\n /** Adjust the generated ECharts option before it is applied. */\n option?(option: Record<string, unknown>): Record<string, unknown>;\n /** Accessible description of what the chart shows. */\n label?: string;\n dataSource?: DataSource;\n className?: string;\n}\n\n/** The contract's function for each aggregate name. */\nexport const AGGREGATE_FUNCTIONS: Record<ChartAggregate, AggregateFunction> = {\n sum: AggregateFunction.SUM,\n avg: AggregateFunction.AVG,\n count: AggregateFunction.COUNT,\n count_distinct: AggregateFunction.COUNT_DISTINCT,\n min: AggregateFunction.MIN,\n max: AggregateFunction.MAX,\n median: AggregateFunction.MEDIAN,\n stddev: AggregateFunction.STDDEV,\n variance: AggregateFunction.VARIANCE,\n percentile: AggregateFunction.PERCENTILE,\n};\n\n/** The contract's grain for each grain name. */\nexport const TIME_GRAINS: Record<ChartGrain, TimeGrain> = {\n minute: TimeGrain.MINUTE,\n hour: TimeGrain.HOUR,\n day: TimeGrain.DAY,\n week: TimeGrain.WEEK,\n month: TimeGrain.MONTH,\n quarter: TimeGrain.QUARTER,\n year: TimeGrain.YEAR,\n};\n\ninterface Loaded extends Pick<ChartOptionInput, \"fields\" | \"rows\"> {\n /** \"first\": more points existed than the limit. \"sample\": the rows are a random sample. */\n cut: \"first\" | \"sample\" | undefined;\n /** How the categories were ordered, so the drawing and the notes agree with the query. */\n sort: \"value\" | \"x\";\n /** What the chart was not filtered by, for its readers (see `DataNotes`). */\n notes: string[];\n}\n\n/** Output column and label for each measure. */\nexport function measureOutputs(y: ChartMeasure[]): { column: string; label: string; measure: ChartMeasure }[] {\n return y.map((measure, i) => {\n if (measure.expression) return { column: `calc_${i}`, label: measure.label ?? measure.expression, measure };\n if (!measure.aggregate) return { column: measure.column ?? \"\", label: measure.label ?? measure.column ?? \"\", measure };\n const subject = measure.column ?? \"rows\";\n const name =\n measure.aggregate === \"percentile\" ? `p${Math.round((measure.percentile ?? 0.9) * 100)}` : measure.aggregate.replace(\"_\", \" \");\n return {\n column: `${measure.aggregate}_${measure.column ?? \"rows\"}_${i}`.replace(/\\W+/g, \"_\"),\n label: measure.label ?? (measure.aggregate === \"count\" && !measure.column ? \"count\" : `${name} of ${subject}`),\n measure,\n };\n });\n}\n\n/** A calculation with each name given a prefix, so its terms are its own. One that cannot be read is sent as it is, and the engine says why. */\nfunction termExpression(expression: string, prefix: string): string {\n try {\n return writeMeasure(parseMeasureExpression(expression), { name: (name) => `${prefix}_${name}`, divide: (left, right) => `(${left} / ${right})` });\n } catch {\n return expression;\n }\n}\n\nexport type ChartQueryInput = Pick<ChartProps, \"sql\" | \"type\" | \"x\" | \"xGrain\" | \"y\" | \"splitBy\" | \"filters\" | \"parameters\" | \"sort\"> & {\n /** Bin width for a numeric x, already resolved from `xBinWidth` or `xBins`. */\n binWidth?: number;\n limit: number;\n};\n\n/** The shape of a loaded chart, in the terms `chartAdvice` checks. Nothing drawn gives no advice. */\nexport function drawnShape(input: Pick<ChartProps, \"type\" | \"x\" | \"y\" | \"stacked\" | \"legend\"> & Pick<ChartOptionInput, \"fields\" | \"rows\"> & { seriesCount: number; binned: boolean; histogram?: boolean }): ChartShape {\n if (input.rows.length === 0) return { type: input.type, categories: 0, series: 0 };\n return {\n type: input.type,\n categories: new Set(input.rows.map((row) => row[input.x])).size,\n series: input.type === \"pie\" ? 1 : input.seriesCount,\n stacked: input.stacked,\n rightAxis: input.y.some((m) => m.axis === \"right\"),\n orderedX: input.binned || isOrdered(input.fields.find((f) => f.name === input.x)),\n ...(input.histogram ? { binned: true } : {}),\n ...(input.legend ? { legend: input.legend } : {}),\n };\n}\n\n/** How a chart's categories are ordered when not told: bars by size, everything else along x. */\nexport function chartSort(input: Pick<ChartQueryInput, \"type\" | \"xGrain\" | \"binWidth\" | \"sort\" | \"y\">): \"value\" | \"x\" {\n if (input.xGrain || input.binWidth) return \"x\";\n return input.sort ?? (input.type === \"bar\" && input.y.every((m) => (m.type ?? \"bar\") === \"bar\") ? \"value\" : \"x\");\n}\n\n/**\n * The query a chart sends. With aggregated measures the engine groups by x\n * (bucketed by time grain or bin width when asked) and by the split column;\n * otherwise it returns a random sample of raw rows.\n */\nexport function buildChartQuery(input: ChartQueryInput): MessageInitShape<typeof ViewQuerySchema> {\n const { sql, type, x, y, splitBy, filters, parameters, limit } = input;\n const outputs = measureOutputs(y);\n const aggregated = outputs.filter((o) => o.measure.aggregate || o.measure.expression);\n if (aggregated.length === 0) {\n const columns = [...new Set([x, ...(splitBy ? [splitBy] : []), ...outputs.map((o) => o.column)])];\n return { baseSql: sql, filters, parameters, columns, sample: { rows: limit } };\n }\n const bucket = input.xGrain\n ? { column: x, by: { case: \"grain\" as const, value: TIME_GRAINS[input.xGrain] } }\n : input.binWidth\n ? { column: x, by: { case: \"binWidth\" as const, value: input.binWidth } }\n : undefined;\n return {\n baseSql: sql,\n filters,\n parameters,\n groupBy: [...(bucket ? [] : [x]), ...(splitBy ? [splitBy] : [])],\n buckets: bucket ? [bucket] : [],\n aggregates: aggregated.flatMap((o) =>\n o.measure.expression\n ? // A calculation's terms are aggregates of their own, named after the calculation so two calculations cannot collide.\n Object.entries(o.measure.terms ?? {}).map(([name, term]) => ({\n function: AGGREGATE_FUNCTIONS[term.aggregate],\n column: term.column ?? \"\",\n alias: `${o.column}_${name}`,\n percentile: term.aggregate === \"percentile\" ? (term.percentile ?? 0.9) : 0,\n }))\n : [\n {\n function: AGGREGATE_FUNCTIONS[o.measure.aggregate!],\n column: o.measure.column ?? \"\",\n alias: o.column,\n percentile: o.measure.aggregate === \"percentile\" ? (o.measure.percentile ?? 0.9) : 0,\n },\n ],\n ),\n derived: aggregated.filter((o) => o.measure.expression).map((o) => ({ alias: o.column, expression: termExpression(o.measure.expression!, o.column) })),\n // By size, the engine keeps the largest when the limit cuts the result; a split chart is put in order from its totals afterwards.\n sorts:\n type === \"pie\" || (chartSort(input) === \"value\" && !splitBy)\n ? [{ column: aggregated[0]!.column, direction: SortDirection.DESC }]\n : [{ column: x, direction: SortDirection.ASC }],\n page: { limit },\n };\n}\n\n/**\n * An ECharts chart bound to a query. With aggregated measures the engine\n * groups the data, so the chart receives one row per point however large the\n * table is. Each measure is a series and can have its own type and y axis,\n * which makes compound charts (bars with a line, two scales). Colours, fonts\n * and radius follow the theme.\n */\n/** The columns a range query returns, as Arrow gives them: each column's values and its type. */\ninterface RangeTable {\n schema: { fields: { name: string; type: DataType }[] };\n getChild(name: string): { get(index: number): unknown } | null;\n}\n\n/**\n * The bin width for `bins` bins over the lowest and highest values the engine\n * found (`lo` and `hi`). Read with the column's type: a DECIMAL arrives as its\n * digits without the point, and read as a plain number it widens the range a\n * hundredfold or more, putting every value in one bin.\n */\nexport function rangeBinWidth(table: RangeTable, bins: number): number {\n const read = (name: string) => {\n const field = table.schema.fields.find((f) => f.name === name);\n const value = table.getChild(name)?.get(0);\n return field ? numericValue(value, field.type) : null;\n };\n const lo = read(\"lo\");\n const hi = read(\"hi\");\n return lo === null || hi === null ? 1 : niceBinWidth(lo, hi, bins);\n}\n\nexport function Chart(props: ChartProps) {\n const { sourceId, sql, type, x, xGrain, xBinWidth, xBins, y, splitBy, filters, parameters, timeTravel, notBefore, limit = 5000, height = 320 } = props;\n const dataSource = useDataSource(props.dataSource);\n const theme = useOptionalTheme();\n const element = useRef<HTMLDivElement>(null);\n const [state, setState] = useState<{ loaded?: Loaded; error?: string; loading: boolean }>({ loading: true });\n\n const outputs = useMemo(() => measureOutputs(y), [JSON.stringify(y)]); // eslint-disable-line react-hooks/exhaustive-deps\n const key = JSON.stringify([sourceId, sql, type, x, xGrain, xBinWidth, xBins, y, splitBy, filters, parameters, timeTravel, notBefore, limit, props.sort], (_, v) =>\n typeof v === \"bigint\" ? `${v}n` : v,\n );\n\n useEffect(() => {\n const controller = new AbortController();\n const call = { signal: controller.signal };\n setState((previous) => ({ ...previous, loading: true, error: undefined }));\n const aggregated = outputs.some((o) => o.measure.aggregate || o.measure.expression);\n const load = async (): Promise<Loaded> => {\n let binWidth = xGrain ? undefined : xBinWidth;\n if (aggregated && !xGrain && !binWidth && xBins) {\n // The bin width comes from the column's range, which the engine works out.\n const range = await collect(\n dataSource.execute(\n {\n sourceId,\n timeTravel,\n notBefore,\n query: {\n baseSql: sql,\n filters,\n parameters,\n aggregates: [\n { function: AggregateFunction.MIN, column: x, alias: \"lo\" },\n { function: AggregateFunction.MAX, column: x, alias: \"hi\" },\n ],\n },\n },\n call,\n ),\n );\n binWidth = rangeBinWidth(range.table, xBins);\n }\n const sort = chartSort({ type, xGrain, binWidth, sort: props.sort, y });\n const query = buildChartQuery({ sql, type, x, xGrain, binWidth, y, splitBy, filters, parameters, limit, sort });\n const result = await collect(dataSource.execute({ sourceId, timeTravel, notBefore, query }, call));\n const fields = result.table.schema.fields;\n const columns = fields.map((_, i) => result.table.getChildAt(i)!);\n const rows = Array.from({ length: result.table.numRows }, (_, r) =>\n Object.fromEntries(fields.map((f, c) => [f.name, chartValue(columns[c]!.get(r), f.type)])),\n );\n return { fields, rows, sort, cut: rows.length < limit ? undefined : aggregated ? \"first\" : \"sample\", notes: dataNotes(result.header.notices) };\n };\n load()\n .then((loaded) => {\n if (!controller.signal.aborted) setState({ loaded, loading: false });\n })\n .catch((error: unknown) => {\n if (!controller.signal.aborted) setState({ error: messageOf(error), loading: false });\n });\n return () => controller.abort();\n }, [dataSource, key]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const onPointClick = useRef(props.onPointClick);\n onPointClick.current = props.onPointClick;\n const mode = theme?.resolvedMode ?? \"light\";\n const themeDocument = theme?.theme ?? defaultTheme;\n const { stacked, legend, xTitle, yTitle, yRightTitle, yFormat, splitSlots, horizontal } = props;\n const palette = useMemo(() => resolveColors(themeDocument[mode], themeDocument.charts?.[mode]).series, [themeDocument, mode]);\n const slotsKey = JSON.stringify(splitSlots ?? null);\n const option = useMemo(() => {\n if (!state.loaded) return undefined;\n const slotColor = (slot: number | undefined) => (slot === undefined ? undefined : palette[slot - 1]);\n const base = buildChartOption({\n type,\n x,\n splitBy,\n series: outputs.map((o) => ({ column: o.column, label: o.label, type: o.measure.type, axis: o.measure.axis, stack: o.measure.stack, color: slotColor(o.measure.slot) })),\n splitColors: splitSlots ? Object.fromEntries(Object.entries(splitSlots).map(([value, slot]) => [value, slotColor(slot) ?? \"\"]).filter(([, color]) => color !== \"\")) : undefined,\n fields: state.loaded.fields,\n rows: state.loaded.rows,\n sort: state.loaded.sort,\n stacked,\n legend,\n xTitle,\n yTitle,\n yRightTitle,\n yFormat,\n horizontal,\n });\n // People who ask for less motion get none: the chart appears in place.\n const still = typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n const withAria = { aria: { enabled: true }, ...(still ? { animation: false } : {}), ...base };\n return props.option ? props.option(withAria) : withAria;\n }, [state.loaded, type, x, splitBy, outputs, props.option, stacked, legend, xTitle, yTitle, yRightTitle, yFormat, horizontal, palette, slotsKey]); // eslint-disable-line react-hooks/exhaustive-deps\n const seriesCount = type !== \"pie\" && Array.isArray((option as { series?: unknown[] } | undefined)?.series) ? (option as { series: unknown[] }).series.length : 0;\n\n useEffect(() => {\n if (!element.current || !option) return;\n const chart = echarts.init(element.current, echartsTheme(themeDocument, mode));\n chart.setOption(option);\n chart.on(\"click\", (event: { seriesName?: string; name?: string; data?: unknown; value?: unknown }) => {\n const row = event.data !== null && typeof event.data === \"object\" ? (event.data as Record<string, string | number | null>) : undefined;\n // Pie slices carry a name; other series carry the dataset row.\n const at = row && x in row ? row[x]! : (event.name ?? null);\n const amount = row && typeof row.value === \"number\" ? row.value : typeof event.value === \"number\" ? event.value : null;\n onPointClick.current?.({ x: at, series: event.seriesName ?? \"\", value: amount });\n });\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(() => chart.resize());\n observer?.observe(element.current);\n const unwheel = wheelScrollsThePage(element.current);\n return () => {\n unwheel();\n observer?.disconnect();\n chart.dispose();\n };\n }, [option, themeDocument, mode]);\n\n // Advice is worked out from what was actually drawn, so it follows filters and the data.\n const advice = props.advice === false || !state.loaded ? [] : chartAdvice(drawnShape({ type, x, y, stacked, legend, seriesCount, binned: Boolean(xGrain || xBinWidth || xBins), histogram: Boolean(xBinWidth || xBins), fields: state.loaded.fields, rows: state.loaded.rows }));\n\n // Rows a time or number axis cannot place are left out, and the chart says so with what they hold.\n const unplaced = state.loaded ? rowsWithoutX({ type, x, series: outputs.map((o) => ({ column: o.column, label: o.label, type: o.measure.type })), fields: state.loaded.fields, rows: state.loaded.rows }) : [];\n const unplacedDetail =\n unplaced.length === 1\n ? ` (${outputs.map((o) => `${o.label}: ${typeof unplaced[0]![o.column] === \"number\" ? numberFormat().format(unplaced[0]![o.column] as number) : String(unplaced[0]![o.column] ?? \"–\")}`).join(\", \")})`\n : \"\";\n const nothingDrawn = !!state.loaded && state.loaded.rows.length === unplaced.length;\n\n const description = props.label ?? text(\"chart.description\", { type, measures: outputs.map((o) => o.label).join(\", \"), x });\n return (\n <figure className={[\"sf-chart\", props.className].filter(Boolean).join(\" \")} aria-busy={state.loading}>\n {state.error ? (\n <p className=\"sf-chart-message\" role=\"alert\" data-error={state.error} style={{ minHeight: height }}>\n {props.errorMessage ?? state.error}\n </p>\n ) : nothingDrawn ? (\n <p className=\"sf-chart-message\" style={{ minHeight: height }}>\n {props.emptyMessage ?? text(\"chart.empty\")}\n </p>\n ) : (\n <div ref={element} className=\"sf-chart-canvas\" role=\"img\" aria-label={description} style={{ height }} />\n )}\n {unplaced.length > 0 && <figcaption className=\"sf-chart-note\">{text(\"chart.missingX\", { x, detail: unplacedDetail })}</figcaption>}\n {seriesCount > palette.length && (\n <figcaption className=\"sf-chart-note\">\n {text(\"chart.coloursRepeat\", { count: seriesCount, colours: palette.length })}\n </figcaption>\n )}\n {advice.map((item) => (\n <figcaption key={item.rule} className=\"sf-chart-note sf-chart-advice\" role=\"note\">\n {text(\"chart.advice\", { message: item.message, instead: item.instead })}\n </figcaption>\n ))}\n {state.loaded && state.loaded.notes.length > 0 && (\n <figcaption className=\"sf-chart-note\" role=\"note\">\n {state.loaded.notes.join(\" \")}\n </figcaption>\n )}\n {state.loaded?.cut && (\n <figcaption className=\"sf-chart-note\">\n {state.loaded.cut === \"sample\"\n ? text(\"chart.sampleNote\", { count: numberFormat().format(limit) })\n : text(state.loaded.sort === \"value\" ? \"chart.largestNote\" : \"chart.firstNote\", { count: numberFormat().format(limit) })}\n </figcaption>\n )}\n </figure>\n );\n}\n"]}
1
+ {"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../src/chart/Chart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAmB,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGnG,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,SAAS,EAAwB,MAAM,oBAAoB,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnI,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,Y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C,IADxD,IAAI,CAAC,IAAI,CAEb,CACd,CAAC,EACD,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAChD,qBAAY,SAAS,EAAC,eAAe,EAAC,IAAI,EAAC,MAAM,YAC9C,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAClB,CACd,EACA,KAAK,CAAC,MAAM,EAAE,GAAG,IAAI,CACpB,qBAAY,SAAS,EAAC,eAAe,YAClC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,QAAQ;oBAC5B,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,GAC/G,CACd,IACM,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { type DataSource, collect, parseMeasureExpression, writeMeasure } from \"@surfaces-ui/data\";\nimport type { MessageInitShape } from \"@bufbuild/protobuf\";\nimport type { DataType } from \"apache-arrow\";\nimport { AggregateFunction, SortDirection, TimeGrain, type ViewQuerySchema } from \"@surfaces-ui/proto\";\nimport { defaultTheme, echartsTheme, resolveColors } from \"@surfaces-ui/tokens\";\nimport { BarChart, FunnelChart, HeatmapChart, LineChart, PieChart, SankeyChart, ScatterChart, TreemapChart } from \"echarts/charts\";\nimport {\n AriaComponent,\n DataZoomComponent,\n DatasetComponent,\n GridComponent,\n LegendComponent,\n TooltipComponent,\n VisualMapComponent,\n} from \"echarts/components\";\nimport * as echarts from \"echarts/core\";\nimport { CanvasRenderer } from \"echarts/renderers\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useDataSource } from \"../data/DataSourceProvider.js\";\nimport { dataNotes } from \"../data/DataNotes.js\";\nimport type { DataMessages } from \"../data/messages.js\";\nimport { chartValue, numericValue } from \"../data/format.js\";\nimport { label as text, numberFormat } from \"../locale/locale.js\";\nimport { type FilterInit, type TimeTravelInit, type ValueInit, messageOf } from \"../data/useRowWindow.js\";\nimport { useOptionalTheme } from \"../theme/ThemeProvider.js\";\nimport { type ChartShape, chartAdvice } from \"./advice.js\";\nimport { wheelScrollsThePage } from \"./wheel.js\";\nimport { type AxisFormat, type ChartOptionInput, type ChartType, type LegendPlacement, type SeriesType, buildChartOption, isOrdered, isWholeChart, niceBinWidth, rowsWithoutX } from \"./option.js\";\nimport { type LabelChart, fitCategoryLabels } from \"./labels.js\";\n\necharts.use([\n BarChart,\n LineChart,\n PieChart,\n ScatterChart,\n // The other chart types: each draws one measure without axes (a heatmap keeps two category axes).\n HeatmapChart,\n FunnelChart,\n TreemapChart,\n SankeyChart,\n VisualMapComponent,\n AriaComponent,\n DataZoomComponent,\n DatasetComponent,\n GridComponent,\n LegendComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\nexport type ChartAggregate =\n | \"sum\"\n | \"avg\"\n | \"count\"\n | \"count_distinct\"\n | \"min\"\n | \"max\"\n | \"median\"\n | \"stddev\"\n | \"variance\"\n | \"percentile\";\n\nexport type ChartGrain = \"minute\" | \"hour\" | \"day\" | \"week\" | \"month\" | \"quarter\" | \"year\";\n\nexport interface ChartMeasure {\n /** Column to plot. Optional only for `count`, which then counts rows. */\n column?: string;\n /**\n * Summarise the column per x value in the engine. Without it the chart\n * plots raw rows: all of them when the result is small, otherwise a random\n * sample.\n */\n aggregate?: ChartAggregate;\n /** For `percentile`: a fraction from 0 to 1. Defaults to 0.9. */\n percentile?: number;\n /**\n * A calculation instead of a column: arithmetic over the measures named in\n * `terms`, such as `refunded / revenue`. The engine works it out after\n * summarising, so it is right for any number of rows and can be sorted by.\n */\n expression?: string;\n /** The measures an `expression` names, by the name it uses for them. */\n terms?: Record<string, { column?: string; aggregate: ChartAggregate; percentile?: number }>;\n /** Name for the legend. Defaults to e.g. \"sum of amount\". */\n label?: string;\n /** Draw this series differently from the chart's `type`, e.g. a line over bars. */\n type?: SeriesType;\n /** The y axis this series is measured on. Use \"right\" for a measure on another scale. Defaults to \"left\". */\n axis?: \"left\" | \"right\";\n /** Series with the same stack name are stacked on each other. */\n stack?: string;\n /**\n * Which of the theme's series colours to use, counting from 1. Give a\n * measure the same slot wherever it appears and it keeps its colour across\n * charts. Without it, series take the theme's colours in order.\n */\n slot?: number;\n}\n\nexport interface ChartProps extends DataMessages {\n sourceId: string;\n /** The base SQL. Grouping and aggregation are applied around it by the backend. */\n sql: string;\n /**\n * How series are drawn unless a measure sets its own `type`. Most charts are a basic type (`BASIC_CHART_TYPES`);\n * the others (`OTHER_CHART_TYPES`: heatmap, funnel, treemap, sankey) draw the first measure for what a basic one\n * cannot show.\n */\n type: ChartType;\n /** Column for the x axis, the slices of a pie, the columns of a heatmap, the stages of a funnel, the parts of a treemap, or where a sankey's flows start. */\n x: string;\n /** Group a date or time x column into buckets of this size, so a time series has one point per bucket. */\n xGrain?: ChartGrain;\n /** Group a numeric x column into bins of this width (a histogram). */\n xBinWidth?: number;\n /** Group a numeric x column into about this many bins; the width is chosen from the column's range. */\n xBins?: number;\n /** One entry per series. */\n y: ChartMeasure[];\n /** Split each measure into one series per distinct value of this column; the rows of a heatmap, the groups of a treemap, or where a sankey's flows go. */\n splitBy?: string;\n /**\n * The theme colour slot for particular values of `splitBy`, by value, e.g.\n * `{ Europe: 1, \"Asia Pacific\": 2 }`. A value then keeps its colour when a\n * filter removes other values.\n */\n splitSlots?: Record<string, number>;\n /** Stack the series. */\n stacked?: boolean;\n /**\n * The order of bars. \"value\" (the default for a bar chart over categories)\n * puts the largest first, and with a row limit keeps the largest. \"x\" keeps\n * the order of the x column. Dates, bins and numbers always keep their own order.\n */\n sort?: \"value\" | \"x\";\n /** Show advice when the chart's shape is one that misleads or cannot be read. Defaults to true. */\n advice?: boolean;\n /** Where the legend goes. Defaults to \"top\" when there is more than one series. */\n legend?: LegendPlacement;\n /** Axis titles. */\n xTitle?: string;\n yTitle?: string;\n yRightTitle?: string;\n /**\n * Turn the bars on their side: categories down the left, largest at the\n * top, values along the bottom. Easier to read with long category names or\n * many of them. Only for bars on one scale; ignored otherwise.\n */\n horizontal?: boolean;\n /** How the left axis writes its numbers: \"percent\" for a rate (6%, not 0.06), \"currency\" for money. Labels only; the values are untouched. */\n yFormat?: AxisFormat;\n filters?: FilterInit[];\n parameters?: ValueInit[];\n timeTravel?: TimeTravelInit;\n /** ISO 8601 time of the run this chart belongs to; see `RowWindowQuery.notBefore`. */\n notBefore?: string;\n /** Most points fetched. Defaults to 5,000; the chart says when it was cut off or sampled. */\n limit?: number;\n /** Height in px. Defaults to 320. */\n height?: number;\n /**\n * Called when a point, bar or slice is clicked, with its x value and\n * series name. Use it to filter other views (cross-filtering).\n */\n onPointClick?(point: { x: string | number | null; series: string; value: number | null }): void;\n /** Adjust the generated ECharts option before it is applied. */\n option?(option: Record<string, unknown>): Record<string, unknown>;\n /** Accessible description of what the chart shows. */\n label?: string;\n dataSource?: DataSource;\n className?: string;\n}\n\n/** The contract's function for each aggregate name. */\nexport const AGGREGATE_FUNCTIONS: Record<ChartAggregate, AggregateFunction> = {\n sum: AggregateFunction.SUM,\n avg: AggregateFunction.AVG,\n count: AggregateFunction.COUNT,\n count_distinct: AggregateFunction.COUNT_DISTINCT,\n min: AggregateFunction.MIN,\n max: AggregateFunction.MAX,\n median: AggregateFunction.MEDIAN,\n stddev: AggregateFunction.STDDEV,\n variance: AggregateFunction.VARIANCE,\n percentile: AggregateFunction.PERCENTILE,\n};\n\n/** The contract's grain for each grain name. */\nexport const TIME_GRAINS: Record<ChartGrain, TimeGrain> = {\n minute: TimeGrain.MINUTE,\n hour: TimeGrain.HOUR,\n day: TimeGrain.DAY,\n week: TimeGrain.WEEK,\n month: TimeGrain.MONTH,\n quarter: TimeGrain.QUARTER,\n year: TimeGrain.YEAR,\n};\n\ninterface Loaded extends Pick<ChartOptionInput, \"fields\" | \"rows\"> {\n /** \"first\": more points existed than the limit. \"sample\": the rows are a random sample. */\n cut: \"first\" | \"sample\" | undefined;\n /** How the categories were ordered, so the drawing and the notes agree with the query. */\n sort: \"value\" | \"x\";\n /** What the chart was not filtered by, for its readers (see `DataNotes`). */\n notes: string[];\n}\n\n/** Output column and label for each measure. */\nexport function measureOutputs(y: ChartMeasure[]): { column: string; label: string; measure: ChartMeasure }[] {\n return y.map((measure, i) => {\n if (measure.expression) return { column: `calc_${i}`, label: measure.label ?? measure.expression, measure };\n if (!measure.aggregate) return { column: measure.column ?? \"\", label: measure.label ?? measure.column ?? \"\", measure };\n const subject = measure.column ?? \"rows\";\n const name =\n measure.aggregate === \"percentile\" ? `p${Math.round((measure.percentile ?? 0.9) * 100)}` : measure.aggregate.replace(\"_\", \" \");\n return {\n column: `${measure.aggregate}_${measure.column ?? \"rows\"}_${i}`.replace(/\\W+/g, \"_\"),\n label: measure.label ?? (measure.aggregate === \"count\" && !measure.column ? \"count\" : `${name} of ${subject}`),\n measure,\n };\n });\n}\n\n/** A calculation with each name given a prefix, so its terms are its own. One that cannot be read is sent as it is, and the engine says why. */\nfunction termExpression(expression: string, prefix: string): string {\n try {\n return writeMeasure(parseMeasureExpression(expression), { name: (name) => `${prefix}_${name}`, divide: (left, right) => `(${left} / ${right})` });\n } catch {\n return expression;\n }\n}\n\nexport type ChartQueryInput = Pick<ChartProps, \"sql\" | \"type\" | \"x\" | \"xGrain\" | \"y\" | \"splitBy\" | \"filters\" | \"parameters\" | \"sort\"> & {\n /** Bin width for a numeric x, already resolved from `xBinWidth` or `xBins`. */\n binWidth?: number;\n limit: number;\n};\n\n/** The shape of a loaded chart, in the terms `chartAdvice` checks. Nothing drawn gives no advice. */\nexport function drawnShape(input: Pick<ChartProps, \"type\" | \"x\" | \"y\" | \"stacked\" | \"legend\" | \"splitBy\"> & Pick<ChartOptionInput, \"fields\" | \"rows\"> & { seriesCount: number; binned: boolean; histogram?: boolean }): ChartShape {\n if (input.rows.length === 0) return { type: input.type, categories: 0, series: 0 };\n return {\n type: input.type,\n categories: new Set(input.rows.map((row) => row[input.x])).size,\n series: isWholeChart(input.type) ? 1 : input.seriesCount,\n stacked: input.stacked,\n rightAxis: input.y.some((m) => m.axis === \"right\"),\n orderedX: input.binned || isOrdered(input.fields.find((f) => f.name === input.x)),\n ...(input.histogram ? { binned: true } : {}),\n ...(input.legend ? { legend: input.legend } : {}),\n ...(input.type === \"sankey\" || input.type === \"heatmap\" ? { split: Boolean(input.splitBy) } : {}),\n };\n}\n\n/** How a chart's categories are ordered when not told: bars by size, everything else along x. */\nexport function chartSort(input: Pick<ChartQueryInput, \"type\" | \"xGrain\" | \"binWidth\" | \"sort\" | \"y\">): \"value\" | \"x\" {\n if (input.xGrain || input.binWidth) return \"x\";\n return input.sort ?? (input.type === \"bar\" && input.y.every((m) => (m.type ?? \"bar\") === \"bar\") ? \"value\" : \"x\");\n}\n\n/**\n * The query a chart sends. With aggregated measures the engine groups by x\n * (bucketed by time grain or bin width when asked) and by the split column;\n * otherwise it returns a random sample of raw rows.\n */\nexport function buildChartQuery(input: ChartQueryInput): MessageInitShape<typeof ViewQuerySchema> {\n const { sql, type, x, y, splitBy, filters, parameters, limit } = input;\n const outputs = measureOutputs(y);\n const aggregated = outputs.filter((o) => o.measure.aggregate || o.measure.expression);\n if (aggregated.length === 0) {\n const columns = [...new Set([x, ...(splitBy ? [splitBy] : []), ...outputs.map((o) => o.column)])];\n return { baseSql: sql, filters, parameters, columns, sample: { rows: limit } };\n }\n const bucket = input.xGrain\n ? { column: x, by: { case: \"grain\" as const, value: TIME_GRAINS[input.xGrain] } }\n : input.binWidth\n ? { column: x, by: { case: \"binWidth\" as const, value: input.binWidth } }\n : undefined;\n return {\n baseSql: sql,\n filters,\n parameters,\n groupBy: [...(bucket ? [] : [x]), ...(splitBy ? [splitBy] : [])],\n buckets: bucket ? [bucket] : [],\n aggregates: aggregated.flatMap((o) =>\n o.measure.expression\n ? // A calculation's terms are aggregates of their own, named after the calculation so two calculations cannot collide.\n Object.entries(o.measure.terms ?? {}).map(([name, term]) => ({\n function: AGGREGATE_FUNCTIONS[term.aggregate],\n column: term.column ?? \"\",\n alias: `${o.column}_${name}`,\n percentile: term.aggregate === \"percentile\" ? (term.percentile ?? 0.9) : 0,\n }))\n : [\n {\n function: AGGREGATE_FUNCTIONS[o.measure.aggregate!],\n column: o.measure.column ?? \"\",\n alias: o.column,\n percentile: o.measure.aggregate === \"percentile\" ? (o.measure.percentile ?? 0.9) : 0,\n },\n ],\n ),\n derived: aggregated.filter((o) => o.measure.expression).map((o) => ({ alias: o.column, expression: termExpression(o.measure.expression!, o.column) })),\n // By size, the engine keeps the largest when the limit cuts the result; a split chart is put in order from its totals afterwards.\n sorts:\n // A part of a whole, a stage or a flow: the largest are kept when the limit cuts the result. A heatmap goes along x.\n (isWholeChart(type) && type !== \"heatmap\") || (chartSort(input) === \"value\" && !splitBy)\n ? [{ column: aggregated[0]!.column, direction: SortDirection.DESC }]\n : [{ column: x, direction: SortDirection.ASC }],\n page: { limit },\n };\n}\n\n/**\n * An ECharts chart bound to a query. With aggregated measures the engine\n * groups the data, so the chart receives one row per point however large the\n * table is. Each measure is a series and can have its own type and y axis,\n * which makes compound charts (bars with a line, two scales). Colours, fonts\n * and radius follow the theme.\n */\n/** The columns a range query returns, as Arrow gives them: each column's values and its type. */\ninterface RangeTable {\n schema: { fields: { name: string; type: DataType }[] };\n getChild(name: string): { get(index: number): unknown } | null;\n}\n\n/**\n * The bin width for `bins` bins over the lowest and highest values the engine\n * found (`lo` and `hi`). Read with the column's type: a DECIMAL arrives as its\n * digits without the point, and read as a plain number it widens the range a\n * hundredfold or more, putting every value in one bin.\n */\nexport function rangeBinWidth(table: RangeTable, bins: number): number {\n const read = (name: string) => {\n const field = table.schema.fields.find((f) => f.name === name);\n const value = table.getChild(name)?.get(0);\n return field ? numericValue(value, field.type) : null;\n };\n const lo = read(\"lo\");\n const hi = read(\"hi\");\n return lo === null || hi === null ? 1 : niceBinWidth(lo, hi, bins);\n}\n\nexport function Chart(props: ChartProps) {\n const { sourceId, sql, type, x, xGrain, xBinWidth, xBins, y, splitBy, filters, parameters, timeTravel, notBefore, limit = 5000, height = 320 } = props;\n const dataSource = useDataSource(props.dataSource);\n const theme = useOptionalTheme();\n const element = useRef<HTMLDivElement>(null);\n const [state, setState] = useState<{ loaded?: Loaded; error?: string; loading: boolean }>({ loading: true });\n\n const outputs = useMemo(() => measureOutputs(y), [JSON.stringify(y)]); // eslint-disable-line react-hooks/exhaustive-deps\n const key = JSON.stringify([sourceId, sql, type, x, xGrain, xBinWidth, xBins, y, splitBy, filters, parameters, timeTravel, notBefore, limit, props.sort], (_, v) =>\n typeof v === \"bigint\" ? `${v}n` : v,\n );\n\n useEffect(() => {\n const controller = new AbortController();\n const call = { signal: controller.signal };\n setState((previous) => ({ ...previous, loading: true, error: undefined }));\n const aggregated = outputs.some((o) => o.measure.aggregate || o.measure.expression);\n const load = async (): Promise<Loaded> => {\n let binWidth = xGrain ? undefined : xBinWidth;\n if (aggregated && !xGrain && !binWidth && xBins) {\n // The bin width comes from the column's range, which the engine works out.\n const range = await collect(\n dataSource.execute(\n {\n sourceId,\n timeTravel,\n notBefore,\n query: {\n baseSql: sql,\n filters,\n parameters,\n aggregates: [\n { function: AggregateFunction.MIN, column: x, alias: \"lo\" },\n { function: AggregateFunction.MAX, column: x, alias: \"hi\" },\n ],\n },\n },\n call,\n ),\n );\n binWidth = rangeBinWidth(range.table, xBins);\n }\n const sort = chartSort({ type, xGrain, binWidth, sort: props.sort, y });\n const query = buildChartQuery({ sql, type, x, xGrain, binWidth, y, splitBy, filters, parameters, limit, sort });\n const result = await collect(dataSource.execute({ sourceId, timeTravel, notBefore, query }, call));\n const fields = result.table.schema.fields;\n const columns = fields.map((_, i) => result.table.getChildAt(i)!);\n const rows = Array.from({ length: result.table.numRows }, (_, r) =>\n Object.fromEntries(fields.map((f, c) => [f.name, chartValue(columns[c]!.get(r), f.type)])),\n );\n return { fields, rows, sort, cut: rows.length < limit ? undefined : aggregated ? \"first\" : \"sample\", notes: dataNotes(result.header.notices) };\n };\n load()\n .then((loaded) => {\n if (!controller.signal.aborted) setState({ loaded, loading: false });\n })\n .catch((error: unknown) => {\n if (!controller.signal.aborted) setState({ error: messageOf(error), loading: false });\n });\n return () => controller.abort();\n }, [dataSource, key]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const onPointClick = useRef(props.onPointClick);\n onPointClick.current = props.onPointClick;\n const mode = theme?.resolvedMode ?? \"light\";\n const themeDocument = theme?.theme ?? defaultTheme;\n const { stacked, legend, xTitle, yTitle, yRightTitle, yFormat, splitSlots, horizontal } = props;\n const colors = useMemo(() => resolveColors(themeDocument[mode], themeDocument.charts?.[mode]), [themeDocument, mode]);\n const palette = colors.series;\n const slotsKey = JSON.stringify(splitSlots ?? null);\n const option = useMemo(() => {\n if (!state.loaded) return undefined;\n const slotColor = (slot: number | undefined) => (slot === undefined ? undefined : palette[slot - 1]);\n const base = buildChartOption({\n type,\n x,\n splitBy,\n series: outputs.map((o) => ({ column: o.column, label: o.label, type: o.measure.type, axis: o.measure.axis, stack: o.measure.stack, color: slotColor(o.measure.slot) })),\n splitColors: splitSlots ? Object.fromEntries(Object.entries(splitSlots).map(([value, slot]) => [value, slotColor(slot) ?? \"\"]).filter(([, color]) => color !== \"\")) : undefined,\n fields: state.loaded.fields,\n rows: state.loaded.rows,\n sort: state.loaded.sort,\n stacked,\n legend,\n xTitle,\n yTitle,\n yRightTitle,\n yFormat,\n horizontal,\n ramp: colors.sequential,\n });\n // People who ask for less motion get none: the chart appears in place.\n const still = typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n const withAria = { aria: { enabled: true }, ...(still ? { animation: false } : {}), ...base };\n return props.option ? props.option(withAria) : withAria;\n }, [state.loaded, type, x, splitBy, outputs, props.option, stacked, legend, xTitle, yTitle, yRightTitle, yFormat, horizontal, palette, slotsKey]); // eslint-disable-line react-hooks/exhaustive-deps\n const seriesCount = !isWholeChart(type) && Array.isArray((option as { series?: unknown[] } | undefined)?.series) ? (option as { series: unknown[] }).series.length : 0;\n\n useEffect(() => {\n if (!element.current || !option) return;\n const chart = echarts.init(element.current, echartsTheme(themeDocument, mode));\n chart.setOption(option);\n chart.on(\"click\", (event: { seriesName?: string; name?: string; data?: unknown; value?: unknown }) => {\n const row = event.data !== null && typeof event.data === \"object\" ? (event.data as Record<string, string | number | null>) : undefined;\n // Pie slices carry a name; other series carry the dataset row.\n const at = row && x in row ? row[x]! : (event.name ?? null);\n const amount = row && typeof row.value === \"number\" ? row.value : typeof event.value === \"number\" ? event.value : null;\n onPointClick.current?.({ x: at, series: event.seriesName ?? \"\", value: amount });\n });\n // Category labels wrap to their bands, whose width is known only once the chart is laid out.\n fitCategoryLabels(chart as unknown as LabelChart);\n const observer =\n typeof ResizeObserver === \"undefined\"\n ? undefined\n : new ResizeObserver(() => {\n chart.resize();\n fitCategoryLabels(chart as unknown as LabelChart);\n });\n observer?.observe(element.current);\n const unwheel = wheelScrollsThePage(element.current);\n return () => {\n unwheel();\n observer?.disconnect();\n chart.dispose();\n };\n }, [option, themeDocument, mode]);\n\n // Advice is worked out from what was actually drawn, so it follows filters and the data.\n const advice = props.advice === false || !state.loaded ? [] : chartAdvice(drawnShape({ type, x, y, stacked, legend, splitBy, seriesCount, binned: Boolean(xGrain || xBinWidth || xBins), histogram: Boolean(xBinWidth || xBins), fields: state.loaded.fields, rows: state.loaded.rows }));\n\n // Rows a time or number axis cannot place are left out, and the chart says so with what they hold.\n const unplaced = state.loaded ? rowsWithoutX({ type, x, series: outputs.map((o) => ({ column: o.column, label: o.label, type: o.measure.type })), fields: state.loaded.fields, rows: state.loaded.rows }) : [];\n const unplacedDetail =\n unplaced.length === 1\n ? ` (${outputs.map((o) => `${o.label}: ${typeof unplaced[0]![o.column] === \"number\" ? numberFormat().format(unplaced[0]![o.column] as number) : String(unplaced[0]![o.column] ?? \"–\")}`).join(\", \")})`\n : \"\";\n const nothingDrawn = !!state.loaded && state.loaded.rows.length === unplaced.length;\n\n const description = props.label ?? text(\"chart.description\", { type, measures: outputs.map((o) => o.label).join(\", \"), x });\n return (\n <figure className={[\"sf-chart\", props.className].filter(Boolean).join(\" \")} aria-busy={state.loading}>\n {state.error ? (\n <p className=\"sf-chart-message\" role=\"alert\" data-error={state.error} style={{ minHeight: height }}>\n {props.errorMessage ?? state.error}\n </p>\n ) : nothingDrawn ? (\n <p className=\"sf-chart-message\" style={{ minHeight: height }}>\n {props.emptyMessage ?? text(\"chart.empty\")}\n </p>\n ) : (\n <div ref={element} className=\"sf-chart-canvas\" role=\"img\" aria-label={description} style={{ height }} />\n )}\n {unplaced.length > 0 && <figcaption className=\"sf-chart-note\">{text(\"chart.missingX\", { x, detail: unplacedDetail })}</figcaption>}\n {seriesCount > palette.length && (\n <figcaption className=\"sf-chart-note\">\n {text(\"chart.coloursRepeat\", { count: seriesCount, colours: palette.length })}\n </figcaption>\n )}\n {advice.map((item) => (\n <figcaption key={item.rule} className=\"sf-chart-note sf-chart-advice\" role=\"note\">\n {text(\"chart.advice\", { message: item.message, instead: item.instead })}\n </figcaption>\n ))}\n {state.loaded && state.loaded.notes.length > 0 && (\n <figcaption className=\"sf-chart-note\" role=\"note\">\n {state.loaded.notes.join(\" \")}\n </figcaption>\n )}\n {state.loaded?.cut && (\n <figcaption className=\"sf-chart-note\">\n {state.loaded.cut === \"sample\"\n ? text(\"chart.sampleNote\", { count: numberFormat().format(limit) })\n : text(state.loaded.sort === \"value\" ? \"chart.largestNote\" : \"chart.firstNote\", { count: numberFormat().format(limit) })}\n </figcaption>\n )}\n </figure>\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { ChartType } from "./option.js";
1
+ import { type ChartType } from "./option.js";
2
2
  /** What a chart is about to draw, in the terms the advice needs. */
3
3
  export interface ChartShape {
4
4
  type: ChartType;
@@ -17,9 +17,11 @@ export interface ChartShape {
17
17
  binned?: boolean;
18
18
  /** Where the legend was asked for, when it was; left out, the chart chooses. */
19
19
  legend?: "top" | "bottom" | "right" | "none";
20
+ /** True when a column splits the measure (the rows of a heatmap, where a sankey's flows go). */
21
+ split?: boolean;
20
22
  }
21
23
  export interface ChartAdvice {
22
- rule: "pie-slices" | "two-scales" | "bar-baseline" | "line-order" | "too-many-lines" | "stack-depth" | "bar-crowding" | "overlapping-areas" | "bars-over-time" | "pie-in-order" | "one-series-legend";
24
+ rule: "pie-slices" | "two-scales" | "bar-baseline" | "line-order" | "too-many-lines" | "stack-depth" | "bar-crowding" | "overlapping-areas" | "bars-over-time" | "pie-in-order" | "one-series-legend" | "sankey-needs-split" | "funnel-in-time" | "funnel-stages" | "heatmap-one-row";
23
25
  message: string;
24
26
  /** What to draw instead. */
25
27
  instead: string;
@@ -1,3 +1,4 @@
1
+ import { isWholeChart } from "./option.js";
1
2
  /**
2
3
  * Checks a chart against the working rules of Edward Tufte and Stephen Few:
3
4
  * show the data honestly, compare like with like, and spend ink only on
@@ -40,7 +41,19 @@ export function chartAdvice(shape) {
40
41
  if (type === "pie" && shape.orderedX) {
41
42
  advice.push({ rule: "pie-in-order", message: "A pie puts its slices round a circle, so the order of these values is lost.", instead: "A line or bars, in the order of x." });
42
43
  }
43
- if (type !== "pie" && series === 1 && shape.legend && shape.legend !== "none") {
44
+ if (type === "sankey" && shape.split === false) {
45
+ advice.push({ rule: "sankey-needs-split", message: "A sankey draws flows from x to splitBy, and has no splitBy to flow to.", instead: "Give splitBy the column the flows go to, or use bars." });
46
+ }
47
+ if (type === "funnel" && shape.orderedX) {
48
+ advice.push({ rule: "funnel-in-time", message: "A funnel is for stages of a process; dates or numbers on x are a change over time.", instead: "A line with a time grain." });
49
+ }
50
+ if (type === "funnel" && categories > 8) {
51
+ advice.push({ rule: "funnel-stages", message: `${categories} stages are too many to compare in a funnel.`, instead: "The main stages only, or bars sorted by size." });
52
+ }
53
+ if (type === "heatmap" && shape.split === false) {
54
+ advice.push({ rule: "heatmap-one-row", message: "A heatmap of one row shows by colour what a bar or a line shows by length, which reads more exactly.", instead: "Bars, or a line for a time; or give splitBy a second dimension." });
55
+ }
56
+ if (!isWholeChart(type) && series === 1 && shape.legend && shape.legend !== "none") {
44
57
  advice.push({ rule: "one-series-legend", message: "A legend for one series repeats what the title says.", instead: "Leave the legend out and name the measure in the title." });
45
58
  }
46
59
  return advice;
@@ -1 +1 @@
1
- {"version":3,"file":"advice.js","sourceRoot":"","sources":["../../src/chart/advice.ts"],"names":[],"mappings":"AA6BA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC;IACnD,IAAI,IAAI,KAAK,KAAK,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,UAAU,2CAA2C,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CAAC;IAClJ,CAAC;IACD,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,8DAA8D;YACvE,OAAO,EAAE,oFAAoF;SAC9F,CAAC,CAAC;IACL,CAAC;IACD,IAAI,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,8DAA8D,EAAE,OAAO,EAAE,yEAAyE,EAAE,CAAC,CAAC;IACrM,CAAC;IACD,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IA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AAE,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,UAAU,0CAA0C,EAAE,OAAO,EAAE,2DAA2D,EAAE,CAAC,CAAC;IAClL,CAAC;IACD,IAAI,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,6EAA6E,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC,CAAC;IAC/K,CAAC;IACD,IAAI,IAAI,KAAK,KAAK,IAAI,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC9E,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,sDAAsD,EAAE,OAAO,EAAE,yDAAyD,EAAE,CAAC,CAAC;IAClL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { ChartType } from \"./option.js\";\n\n/** What a chart is about to draw, in the terms the advice needs. */\nexport interface ChartShape {\n type: ChartType;\n /** Distinct values on the x axis (or slices of a pie). */\n categories?: number;\n /** Series drawn, after any split. */\n series?: number;\n stacked?: boolean;\n /** True when a measure is on a second y scale. */\n rightAxis?: boolean;\n /** True when x is a date, time or number, so its order means something. */\n orderedX?: boolean;\n /** True when the value axis has been told to start somewhere other than zero. */\n truncatedAxis?: boolean;\n /** True when x is a numeric column grouped into bins (a histogram). */\n binned?: boolean;\n /** Where the legend was asked for, when it was; left out, the chart chooses. */\n legend?: \"top\" | \"bottom\" | \"right\" | \"none\";\n}\n\nexport interface ChartAdvice {\n rule: \"pie-slices\" | \"two-scales\" | \"bar-baseline\" | \"line-order\" | \"too-many-lines\" | \"stack-depth\" | \"bar-crowding\" | \"overlapping-areas\" | \"bars-over-time\" | \"pie-in-order\" | \"one-series-legend\";\n message: string;\n /** What to draw instead. */\n instead: string;\n}\n\n/**\n * Checks a chart against the working rules of Edward Tufte and Stephen Few:\n * show the data honestly, compare like with like, and spend ink only on\n * data. It returns advice, not errors; a person or an agent decides.\n */\nexport function chartAdvice(shape: ChartShape): ChartAdvice[] {\n const advice: ChartAdvice[] = [];\n const { type, categories = 0, series = 1 } = shape;\n if (type === \"pie\" && categories > 5) {\n advice.push({ rule: \"pie-slices\", message: `${categories} slices are too many to compare by angle.`, instead: \"A bar chart sorted by value.\" });\n }\n if (shape.rightAxis) {\n advice.push({\n rule: \"two-scales\",\n message: \"Two y scales make heights look comparable when they are not.\",\n instead: \"Two charts stacked on the same x axis, or both measures indexed to a common start.\",\n });\n }\n if (type === \"bar\" && shape.truncatedAxis) {\n advice.push({ rule: \"bar-baseline\", message: \"A bar's length is its value, so the axis must start at zero.\", instead: \"Start at zero, or use a dot or line chart if the differences are small.\" });\n }\n if ((type === \"line\" || type === \"area\") && shape.orderedX === false) {\n advice.push({ rule: \"line-order\", message: \"A line implies order between its points; these categories have none.\", instead: \"A bar chart.\" });\n }\n if (type === \"line\" && series > 5) {\n advice.push({ rule: \"too-many-lines\", message: `${series} lines cross too often to follow.`, instead: \"Small multiples on one shared scale, or highlight one line and grey the rest.\" });\n }\n if (shape.stacked && series > 5) {\n advice.push({ rule: \"stack-depth\", message: `Only the bottom of ${series} stacked segments can be compared across bars.`, instead: \"Keep the largest four and fold the rest into Other, or use small multiples.\" });\n }\n if (type === \"bar\" && !shape.stacked && categories * series > 40) {\n advice.push({ rule: \"bar-crowding\", message: \"Too many bars to read individually.\", instead: \"The top values sorted by size, or a table.\" });\n }\n if (type === \"area\" && !shape.stacked && series > 1) {\n advice.push({ rule: \"overlapping-areas\", message: \"Unstacked areas hide each other.\", instead: \"Lines, or a stacked area if the total matters.\" });\n }\n if (type === \"bar\" && shape.orderedX && !shape.binned && categories > 24) {\n advice.push({ rule: \"bars-over-time\", message: `${categories} bars in a row hide the trend they make.`, instead: \"A line, with a time grain coarse enough for the decision.\" });\n }\n if (type === \"pie\" && shape.orderedX) {\n advice.push({ rule: \"pie-in-order\", message: \"A pie puts its slices round a circle, so the order of these values is lost.\", instead: \"A line or bars, in the order of x.\" });\n }\n if (type !== \"pie\" && series === 1 && shape.legend && shape.legend !== \"none\") {\n advice.push({ rule: \"one-series-legend\", message: \"A legend for one series repeats what the title says.\", instead: \"Leave the legend out and name the measure in the title.\" });\n }\n return advice;\n}\n"]}
1
+ {"version":3,"file":"advice.js","sourceRoot":"","sources":["../../src/chart/advice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,YAAY,EAAE,MAAM,aAAa,CAAC;AA+B3D;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC;IACnD,IAAI,IAAI,KAAK,KAAK,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,UAAU,2CAA2C,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CAAC;IAClJ,CAAC;IACD,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,8DAA8D;YACvE,OAAO,EAAE,oFAAoF;SAC9F,CAAC,CAAC;IACL,CAAC;IACD,IAAI,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,8DAA8D,EAAE,OAAO,EAAE,yEAAyE,EAAE,CAAC,CAAC;IACrM,CAAC;IACD,IAAI,CAAC,IAAI,KAAK,MAA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AAC;IACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACnF,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,sDAAsD,EAAE,OAAO,EAAE,yDAAyD,EAAE,CAAC,CAAC;IAClL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { type ChartType, isWholeChart } from \"./option.js\";\n\n/** What a chart is about to draw, in the terms the advice needs. */\nexport interface ChartShape {\n type: ChartType;\n /** Distinct values on the x axis (or slices of a pie). */\n categories?: number;\n /** Series drawn, after any split. */\n series?: number;\n stacked?: boolean;\n /** True when a measure is on a second y scale. */\n rightAxis?: boolean;\n /** True when x is a date, time or number, so its order means something. */\n orderedX?: boolean;\n /** True when the value axis has been told to start somewhere other than zero. */\n truncatedAxis?: boolean;\n /** True when x is a numeric column grouped into bins (a histogram). */\n binned?: boolean;\n /** Where the legend was asked for, when it was; left out, the chart chooses. */\n legend?: \"top\" | \"bottom\" | \"right\" | \"none\";\n /** True when a column splits the measure (the rows of a heatmap, where a sankey's flows go). */\n split?: boolean;\n}\n\nexport interface ChartAdvice {\n rule: \"pie-slices\" | \"two-scales\" | \"bar-baseline\" | \"line-order\" | \"too-many-lines\" | \"stack-depth\" | \"bar-crowding\" | \"overlapping-areas\" | \"bars-over-time\" | \"pie-in-order\" | \"one-series-legend\" | \"sankey-needs-split\" | \"funnel-in-time\" | \"funnel-stages\" | \"heatmap-one-row\";\n message: string;\n /** What to draw instead. */\n instead: string;\n}\n\n/**\n * Checks a chart against the working rules of Edward Tufte and Stephen Few:\n * show the data honestly, compare like with like, and spend ink only on\n * data. It returns advice, not errors; a person or an agent decides.\n */\nexport function chartAdvice(shape: ChartShape): ChartAdvice[] {\n const advice: ChartAdvice[] = [];\n const { type, categories = 0, series = 1 } = shape;\n if (type === \"pie\" && categories > 5) {\n advice.push({ rule: \"pie-slices\", message: `${categories} slices are too many to compare by angle.`, instead: \"A bar chart sorted by value.\" });\n }\n if (shape.rightAxis) {\n advice.push({\n rule: \"two-scales\",\n message: \"Two y scales make heights look comparable when they are not.\",\n instead: \"Two charts stacked on the same x axis, or both measures indexed to a common start.\",\n });\n }\n if (type === \"bar\" && shape.truncatedAxis) {\n advice.push({ rule: \"bar-baseline\", message: \"A bar's length is its value, so the axis must start at zero.\", instead: \"Start at zero, or use a dot or line chart if the differences are small.\" });\n }\n if ((type === \"line\" || type === \"area\") && shape.orderedX === false) {\n advice.push({ rule: \"line-order\", message: \"A line implies order between its points; these categories have none.\", instead: \"A bar chart.\" });\n }\n if (type === \"line\" && series > 5) {\n advice.push({ rule: \"too-many-lines\", message: `${series} lines cross too often to follow.`, instead: \"Small multiples on one shared scale, or highlight one line and grey the rest.\" });\n }\n if (shape.stacked && series > 5) {\n advice.push({ rule: \"stack-depth\", message: `Only the bottom of ${series} stacked segments can be compared across bars.`, instead: \"Keep the largest four and fold the rest into Other, or use small multiples.\" });\n }\n if (type === \"bar\" && !shape.stacked && categories * series > 40) {\n advice.push({ rule: \"bar-crowding\", message: \"Too many bars to read individually.\", instead: \"The top values sorted by size, or a table.\" });\n }\n if (type === \"area\" && !shape.stacked && series > 1) {\n advice.push({ rule: \"overlapping-areas\", message: \"Unstacked areas hide each other.\", instead: \"Lines, or a stacked area if the total matters.\" });\n }\n if (type === \"bar\" && shape.orderedX && !shape.binned && categories > 24) {\n advice.push({ rule: \"bars-over-time\", message: `${categories} bars in a row hide the trend they make.`, instead: \"A line, with a time grain coarse enough for the decision.\" });\n }\n if (type === \"pie\" && shape.orderedX) {\n advice.push({ rule: \"pie-in-order\", message: \"A pie puts its slices round a circle, so the order of these values is lost.\", instead: \"A line or bars, in the order of x.\" });\n }\n if (type === \"sankey\" && shape.split === false) {\n advice.push({ rule: \"sankey-needs-split\", message: \"A sankey draws flows from x to splitBy, and has no splitBy to flow to.\", instead: \"Give splitBy the column the flows go to, or use bars.\" });\n }\n if (type === \"funnel\" && shape.orderedX) {\n advice.push({ rule: \"funnel-in-time\", message: \"A funnel is for stages of a process; dates or numbers on x are a change over time.\", instead: \"A line with a time grain.\" });\n }\n if (type === \"funnel\" && categories > 8) {\n advice.push({ rule: \"funnel-stages\", message: `${categories} stages are too many to compare in a funnel.`, instead: \"The main stages only, or bars sorted by size.\" });\n }\n if (type === \"heatmap\" && shape.split === false) {\n advice.push({ rule: \"heatmap-one-row\", message: \"A heatmap of one row shows by colour what a bar or a line shows by length, which reads more exactly.\", instead: \"Bars, or a line for a time; or give splitBy a second dimension.\" });\n }\n if (!isWholeChart(type) && series === 1 && shape.legend && shape.legend !== \"none\") {\n advice.push({ rule: \"one-series-legend\", message: \"A legend for one series repeats what the title says.\", instead: \"Leave the legend out and name the measure in the title.\" });\n }\n return advice;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A label broken onto lines no wider than `width`, at its spaces and nowhere
3
+ * else. A label with a word wider than the width is returned as it is: a word
4
+ * cut in the middle ("Ger", "man", "y") reads worse than a label left out,
5
+ * which is what the axis does with one that collides.
6
+ */
7
+ export declare function wrapLabel(text: string, width: number, measure: (text: string) => number): string;
8
+ /** The part of an ECharts instance this needs, so it can be tested without a canvas. */
9
+ export interface LabelChart {
10
+ getOption(): unknown;
11
+ convertToPixel(finder: {
12
+ xAxisIndex: number;
13
+ }, value: number): number | number[];
14
+ setOption(option: unknown): void;
15
+ }
16
+ /**
17
+ * Wraps the labels of a category x axis to the width of their bands, so each
18
+ * one shows. Without it a label wider than its band is hidden where it would
19
+ * touch its neighbour (seen: "3 products" missing between "2 products" and
20
+ * "4 products" in a narrow card). The width is known only once the chart is
21
+ * laid out, so this runs after the option is set and after each resize.
22
+ */
23
+ export declare function fitCategoryLabels(chart: LabelChart, measure?: (text: string) => number): void;
@@ -0,0 +1,82 @@
1
+ /** Air between one label and the next. */
2
+ const GAP = 8;
3
+ /**
4
+ * A label broken onto lines no wider than `width`, at its spaces and nowhere
5
+ * else. A label with a word wider than the width is returned as it is: a word
6
+ * cut in the middle ("Ger", "man", "y") reads worse than a label left out,
7
+ * which is what the axis does with one that collides.
8
+ */
9
+ export function wrapLabel(text, width, measure) {
10
+ if (measure(text) <= width)
11
+ return text;
12
+ const words = text.split(" ").filter((word) => word !== "");
13
+ if (words.length < 2 || words.some((word) => measure(word) > width))
14
+ return text;
15
+ const lines = [];
16
+ let line = "";
17
+ for (const word of words) {
18
+ const longer = line === "" ? word : `${line} ${word}`;
19
+ if (line !== "" && measure(longer) > width) {
20
+ lines.push(line);
21
+ line = word;
22
+ }
23
+ else
24
+ line = longer;
25
+ }
26
+ lines.push(line);
27
+ return lines.join("\n");
28
+ }
29
+ /** Marks the formatter this file sets, to tell it from one a caller gave through `option`. */
30
+ const OURS = Symbol("surfaces category label wrap");
31
+ /** Measures text as the axis draws it, or nothing where there is no canvas to measure with. */
32
+ function canvasMeasure(font) {
33
+ if (typeof document === "undefined")
34
+ return undefined;
35
+ let context = null;
36
+ try {
37
+ context = document.createElement("canvas").getContext("2d");
38
+ }
39
+ catch {
40
+ return undefined;
41
+ }
42
+ if (!context)
43
+ return undefined;
44
+ context.font = font;
45
+ const drawing = context;
46
+ return (text) => drawing.measureText(text).width;
47
+ }
48
+ /**
49
+ * Wraps the labels of a category x axis to the width of their bands, so each
50
+ * one shows. Without it a label wider than its band is hidden where it would
51
+ * touch its neighbour (seen: "3 products" missing between "2 products" and
52
+ * "4 products" in a narrow card). The width is known only once the chart is
53
+ * laid out, so this runs after the option is set and after each resize.
54
+ */
55
+ export function fitCategoryLabels(chart, measure) {
56
+ const option = chart.getOption();
57
+ const axis = option?.xAxis?.[0];
58
+ if (!axis || axis.type !== "category")
59
+ return;
60
+ // Past 60 points the zoom bar shows and the bands are too narrow for words.
61
+ if ((option?.dataZoom?.length ?? 0) > 0)
62
+ return;
63
+ // A formatter the caller gave through `option` is theirs to keep.
64
+ const given = axis.axisLabel?.formatter;
65
+ if (given !== undefined && given !== null && !(typeof given === "function" && OURS in given))
66
+ return;
67
+ const textStyle = Array.isArray(option?.textStyle) ? option.textStyle[0] : option?.textStyle;
68
+ const measured = measure ?? canvasMeasure(`${axis.axisLabel?.fontSize ?? 12}px ${axis.axisLabel?.fontFamily ?? textStyle?.fontFamily ?? "sans-serif"}`);
69
+ if (!measured)
70
+ return;
71
+ const at = (index) => {
72
+ const pixel = chart.convertToPixel({ xAxisIndex: 0 }, index);
73
+ return Array.isArray(pixel) ? pixel[0] : pixel;
74
+ };
75
+ const band = Math.abs(at(1) - at(0));
76
+ if (!Number.isFinite(band) || band <= GAP)
77
+ return;
78
+ const width = band - GAP;
79
+ const formatter = Object.assign((value) => wrapLabel(String(value), width, measured), { [OURS]: true });
80
+ chart.setOption({ xAxis: { axisLabel: { formatter } } });
81
+ }
82
+ //# sourceMappingURL=labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.js","sourceRoot":"","sources":["../../src/chart/labels.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,GAAG,GAAG,CAAC,CAAC;AAEd;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,OAAiC;IACtF,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;IAC5D,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACjF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,IAAI,GAAG,EAAE,CAAC;I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AAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,GAAG;QAAE,OAAO;IAClD,MAAM,KAAK,GAAG,IAAI,GAAG,GAAG,CAAC;IACzB,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACjH,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/** Air between one label and the next. */\nconst GAP = 8;\n\n/**\n * A label broken onto lines no wider than `width`, at its spaces and nowhere\n * else. A label with a word wider than the width is returned as it is: a word\n * cut in the middle (\"Ger\", \"man\", \"y\") reads worse than a label left out,\n * which is what the axis does with one that collides.\n */\nexport function wrapLabel(text: string, width: number, measure: (text: string) => number): string {\n if (measure(text) <= width) return text;\n const words = text.split(\" \").filter((word) => word !== \"\");\n if (words.length < 2 || words.some((word) => measure(word) > width)) return text;\n const lines: string[] = [];\n let line = \"\";\n for (const word of words) {\n const longer = line === \"\" ? word : `${line} ${word}`;\n if (line !== \"\" && measure(longer) > width) {\n lines.push(line);\n line = word;\n } else line = longer;\n }\n lines.push(line);\n return lines.join(\"\\n\");\n}\n\n/** The part of an ECharts instance this needs, so it can be tested without a canvas. */\nexport interface LabelChart {\n getOption(): unknown;\n convertToPixel(finder: { xAxisIndex: number }, value: number): number | number[];\n setOption(option: unknown): void;\n}\n\n/** Marks the formatter this file sets, to tell it from one a caller gave through `option`. */\nconst OURS = Symbol(\"surfaces category label wrap\");\n\ninterface DrawnOption {\n textStyle?: { fontFamily?: string } | { fontFamily?: string }[];\n dataZoom?: unknown[];\n xAxis?: { type?: string; axisLabel?: { formatter?: unknown; fontSize?: number; fontFamily?: string } }[];\n}\n\n/** Measures text as the axis draws it, or nothing where there is no canvas to measure with. */\nfunction canvasMeasure(font: string): ((text: string) => number) | undefined {\n if (typeof document === \"undefined\") return undefined;\n let context: CanvasRenderingContext2D | null = null;\n try {\n context = document.createElement(\"canvas\").getContext(\"2d\");\n } catch {\n return undefined;\n }\n if (!context) return undefined;\n context.font = font;\n const drawing = context;\n return (text) => drawing.measureText(text).width;\n}\n\n/**\n * Wraps the labels of a category x axis to the width of their bands, so each\n * one shows. Without it a label wider than its band is hidden where it would\n * touch its neighbour (seen: \"3 products\" missing between \"2 products\" and\n * \"4 products\" in a narrow card). The width is known only once the chart is\n * laid out, so this runs after the option is set and after each resize.\n */\nexport function fitCategoryLabels(chart: LabelChart, measure?: (text: string) => number): void {\n const option = chart.getOption() as DrawnOption | undefined;\n const axis = option?.xAxis?.[0];\n if (!axis || axis.type !== \"category\") return;\n // Past 60 points the zoom bar shows and the bands are too narrow for words.\n if ((option?.dataZoom?.length ?? 0) > 0) return;\n // A formatter the caller gave through `option` is theirs to keep.\n const given = axis.axisLabel?.formatter;\n if (given !== undefined && given !== null && !(typeof given === \"function\" && OURS in given)) return;\n const textStyle = Array.isArray(option?.textStyle) ? option.textStyle[0] : option?.textStyle;\n const measured = measure ?? canvasMeasure(`${axis.axisLabel?.fontSize ?? 12}px ${axis.axisLabel?.fontFamily ?? textStyle?.fontFamily ?? \"sans-serif\"}`);\n if (!measured) return;\n const at = (index: number) => {\n const pixel = chart.convertToPixel({ xAxisIndex: 0 }, index);\n return Array.isArray(pixel) ? pixel[0]! : pixel;\n };\n const band = Math.abs(at(1) - at(0));\n if (!Number.isFinite(band) || band <= GAP) return;\n const width = band - GAP;\n const formatter = Object.assign((value: unknown) => wrapLabel(String(value), width, measured), { [OURS]: true });\n chart.setOption({ xAxis: { axisLabel: { formatter } } });\n}\n"]}
@@ -1,7 +1,20 @@
1
1
  import { type Field } from "apache-arrow";
2
- export type ChartType = "bar" | "line" | "area" | "scatter" | "pie";
2
+ /**
3
+ * The basic chart types, which answer most questions and come first: bars for amounts across categories, a line or
4
+ * an area for change over time, scatter for two measures, and a pie for a few parts of a whole.
5
+ */
6
+ export declare const BASIC_CHART_TYPES: readonly ["bar", "line", "area", "scatter", "pie"];
7
+ /**
8
+ * The other chart types, for a question a basic one cannot show: a heatmap for a measure across two dimensions, a
9
+ * funnel for how much is left at each stage, a treemap for many parts of a whole, a sankey for flows from one set of
10
+ * values to another. Each draws one measure, from the same query a basic chart sends.
11
+ */
12
+ export declare const OTHER_CHART_TYPES: readonly ["heatmap", "funnel", "treemap", "sankey"];
13
+ export type ChartType = (typeof BASIC_CHART_TYPES)[number] | (typeof OTHER_CHART_TYPES)[number];
3
14
  /** How one series is drawn. A chart whose series differ is a compound chart. */
4
- export type SeriesType = Exclude<ChartType, "pie">;
15
+ export type SeriesType = "bar" | "line" | "area" | "scatter";
16
+ /** A chart drawn without x and y axes: its rows are parts, stages, cells or flows of one measure. */
17
+ export declare const isWholeChart: (type: ChartType) => boolean;
5
18
  export type LegendPlacement = "top" | "bottom" | "right" | "none";
6
19
  export interface ChartSpecSeries {
7
20
  /** Output column holding the values. */
@@ -50,6 +63,8 @@ export interface ChartOptionInput {
50
63
  * every series is a bar on one scale; otherwise it is ignored.
51
64
  */
52
65
  horizontal?: boolean;
66
+ /** The theme's sequential colours, faint to strong, for a heatmap's cells. */
67
+ ramp?: string[];
53
68
  }
54
69
  /** True when a chart of this shape can be turned on its side: bars only, on one scale. */
55
70
  export declare function canTurnSideways(type: ChartType, series: {