derive-dashboards 0.8.0 → 0.10.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 +534 -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 +12 -10
- package/dist/core/document/display.mjs +32 -6
- 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 +31 -5
- 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/tools.mjs +4 -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 +11 -4
- 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-steps.mjs +99 -11
- package/dist/react/arrange.mjs +11 -4
- 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 +257 -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,4 +1,4 @@
|
|
|
1
|
-
import { Env, Header, Measure, Reference,
|
|
1
|
+
import { Env, Header, Measure, Reference, ValueIn } from "../data/types.mjs";
|
|
2
2
|
import { Scene } from "../scene/types.mjs";
|
|
3
3
|
export type HistogramOptions = Header & {
|
|
4
4
|
measure: Measure;
|
|
@@ -12,4 +12,4 @@ export type HistogramOptions = Header & {
|
|
|
12
12
|
slot?: number;
|
|
13
13
|
};
|
|
14
14
|
/** A histogram of some values: how many fall in each bin of one measure. */
|
|
15
|
-
export declare function histogramChart(given: readonly
|
|
15
|
+
export declare function histogramChart(given: readonly ValueIn[], options: HistogramOptions, env: Env): Scene;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { finiteRange } from "../data/clean.mjs";
|
|
1
|
+
import { HEADER, checkInput, finiteRange, keysOf } from "../data/clean.mjs";
|
|
2
2
|
import { percentText } from "../data/format.mjs";
|
|
3
3
|
import { bare, headerNodes, roomy } from "../layout/frame.mjs";
|
|
4
4
|
import { seriesPaint } from "../theme.mjs";
|
|
@@ -7,8 +7,24 @@ import { layoutOf } from "./histogram-layout.mjs";
|
|
|
7
7
|
import { histogramNodes } from "./histogram-marks.mjs";
|
|
8
8
|
import { describeHistogram, stopsOf } from "./histogram-words.mjs";
|
|
9
9
|
// src/kinds/histogram.ts
|
|
10
|
+
/** The keys histogramChart takes: any other is refused, with the one it most likely meant. */
|
|
11
|
+
const KEYS = keysOf({
|
|
12
|
+
...HEADER,
|
|
13
|
+
measure: true,
|
|
14
|
+
bins: true,
|
|
15
|
+
references: true,
|
|
16
|
+
highlight: true,
|
|
17
|
+
slot: true
|
|
18
|
+
});
|
|
10
19
|
/** A histogram of some values: how many fall in each bin of one measure. */
|
|
11
20
|
function histogramChart(given, options, env) {
|
|
21
|
+
checkInput({
|
|
22
|
+
what: "values",
|
|
23
|
+
data: given
|
|
24
|
+
}, options, env, {
|
|
25
|
+
known: KEYS,
|
|
26
|
+
needs: ["measure"]
|
|
27
|
+
});
|
|
12
28
|
const values = finiteOf(given);
|
|
13
29
|
const highlight = finiteRange(options.highlight);
|
|
14
30
|
const layout = layoutOf(values, options, env);
|
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { OTHER } from "../scene/paint.mjs";
|
|
2
|
+
import { zeroOn } from "../marks/axes.mjs";
|
|
3
|
+
import { thinningStep } from "../marks/budget.mjs";
|
|
4
|
+
import { linePoints, pointsOf, seriesLine } from "../marks/series-line.mjs";
|
|
5
|
+
import { MARK, repeatsOf } from "../theme.mjs";
|
|
3
6
|
// src/kinds/line-marks.ts
|
|
4
7
|
/** The lines: grey context first, then the series in reverse, so the first is drawn on top. */
|
|
5
8
|
function lineNodes(drawn, at) {
|
|
6
9
|
const { frame } = at;
|
|
7
10
|
const { plot, place, time } = frame;
|
|
11
|
+
const washed = at.wash ?? drawn.length === 1;
|
|
12
|
+
const step = thinningStep(drawn.reduce((sum, d) => sum + linePoints(d.series, washed && !d.quiet), 0), 4, frame.buckets.length / Math.max(1, plot.width));
|
|
8
13
|
const where = {
|
|
9
14
|
buckets: frame.buckets,
|
|
10
15
|
center: time.center,
|
|
11
|
-
place
|
|
16
|
+
place,
|
|
17
|
+
step
|
|
12
18
|
};
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
19
|
+
const base = zeroOn(frame.axis, place);
|
|
20
|
+
const order = [...drawn.filter((d) => d.quiet), ...drawn.filter((d) => !d.quiet).toReversed()];
|
|
21
|
+
const repeats = repeatsOf(drawn.map((d) => d.quiet ? OTHER : d.color));
|
|
22
|
+
const nodes = order.map((d) => ({
|
|
16
23
|
kind: "group",
|
|
17
24
|
part: "series",
|
|
18
|
-
key: series.key,
|
|
19
|
-
children: seriesLine(series, where, {
|
|
20
|
-
color,
|
|
25
|
+
key: d.series.key,
|
|
26
|
+
children: seriesLine(d.series, where, {
|
|
27
|
+
color: d.color,
|
|
21
28
|
curve: at.curve ?? "straight",
|
|
22
|
-
...quiet ? { quiet } : {},
|
|
23
|
-
...
|
|
29
|
+
...d.quiet ? { quiet: true } : {},
|
|
30
|
+
...repeats[drawn.indexOf(d)] === true ? { dash: MARK.repeat } : {},
|
|
31
|
+
...washed && !d.quiet && base !== void 0 ? { washTo: base } : {}
|
|
24
32
|
})
|
|
25
33
|
}));
|
|
26
34
|
const points = new Map(drawn.map(({ series }) => [series, pointsOf(series.values, where)]));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Env, Header, TimeTable } from "../data/types.mjs";
|
|
1
|
+
import { Env, Header, TimeTable, ValueIn } from "../data/types.mjs";
|
|
2
2
|
import { Scene } from "../scene/types.mjs";
|
|
3
3
|
import { Curve } from "../marks/lines.mjs";
|
|
4
4
|
import { Naming, TimeNotes } from "./time-plan.mjs";
|
|
@@ -14,4 +14,4 @@ export type LineOptions = Header & TimeNotes & {
|
|
|
14
14
|
focus?: readonly string[];
|
|
15
15
|
};
|
|
16
16
|
/** A line chart of series over time. */
|
|
17
|
-
export declare function lineChart(given: TimeTable
|
|
17
|
+
export declare function lineChart(given: TimeTable<ValueIn>, options: LineOptions, env: Env): Scene;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { cleanTable } from "../data/clean.mjs";
|
|
1
|
+
import { HEADER, NOTES, checkInput, cleanTable, keysOf } from "../data/clean.mjs";
|
|
2
|
+
import { ChartInputError } from "../data/input-error.mjs";
|
|
2
3
|
import { OTHER } from "../scene/paint.mjs";
|
|
3
4
|
import { paintAt, paintsOf } from "../theme.mjs";
|
|
4
|
-
import { namingOf } from "./time-plan.mjs";
|
|
5
|
+
import { inFirstUnit, namingOf } from "./time-plan.mjs";
|
|
5
6
|
import { valuesOf } from "./time-plot.mjs";
|
|
6
7
|
import { lineNodes } from "./line-marks.mjs";
|
|
7
8
|
import { timeChart } from "./time-chart.mjs";
|
|
@@ -10,6 +11,8 @@ import { timeChart } from "./time-chart.mjs";
|
|
|
10
11
|
function linesOf(table, options) {
|
|
11
12
|
const paints = paintsOf(table.series);
|
|
12
13
|
const focus = options.focus;
|
|
14
|
+
const keys = table.series.map((s) => s.key);
|
|
15
|
+
for (const [i, key] of (focus ?? []).entries()) if (!keys.includes(key)) throw new ChartInputError(`focus[${String(i)}]`, `Expected a series key: ${keys.join(", ")}.`);
|
|
13
16
|
return table.series.map((series, i) => {
|
|
14
17
|
const quiet = focus !== void 0 && !focus.includes(series.key);
|
|
15
18
|
return {
|
|
@@ -19,14 +22,29 @@ function linesOf(table, options) {
|
|
|
19
22
|
};
|
|
20
23
|
});
|
|
21
24
|
}
|
|
25
|
+
/** The keys lineChart takes: any other is refused, with the one it most likely meant. */
|
|
26
|
+
const KEYS = keysOf({
|
|
27
|
+
...HEADER,
|
|
28
|
+
...NOTES,
|
|
29
|
+
curve: true,
|
|
30
|
+
naming: true,
|
|
31
|
+
wash: true,
|
|
32
|
+
zero: true,
|
|
33
|
+
focus: true
|
|
34
|
+
});
|
|
22
35
|
/** A line chart of series over time. */
|
|
23
36
|
function lineChart(given, options, env) {
|
|
24
|
-
|
|
37
|
+
checkInput({
|
|
38
|
+
what: "table",
|
|
39
|
+
data: given
|
|
40
|
+
}, options, env, { known: KEYS });
|
|
41
|
+
const { table, left } = inFirstUnit(cleanTable(given));
|
|
25
42
|
const lines = linesOf(table, options);
|
|
26
43
|
const bright = lines.flatMap((d, i) => d.quiet ? [] : [i]);
|
|
27
44
|
return timeChart({
|
|
28
45
|
what: "Line chart",
|
|
29
46
|
table,
|
|
47
|
+
left,
|
|
30
48
|
header: options,
|
|
31
49
|
notes: options,
|
|
32
50
|
paints: lines.map((d) => d.color),
|
|
@@ -11,60 +11,90 @@ const GAP = {
|
|
|
11
11
|
y: 26
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* A panel's least and greatest width, its least height, and the least width asked-for
|
|
15
|
-
* may give. These are small multiples' own: a panel holds a name, a value and a line,
|
|
16
|
-
* read beside others, so it is smaller than any other kind's plot.
|
|
14
|
+
* A panel's least and greatest width, its plot's least height, and the least width asked-for
|
|
15
|
+
* columns may give. These are small multiples' own: a panel holds a name, a value and a line,
|
|
16
|
+
* and is read beside others, so it is smaller than any other kind's plot. At its narrowest two
|
|
17
|
+
* panels stand side by side on a phone's tile, about 280 pixels beside the numbers, since a
|
|
18
|
+
* name too long to share its line with the value takes a line of its own; in a narrower tile
|
|
19
|
+
* still, two stand across while each plot is no thinner than its thinnest. No plot is lower than
|
|
20
|
+
* its least: a picture with no room for one is left a panel short, and says which.
|
|
17
21
|
*/
|
|
18
22
|
const PANEL = {
|
|
19
|
-
narrowest:
|
|
23
|
+
narrowest: 130,
|
|
20
24
|
widest: 320,
|
|
21
|
-
lowest:
|
|
25
|
+
lowest: 38,
|
|
22
26
|
thinnest: 48
|
|
23
27
|
};
|
|
24
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* The bounds of a plot's height when the picture has all the height it asks for. Lowest, 72:
|
|
30
|
+
* about three lines of text, room for a line's rise and fall to read and for two grid lines
|
|
31
|
+
* apart; lower is for a picture with no more height to give. Highest, 160: a panel is read at a
|
|
32
|
+
* glance beside the others, and a taller one shows its line no better while it pushes the next
|
|
33
|
+
* row out of sight.
|
|
34
|
+
*/
|
|
35
|
+
const NATURAL = {
|
|
36
|
+
lowest: 72,
|
|
37
|
+
highest: 160
|
|
38
|
+
};
|
|
39
|
+
/** The shape a plot is best at: a little wider than tall. */
|
|
25
40
|
const ASPECT = 1.6;
|
|
26
41
|
/**
|
|
27
42
|
* The column counts worth trying: those the width allows, or the one asked for (`across`, how
|
|
28
43
|
* many panels across). `inset` is the room a panel keeps beside its plot (its own numbers, the
|
|
29
44
|
* dot at its line's end): a panel is never so narrow that its plot is thinner than the least a
|
|
30
|
-
* plot may be.
|
|
45
|
+
* plot may be. Panels are read side by side, so one column is tried only when the width allows
|
|
46
|
+
* no more.
|
|
31
47
|
*/
|
|
32
48
|
function choices(count, width, at) {
|
|
33
49
|
const { across } = at;
|
|
50
|
+
const inset = at.inset ?? 0;
|
|
34
51
|
const wide = Math.max(1, count);
|
|
35
|
-
const room = Math.max(1, Math.floor((width + GAP.x) / (PANEL.thinnest +
|
|
52
|
+
const room = Math.max(1, Math.floor((width + GAP.x) / (PANEL.thinnest + inset + GAP.x)));
|
|
36
53
|
if (across !== void 0 && Number.isFinite(across)) return [Math.max(1, Math.min(wide, room, Math.round(across)))];
|
|
37
|
-
const narrowest = Math.max(PANEL.narrowest, PANEL.thinnest +
|
|
38
|
-
const many = Math.max(
|
|
39
|
-
const few = Math.min(wide, many, Math.max(
|
|
54
|
+
const narrowest = Math.max(PANEL.narrowest, PANEL.thinnest + inset);
|
|
55
|
+
const many = Math.max(Math.min(2, room), Math.floor((width + GAP.x) / (narrowest + GAP.x)));
|
|
56
|
+
const few = Math.min(wide, many, Math.max(Math.min(2, wide), Math.ceil((width + GAP.x) / (PANEL.widest + GAP.x))));
|
|
40
57
|
const last = Math.min(many, Math.max(few, wide));
|
|
41
58
|
return Array.from({ length: last - few + 1 }, (_v, i) => few + i);
|
|
42
59
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
/**
|
|
61
|
+
* How many panels across, from the width and the names alone: of the counts the width allows,
|
|
62
|
+
* those whose panels hold the widest name whole on a line of its own, then the one whose last
|
|
63
|
+
* row is fullest (eight series stand four and four sooner than seven and one), then the most,
|
|
64
|
+
* which leaves the panels lowest. The height has no say: the same width is always drawn in the
|
|
65
|
+
* same columns.
|
|
66
|
+
*/
|
|
67
|
+
function columnsOf(count, width, at = {}) {
|
|
68
|
+
const named = (columns) => cellWidth(width, columns) >= (at.name ?? 0) ? 0 : 1;
|
|
69
|
+
const empty = (columns) => (columns - Math.max(1, count) % columns) % columns;
|
|
70
|
+
return choices(count, width, at).reduce((best, columns) => named(columns) * count + empty(columns) <= named(best) * count + empty(best) ? columns : best);
|
|
71
|
+
}
|
|
72
|
+
/** One panel's width, of so many across a width. */
|
|
73
|
+
const cellWidth = (width, columns) => Math.max(1, (width - (columns - 1) * GAP.x) / columns);
|
|
74
|
+
/**
|
|
75
|
+
* The grid in a room: as many rows as the series need and the room has height for, each panel
|
|
76
|
+
* no lower than its head over a plot of the least height.
|
|
77
|
+
*/
|
|
78
|
+
function panelGrid(count, room, at) {
|
|
79
|
+
const { columns } = at;
|
|
80
|
+
const fit = Math.max(1, Math.floor((room.height + GAP.y) / (at.head + PANEL.lowest + GAP.y)));
|
|
46
81
|
const rows = Math.max(1, Math.min(Math.ceil(count / columns), fit));
|
|
47
82
|
return {
|
|
48
83
|
columns,
|
|
49
84
|
rows,
|
|
50
85
|
shown: Math.min(count, rows * columns),
|
|
51
|
-
width:
|
|
86
|
+
width: cellWidth(room.width, columns),
|
|
52
87
|
height: Math.max(1, (room.height - (rows - 1) * GAP.y) / rows)
|
|
53
88
|
};
|
|
54
89
|
}
|
|
55
|
-
/** How far a panel is from the shape it is best at. */
|
|
56
|
-
const misfit = (grid) => Math.abs(Math.log(grid.width / grid.height / ASPECT));
|
|
57
90
|
/**
|
|
58
|
-
* The
|
|
59
|
-
*
|
|
60
|
-
* and the dot at its line's end.
|
|
91
|
+
* The height every series' panel asks for: as many rows as the series need, each its head over
|
|
92
|
+
* a plot at the shape a panel is best at for the plot's width (`plot`), within its bounds.
|
|
61
93
|
*/
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
return choices(count, room.width, ask).map((c) => gridWith(count, room, c)).reduce((best, grid) => grid.shown > best.shown || grid.shown === best.shown && misfit(grid) < misfit(best) ? grid : best);
|
|
94
|
+
function rowsHeight(count, at) {
|
|
95
|
+
const rows = Math.ceil(Math.max(1, count) / at.columns);
|
|
96
|
+
const plot = Math.min(NATURAL.highest, Math.max(NATURAL.lowest, at.plot / ASPECT));
|
|
97
|
+
return rows * (at.head + plot) + (rows - 1) * GAP.y;
|
|
68
98
|
}
|
|
69
99
|
/** The box of the panel at a place in the grid, counted across and then down. */
|
|
70
100
|
function cellOf(grid, room, index) {
|
|
@@ -104,4 +134,4 @@ function endsUnder(x, at) {
|
|
|
104
134
|
...env.locale === void 0 ? {} : { locale: env.locale }
|
|
105
135
|
}).filter((tick) => env.measure(tick.text, TEXT.tick) <= plot.width);
|
|
106
136
|
}
|
|
107
|
-
export { around, cellOf, endsUnder, panelGrid };
|
|
137
|
+
export { GAP, PANEL, around, cellOf, cellWidth, columnsOf, endsUnder, panelGrid, rowsHeight };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { wordsOf } from "../data/words.mjs";
|
|
2
|
+
import { fitOrNone, wholeOf } from "../text/measure.mjs";
|
|
3
|
+
import { LINE, SPACE, TEXT } from "../theme.mjs";
|
|
4
|
+
import { lastSaid } from "./time-stops.mjs";
|
|
5
5
|
// src/kinds/multiples-head.ts
|
|
6
6
|
/** The name cut to a width, when even its cut form fits there; none for an empty name. */
|
|
7
7
|
const nameIn = (label, width, env) => label === "" ? void 0 : fitOrNone(label, {
|
|
@@ -9,36 +9,66 @@ const nameIn = (label, width, env) => label === "" ? void 0 : fitOrNone(label, {
|
|
|
9
9
|
font: TEXT.name,
|
|
10
10
|
measure: env.measure
|
|
11
11
|
});
|
|
12
|
+
/** A series' last value as its panel writes it, and how wide that is; none when it has no value. */
|
|
13
|
+
function lastValue(series, at) {
|
|
14
|
+
const { value: text } = lastSaid(series, at.buckets, wordsOf(at.env));
|
|
15
|
+
return text === void 0 ? void 0 : {
|
|
16
|
+
text,
|
|
17
|
+
width: at.env.measure(text, TEXT.value)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Whether a series' name fits whole beside its value in a head's width: as it must to share its line. */
|
|
21
|
+
function beside(series, at) {
|
|
22
|
+
const value = lastValue(series, at);
|
|
23
|
+
if (value === void 0 || series.label === "") return true;
|
|
24
|
+
return at.env.measure(series.label, TEXT.name) + SPACE.names + value.width <= at.width;
|
|
25
|
+
}
|
|
12
26
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
27
|
+
* How many lines the panels' heads take, the narrowest head being `width` wide: one when every
|
|
28
|
+
* series' name fits beside its value, else two. Every series is asked, drawn or not, so the
|
|
29
|
+
* width alone says, as it says how many columns there are.
|
|
15
30
|
*/
|
|
16
|
-
|
|
31
|
+
const headLines = (series, at) => series.every((one) => beside(one, at)) ? 1 : 2;
|
|
32
|
+
/** The room a head of some lines takes over its plot: its lines, and a gap so it reads as the panel's title and not as a label on its top grid line. */
|
|
33
|
+
const headRoom = (lines) => lines * LINE.name + 4;
|
|
34
|
+
/**
|
|
35
|
+
* The name and the last value: the name at the left, cut only when wider than the panel; the
|
|
36
|
+
* value at the right on a head of one line, which the panels take only where every name fits
|
|
37
|
+
* beside its value (`headLines`), and under the name on a head of two. The value is left out
|
|
38
|
+
* when it is wider than the panel.
|
|
39
|
+
*/
|
|
40
|
+
function headNodes(at, env, buckets) {
|
|
17
41
|
const { head, series } = at;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
42
|
+
const name = nameIn(series.label, head.width, env);
|
|
43
|
+
const value = lastValue(series, {
|
|
44
|
+
env,
|
|
45
|
+
buckets
|
|
46
|
+
});
|
|
47
|
+
const place = head.height > LINE.name ? {
|
|
48
|
+
x: head.x,
|
|
49
|
+
y: head.y + LINE.name,
|
|
50
|
+
anchor: "start"
|
|
51
|
+
} : {
|
|
52
|
+
x: head.x + head.width,
|
|
23
53
|
y: head.y,
|
|
24
|
-
|
|
54
|
+
anchor: "end"
|
|
25
55
|
};
|
|
26
|
-
const showValue = value !== void 0 && (beside !== void 0 || name === void 0 && valueWidth <= head.width);
|
|
27
56
|
return [...name === void 0 ? [] : [{
|
|
28
57
|
kind: "text",
|
|
29
58
|
part: "name",
|
|
30
59
|
x: head.x,
|
|
60
|
+
y: head.y,
|
|
31
61
|
text: name,
|
|
62
|
+
...wholeOf(name, series.label),
|
|
32
63
|
...TEXT.name,
|
|
33
|
-
|
|
34
|
-
}], ...
|
|
64
|
+
baseline: "hanging"
|
|
65
|
+
}], ...value === void 0 || value.width > head.width ? [] : [{
|
|
35
66
|
kind: "text",
|
|
36
67
|
part: "value",
|
|
37
|
-
|
|
38
|
-
text: value,
|
|
68
|
+
text: value.text,
|
|
39
69
|
...TEXT.value,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}]
|
|
70
|
+
...place,
|
|
71
|
+
baseline: "hanging"
|
|
72
|
+
}]];
|
|
43
73
|
}
|
|
44
|
-
export { headNodes };
|
|
74
|
+
export { headLines, headNodes, headRoom };
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import { contentBox } from "../layout/frame.mjs";
|
|
1
|
+
import { aroundHeight, contentBox } from "../layout/frame.mjs";
|
|
2
2
|
import { X_ROOM, gutterOf } from "../marks/axes.mjs";
|
|
3
|
+
import { MORE_ROOM } from "../marks/more.mjs";
|
|
3
4
|
import { timeScale } from "../scale/time.mjs";
|
|
4
5
|
import { placeOn, tickCount, valueAxis } from "../scale/value.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { widest } from "../text/measure.mjs";
|
|
7
|
+
import { LINE, TEXT } from "../theme.mjs";
|
|
8
|
+
import { PANEL, around, cellOf, cellWidth, columnsOf, endsUnder, panelGrid, rowsHeight } from "./multiples-grid.mjs";
|
|
9
|
+
import { headLines, headRoom } from "./multiples-head.mjs";
|
|
7
10
|
import { END_ROOM, anyValueIn, valuesOf } from "./time-plot.mjs";
|
|
8
11
|
// src/kinds/multiples-layout.ts
|
|
9
12
|
/**
|
|
10
|
-
* The room the name and value take over a panel's plot: their line, and a gap of small
|
|
11
|
-
* multiples' own so the name reads as the panel's title and not as a label on its top grid line.
|
|
12
|
-
*/
|
|
13
|
-
const HEAD = LINE.name + 4;
|
|
14
|
-
/**
|
|
15
|
-
* The room under the panels for the line that counts the rest: its line, and a gap of its own
|
|
16
|
-
* that keeps it apart from the lowest panels' time.
|
|
17
|
-
*/
|
|
18
|
-
const MORE = LINE.tick + 6;
|
|
19
|
-
/**
|
|
20
13
|
* Each series' axis: one over them all, or each its own, reaching the references too (and zero,
|
|
21
14
|
* when asked to keep it), with about `count` ticks.
|
|
22
15
|
*/
|
|
@@ -33,14 +26,9 @@ function axesOf(table, at) {
|
|
|
33
26
|
const all = axisOf(table.series);
|
|
34
27
|
return table.series.map((s) => at.options.shared === false ? axisOf([s]) : all);
|
|
35
28
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Whether a room holds a panel's name over a plot worth reading, beside its own numbers and the
|
|
38
|
-
* room its line's end dot takes at its right.
|
|
39
|
-
*/
|
|
40
|
-
const fits = (room, inset) => room.height >= HEAD + 24 && room.width - inset - END_ROOM >= 24;
|
|
41
29
|
/** The room for the grid: under the header, right of a shared axis's numbers, over the time. */
|
|
42
30
|
function roomOf(table, axes, { options, env }) {
|
|
43
|
-
const gutter = table.series.reduce((
|
|
31
|
+
const gutter = table.series.reduce((most, s, i) => Math.max(most, gutterOf(axes[i] ?? {
|
|
44
32
|
min: 0,
|
|
45
33
|
max: 1,
|
|
46
34
|
ticks: []
|
|
@@ -57,8 +45,26 @@ function roomOf(table, axes, { options, env }) {
|
|
|
57
45
|
}
|
|
58
46
|
};
|
|
59
47
|
}
|
|
60
|
-
/** The
|
|
61
|
-
|
|
48
|
+
/** The highest value a series reaches; below every value for a series with none. */
|
|
49
|
+
const peakOf = (series) => series.values.reduce((top, v) => v !== null && v > top ? v : top, -Infinity);
|
|
50
|
+
/**
|
|
51
|
+
* The series that get a panel when only `shown` fit, each with its place: those that reach
|
|
52
|
+
* highest (a series with no value last, the first of equals first), in the order given.
|
|
53
|
+
*/
|
|
54
|
+
function keptOf(series, shown) {
|
|
55
|
+
return series.map((one, at) => ({
|
|
56
|
+
series: one,
|
|
57
|
+
at,
|
|
58
|
+
peak: peakOf(one)
|
|
59
|
+
})).toSorted((a, b) => b.peak - a.peak || a.at - b.at).slice(0, shown).toSorted((a, b) => a.at - b.at);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The frame for an axis of about `count` ticks, with as many columns as the width gives or as
|
|
63
|
+
* `columns` says: panels that hold the widest name whole where the width has room for them.
|
|
64
|
+
* A panel's head is narrowest in any column but the first, which reaches over a shared
|
|
65
|
+
* scale's numbers: one column wide, it is the first.
|
|
66
|
+
*/
|
|
67
|
+
function frameOf(table, options, at) {
|
|
62
68
|
const shared = options.shared !== false;
|
|
63
69
|
const axes = axesOf(table, {
|
|
64
70
|
options,
|
|
@@ -68,36 +74,62 @@ function placed(table, options, at) {
|
|
|
68
74
|
options,
|
|
69
75
|
env: at.env
|
|
70
76
|
});
|
|
71
|
-
const count = table.series.length;
|
|
72
|
-
const none = {
|
|
73
|
-
panels: [],
|
|
74
|
-
room: whole,
|
|
75
|
-
hidden: count
|
|
76
|
-
};
|
|
77
77
|
const inset = shared ? 0 : gutter;
|
|
78
78
|
const ask = {
|
|
79
|
-
|
|
80
|
-
inset: inset + END_ROOM
|
|
79
|
+
across: options.across,
|
|
80
|
+
inset: inset + END_ROOM,
|
|
81
|
+
name: widest(table.series.map((s) => s.label), TEXT.name, at.env.measure)
|
|
81
82
|
};
|
|
82
|
-
|
|
83
|
-
const
|
|
83
|
+
const columns = at.columns ?? columnsOf(table.series.length, whole.width, ask);
|
|
84
|
+
const width = cellWidth(whole.width, columns);
|
|
85
|
+
const narrowest = shared && columns === 1 ? width + gutter : width;
|
|
86
|
+
const lines = headLines(table.series, {
|
|
87
|
+
width: narrowest,
|
|
88
|
+
env: at.env,
|
|
89
|
+
buckets: table.x.buckets
|
|
90
|
+
});
|
|
91
|
+
const plot = width - inset - END_ROOM;
|
|
92
|
+
const roomy = anyValueIn(table) && plot >= 24;
|
|
93
|
+
return {
|
|
94
|
+
axes,
|
|
95
|
+
gutter,
|
|
96
|
+
whole,
|
|
97
|
+
inset,
|
|
98
|
+
across: {
|
|
99
|
+
columns,
|
|
100
|
+
head: headRoom(lines)
|
|
101
|
+
},
|
|
102
|
+
lines,
|
|
103
|
+
plot,
|
|
104
|
+
roomy
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** The panels' places in a frame: none with nothing to draw, or no room for a panel's head over a plot. */
|
|
108
|
+
function placed(table, frame, env) {
|
|
109
|
+
const { whole, across, gutter, inset, axes } = frame;
|
|
110
|
+
const count = table.series.length;
|
|
111
|
+
const all = panelGrid(count, whole, across);
|
|
84
112
|
const room = all.shown < count ? {
|
|
85
113
|
...whole,
|
|
86
|
-
height: whole.height -
|
|
114
|
+
height: whole.height - MORE_ROOM
|
|
87
115
|
} : whole;
|
|
88
|
-
const grid = all.shown < count ? panelGrid(count, room,
|
|
89
|
-
if (!
|
|
116
|
+
const grid = all.shown < count ? panelGrid(count, room, across) : all;
|
|
117
|
+
if (!frame.roomy || room.height < across.head + PANEL.lowest) return {
|
|
118
|
+
panels: [],
|
|
119
|
+
room: whole
|
|
120
|
+
};
|
|
121
|
+
const shared = inset === 0;
|
|
90
122
|
return {
|
|
91
|
-
panels: table.series
|
|
123
|
+
panels: keptOf(table.series, grid.shown).map(({ series, at: own }, i) => {
|
|
92
124
|
const cell = cellOf(grid, room, i);
|
|
93
125
|
const left = shared && i % grid.columns === 0 ? cell.x - gutter : cell.x;
|
|
94
126
|
const plot = {
|
|
95
127
|
x: cell.x + inset,
|
|
96
|
-
y: cell.y +
|
|
97
|
-
width: Math.max(1,
|
|
98
|
-
height: Math.max(1, cell.height -
|
|
128
|
+
y: cell.y + across.head,
|
|
129
|
+
width: Math.max(1, frame.plot),
|
|
130
|
+
height: Math.max(1, cell.height - across.head)
|
|
99
131
|
};
|
|
100
|
-
const axis = axes[
|
|
132
|
+
const axis = axes[own] ?? {
|
|
101
133
|
min: 0,
|
|
102
134
|
max: 1,
|
|
103
135
|
ticks: []
|
|
@@ -114,7 +146,7 @@ function placed(table, options, at) {
|
|
|
114
146
|
x: left,
|
|
115
147
|
y: cell.y,
|
|
116
148
|
width: cell.x + cell.width - left,
|
|
117
|
-
height: LINE.name
|
|
149
|
+
height: frame.lines * LINE.name
|
|
118
150
|
},
|
|
119
151
|
plot,
|
|
120
152
|
axis,
|
|
@@ -124,36 +156,58 @@ function placed(table, options, at) {
|
|
|
124
156
|
times: lowest ? endsUnder(table.x, {
|
|
125
157
|
plot,
|
|
126
158
|
center: time.center,
|
|
127
|
-
env
|
|
159
|
+
env
|
|
128
160
|
}) : []
|
|
129
161
|
};
|
|
130
162
|
}),
|
|
131
|
-
room
|
|
132
|
-
hidden: count - grid.shown
|
|
163
|
+
room
|
|
133
164
|
};
|
|
134
165
|
}
|
|
135
166
|
/**
|
|
167
|
+
* The height the panels ask for in a frame: the header and the source, every series' panel at
|
|
168
|
+
* its best shape, and the time under the lowest; no line counts the rest, since none is left
|
|
169
|
+
* out. None when there is no room across for a plot.
|
|
170
|
+
*/
|
|
171
|
+
const naturalIn = (table, frame, options) => frame.roomy ? aroundHeight(options) + X_ROOM + rowsHeight(table.series.length, {
|
|
172
|
+
...frame.across,
|
|
173
|
+
plot: frame.plot
|
|
174
|
+
}) : void 0;
|
|
175
|
+
/**
|
|
176
|
+
* The height small multiples ask for, worked out from the width alone and without placing a
|
|
177
|
+
* panel: the frame of the fewest ticks, which the layout's columns and its height asked for are
|
|
178
|
+
* both taken from.
|
|
179
|
+
*/
|
|
180
|
+
const naturalOf = (table, options, env) => naturalIn(table, frameOf(table, options, {
|
|
181
|
+
env,
|
|
182
|
+
count: tickCount(0)
|
|
183
|
+
}), options);
|
|
184
|
+
/**
|
|
136
185
|
* The panels' places: the grid in the room the header, the left ticks and the time leave. How
|
|
137
186
|
* many ticks a panel has room for depends on its height, and its height on the room the ticks'
|
|
138
187
|
* numbers leave; so the panels are placed with the fewest ticks first, then with as many as
|
|
139
|
-
* that height has room for. Wider numbers can leave a panel a little
|
|
188
|
+
* that height has room for, in the same columns. Wider numbers can leave a panel a little
|
|
189
|
+
* narrower, its ticks closer. The columns and the height asked for are the first frame's, which
|
|
190
|
+
* the height given has no say in.
|
|
140
191
|
*/
|
|
141
192
|
function layoutOf(table, options, env) {
|
|
142
|
-
const
|
|
193
|
+
const frame = frameOf(table, options, {
|
|
143
194
|
env,
|
|
144
195
|
count: tickCount(0)
|
|
145
196
|
});
|
|
197
|
+
const fewest = placed(table, frame, env);
|
|
146
198
|
const count = tickCount(fewest.panels[0]?.plot.height ?? 0);
|
|
147
|
-
const
|
|
199
|
+
const columns = frame.across.columns;
|
|
200
|
+
const more = count === tickCount(0) ? fewest : placed(table, frameOf(table, options, {
|
|
148
201
|
env,
|
|
149
|
-
count
|
|
150
|
-
|
|
151
|
-
|
|
202
|
+
count,
|
|
203
|
+
columns
|
|
204
|
+
}), env);
|
|
205
|
+
const { panels, room } = more.panels.length === 0 ? fewest : more;
|
|
152
206
|
return {
|
|
153
207
|
panels,
|
|
154
208
|
plot: around(panels.map((p) => p.plot), room),
|
|
155
|
-
|
|
156
|
-
|
|
209
|
+
moreY: room.y + room.height + X_ROOM + MORE_ROOM / 2,
|
|
210
|
+
natural: naturalIn(table, frame, options)
|
|
157
211
|
};
|
|
158
212
|
}
|
|
159
|
-
export { layoutOf };
|
|
213
|
+
export { layoutOf, naturalOf };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tickUnder, valueGrid,
|
|
1
|
+
import { tickUnder, valueGrid, zeroLine, zeroOn } from "../marks/axes.mjs";
|
|
2
2
|
import { alongLine, levelNotes, marked } from "../marks/notes.mjs";
|
|
3
3
|
import { pointsOf, seriesLine } from "../marks/series-line.mjs";
|
|
4
4
|
import { ownPaint } from "../theme.mjs";
|
|
@@ -62,15 +62,16 @@ function panelNodes(at, look) {
|
|
|
62
62
|
reads: series.measure,
|
|
63
63
|
numbers: at.ticks
|
|
64
64
|
});
|
|
65
|
-
const base =
|
|
65
|
+
const base = zeroOn(at.axis, place);
|
|
66
66
|
const line = seriesLine(series, {
|
|
67
67
|
buckets: look.x.buckets,
|
|
68
68
|
center: at.time.center,
|
|
69
|
-
place
|
|
69
|
+
place,
|
|
70
|
+
step: look.step
|
|
70
71
|
}, {
|
|
71
72
|
color: colorOf(series, look),
|
|
72
73
|
curve: look.curve,
|
|
73
|
-
washTo: base
|
|
74
|
+
...base === void 0 ? {} : { washTo: base }
|
|
74
75
|
});
|
|
75
76
|
const notes = levels(at, look);
|
|
76
77
|
const children = [
|
|
@@ -82,7 +83,7 @@ function panelNodes(at, look) {
|
|
|
82
83
|
}),
|
|
83
84
|
...notes.lines,
|
|
84
85
|
...at.ticks ? notes.names : [],
|
|
85
|
-
...headNodes(at, look.env),
|
|
86
|
+
...headNodes(at, look.env, look.x.buckets),
|
|
86
87
|
...timeLabels(at)
|
|
87
88
|
];
|
|
88
89
|
return [{
|