@surfaces-ui/components 0.6.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.
- package/NOTICE +50 -0
- package/dist/appComponents.d.ts +9 -0
- package/dist/appComponents.js +105 -1
- package/dist/appComponents.js.map +1 -1
- package/dist/brand/MovingMark.d.ts +15 -0
- package/dist/brand/MovingMark.js +52 -0
- package/dist/brand/MovingMark.js.map +1 -0
- package/dist/brand/SurfacesMark.d.ts +9 -0
- package/dist/brand/SurfacesMark.js +12 -0
- package/dist/brand/SurfacesMark.js.map +1 -0
- package/dist/brand/index.d.ts +3 -0
- package/dist/brand/index.js +3 -0
- package/dist/brand/index.js.map +1 -0
- package/dist/brand/markMotion.d.ts +29 -0
- package/dist/brand/markMotion.js +89 -0
- package/dist/brand/markMotion.js.map +1 -0
- package/dist/chart/Chart.d.ts +8 -4
- package/dist/chart/Chart.js +19 -8
- package/dist/chart/Chart.js.map +1 -1
- package/dist/chart/advice.d.ts +4 -2
- package/dist/chart/advice.js +14 -1
- package/dist/chart/advice.js.map +1 -1
- package/dist/chart/option.d.ts +17 -2
- package/dist/chart/option.js +146 -3
- package/dist/chart/option.js.map +1 -1
- package/dist/controls/ItemControls.d.ts +6 -2
- package/dist/controls/ItemControls.js +8 -3
- package/dist/controls/ItemControls.js.map +1 -1
- package/dist/controls/OutlineIcon.d.ts +9 -0
- package/dist/controls/OutlineIcon.js +12 -0
- package/dist/controls/OutlineIcon.js.map +1 -0
- package/dist/feedback/ErrorPage.d.ts +27 -0
- package/dist/feedback/ErrorPage.js +12 -0
- package/dist/feedback/ErrorPage.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/loading/ChartArt.d.ts +8 -0
- package/dist/loading/ChartArt.js +29 -0
- package/dist/loading/ChartArt.js.map +1 -0
- package/dist/loading/DraftCard.d.ts +10 -0
- package/dist/loading/DraftCard.js +38 -0
- package/dist/loading/DraftCard.js.map +1 -0
- package/dist/loading/Loading.d.ts +49 -0
- package/dist/loading/Loading.js +38 -0
- package/dist/loading/Loading.js.map +1 -0
- package/dist/locale/locale.d.ts +1 -0
- package/dist/locale/locale.js +1 -0
- package/dist/locale/locale.js.map +1 -1
- package/dist/result/QueryResult.js +2 -1
- package/dist/result/QueryResult.js.map +1 -1
- package/dist/schema/SchemaExplorer.d.ts +4 -0
- package/dist/schema/SchemaExplorer.js +46 -28
- package/dist/schema/SchemaExplorer.js.map +1 -1
- package/dist/styles.css +809 -67
- package/dist/styles.layer.css +809 -67
- package/dist/text/Markdown.js +21 -8
- package/dist/text/Markdown.js.map +1 -1
- package/dist/workspace/icons.js +2 -1
- package/dist/workspace/icons.js.map +1 -1
- package/package.json +11 -6
package/dist/chart/Chart.js.map
CHANGED
|
@@ -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,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,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I,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\";\nimport { type LabelChart, fitCategoryLabels } from \"./labels.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 // 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, 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,sBAA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AAM,YAC9E,IAAI,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,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"]}
|
package/dist/chart/advice.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
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;
|
package/dist/chart/advice.js
CHANGED
|
@@ -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
|
|
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;
|
package/dist/chart/advice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advice.js","sourceRoot":"","sources":["../../src/chart/advice.ts"],"names":[],"mappings":"
|
|
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,CAA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AE,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,oFAAoF,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC,CAAC;IAC/K,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,UAAU,8CAA8C,EAAE,OAAO,EAAE,+CAA+C,EAAE,CAAC,CAAC;IACzK,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;QAChD,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,sGAAsG,EAAE,OAAO,EAAE,iEAAiE,EAAE,CAAC,CAAC;IACxO,CAAC;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"]}
|
package/dist/chart/option.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { type Field } from "apache-arrow";
|
|
2
|
-
|
|
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 =
|
|
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: {
|
package/dist/chart/option.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { DataType } from "apache-arrow";
|
|
2
2
|
import { numberFormat } from "../locale/locale.js";
|
|
3
|
+
/**
|
|
4
|
+
* The basic chart types, which answer most questions and come first: bars for amounts across categories, a line or
|
|
5
|
+
* an area for change over time, scatter for two measures, and a pie for a few parts of a whole.
|
|
6
|
+
*/
|
|
7
|
+
export const BASIC_CHART_TYPES = ["bar", "line", "area", "scatter", "pie"];
|
|
8
|
+
/**
|
|
9
|
+
* The other chart types, for a question a basic one cannot show: a heatmap for a measure across two dimensions, a
|
|
10
|
+
* 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
|
|
11
|
+
* values to another. Each draws one measure, from the same query a basic chart sends.
|
|
12
|
+
*/
|
|
13
|
+
export const OTHER_CHART_TYPES = ["heatmap", "funnel", "treemap", "sankey"];
|
|
14
|
+
/** A chart drawn without x and y axes: its rows are parts, stages, cells or flows of one measure. */
|
|
15
|
+
export const isWholeChart = (type) => type !== "bar" && type !== "line" && type !== "area" && type !== "scatter";
|
|
3
16
|
/**
|
|
4
17
|
* An axis title sits a fixed gap beyond the tick labels, wherever they end. A gap measured from the axis line
|
|
5
18
|
* suits one width of label only: beside two-digit ticks the title ran off the chart's edge.
|
|
@@ -97,7 +110,7 @@ function endsApart(series, dataset, rows) {
|
|
|
97
110
|
* a count of the rows with no date would otherwise flatten the line of every week that has one.
|
|
98
111
|
*/
|
|
99
112
|
export function rowsWithoutX(input) {
|
|
100
|
-
if (input.type
|
|
113
|
+
if (isWholeChart(input.type))
|
|
101
114
|
return [];
|
|
102
115
|
const kinds = input.series.map((s) => s.type ?? input.type);
|
|
103
116
|
const xType = axisType(input.fields.find((f) => f.name === input.x), kinds.every((k) => k === "scatter"));
|
|
@@ -114,10 +127,12 @@ export function buildChartOption(given) {
|
|
|
114
127
|
const { type, x, splitBy } = input;
|
|
115
128
|
const xField = input.fields.find((f) => f.name === x);
|
|
116
129
|
// A date or number axis is drawn in its own order, whatever order the rows arrived in.
|
|
117
|
-
const byX = type
|
|
130
|
+
const byX = !isWholeChart(type) && isOrdered(xField) && input.sort === "value";
|
|
118
131
|
// A missing category is drawn under its own name rather than dropped from the axis.
|
|
119
|
-
const named = type
|
|
132
|
+
const named = !isWholeChart(type) && input.sort === "value" && !isOrdered(xField) ? input.rows.map((row) => (row[x] == null ? { ...row, [x]: "null" } : row)) : input.rows;
|
|
120
133
|
const rows = byX ? [...input.rows].sort((a, b) => (typeof a[x] === "number" && typeof b[x] === "number" ? a[x] - b[x] : String(a[x]).localeCompare(String(b[x])))) : named;
|
|
134
|
+
if (type === "heatmap" || type === "funnel" || type === "treemap" || type === "sankey")
|
|
135
|
+
return otherChartOption({ ...input, type, rows });
|
|
121
136
|
if (type === "pie") {
|
|
122
137
|
const measure = input.series[0];
|
|
123
138
|
return {
|
|
@@ -239,6 +254,134 @@ export function buildChartOption(given) {
|
|
|
239
254
|
series,
|
|
240
255
|
};
|
|
241
256
|
}
|
|
257
|
+
/** A value on a category axis, as a person reads it: a date for a time (the engine's buckets are UTC), else its text. */
|
|
258
|
+
function categoryName(value, field) {
|
|
259
|
+
if (value == null)
|
|
260
|
+
return "null";
|
|
261
|
+
if (typeof value === "number" && field && (DataType.isTimestamp(field.type) || DataType.isDate(field.type)))
|
|
262
|
+
return new Date(value).toISOString().slice(0, 10);
|
|
263
|
+
return String(value);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The distinct values of a column: in their own order when they have one (dates, numbers), largest first by the
|
|
267
|
+
* measure when `measure` is given, and otherwise in the order the rows give them (which the engine sorted).
|
|
268
|
+
*/
|
|
269
|
+
function valuesOf(rows, column, field, measure) {
|
|
270
|
+
const seen = [...new Map(rows.map((row) => [row[column] ?? null, row[column] ?? null])).values()];
|
|
271
|
+
if (isOrdered(field))
|
|
272
|
+
return seen.sort((a, b) => (typeof a === "number" && typeof b === "number" ? a - b : String(a).localeCompare(String(b))));
|
|
273
|
+
if (!measure)
|
|
274
|
+
return seen;
|
|
275
|
+
const order = categoriesBySize(rows, column, measure);
|
|
276
|
+
return seen.sort((a, b) => order.indexOf(String(a ?? "null")) - order.indexOf(String(b ?? "null")));
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* The option for a chart drawn without axes, from one measure (the first series): a heatmap (x across, `splitBy`
|
|
280
|
+
* down, the measure as colour on the theme's sequential ramp), a funnel (x as stages), a treemap (x as parts, grouped
|
|
281
|
+
* by `splitBy` when given) or a sankey (flows from x to `splitBy`, which it needs).
|
|
282
|
+
*/
|
|
283
|
+
function otherChartOption(input) {
|
|
284
|
+
const { type, x, splitBy, rows } = input;
|
|
285
|
+
const measure = input.series[0];
|
|
286
|
+
const format = tooltipFormatter(input.yFormat);
|
|
287
|
+
const xField = input.fields.find((f) => f.name === x);
|
|
288
|
+
const splitField = splitBy ? input.fields.find((f) => f.name === splitBy) : undefined;
|
|
289
|
+
const value = (row) => (measure ? row[measure.column] : null);
|
|
290
|
+
const name = measure?.label ?? "";
|
|
291
|
+
if (!measure)
|
|
292
|
+
return { series: [] };
|
|
293
|
+
if (type === "heatmap") {
|
|
294
|
+
// Weekdays, hours and the like keep the order the rows give them; by size only when asked for.
|
|
295
|
+
const bySize = input.sort === "value" ? measure.column : undefined;
|
|
296
|
+
const across = valuesOf(rows, x, xField, bySize);
|
|
297
|
+
const down = splitBy ? valuesOf(rows, splitBy, splitField, bySize) : [null];
|
|
298
|
+
const at = (list, v) => list.findIndex((item) => item === (v ?? null));
|
|
299
|
+
const data = rows.map((row) => [at(across, row[x] ?? null), splitBy ? at(down, row[splitBy] ?? null) : 0, value(row)]);
|
|
300
|
+
const numbers = rows.map((row) => Number(value(row))).filter((n) => Number.isFinite(n));
|
|
301
|
+
const cells = across.length * down.length;
|
|
302
|
+
return {
|
|
303
|
+
useUTC: true,
|
|
304
|
+
tooltip: { trigger: "item", valueFormatter: format },
|
|
305
|
+
grid: { left: 8, right: 16, top: 16, bottom: 56, outerBoundsMode: "same", outerBoundsContain: "all" },
|
|
306
|
+
xAxis: { type: "category", data: across.map((v) => categoryName(v, xField)), name: input.xTitle, nameLocation: "middle", ...TITLE_CLEAR, splitArea: { show: false }, axisLabel: { hideOverlap: true } },
|
|
307
|
+
yAxis: { type: "category", data: down.map((v) => (splitBy ? categoryName(v, splitField) : name)), inverse: true, name: input.yTitle, nameLocation: "middle", ...TITLE_CLEAR, axisLabel: { hideOverlap: true } },
|
|
308
|
+
visualMap: {
|
|
309
|
+
type: "continuous",
|
|
310
|
+
min: numbers.length ? Math.min(0, ...numbers) : 0,
|
|
311
|
+
max: numbers.length ? Math.max(...numbers) : 1,
|
|
312
|
+
orient: "horizontal",
|
|
313
|
+
left: "center",
|
|
314
|
+
bottom: 0,
|
|
315
|
+
itemHeight: 120,
|
|
316
|
+
calculable: false,
|
|
317
|
+
formatter: (v) => axisFormatter(input.yFormat)(v),
|
|
318
|
+
...(input.ramp?.length ? { inRange: { color: input.ramp } } : {}),
|
|
319
|
+
},
|
|
320
|
+
series: [{ type: "heatmap", name, data, label: { show: cells <= 48, formatter: (p) => axisFormatter(input.yFormat)(Number(p.value[2])) }, emphasis: { itemStyle: { borderWidth: 1 } } }],
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
if (type === "funnel") {
|
|
324
|
+
return {
|
|
325
|
+
tooltip: { trigger: "item", valueFormatter: format },
|
|
326
|
+
legend: { show: false },
|
|
327
|
+
series: [
|
|
328
|
+
{
|
|
329
|
+
type: "funnel",
|
|
330
|
+
name,
|
|
331
|
+
// One measure, so one colour: a colour per stage would only decorate.
|
|
332
|
+
colorBy: "series",
|
|
333
|
+
// Largest at the top, as stages narrow; "x" keeps the stages in the order the rows give them.
|
|
334
|
+
sort: input.sort === "x" ? "none" : "descending",
|
|
335
|
+
left: "10%",
|
|
336
|
+
width: "80%",
|
|
337
|
+
top: 8,
|
|
338
|
+
bottom: 8,
|
|
339
|
+
minSize: "2%",
|
|
340
|
+
gap: 2,
|
|
341
|
+
label: { show: true, position: "inside", formatter: "{b}" },
|
|
342
|
+
data: rows.map((row) => ({ name: categoryName(row[x] ?? null, xField), value: value(row) })),
|
|
343
|
+
},
|
|
344
|
+
],
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
if (type === "treemap") {
|
|
348
|
+
const leaf = (row) => ({ name: categoryName(row[x] ?? null, xField), value: value(row) });
|
|
349
|
+
const data = splitBy
|
|
350
|
+
? valuesOf(rows, splitBy, splitField, measure.column).map((group) => ({ name: categoryName(group, splitField), children: rows.filter((row) => (row[splitBy] ?? null) === group).map(leaf) }))
|
|
351
|
+
: rows.map(leaf);
|
|
352
|
+
return {
|
|
353
|
+
tooltip: { trigger: "item", valueFormatter: format },
|
|
354
|
+
series: [
|
|
355
|
+
{
|
|
356
|
+
type: "treemap",
|
|
357
|
+
name,
|
|
358
|
+
roam: false,
|
|
359
|
+
nodeClick: false,
|
|
360
|
+
breadcrumb: { show: false },
|
|
361
|
+
top: 0,
|
|
362
|
+
left: 0,
|
|
363
|
+
right: 0,
|
|
364
|
+
bottom: 0,
|
|
365
|
+
label: { show: true, formatter: "{b}" },
|
|
366
|
+
upperLabel: { show: !!splitBy, height: 20 },
|
|
367
|
+
data,
|
|
368
|
+
},
|
|
369
|
+
],
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
// A sankey: each row a flow from its x to its split value. Without a split there is nothing to flow to.
|
|
373
|
+
if (!splitBy)
|
|
374
|
+
return { series: [] };
|
|
375
|
+
const links = rows
|
|
376
|
+
.map((row) => ({ source: categoryName(row[x] ?? null, xField), target: categoryName(row[splitBy] ?? null, splitField), value: Number(value(row)) }))
|
|
377
|
+
// A flow from a value to itself, or of nothing, cannot be drawn.
|
|
378
|
+
.filter((link) => link.source !== link.target && Number.isFinite(link.value) && link.value > 0);
|
|
379
|
+
const nodes = [...new Set(links.flatMap((link) => [link.source, link.target]))].map((n) => ({ name: n }));
|
|
380
|
+
return {
|
|
381
|
+
tooltip: { trigger: "item", valueFormatter: format },
|
|
382
|
+
series: [{ type: "sankey", name, left: 8, right: 96, top: 8, bottom: 8, nodeGap: 10, emphasis: { focus: "adjacency" }, lineStyle: { color: "gradient", curveness: 0.5, opacity: 0.4 }, label: { show: true }, data: nodes, links }],
|
|
383
|
+
};
|
|
384
|
+
}
|
|
242
385
|
/** A round bin width that splits [min, max] into about `bins` bins. */
|
|
243
386
|
export function niceBinWidth(min, max, bins) {
|
|
244
387
|
const span = max - min;
|