derive-dashboards 0.7.1 → 0.9.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/CHANGELOG.md +513 -0
- package/README.md +8 -2
- package/dist/adapter/statement.mjs +9 -7
- package/dist/authorize.mjs +27 -6
- package/dist/body.mjs +28 -25
- package/dist/cache.d.mts +2 -2
- package/dist/charts/data/buckets.d.mts +25 -7
- package/dist/charts/data/buckets.mjs +92 -15
- package/dist/charts/data/clean.mjs +254 -12
- package/dist/charts/data/format.d.mts +7 -2
- package/dist/charts/data/format.mjs +68 -70
- package/dist/charts/data/input-error.d.mts +2 -0
- package/dist/charts/data/input-error.mjs +2 -0
- package/dist/charts/data/rows.d.mts +3 -1
- package/dist/charts/data/rows.mjs +4 -2
- package/dist/charts/data/types.d.mts +50 -7
- package/dist/charts/data/words.d.mts +13 -0
- package/dist/charts/data/words.mjs +8 -1
- package/dist/charts/describe.mjs +6 -6
- package/dist/charts/index.d.mts +14 -14
- package/dist/charts/index.mjs +4 -1
- package/dist/charts/kinds/area-marks.mjs +86 -44
- package/dist/charts/kinds/area.d.mts +3 -3
- package/dist/charts/kinds/area.mjs +32 -11
- package/dist/charts/kinds/bars-data.d.mts +3 -3
- package/dist/charts/kinds/bars-data.mjs +12 -6
- package/dist/charts/kinds/bars-layout.mjs +60 -6
- package/dist/charts/kinds/bars-marks.mjs +6 -6
- package/dist/charts/kinds/bars.d.mts +5 -3
- package/dist/charts/kinds/bars.mjs +39 -6
- package/dist/charts/kinds/columns-data.mjs +14 -5
- package/dist/charts/kinds/columns-marks.mjs +52 -23
- package/dist/charts/kinds/columns.d.mts +2 -2
- package/dist/charts/kinds/columns.mjs +36 -10
- package/dist/charts/kinds/course-data.mjs +44 -0
- package/dist/charts/kinds/course-layout.mjs +77 -0
- package/dist/charts/kinds/course-marks.mjs +52 -0
- package/dist/charts/kinds/course-words.mjs +64 -0
- package/dist/charts/kinds/course.d.mts +10 -0
- package/dist/charts/kinds/course.mjs +55 -0
- package/dist/charts/kinds/dumbbell-data.d.mts +4 -4
- package/dist/charts/kinds/dumbbell-data.mjs +3 -3
- package/dist/charts/kinds/dumbbell-layout.mjs +17 -8
- package/dist/charts/kinds/dumbbell.d.mts +5 -3
- package/dist/charts/kinds/dumbbell.mjs +35 -4
- package/dist/charts/kinds/funnel-data.d.mts +3 -3
- package/dist/charts/kinds/funnel-data.mjs +11 -16
- package/dist/charts/kinds/funnel-layout.mjs +7 -6
- package/dist/charts/kinds/funnel.d.mts +5 -4
- package/dist/charts/kinds/funnel.mjs +33 -6
- package/dist/charts/kinds/grid-data.d.mts +3 -3
- package/dist/charts/kinds/grid-data.mjs +55 -13
- package/dist/charts/kinds/grid-layout.mjs +88 -13
- package/dist/charts/kinds/grid-legend.mjs +60 -0
- package/dist/charts/kinds/grid-marks.mjs +81 -32
- package/dist/charts/kinds/grid-time.mjs +19 -5
- package/dist/charts/kinds/grid-words.mjs +57 -35
- package/dist/charts/kinds/grid.d.mts +7 -4
- package/dist/charts/kinds/grid.mjs +51 -9
- package/dist/charts/kinds/histogram-data.mjs +68 -26
- package/dist/charts/kinds/histogram-layout.mjs +4 -3
- package/dist/charts/kinds/histogram-words.mjs +2 -3
- package/dist/charts/kinds/histogram.d.mts +2 -2
- package/dist/charts/kinds/histogram.mjs +17 -1
- package/dist/charts/kinds/line-marks.mjs +19 -11
- package/dist/charts/kinds/line.d.mts +2 -2
- package/dist/charts/kinds/line.mjs +21 -3
- package/dist/charts/kinds/multiples-grid.mjs +57 -27
- package/dist/charts/kinds/multiples-head.mjs +52 -22
- package/dist/charts/kinds/multiples-layout.mjs +106 -52
- package/dist/charts/kinds/multiples-marks.mjs +6 -5
- package/dist/charts/kinds/multiples-words.mjs +53 -38
- package/dist/charts/kinds/multiples.d.mts +2 -2
- package/dist/charts/kinds/multiples.mjs +35 -7
- package/dist/charts/kinds/row-chart.d.mts +7 -0
- package/dist/charts/kinds/row-chart.mjs +47 -10
- package/dist/charts/kinds/row-marks.mjs +5 -5
- package/dist/charts/kinds/scatter-data.d.mts +5 -5
- package/dist/charts/kinds/scatter-data.mjs +6 -6
- package/dist/charts/kinds/scatter-marks.mjs +46 -19
- package/dist/charts/kinds/scatter-words.mjs +8 -8
- package/dist/charts/kinds/scatter.d.mts +5 -3
- package/dist/charts/kinds/scatter.mjs +18 -0
- package/dist/charts/kinds/stat-data.mjs +7 -7
- package/dist/charts/kinds/stat-marks.mjs +2 -2
- package/dist/charts/kinds/stat.d.mts +4 -4
- package/dist/charts/kinds/stat.mjs +19 -0
- package/dist/charts/kinds/time-chart.mjs +13 -4
- package/dist/charts/kinds/time-frame.mjs +50 -19
- package/dist/charts/kinds/time-plan.mjs +29 -2
- package/dist/charts/kinds/time-plot.mjs +1 -1
- package/dist/charts/kinds/time-stops.mjs +58 -29
- package/dist/charts/kinds/waterfall-data.d.mts +3 -3
- package/dist/charts/kinds/waterfall-data.mjs +2 -2
- package/dist/charts/kinds/waterfall.d.mts +5 -4
- package/dist/charts/kinds/waterfall.mjs +29 -2
- package/dist/charts/layout/frame.mjs +5 -3
- package/dist/charts/layout/stack.mjs +43 -22
- package/dist/charts/marks/axes.mjs +12 -6
- package/dist/charts/marks/budget.mjs +14 -0
- package/dist/charts/marks/end-labels.mjs +24 -10
- package/dist/charts/marks/legend.mjs +19 -8
- package/dist/charts/marks/lines.mjs +3 -3
- package/dist/charts/marks/more.mjs +79 -13
- package/dist/charts/marks/notes.mjs +12 -6
- package/dist/charts/marks/series-line.mjs +14 -10
- package/dist/charts/marks/thin.mjs +16 -33
- package/dist/charts/marks/x-axis.mjs +3 -2
- package/dist/charts/scale/calendar.mjs +41 -26
- package/dist/charts/scale/linear.mjs +58 -0
- package/dist/charts/scale/value.d.mts +21 -0
- package/dist/charts/scale/value.mjs +67 -9
- package/dist/charts/scene/lazy.mjs +27 -0
- package/dist/charts/scene/markup.mjs +2 -1
- package/dist/charts/scene/svg.mjs +20 -8
- package/dist/charts/scene/types.d.mts +34 -0
- package/dist/charts/text/measure.mjs +33 -3
- package/dist/charts/theme.d.mts +25 -25
- package/dist/charts/theme.mjs +47 -30
- package/dist/charts-react/Chart.d.mts +20 -0
- package/dist/charts-react/Chart.mjs +9 -67
- package/dist/charts-react/Reader.mjs +50 -96
- package/dist/charts-react/box.mjs +106 -0
- package/dist/charts-react/bucket-names.mjs +9 -24
- package/dist/charts-react/columns-picture.mjs +12 -0
- package/dist/charts-react/exact-sum.mjs +4 -7
- package/dist/charts-react/from-answer.mjs +9 -4
- package/dist/charts-react/index.d.mts +9 -2
- package/dist/charts-react/index.mjs +9 -2
- package/dist/charts-react/kinds/area.d.mts +4 -0
- package/dist/charts-react/kinds/area.mjs +38 -0
- package/dist/charts-react/kinds/bar.d.mts +4 -0
- package/dist/charts-react/kinds/bar.mjs +15 -0
- package/dist/charts-react/kinds/funnel.d.mts +4 -0
- package/dist/charts-react/kinds/funnel.mjs +13 -0
- package/dist/charts-react/kinds/heatmap.d.mts +4 -0
- package/dist/charts-react/kinds/heatmap.mjs +13 -0
- package/dist/charts-react/kinds/line.d.mts +4 -0
- package/dist/charts-react/kinds/line.mjs +20 -0
- package/dist/charts-react/kinds/multiples.d.mts +4 -0
- package/dist/charts-react/kinds/multiples.mjs +33 -0
- package/dist/charts-react/kinds/number.d.mts +5 -0
- package/dist/charts-react/kinds/number.mjs +86 -0
- package/dist/charts-react/plan-bars.mjs +15 -8
- package/dist/charts-react/plan-funnel.mjs +3 -1
- package/dist/charts-react/plan-grid.mjs +14 -5
- package/dist/charts-react/plan-of.mjs +17 -0
- package/dist/charts-react/plan-parts.mjs +16 -5
- package/dist/charts-react/plan-time.mjs +4 -53
- package/dist/charts-react/reader-page.d.mts +1 -1
- package/dist/charts-react/reader-page.mjs +19 -9
- package/dist/charts-react/renderers.d.mts +14 -0
- package/dist/charts-react/renderers.mjs +22 -0
- package/dist/charts-react/table.d.mts +1 -0
- package/dist/charts-react/table.mjs +108 -0
- package/dist/charts-react/tiles.mjs +21 -49
- package/dist/charts-react/useScene.mjs +45 -17
- package/dist/charts-react/words.mjs +19 -0
- package/dist/checks.mjs +97 -19
- package/dist/cli/add.mjs +4 -3
- package/dist/cli/doctor.mjs +2 -2
- package/dist/core/conformance/index.d.mts +5 -2
- package/dist/core/conformance/index.mjs +5 -2
- package/dist/core/conformance/memory/aggregate.mjs +11 -6
- package/dist/core/conformance/memory/rows.d.mts +7 -3
- package/dist/core/conformance/memory/rows.mjs +19 -13
- package/dist/core/conformance/memory/source.mjs +4 -4
- package/dist/core/document/control-fields.d.mts +20 -0
- package/dist/core/document/control-fields.mjs +117 -0
- package/dist/core/document/display-comparisons.d.mts +17 -0
- package/dist/core/document/display-comparisons.mjs +15 -4
- package/dist/core/document/display-entries.d.mts +14 -0
- package/dist/core/document/display-entries.mjs +25 -9
- package/dist/core/document/display-validation.d.mts +5 -1
- package/dist/core/document/display-validation.mjs +14 -7
- package/dist/core/document/display.d.mts +11 -8
- package/dist/core/document/display.mjs +26 -3
- package/dist/core/document/layout.d.mts +8 -9
- package/dist/core/document/layout.mjs +23 -6
- package/dist/core/document/stacked.d.mts +0 -7
- package/dist/core/document/types.mjs +8 -6
- package/dist/core/document/upgrade.d.mts +1 -0
- package/dist/core/document/upgrade.mjs +4 -2
- package/dist/core/engine/access.mjs +3 -3
- package/dist/core/engine/assert.mjs +4 -2
- package/dist/core/engine/bucket.mjs +2 -2
- package/dist/core/engine/checks.mjs +6 -7
- package/dist/core/engine/custom/ask.mjs +22 -2
- package/dist/core/engine/custom/cells.mjs +22 -22
- package/dist/core/engine/custom/level.mjs +12 -13
- package/dist/core/engine/custom/measures.mjs +12 -9
- package/dist/core/engine/custom/reader.mjs +3 -1
- package/dist/core/engine/custom/records.mjs +8 -7
- package/dist/core/engine/custom/unread.mjs +78 -0
- package/dist/core/engine/custom/where.mjs +15 -10
- package/dist/core/engine/index.d.mts +2 -13
- package/dist/core/engine/index.mjs +2 -12
- package/dist/core/engine/measure.mjs +1 -0
- package/dist/core/engine/members.mjs +7 -3
- package/dist/core/engine/nan.mjs +10 -1
- package/dist/core/engine/native.mjs +2 -20
- package/dist/core/engine/numbers.mjs +26 -14
- package/dist/core/engine/postgres.mjs +9 -5
- package/dist/core/engine/prepare.mjs +4 -4
- package/dist/core/engine/rank-sets.mjs +1 -1
- package/dist/core/engine/read.mjs +5 -4
- package/dist/core/engine/reader.d.mts +6 -0
- package/dist/core/engine/record-layout.mjs +3 -3
- package/dist/core/engine/run.mjs +77 -20
- package/dist/core/engine/segmented.d.mts +2 -1
- package/dist/core/engine/segmented.mjs +19 -12
- package/dist/core/engine/series.mjs +1 -1
- package/dist/core/engine/shape.mjs +8 -8
- package/dist/core/engine/sql-partition.mjs +2 -2
- package/dist/core/engine/sql-pass.mjs +3 -2
- package/dist/core/engine/sql-reader.mjs +13 -5
- package/dist/core/engine/sql-reads.mjs +2 -1
- package/dist/core/engine/sql-records.mjs +2 -2
- package/dist/core/engine/sql-split.mjs +1 -1
- package/dist/core/engine/sql-unread.mjs +70 -0
- package/dist/core/engine/time.mjs +2 -1
- package/dist/core/engine/types.d.mts +17 -0
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +24 -1
- package/dist/core/error/codes.mjs +23 -3
- package/dist/core/error/refusal.d.mts +8 -3
- package/dist/core/error/refusal.mjs +6 -1
- package/dist/core/exact/decimal.d.mts +1 -14
- package/dist/core/exact/decimal.mjs +9 -19
- package/dist/core/exact/stored.d.mts +9 -0
- package/dist/core/exact/stored.mjs +38 -0
- package/dist/core/exact/text.d.mts +16 -1
- package/dist/core/exact/text.mjs +50 -1
- package/dist/core/format/digits.mjs +55 -0
- package/dist/core/format/index.d.mts +16 -0
- package/dist/core/format/index.mjs +27 -0
- package/dist/core/format/number.d.mts +27 -0
- package/dist/core/format/number.mjs +158 -0
- package/dist/core/format/write.d.mts +6 -0
- package/dist/core/format/write.mjs +57 -0
- package/dist/core/index.d.mts +43 -33
- package/dist/core/index.mjs +31 -28
- package/dist/core/model/defaults.d.mts +18 -1
- package/dist/core/model/defaults.mjs +19 -1
- package/dist/core/model/define.d.mts +17 -8
- package/dist/core/model/define.mjs +2 -0
- package/dist/core/model/member.d.mts +5 -3
- package/dist/core/model/member.mjs +33 -6
- package/dist/core/model/storage.mjs +40 -12
- package/dist/core/model/types.d.mts +17 -1
- package/dist/core/model/types.mjs +5 -0
- package/dist/core/model/validate/expr.d.mts +1 -7
- package/dist/core/model/validate/fields.d.mts +2 -0
- package/dist/core/model/validate/fields.mjs +14 -7
- package/dist/core/model/validate/issues.mjs +5 -1
- package/dist/core/model/validate/known-members.mjs +6 -5
- package/dist/core/model/validate/shape.mjs +36 -3
- package/dist/core/model/validate/source.mjs +2 -2
- package/dist/core/oracle/data.d.mts +4 -2
- package/dist/core/oracle/evaluate.d.mts +19 -1
- package/dist/core/oracle/evaluate.mjs +56 -10
- package/dist/core/oracle/expr.mjs +1 -1
- package/dist/core/oracle/facts.mjs +12 -5
- package/dist/core/oracle/measure.mjs +1 -1
- package/dist/core/oracle/request.mjs +39 -4
- package/dist/core/oracle/segmented.d.mts +3 -1
- package/dist/core/oracle/segmented.mjs +19 -13
- package/dist/core/oracle/unread.mjs +32 -0
- package/dist/core/oracle/visibility.mjs +4 -3
- package/dist/core/policy/bind.d.mts +2 -11
- package/dist/core/policy/bind.mjs +1 -1
- package/dist/core/policy/match.mjs +1 -1
- package/dist/core/query/closure.d.mts +7 -2
- package/dist/core/query/closure.mjs +29 -12
- package/dist/core/query/compose-tile.d.mts +3 -2
- package/dist/core/query/compose-tile.mjs +32 -13
- package/dist/core/query/compose.d.mts +0 -5
- package/dist/core/query/drill/internal.d.mts +5 -5
- package/dist/core/query/drill/internal.mjs +11 -0
- package/dist/core/query/drill/links.d.mts +2 -3
- package/dist/core/query/drill/links.mjs +18 -4
- package/dist/core/query/drill/selection.d.mts +8 -2
- package/dist/core/query/drill/selection.mjs +14 -3
- package/dist/core/query/drill/synthetic.mjs +1 -1
- package/dist/core/query/drill/time.mjs +11 -10
- package/dist/core/query/filter.d.mts +1 -6
- package/dist/core/query/filter.mjs +1 -4
- package/dist/core/query/fold.mjs +23 -0
- package/dist/core/query/segments.mjs +42 -3
- package/dist/core/query/to-wire.d.mts +7 -0
- package/dist/core/query/to-wire.mjs +14 -2
- package/dist/core/query/types.d.mts +30 -13
- package/dist/core/result/columns.mjs +23 -13
- package/dist/core/result/number.mjs +3 -3
- package/dist/core/result/status.d.mts +13 -0
- package/dist/core/result/status.mjs +18 -0
- package/dist/core/result/time-axis.d.mts +14 -13
- package/dist/core/result/time-axis.mjs +20 -2
- package/dist/core/result/types.d.mts +33 -3
- package/dist/core/result/whole.d.mts +23 -0
- package/dist/core/result/whole.mjs +27 -0
- package/dist/core/schema/agent-query.d.mts +89 -0
- package/dist/core/schema/agent-query.mjs +115 -0
- package/dist/core/schema/aliases.mjs +1 -52
- package/dist/core/schema/answer-parts.mjs +17 -13
- package/dist/core/schema/answers.d.mts +787 -319
- package/dist/core/schema/commands.d.mts +33 -23
- package/dist/core/schema/commands.mjs +26 -18
- package/dist/core/schema/custom.mjs +46 -45
- package/dist/core/schema/document.d.mts +32 -27
- package/dist/core/schema/document.mjs +61 -81
- package/dist/core/schema/drill-answers.mjs +4 -1
- package/dist/core/schema/drill.d.mts +14 -9
- package/dist/core/schema/drill.mjs +23 -22
- package/dist/core/schema/index.d.mts +5 -3
- package/dist/core/schema/index.mjs +5 -3
- package/dist/core/schema/options.d.mts +92 -0
- package/dist/core/schema/options.mjs +104 -0
- package/dist/core/schema/picks.d.mts +2 -2
- package/dist/core/schema/picks.mjs +7 -6
- package/dist/core/schema/query.d.mts +9 -83
- package/dist/core/schema/query.mjs +49 -73
- package/dist/core/schema/strict.d.mts +3 -0
- package/dist/core/schema/strict.mjs +91 -0
- package/dist/core/schema/union-error.mjs +30 -7
- package/dist/core/schema/view.d.mts +4 -3
- package/dist/core/schema/view.mjs +16 -11
- package/dist/core/store/ddl.d.mts +0 -2
- package/dist/core/store/ddl.mjs +1 -5
- package/dist/core/time/bucket.d.mts +1 -18
- package/dist/core/time/bucket.mjs +12 -8
- package/dist/core/time/compare.mjs +3 -2
- package/dist/core/time/index.d.mts +7 -8
- package/dist/core/time/instant.d.mts +15 -9
- package/dist/core/time/instant.mjs +23 -9
- package/dist/core/time/range.d.mts +3 -15
- package/dist/core/time/range.mjs +17 -7
- package/dist/core/time/stored.d.mts +8 -5
- package/dist/core/time/stored.mjs +51 -15
- package/dist/core/time/temporal.d.mts +1 -5
- package/dist/core/time/temporal.mjs +9 -4
- package/dist/core/time/text-time.d.mts +31 -2
- package/dist/core/time/text-time.mjs +139 -22
- package/dist/core/time/zone.d.mts +6 -1
- package/dist/core/time/zone.mjs +13 -4
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/dashboard.d.mts +185 -0
- package/dist/core/types/dashboard.mjs +26 -0
- package/dist/core/types/drill-api.d.mts +14 -2
- package/dist/core/types/infer.d.mts +0 -4
- package/dist/core/types/options-check.d.mts +42 -0
- package/dist/core/types/options-check.mjs +90 -0
- package/dist/core/types/options.d.mts +14 -8
- package/dist/core/value/casefold.d.mts +1 -3
- package/dist/core/value/stored.d.mts +26 -0
- package/dist/core/value/stored.mjs +28 -0
- package/dist/cursor-seal.mjs +37 -9
- package/dist/dashboard-documents.d.mts +14 -6
- package/dist/dashboard-documents.mjs +32 -12
- package/dist/dashboards.mjs +10 -9
- package/dist/drill-access.mjs +6 -6
- package/dist/drill-change.mjs +18 -20
- package/dist/drill-comparison.mjs +2 -1
- package/dist/drill-crumbs.mjs +63 -28
- package/dist/drill-distinct.mjs +2 -1
- package/dist/drill-explain.mjs +1 -1
- package/dist/drill-items.mjs +1 -1
- package/dist/drill-open.mjs +39 -23
- package/dist/drill-seal.mjs +41 -13
- package/dist/drill-share.mjs +1 -1
- package/dist/drill-summary.mjs +2 -1
- package/dist/drill-targets.mjs +4 -4
- package/dist/drill-views.mjs +4 -3
- package/dist/drill.mjs +1 -1
- package/dist/editing.mjs +5 -3
- package/dist/endpoints/index.d.mts +29 -8
- package/dist/endpoints/index.mjs +4 -1
- package/dist/endpoints/meta.mjs +4 -3
- package/dist/endpoints/query.mjs +5 -2
- package/dist/endpoints/read.mjs +7 -6
- package/dist/endpoints/versions.mjs +2 -1
- package/dist/execute.d.mts +3 -0
- package/dist/execute.mjs +23 -12
- package/dist/grant.d.mts +9 -0
- package/dist/grant.mjs +43 -0
- package/dist/handler.mjs +8 -13
- package/dist/http.d.mts +6 -2
- package/dist/http.mjs +6 -2
- package/dist/index.d.mts +25 -4
- package/dist/index.mjs +91 -40
- package/dist/llms.txt +3 -3
- package/dist/mcp/api.mjs +2 -1
- package/dist/mcp/query.mjs +3 -8
- package/dist/mcp/resolve.mjs +9 -2
- package/dist/node/index.d.mts +36 -0
- package/dist/node/index.mjs +89 -0
- package/dist/node/request.d.mts +12 -0
- package/dist/node/request.mjs +119 -0
- package/dist/node/response.mjs +58 -0
- package/dist/principal.mjs +15 -7
- package/dist/react/Canvas.mjs +90 -69
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +15 -1
- package/dist/react/Dashboard.mjs +43 -42
- package/dist/react/DashboardList.mjs +9 -4
- package/dist/react/Editing.d.mts +9 -0
- package/dist/react/Editing.mjs +8 -3
- package/dist/react/Grid.mjs +1 -1
- package/dist/react/Header.mjs +25 -52
- package/dist/react/History.mjs +3 -2
- package/dist/react/LoadFailed.mjs +59 -0
- package/dist/react/Panel.d.mts +1 -1
- package/dist/react/Panel.mjs +1 -1
- package/dist/react/Parts.d.mts +34 -0
- package/dist/react/Parts.mjs +9 -6
- package/dist/react/ReviewPanel.mjs +1 -1
- package/dist/react/RowBody.d.mts +2 -0
- package/dist/react/RowBody.mjs +5 -1
- package/dist/react/Share.mjs +153 -0
- package/dist/react/TabStrip.mjs +37 -0
- package/dist/react/Tile.d.mts +3 -1
- package/dist/react/Tile.mjs +89 -92
- package/dist/react/TileState.mjs +117 -0
- package/dist/react/ago.mjs +45 -0
- package/dist/react/arrange.mjs +1 -1
- package/dist/react/board.mjs +2 -2
- package/dist/react/bucket-name.d.mts +8 -0
- package/dist/react/bucket-name.mjs +13 -0
- package/dist/react/builder/DisplayOptions.mjs +219 -0
- package/dist/react/builder/Preview.mjs +13 -13
- package/dist/react/builder/RangeEditor.mjs +4 -3
- package/dist/react/builder/WidgetBuilder.d.mts +1 -7
- package/dist/react/builder/WidgetBuilder.mjs +12 -3
- package/dist/react/builder/base.d.mts +13 -2
- package/dist/react/builder/base.mjs +70 -12
- package/dist/react/builder/display.d.mts +3 -0
- package/dist/react/builder/display.mjs +256 -0
- package/dist/react/builder/labels.mjs +19 -5
- package/dist/react/builder/options.mjs +11 -6
- package/dist/react/builder/state.mjs +25 -3
- package/dist/react/builder/useBuilder.d.mts +7 -1
- package/dist/react/builder/useBuilder.mjs +6 -9
- package/dist/react/builder/usePreview.mjs +3 -2
- package/dist/react/builder/words.d.mts +16 -1
- package/dist/react/builder/words.mjs +41 -1
- package/dist/react/change-text.mjs +149 -0
- package/dist/react/client.d.mts +9 -0
- package/dist/react/client.mjs +105 -14
- package/dist/react/columns.mjs +9 -1
- package/dist/react/context.d.mts +24 -3
- package/dist/react/context.mjs +23 -7
- package/dist/react/dates-shown.mjs +76 -0
- package/dist/react/draft.mjs +3 -2
- package/dist/react/drill/Bars.mjs +12 -16
- package/dist/react/drill/Comparison.mjs +1 -1
- package/dist/react/drill/DrillPanel.d.mts +1 -1
- package/dist/react/drill/DrillPanel.mjs +2 -1
- package/dist/react/drill/Header.mjs +65 -12
- package/dist/react/drill/Items.d.mts +1 -1
- package/dist/react/drill/Notes.mjs +10 -7
- package/dist/react/drill/PanelStates.mjs +8 -1
- package/dist/react/drill/Trend.mjs +10 -5
- package/dist/react/drill/board.d.mts +1 -1
- package/dist/react/drill/board.mjs +1 -0
- package/dist/react/drill/host.mjs +4 -1
- package/dist/react/drill/lazy.mjs +2 -27
- package/dist/react/drill/props.d.mts +19 -8
- package/dist/react/drill/props.mjs +62 -18
- package/dist/react/drill/state.d.mts +15 -5
- package/dist/react/drill/state.mjs +12 -3
- package/dist/react/drill/words.d.mts +46 -3
- package/dist/react/drill/words.mjs +30 -5
- package/dist/react/english.mjs +33 -8
- package/dist/react/export/ExportButton.mjs +4 -1
- package/dist/react/export/csv.d.mts +7 -2
- package/dist/react/export/csv.mjs +24 -7
- package/dist/react/failure-words.mjs +60 -0
- package/dist/react/filters/bar.d.mts +1 -1
- package/dist/react/filters/bar.mjs +4 -1
- package/dist/react/filters/calendar.mjs +23 -8
- package/dist/react/filters/chip.mjs +7 -3
- package/dist/react/filters/context.d.mts +13 -1
- package/dist/react/filters/context.mjs +1 -1
- package/dist/react/filters/dates-said.mjs +57 -0
- package/dist/react/filters/days.d.mts +3 -4
- package/dist/react/filters/days.mjs +10 -17
- package/dist/react/filters/hooks.d.mts +11 -0
- package/dist/react/filters/hooks.mjs +10 -6
- package/dist/react/filters/menu-search.mjs +17 -9
- package/dist/react/filters/menu.mjs +10 -8
- package/dist/react/filters/phone.mjs +41 -16
- package/dist/react/filters/place.mjs +40 -0
- package/dist/react/filters/popover.mjs +18 -13
- package/dist/react/filters/rules.d.mts +4 -3
- package/dist/react/filters/rules.mjs +3 -3
- package/dist/react/filters/sheet.mjs +7 -3
- package/dist/react/filters/state.mjs +6 -1
- package/dist/react/filters/values.mjs +24 -7
- package/dist/react/filters/words.d.mts +13 -0
- package/dist/react/filters/words.mjs +5 -0
- package/dist/react/format-time.d.mts +17 -6
- package/dist/react/format-time.mjs +152 -33
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +35 -122
- package/dist/react/headline.d.mts +12 -0
- package/dist/react/headline.mjs +107 -0
- package/dist/react/index.d.mts +20 -17
- package/dist/react/index.mjs +13 -10
- package/dist/react/lazy.mjs +38 -0
- package/dist/react/messages.d.mts +78 -2
- package/dist/react/now.mjs +38 -0
- package/dist/react/place.mjs +4 -2
- package/dist/react/read.d.mts +1 -0
- package/dist/react/read.mjs +140 -9
- package/dist/react/renderers/exact.mjs +31 -59
- package/dist/react/renderers/index.d.mts +27 -6
- package/dist/react/renderers/index.mjs +154 -92
- package/dist/react/renderers/list-parts.mjs +24 -0
- package/dist/react/renderers/list.d.mts +1 -0
- package/dist/react/renderers/list.mjs +99 -43
- package/dist/react/renderers/more-rows.mjs +75 -0
- package/dist/react/renderers/number-before.mjs +320 -0
- package/dist/react/renderers/number-period.mjs +54 -0
- package/dist/react/renderers/number-whole.mjs +29 -0
- package/dist/react/renderers/props.d.mts +24 -1
- package/dist/react/renderers/props.mjs +8 -0
- package/dist/react/renderers/table-cells.mjs +137 -31
- package/dist/react/renderers/table-fit.mjs +55 -10
- package/dist/react/renderers/table-measure.mjs +29 -9
- package/dist/react/renderers/table-row.mjs +14 -9
- package/dist/react/renderers/table-scale.mjs +2 -3
- package/dist/react/renderers/table-sort.mjs +3 -2
- package/dist/react/renderers/table-whole.mjs +37 -0
- package/dist/react/renderers/table.mjs +73 -53
- package/dist/react/review.d.mts +7 -0
- package/dist/react/review.mjs +35 -8
- package/dist/react/roving.d.mts +6 -0
- package/dist/react/roving.mjs +123 -0
- package/dist/react/says-dates.d.mts +7 -0
- package/dist/react/says-dates.mjs +51 -0
- package/dist/react/series.mjs +5 -6
- package/dist/react/stable.mjs +1 -1
- package/dist/react/tabs/EditTabs.mjs +125 -0
- package/dist/react/tabs/NameField.mjs +72 -0
- package/dist/react/tabs/TabMenu.mjs +175 -0
- package/dist/react/tabs/actions.mjs +37 -0
- package/dist/react/tabs/commands.mjs +76 -0
- package/dist/react/tabs/focus.mjs +22 -0
- package/dist/react/tabs/keys.mjs +28 -0
- package/dist/react/theme-unlayered.css +1 -1
- package/dist/react/theme.css +1 -1
- package/dist/react/tile-store.d.mts +4 -0
- package/dist/react/tile-store.mjs +93 -13
- package/dist/react/touch.d.mts +16 -0
- package/dist/react/touch.mjs +39 -0
- package/dist/react/useBoard.d.mts +6 -0
- package/dist/react/useBoard.mjs +1 -0
- package/dist/react/useDashboard.d.mts +2 -0
- package/dist/react/useDashboard.mjs +5 -2
- package/dist/react/useTiles.d.mts +3 -0
- package/dist/react/useTiles.mjs +73 -17
- package/dist/react/view-grid.mjs +2 -2
- package/dist/react/view.mjs +1 -1
- package/dist/recharts/axes.mjs +1 -1
- package/dist/recharts/axis.mjs +23 -73
- package/dist/recharts/bar.d.mts +2 -1
- package/dist/recharts/bar.mjs +140 -64
- package/dist/recharts/fit.mjs +33 -0
- package/dist/recharts/line.mjs +23 -17
- package/dist/recharts/marks.mjs +2 -1
- package/dist/recharts/parts.mjs +19 -14
- package/dist/recharts/table.mjs +8 -3
- package/dist/refusal.mjs +46 -0
- package/dist/registry/filter-bar.json +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +25 -9
- package/dist/tile-doc.mjs +1 -1
- package/package.json +21 -6
- package/dist/charts-react/plan.d.mts +0 -3
- package/dist/charts-react/plan.mjs +0 -37
- package/dist/charts-react/tiles.d.mts +0 -24
- package/dist/core/policy/match.d.mts +0 -16
- package/dist/core/schema/aliases.d.mts +0 -7
- package/dist/core/time/compare.d.mts +0 -30
- package/dist/react/EditBar.d.mts +0 -16
- package/dist/react/History.d.mts +0 -30
- package/dist/react/ReviewPanel.d.mts +0 -15
- package/dist/react/digits.mjs +0 -46
- package/dist/react/drill/trend-touch.mjs +0 -33
- package/dist/react/renderers/exact.d.mts +0 -6
|
@@ -3,10 +3,10 @@ import { arrowed, changeWritten, movedAsWritten } from "../data/format.mjs";
|
|
|
3
3
|
import { ranked } from "../data/rows.mjs";
|
|
4
4
|
// src/kinds/dumbbell-data.ts
|
|
5
5
|
/** The rows as they can be drawn: an end that is not a finite number is missing. */
|
|
6
|
-
const cleaned = (rows) => rows.map((row) => ({
|
|
6
|
+
const cleaned = (rows) => rows.map((row, i) => ({
|
|
7
7
|
...row,
|
|
8
|
-
from: drawable(row.from),
|
|
9
|
-
to: drawable(row.to)
|
|
8
|
+
from: drawable(row.from, "rows[#].from", i),
|
|
9
|
+
to: drawable(row.to, "rows[#].to", i)
|
|
10
10
|
}));
|
|
11
11
|
/** A row's change, from then to now; nothing when an end is missing. */
|
|
12
12
|
const changeOf = (row) => row.from === null || row.to === null ? null : row.to - row.from;
|
|
@@ -60,16 +60,17 @@ function keyOver(options, env) {
|
|
|
60
60
|
measure: env.measure
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
+
/** A dumbbell's rows: under its key when it has one, over the axis that gives the scale. */
|
|
64
|
+
const rowRule = (options, key) => ({
|
|
65
|
+
header: options,
|
|
66
|
+
above: key?.height ?? 0,
|
|
67
|
+
below: X_ROOM
|
|
68
|
+
});
|
|
63
69
|
/** Where the rows go under a key of this height, and where a value sits along a row. */
|
|
64
70
|
function arranged(rows, options, at) {
|
|
65
71
|
const { env } = at;
|
|
66
|
-
const above = at.legend?.height ?? 0;
|
|
67
72
|
const labels = rows.map((r) => r.label);
|
|
68
|
-
const frame = rowFrame(labels,
|
|
69
|
-
header: options,
|
|
70
|
-
above,
|
|
71
|
-
below: X_ROOM
|
|
72
|
-
}, env);
|
|
73
|
+
const frame = rowFrame(labels, rowRule(options, at.legend), env);
|
|
73
74
|
const { written, reach } = reachFor(rows, frame, {
|
|
74
75
|
says: options,
|
|
75
76
|
env
|
|
@@ -108,6 +109,14 @@ function layoutOf(rows, options, env) {
|
|
|
108
109
|
env,
|
|
109
110
|
legend: keyOver(options, env)
|
|
110
111
|
});
|
|
111
|
-
|
|
112
|
+
if (hasRoom(keyed.frame, keyed.reach, true)) return keyed;
|
|
113
|
+
const unkeyed = arranged(rows, options, { env });
|
|
114
|
+
return {
|
|
115
|
+
...unkeyed,
|
|
116
|
+
frame: {
|
|
117
|
+
...unkeyed.frame,
|
|
118
|
+
natural: keyed.frame.natural
|
|
119
|
+
}
|
|
120
|
+
};
|
|
112
121
|
}
|
|
113
|
-
export { DOT_REACH, layoutOf };
|
|
122
|
+
export { DOT_REACH, keyOver, layoutOf, rowRule };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Env, Header } from "../data/types.mjs";
|
|
1
|
+
import { Env, Header, ValueIn } from "../data/types.mjs";
|
|
2
2
|
import { Scene } from "../scene/types.mjs";
|
|
3
|
-
import { DumbbellRow, DumbbellSort } from "./dumbbell-data.mjs";
|
|
3
|
+
import { DumbbellRow as DumbbellRow$1, DumbbellSort } from "./dumbbell-data.mjs";
|
|
4
4
|
import { Wording } from "./dumbbell-words.mjs";
|
|
5
|
+
/** A row of a dumbbell as a host gives it: each end a number, decimal text, or null. */
|
|
6
|
+
export type DumbbellRow<V extends ValueIn = ValueIn> = DumbbellRow$1<V>;
|
|
5
7
|
/** A dumbbell's words (its measure, the names of its two ends, its points), and how it is drawn. */
|
|
6
8
|
export type DumbbellOptions = Header & Wording & {
|
|
7
9
|
/** By the value now, largest first (the default), by the change, or in the order given. */
|
|
@@ -11,4 +13,4 @@ export type DumbbellOptions = Header & Wording & {
|
|
|
11
13
|
};
|
|
12
14
|
/** Each thing's value then and now, as a dot and a dot joined by the change. */
|
|
13
15
|
export declare function dumbbellChart(rows: readonly DumbbellRow[], options: DumbbellOptions, env: Env): Scene;
|
|
14
|
-
export type {
|
|
16
|
+
export type { DumbbellSort };
|
|
@@ -1,15 +1,42 @@
|
|
|
1
|
+
import { HEADER, checkInput, keysOf } from "../data/clean.mjs";
|
|
1
2
|
import { bare, headerNodes } from "../layout/frame.mjs";
|
|
2
3
|
import { seriesPaint } from "../theme.mjs";
|
|
4
|
+
import { leftOf, leftOut } from "../marks/more.mjs";
|
|
3
5
|
import { rowsMore } from "./row-marks.mjs";
|
|
4
|
-
import { cleaned, ordered } from "./dumbbell-data.mjs";
|
|
5
|
-
import { layoutOf } from "./dumbbell-layout.mjs";
|
|
6
|
+
import { anyValue, cleaned, ordered } from "./dumbbell-data.mjs";
|
|
7
|
+
import { keyOver, layoutOf, rowRule } from "./dumbbell-layout.mjs";
|
|
6
8
|
import { axisNodes, rowNodes } from "./dumbbell-marks.mjs";
|
|
7
9
|
import { describeDumbbell, stopOf } from "./dumbbell-words.mjs";
|
|
8
|
-
import { hasRoom } from "./row-chart.mjs";
|
|
10
|
+
import { hasRoom, sizingOf, wantsOf } from "./row-chart.mjs";
|
|
9
11
|
// src/kinds/dumbbell.ts
|
|
12
|
+
/** The keys dumbbellChart takes: any other is refused, with the one it most likely meant. */
|
|
13
|
+
const KEYS = keysOf({
|
|
14
|
+
...HEADER,
|
|
15
|
+
measure: true,
|
|
16
|
+
points: true,
|
|
17
|
+
fromLabel: true,
|
|
18
|
+
toLabel: true,
|
|
19
|
+
sort: true,
|
|
20
|
+
slot: true
|
|
21
|
+
});
|
|
10
22
|
/** Each thing's value then and now, as a dot and a dot joined by the change. */
|
|
11
23
|
function dumbbellChart(rows, options, env) {
|
|
24
|
+
checkInput({
|
|
25
|
+
what: "rows",
|
|
26
|
+
data: rows
|
|
27
|
+
}, options, env, {
|
|
28
|
+
known: KEYS,
|
|
29
|
+
needs: [
|
|
30
|
+
"measure",
|
|
31
|
+
"fromLabel",
|
|
32
|
+
"toLabel"
|
|
33
|
+
]
|
|
34
|
+
});
|
|
12
35
|
const all = ordered(cleaned(rows), options.sort ?? "value");
|
|
36
|
+
if (env.sizing === true) return sizingOf(env, rowRule(options, keyOver(options, env)), {
|
|
37
|
+
count: all.length,
|
|
38
|
+
drawn: anyValue(all)
|
|
39
|
+
});
|
|
13
40
|
const layout = layoutOf(all, options, env);
|
|
14
41
|
const { frame, plot, x, kept, zero } = layout;
|
|
15
42
|
const roomy = hasRoom(frame, layout.reach, layout.drawn);
|
|
@@ -35,11 +62,15 @@ function dumbbellChart(rows, options, env) {
|
|
|
35
62
|
slot,
|
|
36
63
|
nodes: rowNodes(row, slot, at)
|
|
37
64
|
}));
|
|
65
|
+
const left = leftOut(all, kept);
|
|
38
66
|
return {
|
|
39
67
|
width: env.width,
|
|
40
68
|
height: env.height,
|
|
41
69
|
plot,
|
|
70
|
+
natural: frame.natural,
|
|
42
71
|
summary,
|
|
72
|
+
...leftOf(left),
|
|
73
|
+
...wantsOf(frame),
|
|
43
74
|
nodes: [
|
|
44
75
|
...headerNodes(env, options),
|
|
45
76
|
...layout.legend?.nodes ?? [],
|
|
@@ -48,7 +79,7 @@ function dumbbellChart(rows, options, env) {
|
|
|
48
79
|
env
|
|
49
80
|
}),
|
|
50
81
|
...placed.flatMap(({ nodes }) => nodes),
|
|
51
|
-
...rowsMore(
|
|
82
|
+
...rowsMore(left, {
|
|
52
83
|
frame,
|
|
53
84
|
env,
|
|
54
85
|
y: layout.moreY
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Named } from "../data/rows.mjs";
|
|
2
|
-
import { Value } from "../data/types.mjs";
|
|
2
|
+
import { Value, ValueIn } from "../data/types.mjs";
|
|
3
3
|
/** A step of a funnel: how many reached it. */
|
|
4
|
-
export type FunnelStep = Named & {
|
|
5
|
-
value:
|
|
4
|
+
export type FunnelStep<V extends ValueIn = Value> = Named & {
|
|
5
|
+
value: V;
|
|
6
6
|
/**
|
|
7
7
|
* The value as the host writes it, when it has its own text for it (an exact amount keeps
|
|
8
8
|
* every digit a float would lose); the measure's text when left out.
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import { drawable } from "../data/clean.mjs";
|
|
2
|
-
import { orderAsWritten,
|
|
1
|
+
import { drawable, finiteOrNone, writtenOf } from "../data/clean.mjs";
|
|
2
|
+
import { orderAsWritten, said, topAsWritten } from "../data/format.mjs";
|
|
3
3
|
// src/kinds/funnel-data.ts
|
|
4
4
|
/** A step's value as it is written: the host's own text for it, else the measure's. */
|
|
5
5
|
const stepText = (step, measure) => said(step.text) ?? (step.value === null ? "" : measure.text(step.value));
|
|
6
6
|
/**
|
|
7
|
-
* A share as a funnel writes it. A share that is not nothing is never written as nothing: three
|
|
8
|
-
* of a million who went on are "<0.1%", not "0%", which would say that no one did.
|
|
9
|
-
*/
|
|
10
|
-
function sharePercent(locale) {
|
|
11
|
-
const percent = percentText(locale);
|
|
12
|
-
const least = `<${percent(.001)}`;
|
|
13
|
-
return (share) => share > 0 && percent(share) === percent(0) ? least : percent(share);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
7
|
* The steps as they can be drawn. A value that is not finite is missing. So is a negative one:
|
|
17
8
|
* a count of people cannot be below zero, so it is a fault upstream, not a number to draw or say.
|
|
9
|
+
* A value given as decimal text is written with every digit.
|
|
18
10
|
*/
|
|
19
|
-
const cleaned = (steps) => steps.map((step) => {
|
|
20
|
-
const value = drawable(step.value);
|
|
11
|
+
const cleaned = (steps, measure) => steps.map((step, i) => {
|
|
12
|
+
const value = drawable(step.value, "steps[#].value", i);
|
|
13
|
+
const drawn = value !== null && value >= 0 ? value : null;
|
|
14
|
+
const text = drawn === null ? void 0 : step.text ?? writtenOf(step.value, measure);
|
|
21
15
|
return {
|
|
22
16
|
...step,
|
|
23
|
-
value:
|
|
17
|
+
value: drawn,
|
|
18
|
+
...text === void 0 ? {} : { text }
|
|
24
19
|
};
|
|
25
20
|
});
|
|
26
21
|
/**
|
|
@@ -30,7 +25,7 @@ const cleaned = (steps) => steps.map((step) => {
|
|
|
30
25
|
function ratio(part, whole) {
|
|
31
26
|
if (part === null || whole === void 0 || whole === null || whole <= 0) return null;
|
|
32
27
|
const quotient = part / whole;
|
|
33
|
-
return quotient === 0 && part > 0 ? Number.MIN_VALUE :
|
|
28
|
+
return quotient === 0 && part > 0 ? Number.MIN_VALUE : finiteOrNone(quotient);
|
|
34
29
|
}
|
|
35
30
|
/**
|
|
36
31
|
* The step that lost the most: the lowest rate, when it is written below 100% and the step's
|
|
@@ -67,4 +62,4 @@ function flowOf(values, at) {
|
|
|
67
62
|
}
|
|
68
63
|
/** Which way a rate went, as its percent reads: down when fewer went on, none at 100%. */
|
|
69
64
|
const rateWay = (rate, percent) => orderAsWritten(rate, 1, percent);
|
|
70
|
-
export { cleaned, flowOf, rateWay,
|
|
65
|
+
export { cleaned, flowOf, rateWay, stepText };
|
|
@@ -5,14 +5,15 @@ import { ROW, barThick, reachOf, rowFrame, rowPlot } from "./row-chart.mjs";
|
|
|
5
5
|
// src/kinds/funnel-layout.ts
|
|
6
6
|
/** The room between two bars that hold the share that went on between them: a line of small words. */
|
|
7
7
|
const TALKING = LINE.tick;
|
|
8
|
+
/** A funnel's rows: a row may grow by the room the words between two bars take, past a bar row's most. */
|
|
9
|
+
const rowRule = (options) => ({
|
|
10
|
+
header: options,
|
|
11
|
+
most: ROW.most + TALKING - ROW.between
|
|
12
|
+
});
|
|
8
13
|
/** Where the steps go and which of them are drawn. */
|
|
9
14
|
function layoutOf(steps, options, env) {
|
|
10
15
|
const values = steps.flatMap((s) => s.value === null ? [] : [s.value]);
|
|
11
|
-
const
|
|
12
|
-
const frame = rowFrame(steps.map((s) => s.label), {
|
|
13
|
-
header: options,
|
|
14
|
-
most
|
|
15
|
-
}, env);
|
|
16
|
+
const frame = rowFrame(steps.map((s) => s.label), rowRule(options), env);
|
|
16
17
|
const written = steps.filter((s) => s.value !== null).map((s) => stepText(s, options.measure));
|
|
17
18
|
const reach = reachOf(frame, written, { env });
|
|
18
19
|
const talks = barThick(frame.rowHeight, TALKING) >= barThick(ROW.least);
|
|
@@ -29,4 +30,4 @@ function layoutOf(steps, options, env) {
|
|
|
29
30
|
plot: rowPlot(frame, reach, kept.length)
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
export { layoutOf };
|
|
33
|
+
export { layoutOf, rowRule };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Env, Header, Measure } from "../data/types.mjs";
|
|
1
|
+
import { Env, Header, Measure, ValueIn } from "../data/types.mjs";
|
|
2
2
|
import { Scene } from "../scene/types.mjs";
|
|
3
|
-
import { FunnelStep } from "./funnel-data.mjs";
|
|
3
|
+
import { FunnelStep as FunnelStep$1 } from "./funnel-data.mjs";
|
|
4
|
+
/** A step of a funnel as a host gives it: its value a number, decimal text, or null. */
|
|
5
|
+
export type FunnelStep<V extends ValueIn = ValueIn> = FunnelStep$1<V>;
|
|
4
6
|
export type FunnelOptions = Header & {
|
|
5
7
|
measure: Measure;
|
|
6
8
|
/** The palette place of the bars' colour. */
|
|
7
9
|
slot?: number;
|
|
8
10
|
};
|
|
9
11
|
/** A funnel of steps in order, each read against the first and the one before it. */
|
|
10
|
-
export declare function funnelChart(given: readonly FunnelStep[], options: FunnelOptions, env: Env): Scene;
|
|
11
|
-
export type { FunnelStep };
|
|
12
|
+
export declare function funnelChart(given: readonly FunnelStep[], options: FunnelOptions, env: Env): Scene;
|
|
@@ -1,17 +1,40 @@
|
|
|
1
|
+
import { HEADER, checkInput, keysOf } from "../data/clean.mjs";
|
|
2
|
+
import { percentText } from "../data/format.mjs";
|
|
1
3
|
import { bare, headerNodes } from "../layout/frame.mjs";
|
|
2
4
|
import { seriesPaint } from "../theme.mjs";
|
|
5
|
+
import { leftOf, leftOut } from "../marks/more.mjs";
|
|
3
6
|
import { rowsMore, rowsZero } from "./row-marks.mjs";
|
|
4
|
-
import { cleaned, flowOf
|
|
5
|
-
import { layoutOf } from "./funnel-layout.mjs";
|
|
7
|
+
import { cleaned, flowOf } from "./funnel-data.mjs";
|
|
8
|
+
import { layoutOf, rowRule } from "./funnel-layout.mjs";
|
|
6
9
|
import { rateNodes, ratesWritten, rowNodes } from "./funnel-marks.mjs";
|
|
7
10
|
import { describeFunnel, stopOf } from "./funnel-words.mjs";
|
|
8
|
-
import { hasRoom } from "./row-chart.mjs";
|
|
11
|
+
import { hasRoom, sizingOf, wantsOf } from "./row-chart.mjs";
|
|
9
12
|
// src/kinds/funnel.ts
|
|
13
|
+
/** The keys funnelChart takes: any other is refused, with the one it most likely meant. */
|
|
14
|
+
const KEYS = keysOf({
|
|
15
|
+
...HEADER,
|
|
16
|
+
measure: true,
|
|
17
|
+
slot: true
|
|
18
|
+
});
|
|
10
19
|
/** A funnel of steps in order, each read against the first and the one before it. */
|
|
11
20
|
function funnelChart(given, options, env) {
|
|
21
|
+
checkInput({
|
|
22
|
+
what: "steps",
|
|
23
|
+
data: given
|
|
24
|
+
}, options, env, {
|
|
25
|
+
known: KEYS,
|
|
26
|
+
needs: ["measure"]
|
|
27
|
+
});
|
|
12
28
|
const { measure } = options;
|
|
13
|
-
const steps = cleaned(given);
|
|
14
|
-
|
|
29
|
+
const steps = cleaned(given, measure);
|
|
30
|
+
if (env.sizing === true) {
|
|
31
|
+
const drawn = steps.some((step) => step.value !== null);
|
|
32
|
+
return sizingOf(env, rowRule(options), {
|
|
33
|
+
count: steps.length,
|
|
34
|
+
drawn
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const percent = percentText(env.locale);
|
|
15
38
|
const flow = flowOf(steps.map((s) => s.value), {
|
|
16
39
|
measure,
|
|
17
40
|
percent
|
|
@@ -45,11 +68,15 @@ function funnelChart(given, options, env) {
|
|
|
45
68
|
slot,
|
|
46
69
|
nodes: rowNodes(step, slot, at)
|
|
47
70
|
}));
|
|
71
|
+
const left = leftOut(steps, kept);
|
|
48
72
|
return {
|
|
49
73
|
width: env.width,
|
|
50
74
|
height: env.height,
|
|
51
75
|
plot,
|
|
76
|
+
natural: frame.natural,
|
|
52
77
|
summary,
|
|
78
|
+
...leftOf(left),
|
|
79
|
+
...wantsOf(frame),
|
|
53
80
|
nodes: [
|
|
54
81
|
...headerNodes(env, options),
|
|
55
82
|
...placed.flatMap(({ slot, nodes }) => [...rateNodes(slot, at), ...nodes]),
|
|
@@ -58,7 +85,7 @@ function funnelChart(given, options, env) {
|
|
|
58
85
|
x: layout.x,
|
|
59
86
|
plot
|
|
60
87
|
}),
|
|
61
|
-
...rowsMore(
|
|
88
|
+
...rowsMore(left, {
|
|
62
89
|
frame,
|
|
63
90
|
env
|
|
64
91
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Named } from "../data/rows.mjs";
|
|
2
|
-
import { Value } from "../data/types.mjs";
|
|
3
|
-
export type GridData = {
|
|
2
|
+
import { Value, ValueIn } from "../data/types.mjs";
|
|
3
|
+
export type GridData<V extends ValueIn = Value> = {
|
|
4
4
|
/** The rows and the columns, each by its label and, when two may share one, its key. */
|
|
5
5
|
rows: readonly Named[];
|
|
6
6
|
/** How neighbouring time buckets were averaged across the grid, when applicable. */
|
|
@@ -9,7 +9,7 @@ export type GridData = {
|
|
|
9
9
|
note?: string;
|
|
10
10
|
})[];
|
|
11
11
|
/** `values[row][column]`. */
|
|
12
|
-
values: readonly (readonly
|
|
12
|
+
values: readonly (readonly V[])[];
|
|
13
13
|
/**
|
|
14
14
|
* `texts[row][column]`: a value as the host writes it, where it has its own text for it (an
|
|
15
15
|
* exact amount keeps every digit a float would lose); the measure's text where left out.
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
import { drawable, finiteRange } from "../data/clean.mjs";
|
|
2
|
-
import {
|
|
1
|
+
import { drawable, finiteRange, readValues } from "../data/clean.mjs";
|
|
2
|
+
import { said } from "../data/format.mjs";
|
|
3
|
+
import { ChartInputError } from "../data/input-error.mjs";
|
|
4
|
+
import { fractionAlong } from "../data/range.mjs";
|
|
3
5
|
// src/kinds/grid-data.ts
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* A cell's value as it is written in full: the host's own text for it, else the measure's. The
|
|
8
|
+
* one writer of a cell for its stop, its row of the table and its number on the picture where
|
|
9
|
+
* that has room.
|
|
10
|
+
*/
|
|
11
|
+
const cellText = (data, measure, at) => said(data.texts?.[at.row]?.[at.column]) ?? measure.text(at.value);
|
|
12
|
+
/**
|
|
13
|
+
* The grid as it can be drawn: a value that is not a finite number is none, and one given as
|
|
14
|
+
* decimal text is written with every digit.
|
|
15
|
+
*/
|
|
16
|
+
function cleaned(data, measure) {
|
|
17
|
+
const { rows, columns, values } = data;
|
|
18
|
+
if (values.length !== rows.length) throw new ChartInputError("values", `Expected a list of values for each of the ${String(rows.length)} rows.`);
|
|
19
|
+
for (const [r, row] of values.entries()) if (row.length > columns.length) throw new ChartInputError(`values[${String(r)}]`, `Expected at most ${String(columns.length)} values, one a column.`);
|
|
20
|
+
const read = values.map((row, r) => readValues(row, (v, c) => drawable(v, "values[#][#]", r, c), {
|
|
21
|
+
measure,
|
|
22
|
+
texts: data.texts?.[r]
|
|
23
|
+
}));
|
|
24
|
+
const texts = read.some((row) => row.texts !== void 0) ? { texts: read.map((row, r) => row.texts ?? data.texts?.[r] ?? []) } : {};
|
|
25
|
+
return {
|
|
26
|
+
...data,
|
|
27
|
+
values: read.map((row) => row.values),
|
|
28
|
+
...texts
|
|
29
|
+
};
|
|
30
|
+
}
|
|
9
31
|
/**
|
|
10
32
|
* How dark a value's cell is, from 0 to 1 across the range given, else the data's own. A range
|
|
11
33
|
* of one value (every cell alike, or one cell) is opened from zero to it, as a value axis opens
|
|
@@ -16,20 +38,40 @@ function shadeOf(from, to) {
|
|
|
16
38
|
const fraction = fractionAlong(low, high);
|
|
17
39
|
return (value) => Math.max(0, Math.min(1, fraction(value)));
|
|
18
40
|
}
|
|
19
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The least and the most of a grid's values, read once each with no list made of them: a grid's
|
|
43
|
+
* height is asked before every layout, and its legend's room is part of the answer.
|
|
44
|
+
*/
|
|
45
|
+
function endsOf(values) {
|
|
46
|
+
let low = Number.POSITIVE_INFINITY;
|
|
47
|
+
let high = Number.NEGATIVE_INFINITY;
|
|
48
|
+
for (const row of values) for (const value of row) {
|
|
49
|
+
if (value === null) continue;
|
|
50
|
+
low = Math.min(low, value);
|
|
51
|
+
high = Math.max(high, value);
|
|
52
|
+
}
|
|
53
|
+
return [low, high];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* How a grid is shaded: how dark each value is, whether below zero takes a second hue (a shared
|
|
57
|
+
* zero and equal strength at equal distances from it on a mixed-sign heatmap), and the ends of
|
|
58
|
+
* the range the shade runs between, which its legend writes.
|
|
59
|
+
*/
|
|
20
60
|
function colorsOf(data, range, diverging = false) {
|
|
21
|
-
const
|
|
22
|
-
const [low, high] =
|
|
61
|
+
const ends = finiteRange(range) ?? endsOf(data.values);
|
|
62
|
+
const [low, high] = ends;
|
|
23
63
|
if (diverging && low < 0 && high > 0) {
|
|
24
64
|
const magnitude = Math.max(-low, high);
|
|
25
65
|
return {
|
|
26
66
|
mixed: true,
|
|
27
|
-
shade: (value) => Math.min(1, Math.abs(value) / magnitude)
|
|
67
|
+
shade: (value) => Math.min(1, Math.abs(value) / magnitude),
|
|
68
|
+
ends
|
|
28
69
|
};
|
|
29
70
|
}
|
|
30
71
|
return {
|
|
31
72
|
mixed: false,
|
|
32
|
-
shade: shadeOf(low, high)
|
|
73
|
+
shade: shadeOf(low, high),
|
|
74
|
+
ends
|
|
33
75
|
};
|
|
34
76
|
}
|
|
35
|
-
export { cleaned, colorsOf };
|
|
77
|
+
export { cellText, cleaned, colorsOf };
|
|
@@ -1,29 +1,103 @@
|
|
|
1
1
|
import { keyOf, pairKey } from "../data/rows.mjs";
|
|
2
|
+
import { shapesFor } from "../marks/budget.mjs";
|
|
2
3
|
import { widest } from "../text/measure.mjs";
|
|
3
|
-
import { LINE, MARK, TEXT } from "../theme.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { LINE, MARK, SPACE, TEXT } from "../theme.mjs";
|
|
5
|
+
import { cellText, colorsOf } from "./grid-data.mjs";
|
|
6
|
+
import { namesWidth, rowFrame, rowPlot } from "./row-chart.mjs";
|
|
5
7
|
// src/kinds/grid-layout.ts
|
|
6
8
|
/** The room the column names take over the cells: a line of them, and the grid's own gap under it. */
|
|
7
9
|
const HEAD = LINE.tick + 6;
|
|
8
10
|
/** A row is this tall at most. */
|
|
9
11
|
const TALLEST = 30;
|
|
12
|
+
/** The legend's ramp: how wide and how tall it is, and how many steps of shade it is made of. */
|
|
13
|
+
const RAMP = {
|
|
14
|
+
width: 96,
|
|
15
|
+
height: 6,
|
|
16
|
+
steps: 5
|
|
17
|
+
};
|
|
18
|
+
/** The room the legend takes under the rows: the gap over it, and its line. */
|
|
19
|
+
const LEGEND = SPACE.under + LINE.tick;
|
|
10
20
|
/** The room a cell keeps around its number, across and down. */
|
|
11
21
|
const INSET = {
|
|
12
22
|
across: 6,
|
|
13
23
|
down: 4
|
|
14
24
|
};
|
|
15
|
-
/** Whether a cell's number fits inside it. */
|
|
16
|
-
const fits = (
|
|
17
|
-
/**
|
|
18
|
-
function
|
|
25
|
+
/** Whether a cell's number, so written, fits inside it. */
|
|
26
|
+
const fits = (text, cell, env) => env.measure(text, TEXT.value) <= cell.box.width - INSET.across && cell.box.height >= TEXT.value.size + INSET.down;
|
|
27
|
+
/** How the cells' numbers are written: the first way every one of them fits. */
|
|
28
|
+
function writing(filled, data, measure, env) {
|
|
29
|
+
const full = (cell) => cellText(data, measure, cell);
|
|
30
|
+
const short = (cell) => measure.tick(cell.value);
|
|
31
|
+
return [full, short].find((write) => filled.every((cell) => fits(write(cell), cell, env)));
|
|
32
|
+
}
|
|
33
|
+
/** No more rows than the picture's mark budget has cells for, since a row draws a cell a column. */
|
|
34
|
+
const capOf = (data, env) => Math.max(1, Math.floor(shapesFor(env.width) / Math.max(1, data.columns.length)));
|
|
35
|
+
/** The room the sizes take beside the row names, with the gap after them: none without sizes. */
|
|
36
|
+
function sizesOf(options, env) {
|
|
37
|
+
const sized = options.sizes === void 0 ? [] : [...options.sizes, options.sizeTitle ?? ""];
|
|
38
|
+
return sized.length === 0 ? 0 : Math.ceil(widest(sized, TEXT.name, env.measure)) + 14;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The range's two ends as a legend writes them: short, as an axis tick is, or in full where
|
|
42
|
+
* short they read alike (1,001 and 1,004 are both "1K"). None when they are one value, or read
|
|
43
|
+
* alike even in full: a ramp between two of the same number says nothing.
|
|
44
|
+
*/
|
|
45
|
+
function endsWritten(ends, measure) {
|
|
46
|
+
if (!(ends[0] < ends[1])) return void 0;
|
|
47
|
+
return [measure.tick, measure.text].map((write) => [write(ends[0]), write(ends[1])]).find(([low, high]) => low !== high);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* How much of the legend the picture has room for: its numbers and ramp, then the measure's
|
|
51
|
+
* name; nothing when even the numbers do not fit its whole width, or the range's ends are one
|
|
52
|
+
* value or read alike even in full (`endsWritten`). It starts under the cells' left edge where
|
|
53
|
+
* that leaves it room, and at the picture's own edge where long row names leave none: a grid
|
|
54
|
+
* whose cells are too small for their numbers is read by its legend alone. The room beside
|
|
55
|
+
* the names is judged with the names of every row the grid has cells for, as at the height it
|
|
56
|
+
* asks for: fewer rows drawn only narrow the names, so the height it asks for does not turn on
|
|
57
|
+
* the height it is given.
|
|
58
|
+
*/
|
|
59
|
+
function legendFit(options, data, env, ends = colorsOf(data, options.range, options.diverging).ends) {
|
|
60
|
+
const { label } = options.measure;
|
|
61
|
+
const words = endsWritten(ends, options.measure);
|
|
62
|
+
if (words === void 0) return void 0;
|
|
63
|
+
const [low, high] = words;
|
|
64
|
+
const rows = data.rows.slice(0, capOf(data, env)).map((row) => row.label);
|
|
65
|
+
const names = namesWidth([...rows, ...options.rowTitle === void 0 ? [] : [options.rowTitle]], env);
|
|
66
|
+
const beside = env.width - names - SPACE.names - sizesOf(options, env);
|
|
67
|
+
const wide = (text = "") => env.measure(text, TEXT.tick) + SPACE.value;
|
|
68
|
+
const numbers = wide(low) + RAMP.width + wide(high);
|
|
69
|
+
if (numbers > env.width) return void 0;
|
|
70
|
+
const named = numbers + wide(label) <= env.width;
|
|
71
|
+
return {
|
|
72
|
+
ends,
|
|
73
|
+
words,
|
|
74
|
+
named,
|
|
75
|
+
edge: (named ? numbers + wide(label) : numbers) > beside
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A grid's rows: the columns' names over them (and the word over those, when given), a cell no
|
|
80
|
+
* taller than reads as one, the legend under them when it fits, and no more rows than the
|
|
81
|
+
* mark budget has cells for.
|
|
82
|
+
*/
|
|
83
|
+
const rowRule = (options, data, env, legend = legendFit(options, data, env)) => ({
|
|
84
|
+
header: options,
|
|
85
|
+
above: HEAD + (options.columnTitle === void 0 ? 0 : LINE.tick),
|
|
86
|
+
below: legend === void 0 ? 0 : LEGEND,
|
|
87
|
+
most: TALLEST,
|
|
88
|
+
cap: capOf(data, env)
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* Where the rows, the sizes and the cells go. `ends` are the ends of the range the shade runs
|
|
92
|
+
* between, when the caller has worked them out already: finding them reads every value.
|
|
93
|
+
*/
|
|
94
|
+
function layoutOf(data, options, env, ends) {
|
|
95
|
+
const legend = legendFit(options, data, env, ends);
|
|
19
96
|
const frame = rowFrame(data.rows.map((row) => row.label), {
|
|
20
|
-
|
|
21
|
-
above: HEAD,
|
|
22
|
-
most: TALLEST,
|
|
97
|
+
...rowRule(options, data, env, legend),
|
|
23
98
|
...options.rowTitle === void 0 ? {} : { also: [options.rowTitle] }
|
|
24
99
|
}, env);
|
|
25
|
-
const
|
|
26
|
-
const sizes = sized.length === 0 ? 0 : Math.ceil(widest(sized, TEXT.name, env.measure)) + 14;
|
|
100
|
+
const sizes = sizesOf(options, env);
|
|
27
101
|
const x = frame.left + sizes;
|
|
28
102
|
const width = Math.max(1, env.width - x);
|
|
29
103
|
const across = {
|
|
@@ -44,7 +118,8 @@ function layoutOf(data, options, env) {
|
|
|
44
118
|
filled,
|
|
45
119
|
empty: emptyOf(data, placed),
|
|
46
120
|
drawn: data.values.some((row) => row.some((value) => value !== null)),
|
|
47
|
-
|
|
121
|
+
write: writing(filled, data, options.measure, env),
|
|
122
|
+
legend
|
|
48
123
|
};
|
|
49
124
|
}
|
|
50
125
|
/** The box of the cell at a row and a column of those drawn. */
|
|
@@ -74,4 +149,4 @@ const emptyOf = (data, layout) => placesOf(data, layout.frame.shown).flatMap(({
|
|
|
74
149
|
...place,
|
|
75
150
|
box: boxAt(place, layout)
|
|
76
151
|
}] : []);
|
|
77
|
-
export { layoutOf };
|
|
152
|
+
export { RAMP, layoutOf, rowRule };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { RULE } from "../scene/paint.mjs";
|
|
2
|
+
import { pathRound } from "../scene/markup.mjs";
|
|
3
|
+
import { LINE, MARK, SPACE, TEXT } from "../theme.mjs";
|
|
4
|
+
import { RAMP } from "./grid-layout.mjs";
|
|
5
|
+
import { fillOf } from "./grid-marks.mjs";
|
|
6
|
+
// src/kinds/grid-legend.ts
|
|
7
|
+
/**
|
|
8
|
+
* The legend under the rows, the top of its room at `y`; nothing when there is none, or when the
|
|
9
|
+
* rows drawn have no cell for it to explain.
|
|
10
|
+
*/
|
|
11
|
+
function legendNodes(at, y) {
|
|
12
|
+
const { layout, measure, env } = at;
|
|
13
|
+
const { legend } = layout;
|
|
14
|
+
if (legend === void 0 || layout.filled.length === 0) return [];
|
|
15
|
+
const [low, high] = legend.ends;
|
|
16
|
+
const middle = y + SPACE.under + LINE.tick / 2;
|
|
17
|
+
const text = (words, x) => ({
|
|
18
|
+
kind: "text",
|
|
19
|
+
part: "legend",
|
|
20
|
+
x,
|
|
21
|
+
y: middle,
|
|
22
|
+
text: words,
|
|
23
|
+
...TEXT.tick,
|
|
24
|
+
baseline: "middle"
|
|
25
|
+
});
|
|
26
|
+
const after = (words, x) => x + env.measure(words, TEXT.tick) + SPACE.value;
|
|
27
|
+
const [least, most] = legend.words;
|
|
28
|
+
const start = legend.edge ? 0 : layout.across.from;
|
|
29
|
+
const from = after(least, start);
|
|
30
|
+
const width = RAMP.width / RAMP.steps;
|
|
31
|
+
const steps = Array.from({ length: RAMP.steps }, (_v, i) => {
|
|
32
|
+
const along = i / (RAMP.steps - 1);
|
|
33
|
+
return {
|
|
34
|
+
kind: "rect",
|
|
35
|
+
part: "legend",
|
|
36
|
+
x: from + i * width,
|
|
37
|
+
y: middle - RAMP.height / 2,
|
|
38
|
+
width,
|
|
39
|
+
height: RAMP.height,
|
|
40
|
+
...fillOf({ value: low * (1 - along) + high * along }, at)
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const end = from + RAMP.width + SPACE.value;
|
|
44
|
+
const top = middle - RAMP.height / 2;
|
|
45
|
+
const frame = {
|
|
46
|
+
kind: "path",
|
|
47
|
+
part: "legend",
|
|
48
|
+
d: `M${pathRound(from)},${pathRound(top)}H${pathRound(from + RAMP.width)}V${pathRound(top + RAMP.height)}H${pathRound(from)}Z`,
|
|
49
|
+
stroke: RULE,
|
|
50
|
+
strokeWidth: MARK.hair
|
|
51
|
+
};
|
|
52
|
+
return [
|
|
53
|
+
text(least, start),
|
|
54
|
+
...steps,
|
|
55
|
+
frame,
|
|
56
|
+
text(most, end),
|
|
57
|
+
...legend.named ? [text(measure.label, after(most, end))] : []
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
export { legendNodes };
|