derive-dashboards 0.8.0 → 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 +67 -26
- 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 -30
- 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 +49 -8
- 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 +10 -5
- 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/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.mjs +13 -4
- 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 +10 -8
- package/dist/core/document/display.mjs +25 -4
- 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 -19
- package/dist/core/time/bucket.mjs +6 -6
- 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.mjs +2 -2
- 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 +88 -67
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +9 -1
- package/dist/react/Dashboard.mjs +42 -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 +4 -35
- 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/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/host.mjs +4 -1
- package/dist/react/drill/lazy.mjs +2 -27
- package/dist/react/drill/props.d.mts +17 -7
- package/dist/react/drill/props.mjs +55 -14
- 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 +27 -133
- package/dist/react/headline.d.mts +6 -3
- package/dist/react/headline.mjs +81 -25
- package/dist/react/index.d.mts +19 -17
- package/dist/react/index.mjs +12 -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/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 +141 -102
- 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 +21 -15
- package/dist/recharts/marks.mjs +2 -1
- package/dist/recharts/parts.mjs +16 -13
- 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 +23 -8
- 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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Points } from "../data/format.mjs";
|
|
2
|
-
import { Env, Measure, TimeTable,
|
|
2
|
+
import { Env, Measure, TimeTable, ValueIn } from "../data/types.mjs";
|
|
3
3
|
import { Scene } from "../scene/types.mjs";
|
|
4
4
|
export type StatOptions = {
|
|
5
5
|
title: string;
|
|
6
6
|
measure: Measure;
|
|
7
7
|
/** The number the stat is about. */
|
|
8
|
-
value:
|
|
8
|
+
value: ValueIn;
|
|
9
9
|
/** The number as the host writes it, when it has a more exact way than the measure's. */
|
|
10
10
|
text?: string;
|
|
11
11
|
/**
|
|
@@ -13,7 +13,7 @@ export type StatOptions = {
|
|
|
13
13
|
* value (a stat says "vs last month"; its value is said only when it has no name), where
|
|
14
14
|
* ranked bars, which have room in a tooltip, say both.
|
|
15
15
|
*/
|
|
16
|
-
against?:
|
|
16
|
+
against?: ValueIn;
|
|
17
17
|
againstLabel?: string;
|
|
18
18
|
/**
|
|
19
19
|
* How a change is written when the values are shares: "4 pts" for a size of 4, with no sign
|
|
@@ -25,4 +25,4 @@ export type StatOptions = {
|
|
|
25
25
|
slot?: number;
|
|
26
26
|
};
|
|
27
27
|
/** A stat: a number, its change, and (given a series) its course underneath. */
|
|
28
|
-
export declare function statChart(given: TimeTable | undefined, options: StatOptions, env: Env): Scene;
|
|
28
|
+
export declare function statChart(given: TimeTable<ValueIn> | undefined, options: StatOptions, env: Env): Scene;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { checkInput, keysOf } from "../data/clean.mjs";
|
|
1
2
|
import { percentText } from "../data/format.mjs";
|
|
2
3
|
import { seriesPaint } from "../theme.mjs";
|
|
3
4
|
import { settled, statOf } from "./stat-data.mjs";
|
|
@@ -5,8 +6,26 @@ import { layoutOf } from "./stat-layout.mjs";
|
|
|
5
6
|
import { courseNodes, headNodes } from "./stat-marks.mjs";
|
|
6
7
|
import { describeStat, stopsOf } from "./stat-words.mjs";
|
|
7
8
|
// src/kinds/stat.ts
|
|
9
|
+
/** The keys statChart takes: any other is refused, with the one it most likely meant. */
|
|
10
|
+
const KEYS = keysOf({
|
|
11
|
+
title: true,
|
|
12
|
+
measure: true,
|
|
13
|
+
value: true,
|
|
14
|
+
text: true,
|
|
15
|
+
against: true,
|
|
16
|
+
againstLabel: true,
|
|
17
|
+
points: true,
|
|
18
|
+
slot: true
|
|
19
|
+
});
|
|
8
20
|
/** A stat: a number, its change, and (given a series) its course underneath. */
|
|
9
21
|
function statChart(given, options, env) {
|
|
22
|
+
checkInput({
|
|
23
|
+
what: "course",
|
|
24
|
+
data: given
|
|
25
|
+
}, options, env, {
|
|
26
|
+
known: KEYS,
|
|
27
|
+
needs: ["measure", "title"]
|
|
28
|
+
});
|
|
10
29
|
const stat = statOf(options, percentText(env.locale));
|
|
11
30
|
const table = settled(given);
|
|
12
31
|
const layout = layoutOf(stat, table, env);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { bare } from "../layout/frame.mjs";
|
|
2
|
-
import { zeroLine } from "../marks/axes.mjs";
|
|
2
|
+
import { X_ROOM, zeroLine } from "../marks/axes.mjs";
|
|
3
|
+
import { MORE_ROOM, leftLine, leftOf } from "../marks/more.mjs";
|
|
3
4
|
import { bucketTitles } from "../scale/calendar.mjs";
|
|
4
5
|
import { endNames, framedOrNone } from "./time-frame.mjs";
|
|
5
6
|
import { notesOf } from "./time-notes.mjs";
|
|
6
|
-
import { describePlan, namingOf, reachEnd } from "./time-plan.mjs";
|
|
7
|
+
import { describePlan, inFirstUnit, namingOf, reachEnd } from "./time-plan.mjs";
|
|
7
8
|
import { END_ROOM, anyValueIn, valuesOf } from "./time-plot.mjs";
|
|
8
9
|
import { timeStops } from "./time-stops.mjs";
|
|
9
10
|
// src/kinds/time-chart.ts
|
|
@@ -23,6 +24,7 @@ function framedChart(given, env, how) {
|
|
|
23
24
|
const titles = bucketTitles(given.table.x, env.locale);
|
|
24
25
|
const summary = describePlan(given, titles);
|
|
25
26
|
const { room } = how;
|
|
27
|
+
const left = given.left ?? [];
|
|
26
28
|
if (room === void 0) return bare(env, given.header, summary);
|
|
27
29
|
const { plan, frame, legend } = room;
|
|
28
30
|
const painted = how.paint(frame);
|
|
@@ -37,6 +39,7 @@ function framedChart(given, env, how) {
|
|
|
37
39
|
plot,
|
|
38
40
|
summary,
|
|
39
41
|
...plan.footnote === void 0 ? {} : { footnote: plan.footnote },
|
|
42
|
+
...leftOf(left),
|
|
40
43
|
nodes: [
|
|
41
44
|
...frame.base,
|
|
42
45
|
...legend === void 0 ? [] : legend.nodes,
|
|
@@ -49,7 +52,12 @@ function framedChart(given, env, how) {
|
|
|
49
52
|
...notes.levels.lines,
|
|
50
53
|
...notes.levels.names,
|
|
51
54
|
...notes.moments.names,
|
|
52
|
-
...endNames(room, painted, env)
|
|
55
|
+
...endNames(room, painted, env),
|
|
56
|
+
...leftLine(left, {
|
|
57
|
+
y: plot.y + plot.height + X_ROOM + MORE_ROOM / 2,
|
|
58
|
+
width: env.width,
|
|
59
|
+
env
|
|
60
|
+
})
|
|
53
61
|
],
|
|
54
62
|
hover: {
|
|
55
63
|
snap: "x",
|
|
@@ -63,6 +71,7 @@ function framedChart(given, env, how) {
|
|
|
63
71
|
titles,
|
|
64
72
|
paints: plan.paints,
|
|
65
73
|
noteAt: plan.noteAt,
|
|
74
|
+
topFirst: plan.stacked,
|
|
66
75
|
...painted.dotY === void 0 ? {} : { y: painted.dotY },
|
|
67
76
|
...painted.markAt === void 0 ? {} : { markAt: painted.markAt },
|
|
68
77
|
...painted.spanAt === void 0 ? {} : { spanAt: painted.spanAt },
|
|
@@ -71,4 +80,4 @@ function framedChart(given, env, how) {
|
|
|
71
80
|
}
|
|
72
81
|
};
|
|
73
82
|
}
|
|
74
|
-
export { END_ROOM, anyValueIn, framedChart, framedOf, namingOf, reachEnd, timeChart, timeStops, valuesOf };
|
|
83
|
+
export { END_ROOM, anyValueIn, framedChart, framedOf, inFirstUnit, namingOf, reachEnd, timeChart, timeStops, valuesOf };
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { lastAt } from "../data/rows.mjs";
|
|
1
|
+
import { wordsOf } from "../data/words.mjs";
|
|
3
2
|
import { roomy } from "../layout/frame.mjs";
|
|
4
3
|
import { endLabels, endRoom } from "../marks/end-labels.mjs";
|
|
5
4
|
import { cappedLegend, firstLegend, underHeader } from "../marks/legend.mjs";
|
|
5
|
+
import { MORE_ROOM } from "../marks/more.mjs";
|
|
6
6
|
import { paintAt } from "../theme.mjs";
|
|
7
|
-
import { fitted, namedOf } from "./time-plan.mjs";
|
|
7
|
+
import { awayFromEnds, fitted, namedOf } from "./time-plan.mjs";
|
|
8
8
|
import { END_ROOM, timePlot } from "./time-plot.mjs";
|
|
9
|
+
import { lastSaid } from "./time-stops.mjs";
|
|
9
10
|
// src/kinds/time-frame.ts
|
|
10
11
|
/**
|
|
11
12
|
* The name beside each named series' end: the series (when there are several) and its last
|
|
12
|
-
* value
|
|
13
|
+
* value, "so far" after a value whose period is still running, as a pointer and the summary
|
|
14
|
+
* say it. `across` is where a bucket's marks stand, for a kind whose marks end at their last
|
|
13
15
|
* value (lines): a series that stops before the last bucket says how far across it ends.
|
|
14
16
|
*/
|
|
15
|
-
function labelsOf(plan,
|
|
17
|
+
function labelsOf(plan, env, at = {}) {
|
|
18
|
+
const { painted, across } = at;
|
|
16
19
|
const several = plan.table.series.length > 1;
|
|
20
|
+
const words = wordsOf(env);
|
|
17
21
|
return namedOf(plan).flatMap((i) => {
|
|
18
22
|
const series = plan.table.series[i];
|
|
19
|
-
|
|
20
|
-
const
|
|
23
|
+
if (series === void 0) return [];
|
|
24
|
+
const { last, value } = lastSaid(series, plan.table.x.buckets, words);
|
|
21
25
|
const y = painted === void 0 ? 0 : painted.labelY(i);
|
|
22
|
-
if (
|
|
26
|
+
if (value === void 0 || y === void 0) return [];
|
|
23
27
|
const name = several ? { name: series.label } : {};
|
|
24
28
|
const x = across === void 0 ? {} : { x: across(last) };
|
|
25
29
|
return [{
|
|
@@ -32,14 +36,22 @@ function labelsOf(plan, painted, across) {
|
|
|
32
36
|
}];
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* The legend over the plot, when that is how the series are named. A series whose last period
|
|
41
|
+
* is still running is named with its last value, "so far", as a name at its end would be: a
|
|
42
|
+
* legend is the only place a narrow chart writes it.
|
|
43
|
+
*/
|
|
36
44
|
function legendOf(plan, env, rows) {
|
|
37
45
|
if (plan.naming !== "legend") return void 0;
|
|
38
|
-
const
|
|
46
|
+
const named = plan.stacked === true ? namedOf(plan).toReversed() : namedOf(plan);
|
|
47
|
+
const words = wordsOf(env);
|
|
48
|
+
const items = named.flatMap((i) => {
|
|
39
49
|
const series = plan.table.series[i];
|
|
40
|
-
|
|
50
|
+
if (series === void 0) return [];
|
|
51
|
+
const last = lastSaid(series, plan.table.x.buckets, words);
|
|
52
|
+
return [{
|
|
41
53
|
key: series.key,
|
|
42
|
-
label: series.label,
|
|
54
|
+
label: last.running ? `${series.label} ${last.value ?? ""}` : series.label,
|
|
43
55
|
color: paintAt(plan.paints, i),
|
|
44
56
|
...plan.swatch === void 0 ? {} : { shape: plan.swatch }
|
|
45
57
|
}];
|
|
@@ -50,9 +62,24 @@ function legendOf(plan, env, rows) {
|
|
|
50
62
|
env
|
|
51
63
|
});
|
|
52
64
|
}
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The most of the width the names at the marks' ends take. Names that do not fit whole in it
|
|
67
|
+
* go to a legend: a cut name reads as another series, and room given to it starves the plot.
|
|
68
|
+
*/
|
|
69
|
+
const ENDS = .3;
|
|
70
|
+
/** The plan with its series named in a legend where their names would not fit whole at their ends. */
|
|
71
|
+
function wholeAtEnds(plan, env) {
|
|
72
|
+
if (plan.naming !== "end") return plan;
|
|
73
|
+
const most = env.width * ENDS;
|
|
74
|
+
return endRoom(labelsOf(plan, env), {
|
|
75
|
+
measure: env.measure,
|
|
76
|
+
most: Number.POSITIVE_INFINITY
|
|
77
|
+
}) <= most ? plan : {
|
|
78
|
+
...plan,
|
|
79
|
+
naming: awayFromEnds(plan.table.series.length)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** The plot's frame, with room above for a legend, to the right for names, and under it for what was left out. */
|
|
56
83
|
function frameOf(plan, env, room) {
|
|
57
84
|
const references = plan.notes.references ?? [];
|
|
58
85
|
return timePlot(plan.table, env, {
|
|
@@ -61,13 +88,14 @@ function frameOf(plan, env, room) {
|
|
|
61
88
|
zero: plan.zero,
|
|
62
89
|
bands: plan.bands,
|
|
63
90
|
...plan.gutter === void 0 ? {} : { gutter: plan.gutter },
|
|
64
|
-
...room
|
|
91
|
+
...room,
|
|
92
|
+
...(plan.left?.length ?? 0) > 0 ? { bottom: MORE_ROOM } : {}
|
|
65
93
|
});
|
|
66
94
|
}
|
|
67
95
|
/** The plan framed: the room its names take measured, and the plot put in what is left. */
|
|
68
96
|
function framed(plan, env, rows) {
|
|
69
97
|
const legend = legendOf(plan, env, rows);
|
|
70
|
-
const right = plan.naming === "end" ? endRoom(labelsOf(plan), {
|
|
98
|
+
const right = plan.naming === "end" ? endRoom(labelsOf(plan, env), {
|
|
71
99
|
measure: env.measure,
|
|
72
100
|
most: env.width * ENDS
|
|
73
101
|
}) : END_ROOM;
|
|
@@ -90,7 +118,7 @@ const holds = (tried) => roomy(tried.frame.plot) && (tried.plan.naming !== "lege
|
|
|
90
118
|
* name, so it gives its legend up and is drawn.
|
|
91
119
|
*/
|
|
92
120
|
function framedOrNone(given, env) {
|
|
93
|
-
const plan = fitted(given, env);
|
|
121
|
+
const plan = wholeAtEnds(fitted(given, env), env);
|
|
94
122
|
const found = plan.naming === "legend" ? firstLegend((rows) => framed(plan, env, rows), holds) : [framed(plan, env, 0)].find((tried) => holds(tried));
|
|
95
123
|
if (found !== void 0 || plan.table.series.length > 1) return found;
|
|
96
124
|
const plain = framed({
|
|
@@ -104,7 +132,10 @@ function endNames(room, painted, env) {
|
|
|
104
132
|
if (room.plan.naming !== "end") return [];
|
|
105
133
|
const { plot, time } = room.frame;
|
|
106
134
|
const across = room.plan.bands ? void 0 : time.center;
|
|
107
|
-
return endLabels(labelsOf(room.plan,
|
|
135
|
+
return endLabels(labelsOf(room.plan, env, {
|
|
136
|
+
painted,
|
|
137
|
+
...across === void 0 ? {} : { across }
|
|
138
|
+
}), {
|
|
108
139
|
plot,
|
|
109
140
|
room: room.right,
|
|
110
141
|
measure: env.measure
|
|
@@ -51,7 +51,34 @@ function describePlan(plan, titles) {
|
|
|
51
51
|
coursesSaid(table, titles),
|
|
52
52
|
focusSaid(plan.focusLabels ?? []),
|
|
53
53
|
...plan.also ?? [],
|
|
54
|
-
...missingOf(table)
|
|
54
|
+
...missingOf(table),
|
|
55
|
+
...unitLeft(plan.left ?? [])
|
|
55
56
|
]);
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
+
/** What the summary says of the series in another unit: that they are not drawn here. */
|
|
59
|
+
const unitLeft = (left) => left.length === 0 ? [] : [`${left.map((s) => s.label).join(", ")} in another unit, not drawn on this axis`];
|
|
60
|
+
/**
|
|
61
|
+
* A table's series in its first series' unit (`Measure.unit`), and those in another, which its
|
|
62
|
+
* one value axis would read on the wrong scale: those are not drawn, and the chart names them
|
|
63
|
+
* under it (`Scene.left`), as a dashboard tile names a value in a second unit under its chart.
|
|
64
|
+
* The one owner of that rule for every chart over time drawn on one axis.
|
|
65
|
+
*/
|
|
66
|
+
function inFirstUnit(table) {
|
|
67
|
+
const unit = table.series[0]?.measure.unit;
|
|
68
|
+
const left = table.series.filter((s) => s.measure.unit !== unit).map((s) => ({
|
|
69
|
+
key: s.key,
|
|
70
|
+
label: s.label
|
|
71
|
+
}));
|
|
72
|
+
if (left.length === 0) return {
|
|
73
|
+
table,
|
|
74
|
+
left
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
table: {
|
|
78
|
+
...table,
|
|
79
|
+
series: table.series.filter((s) => s.measure.unit === unit)
|
|
80
|
+
},
|
|
81
|
+
left
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export { awayFromEnds, describePlan, fitted, inFirstUnit, namedOf, namingOf, reachEnd };
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { textAt } from "../data/format.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { lastAt } from "../data/rows.mjs";
|
|
3
|
+
import { periodNote, wordsOf } from "../data/words.mjs";
|
|
4
|
+
import { lazyStop } from "../scene/lazy.mjs";
|
|
3
5
|
import { paintAt } from "../theme.mjs";
|
|
6
|
+
import { isRunning } from "derive-dashboards/core";
|
|
4
7
|
// src/kinds/time-stops.ts
|
|
5
|
-
/**
|
|
6
|
-
|
|
8
|
+
/**
|
|
9
|
+
* A series' last value as it is written beside its name (an end label, a legend, a panel's
|
|
10
|
+
* head), "so far" after one whose period is still running, as a pointer and the summary say it.
|
|
11
|
+
*/
|
|
12
|
+
function lastSaid(series, buckets, words) {
|
|
13
|
+
const last = lastAt(series.values);
|
|
14
|
+
const text = textAt(series, last);
|
|
15
|
+
const running = text !== void 0 && isRunning(buckets[last]);
|
|
16
|
+
return {
|
|
17
|
+
last,
|
|
18
|
+
running,
|
|
19
|
+
value: running ? `${text} ${words.soFar}` : text
|
|
20
|
+
};
|
|
21
|
+
}
|
|
7
22
|
/** What a stop says beside its bucket's name: that the data covers only part of it, then what the kind says of it. */
|
|
8
23
|
function noteOf(said) {
|
|
9
24
|
const notes = said.filter((one) => one !== void 0);
|
|
@@ -17,40 +32,54 @@ const foundAt = (series, index, at) => at.markAt?.(series, index) ?? {
|
|
|
17
32
|
x: at.center(index),
|
|
18
33
|
y: at.y?.(series, index) ?? at.plot.y
|
|
19
34
|
};
|
|
20
|
-
/**
|
|
21
|
-
function
|
|
35
|
+
/** The series that have a value at a bucket, each as a stop's item. */
|
|
36
|
+
function itemsAt(table, i, at) {
|
|
37
|
+
const items = table.series.flatMap((series, s) => {
|
|
38
|
+
const value = textAt(series, i);
|
|
39
|
+
if (value === void 0) return [];
|
|
40
|
+
const before = series.previous?.[i] ?? null;
|
|
41
|
+
return [{
|
|
42
|
+
key: series.key,
|
|
43
|
+
label: series.label,
|
|
44
|
+
value,
|
|
45
|
+
color: paintAt(at.paints, s),
|
|
46
|
+
...foundAt(series, i, at),
|
|
47
|
+
...before === null ? {} : { aside: at.words.before(series.measure.text(before)) }
|
|
48
|
+
}];
|
|
49
|
+
});
|
|
50
|
+
return at.topFirst === true ? items.toReversed() : items;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* One stop per bucket, each with the series that have a value there; a kind may `shape` each
|
|
54
|
+
* stop's fields, or leave a bucket out. A stop's values are written when it is first read
|
|
55
|
+
* (`lazyStop`): building the scene writes none.
|
|
56
|
+
*/
|
|
57
|
+
function timeStops(table, env, at, shape) {
|
|
22
58
|
const words = wordsOf(env);
|
|
23
|
-
return table.x.buckets.
|
|
59
|
+
return table.x.buckets.flatMap((bucket, i) => {
|
|
24
60
|
const x = at.center(i);
|
|
25
61
|
const span = at.spanAt?.(i);
|
|
26
|
-
const
|
|
27
|
-
const value = textAt(series, i);
|
|
28
|
-
if (value === void 0) return [];
|
|
29
|
-
const before = series.previous?.[i] ?? null;
|
|
30
|
-
return [{
|
|
31
|
-
key: series.key,
|
|
32
|
-
label: series.label,
|
|
33
|
-
value,
|
|
34
|
-
color: paintAt(at.paints, s),
|
|
35
|
-
...foundAt(series, i, at),
|
|
36
|
-
...before === null ? {} : { aside: words.before(series.measure.text(before)) }
|
|
37
|
-
}];
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
62
|
+
const fields = {
|
|
40
63
|
key: bucket.label,
|
|
41
64
|
x,
|
|
42
65
|
y: at.plot.y,
|
|
43
66
|
title: at.titles[i] ?? bucket.label,
|
|
44
|
-
items,
|
|
45
67
|
...span === void 0 ? {} : { span },
|
|
46
|
-
...noteOf([
|
|
47
|
-
...at.band === void 0 ? {} : { band:
|
|
48
|
-
x: x - at.band / 2,
|
|
49
|
-
y: at.plot.y,
|
|
50
|
-
width: at.band,
|
|
51
|
-
height: at.plot.height
|
|
52
|
-
} }
|
|
68
|
+
...noteOf([periodNote(bucket, words), at.noteAt?.(i)]),
|
|
69
|
+
...at.band === void 0 ? {} : { band: bandAt(x, at.band, at.plot) }
|
|
53
70
|
};
|
|
71
|
+
const shaped = shape === void 0 ? fields : shape(fields, i);
|
|
72
|
+
return shaped === void 0 ? [] : [lazyStop(shaped, () => itemsAt(table, i, {
|
|
73
|
+
...at,
|
|
74
|
+
words
|
|
75
|
+
}))];
|
|
54
76
|
});
|
|
55
77
|
}
|
|
56
|
-
|
|
78
|
+
/** The band a pointer lights at a bucket: its width, the plot's height. */
|
|
79
|
+
const bandAt = (x, band, plot) => ({
|
|
80
|
+
x: x - band / 2,
|
|
81
|
+
y: plot.y,
|
|
82
|
+
width: band,
|
|
83
|
+
height: plot.height
|
|
84
|
+
});
|
|
85
|
+
export { lastSaid, timeStops };
|
|
@@ -1,7 +1,7 @@
|
|
|
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 waterfall: a total, or a change to the running total (the default). */
|
|
4
|
-
export type WaterfallStep = Named & {
|
|
5
|
-
value:
|
|
4
|
+
export type WaterfallStep<V extends ValueIn = Value> = Named & {
|
|
5
|
+
value: V;
|
|
6
6
|
kind?: "total" | "change";
|
|
7
7
|
};
|
|
@@ -2,9 +2,9 @@ import { drawable } from "../data/clean.mjs";
|
|
|
2
2
|
import { changeWritten, signAsWritten, signed } from "../data/format.mjs";
|
|
3
3
|
// src/kinds/waterfall-data.ts
|
|
4
4
|
/** The steps with every value that cannot be drawn taken as missing. */
|
|
5
|
-
const cleaned = (steps) => steps.map((s) => ({
|
|
5
|
+
const cleaned = (steps) => steps.map((s, i) => ({
|
|
6
6
|
...s,
|
|
7
|
-
value: drawable(s.value)
|
|
7
|
+
value: drawable(s.value, "steps[#].value", i)
|
|
8
8
|
}));
|
|
9
9
|
/** Each step with its leg, walking the running total from zero. */
|
|
10
10
|
function walked(steps) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Points } from "../data/format.mjs";
|
|
2
|
-
import { Env, Header, Measure } from "../data/types.mjs";
|
|
2
|
+
import { Env, Header, Measure, ValueIn } from "../data/types.mjs";
|
|
3
3
|
import { Scene } from "../scene/types.mjs";
|
|
4
|
-
import { WaterfallStep } from "./waterfall-data.mjs";
|
|
4
|
+
import { WaterfallStep as WaterfallStep$1 } from "./waterfall-data.mjs";
|
|
5
|
+
/** A step of a waterfall as a host gives it: its value a number, decimal text, or null. */
|
|
6
|
+
export type WaterfallStep<V extends ValueIn = ValueIn> = WaterfallStep$1<V>;
|
|
5
7
|
export type WaterfallOptions = Header & {
|
|
6
8
|
measure: Measure;
|
|
7
9
|
/** The palette place of the changes when the measure says no way is better. */
|
|
@@ -13,5 +15,4 @@ export type WaterfallOptions = Header & {
|
|
|
13
15
|
points?: Points;
|
|
14
16
|
};
|
|
15
17
|
/** A waterfall of totals and the changes between them. */
|
|
16
|
-
export declare function waterfallChart(given: readonly WaterfallStep[], options: WaterfallOptions, env: Env): Scene;
|
|
17
|
-
export type { WaterfallStep };
|
|
18
|
+
export declare function waterfallChart(given: readonly WaterfallStep[], options: WaterfallOptions, env: Env): Scene;
|
|
@@ -1,16 +1,39 @@
|
|
|
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, rowsZero } from "./row-marks.mjs";
|
|
4
|
-
import { hasRoom } from "./row-chart.mjs";
|
|
6
|
+
import { hasRoom, sizingOf, wantsOf } from "./row-chart.mjs";
|
|
5
7
|
import { cleaned, walked } from "./waterfall-data.mjs";
|
|
6
8
|
import { layoutOf } from "./waterfall-layout.mjs";
|
|
7
9
|
import { joinNodes, rowNodes } from "./waterfall-marks.mjs";
|
|
8
10
|
import { describeWaterfall, stopOf } from "./waterfall-words.mjs";
|
|
9
11
|
// src/kinds/waterfall.ts
|
|
12
|
+
/** The keys waterfallChart takes: any other is refused, with the one it most likely meant. */
|
|
13
|
+
const KEYS = keysOf({
|
|
14
|
+
...HEADER,
|
|
15
|
+
measure: true,
|
|
16
|
+
slot: true,
|
|
17
|
+
points: true
|
|
18
|
+
});
|
|
10
19
|
/** A waterfall of totals and the changes between them. */
|
|
11
20
|
function waterfallChart(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
29
|
const rows = walked(cleaned(given));
|
|
30
|
+
if (env.sizing === true) {
|
|
31
|
+
const drawn = rows.some(({ leg }) => leg.known);
|
|
32
|
+
return sizingOf(env, { header: options }, {
|
|
33
|
+
count: rows.length,
|
|
34
|
+
drawn
|
|
35
|
+
});
|
|
36
|
+
}
|
|
14
37
|
const { frame, reach, x, kept, moreSlot, drawn, numbers, plot } = layoutOf(rows, options, env);
|
|
15
38
|
const { points } = options;
|
|
16
39
|
const roomy = hasRoom(frame, reach, drawn);
|
|
@@ -34,11 +57,15 @@ function waterfallChart(given, options, env) {
|
|
|
34
57
|
slot,
|
|
35
58
|
nodes: rowNodes(row, slot, at)
|
|
36
59
|
}));
|
|
60
|
+
const left = leftOut(rows, placed.map(({ row }) => row));
|
|
37
61
|
return {
|
|
38
62
|
width: env.width,
|
|
39
63
|
height: env.height,
|
|
40
64
|
plot,
|
|
65
|
+
natural: frame.natural,
|
|
41
66
|
summary,
|
|
67
|
+
...leftOf(left),
|
|
68
|
+
...wantsOf(frame),
|
|
42
69
|
nodes: [
|
|
43
70
|
...headerNodes(env, options),
|
|
44
71
|
...joinNodes(kept, at),
|
|
@@ -48,7 +75,7 @@ function waterfallChart(given, options, env) {
|
|
|
48
75
|
x,
|
|
49
76
|
plot
|
|
50
77
|
}),
|
|
51
|
-
...rowsMore(
|
|
78
|
+
...rowsMore(left, {
|
|
52
79
|
frame,
|
|
53
80
|
env,
|
|
54
81
|
slot: moreSlot
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { said } from "../data/format.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { fitted } from "../text/measure.mjs";
|
|
3
3
|
import { LINE, SPACE, TEXT } from "../theme.mjs";
|
|
4
4
|
// src/layout/frame.ts
|
|
5
5
|
/** The room a header's two lines take. */
|
|
@@ -27,6 +27,8 @@ function headerHeight(header) {
|
|
|
27
27
|
}
|
|
28
28
|
/** The room the source line takes at the bottom; nothing for a chart with none. */
|
|
29
29
|
const footHeight = (header) => linesOf(header).source === void 0 ? 0 : SOURCE_ROOM;
|
|
30
|
+
/** The room a header and a source take between them: what a picture is taller by than its content. */
|
|
31
|
+
const aroundHeight = (header) => headerHeight(header) + footHeight(header);
|
|
30
32
|
/**
|
|
31
33
|
* The room between the header and the source line, the picture's full width: where a chart with
|
|
32
34
|
* no axis down its side (rows lying down, a grid of panels) lays itself out.
|
|
@@ -67,7 +69,7 @@ function headerNodes(env, header) {
|
|
|
67
69
|
part: "header",
|
|
68
70
|
x: 0,
|
|
69
71
|
y,
|
|
70
|
-
|
|
72
|
+
...fitted(text, env.width, font, env.measure),
|
|
71
73
|
baseline: "hanging",
|
|
72
74
|
...font
|
|
73
75
|
});
|
|
@@ -94,4 +96,4 @@ function plotBox(env, header, margins) {
|
|
|
94
96
|
height: Math.max(1, env.height - top - bottom)
|
|
95
97
|
};
|
|
96
98
|
}
|
|
97
|
-
export { bare, contentBox, headerHeight, headerNodes, plotBox, roomy };
|
|
99
|
+
export { aroundHeight, bare, contentBox, headerHeight, headerNodes, plotBox, roomy };
|
|
@@ -1,31 +1,52 @@
|
|
|
1
1
|
// src/layout/stack.ts
|
|
2
|
-
/**
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
return series.map((values) => Array.from({ length: places }, (_v, i) => {
|
|
2
|
+
/** One series stacked on the piles so far, which it grows: its values' starts and ends. */
|
|
3
|
+
function pushed(values, piles) {
|
|
4
|
+
const from = new Float64Array(piles.up.length).fill(NaN);
|
|
5
|
+
const to = new Float64Array(piles.up.length).fill(NaN);
|
|
6
|
+
for (let i = 0; i < from.length; i++) {
|
|
9
7
|
const value = values[i] ?? null;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
stack[place] = from + value;
|
|
8
|
+
if (value === null) continue;
|
|
9
|
+
const pile = value >= 0 ? piles.up : piles.down;
|
|
10
|
+
from[i] = pile[i] ?? 0;
|
|
11
|
+
to[i] = (pile[i] ?? 0) + value;
|
|
12
|
+
pile[i] = to[i] ?? 0;
|
|
13
|
+
}
|
|
17
14
|
return {
|
|
18
15
|
from,
|
|
19
|
-
to
|
|
16
|
+
to
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
|
-
/** Every height an axis must reach for some series stacked at each place. */
|
|
23
|
-
const stackHeights = (series, places) => stackEnds(stacked(series, places));
|
|
24
19
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
20
|
+
* Each series' values with a missing one as zero wherever another series has a value at that
|
|
21
|
+
* place: what a band stacks, so the bands above rest on the band below and none breaks off
|
|
22
|
+
* there. A place where no series has a value stays empty, a break in every band.
|
|
23
|
+
*/
|
|
24
|
+
function zeroed(series, places) {
|
|
25
|
+
const some = Array.from({ length: places }, (_p, i) => series.some((values) => (values[i] ?? null) !== null));
|
|
26
|
+
return series.map((values) => some.map((filled, i) => values[i] ?? (filled ? 0 : null)));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The series stacked at each of `places` places. A column leaves a missing value out (`gap`); a
|
|
30
|
+
* band stacks it as zero where the place has other values (`zero`).
|
|
27
31
|
*/
|
|
28
|
-
function
|
|
29
|
-
|
|
32
|
+
function stackOf(series, places, missing = "gap") {
|
|
33
|
+
const piles = {
|
|
34
|
+
up: new Float64Array(places),
|
|
35
|
+
down: new Float64Array(places)
|
|
36
|
+
};
|
|
37
|
+
const stacked = (missing === "zero" ? zeroed(series, places) : series).map((values) => pushed(values, piles));
|
|
38
|
+
const to = stacked.map((one) => one.to);
|
|
39
|
+
let [low, high] = [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY];
|
|
40
|
+
for (const ends of to) for (const end of ends) if (Number.isFinite(end)) [low, high] = [Math.min(low, end), Math.max(high, end)];
|
|
41
|
+
const settled = (value) => Number(value.toPrecision(12));
|
|
42
|
+
const reach = low <= high ? [settled(low), settled(high)] : [];
|
|
43
|
+
return {
|
|
44
|
+
from: stacked.map((one) => one.from),
|
|
45
|
+
to,
|
|
46
|
+
places,
|
|
47
|
+
reach
|
|
48
|
+
};
|
|
30
49
|
}
|
|
31
|
-
|
|
50
|
+
/** Whether a series has a value at a place in a stack. */
|
|
51
|
+
const stackedAt = (stack, series, place) => !Number.isNaN(stack.to[series]?.[place] ?? NaN);
|
|
52
|
+
export { stackOf, stackedAt };
|
|
@@ -5,13 +5,16 @@ import { LINE, MARK, SPACE, TEXT } from "../theme.mjs";
|
|
|
5
5
|
/** The room the labels under a plot take: the gap above them, their height, and a little under. */
|
|
6
6
|
const X_ROOM = SPACE.under + LINE.tick;
|
|
7
7
|
/**
|
|
8
|
-
* How an axis's ticks read: the measure's short form,
|
|
9
|
-
* for values a few hundred apart), in
|
|
8
|
+
* How an axis's ticks read: the measure's short form, in the unit the axis steps in when it
|
|
9
|
+
* names one, unless that reads two ticks alike (1M, 1M for values a few hundred apart), in
|
|
10
|
+
* which case its full form.
|
|
10
11
|
*/
|
|
11
12
|
function tickTexts(axis, reads) {
|
|
12
13
|
if (reads === void 0) return String;
|
|
13
|
-
const
|
|
14
|
-
|
|
14
|
+
const { unit } = axis;
|
|
15
|
+
const tick = (value) => reads.tick(value, unit);
|
|
16
|
+
const short = axis.ticks.map((t) => tick(t));
|
|
17
|
+
return new Set(short).size === short.length ? tick : reads.text;
|
|
15
18
|
}
|
|
16
19
|
/** The left margin a value axis needs: its widest label and the gutter. */
|
|
17
20
|
function gutterOf(axis, reads, measure) {
|
|
@@ -80,6 +83,8 @@ function across(place, at) {
|
|
|
80
83
|
* stand on, on an axis that leaves zero out.
|
|
81
84
|
*/
|
|
82
85
|
const zeroIn = (plot, place) => Math.min(plot.y + plot.height, Math.max(plot.y, place(0)));
|
|
86
|
+
/** Where zero sits, when it is on the axis: what a wash under a line fills down to, else none. */
|
|
87
|
+
const zeroOn = (axis, place) => axis.min > 0 || axis.max < 0 ? void 0 : place(0);
|
|
83
88
|
/** The zero line, when zero is on the axis: drawn over the marks that stand on it. */
|
|
84
89
|
function zeroLine(axis, at) {
|
|
85
90
|
if (axis.min > 0 || axis.max < 0) return [];
|
|
@@ -135,4 +140,4 @@ function readable(labels, at) {
|
|
|
135
140
|
* axis's room, is left out, and when only one would be left none is written.
|
|
136
141
|
*/
|
|
137
142
|
const writtenOf = (ticks, at) => scaled(readable(ticks.filter((one, i) => one.text !== ticks[i - 1]?.text), at));
|
|
138
|
-
export { X_ROOM, gutterOf, labelsUnder, scaled, tickTexts, tickUnder, valueGrid, writtenOf, zeroIn, zeroLine };
|
|
143
|
+
export { X_ROOM, gutterOf, labelsUnder, scaled, tickTexts, tickUnder, valueGrid, writtenOf, zeroIn, zeroLine, zeroOn };
|