derive-dashboards 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +513 -0
- package/README.md +8 -2
- package/dist/adapter/statement.mjs +9 -7
- package/dist/authorize.mjs +27 -6
- package/dist/body.mjs +28 -25
- package/dist/cache.d.mts +2 -2
- package/dist/charts/data/buckets.d.mts +25 -7
- package/dist/charts/data/buckets.mjs +92 -15
- package/dist/charts/data/clean.mjs +254 -12
- package/dist/charts/data/format.d.mts +7 -2
- package/dist/charts/data/format.mjs +68 -70
- package/dist/charts/data/input-error.d.mts +2 -0
- package/dist/charts/data/input-error.mjs +2 -0
- package/dist/charts/data/rows.d.mts +3 -1
- package/dist/charts/data/rows.mjs +4 -2
- package/dist/charts/data/types.d.mts +50 -7
- package/dist/charts/data/words.d.mts +13 -0
- package/dist/charts/data/words.mjs +8 -1
- package/dist/charts/describe.mjs +6 -6
- package/dist/charts/index.d.mts +14 -14
- package/dist/charts/index.mjs +4 -1
- package/dist/charts/kinds/area-marks.mjs +86 -44
- package/dist/charts/kinds/area.d.mts +3 -3
- package/dist/charts/kinds/area.mjs +32 -11
- package/dist/charts/kinds/bars-data.d.mts +3 -3
- package/dist/charts/kinds/bars-data.mjs +12 -6
- package/dist/charts/kinds/bars-layout.mjs +60 -6
- package/dist/charts/kinds/bars-marks.mjs +6 -6
- package/dist/charts/kinds/bars.d.mts +5 -3
- package/dist/charts/kinds/bars.mjs +39 -6
- package/dist/charts/kinds/columns-data.mjs +14 -5
- package/dist/charts/kinds/columns-marks.mjs +52 -23
- package/dist/charts/kinds/columns.d.mts +2 -2
- package/dist/charts/kinds/columns.mjs +36 -10
- package/dist/charts/kinds/course-data.mjs +44 -0
- package/dist/charts/kinds/course-layout.mjs +77 -0
- package/dist/charts/kinds/course-marks.mjs +52 -0
- package/dist/charts/kinds/course-words.mjs +64 -0
- package/dist/charts/kinds/course.d.mts +10 -0
- package/dist/charts/kinds/course.mjs +55 -0
- package/dist/charts/kinds/dumbbell-data.d.mts +4 -4
- package/dist/charts/kinds/dumbbell-data.mjs +3 -3
- package/dist/charts/kinds/dumbbell-layout.mjs +17 -8
- package/dist/charts/kinds/dumbbell.d.mts +5 -3
- package/dist/charts/kinds/dumbbell.mjs +35 -4
- package/dist/charts/kinds/funnel-data.d.mts +3 -3
- package/dist/charts/kinds/funnel-data.mjs +11 -16
- package/dist/charts/kinds/funnel-layout.mjs +7 -6
- package/dist/charts/kinds/funnel.d.mts +5 -4
- package/dist/charts/kinds/funnel.mjs +33 -6
- package/dist/charts/kinds/grid-data.d.mts +3 -3
- package/dist/charts/kinds/grid-data.mjs +55 -13
- package/dist/charts/kinds/grid-layout.mjs +88 -13
- package/dist/charts/kinds/grid-legend.mjs +60 -0
- package/dist/charts/kinds/grid-marks.mjs +81 -32
- package/dist/charts/kinds/grid-time.mjs +19 -5
- package/dist/charts/kinds/grid-words.mjs +57 -35
- package/dist/charts/kinds/grid.d.mts +7 -4
- package/dist/charts/kinds/grid.mjs +51 -9
- package/dist/charts/kinds/histogram-data.mjs +68 -26
- package/dist/charts/kinds/histogram-layout.mjs +4 -3
- package/dist/charts/kinds/histogram-words.mjs +2 -3
- package/dist/charts/kinds/histogram.d.mts +2 -2
- package/dist/charts/kinds/histogram.mjs +17 -1
- package/dist/charts/kinds/line-marks.mjs +19 -11
- package/dist/charts/kinds/line.d.mts +2 -2
- package/dist/charts/kinds/line.mjs +21 -3
- package/dist/charts/kinds/multiples-grid.mjs +57 -27
- package/dist/charts/kinds/multiples-head.mjs +52 -22
- package/dist/charts/kinds/multiples-layout.mjs +106 -52
- package/dist/charts/kinds/multiples-marks.mjs +6 -5
- package/dist/charts/kinds/multiples-words.mjs +53 -38
- package/dist/charts/kinds/multiples.d.mts +2 -2
- package/dist/charts/kinds/multiples.mjs +35 -7
- package/dist/charts/kinds/row-chart.d.mts +7 -0
- package/dist/charts/kinds/row-chart.mjs +47 -10
- package/dist/charts/kinds/row-marks.mjs +5 -5
- package/dist/charts/kinds/scatter-data.d.mts +5 -5
- package/dist/charts/kinds/scatter-data.mjs +6 -6
- package/dist/charts/kinds/scatter-marks.mjs +46 -19
- package/dist/charts/kinds/scatter-words.mjs +8 -8
- package/dist/charts/kinds/scatter.d.mts +5 -3
- package/dist/charts/kinds/scatter.mjs +18 -0
- package/dist/charts/kinds/stat-data.mjs +7 -7
- package/dist/charts/kinds/stat-marks.mjs +2 -2
- package/dist/charts/kinds/stat.d.mts +4 -4
- package/dist/charts/kinds/stat.mjs +19 -0
- package/dist/charts/kinds/time-chart.mjs +13 -4
- package/dist/charts/kinds/time-frame.mjs +50 -19
- package/dist/charts/kinds/time-plan.mjs +29 -2
- package/dist/charts/kinds/time-plot.mjs +1 -1
- package/dist/charts/kinds/time-stops.mjs +58 -29
- package/dist/charts/kinds/waterfall-data.d.mts +3 -3
- package/dist/charts/kinds/waterfall-data.mjs +2 -2
- package/dist/charts/kinds/waterfall.d.mts +5 -4
- package/dist/charts/kinds/waterfall.mjs +29 -2
- package/dist/charts/layout/frame.mjs +5 -3
- package/dist/charts/layout/stack.mjs +43 -22
- package/dist/charts/marks/axes.mjs +12 -6
- package/dist/charts/marks/budget.mjs +14 -0
- package/dist/charts/marks/end-labels.mjs +24 -10
- package/dist/charts/marks/legend.mjs +19 -8
- package/dist/charts/marks/lines.mjs +3 -3
- package/dist/charts/marks/more.mjs +79 -13
- package/dist/charts/marks/notes.mjs +12 -6
- package/dist/charts/marks/series-line.mjs +14 -10
- package/dist/charts/marks/thin.mjs +16 -33
- package/dist/charts/marks/x-axis.mjs +3 -2
- package/dist/charts/scale/calendar.mjs +41 -26
- package/dist/charts/scale/linear.mjs +58 -0
- package/dist/charts/scale/value.d.mts +21 -0
- package/dist/charts/scale/value.mjs +67 -9
- package/dist/charts/scene/lazy.mjs +27 -0
- package/dist/charts/scene/markup.mjs +2 -1
- package/dist/charts/scene/svg.mjs +20 -8
- package/dist/charts/scene/types.d.mts +34 -0
- package/dist/charts/text/measure.mjs +33 -3
- package/dist/charts/theme.d.mts +25 -25
- package/dist/charts/theme.mjs +47 -30
- package/dist/charts-react/Chart.d.mts +20 -0
- package/dist/charts-react/Chart.mjs +9 -67
- package/dist/charts-react/Reader.mjs +50 -96
- package/dist/charts-react/box.mjs +106 -0
- package/dist/charts-react/bucket-names.mjs +9 -24
- package/dist/charts-react/columns-picture.mjs +12 -0
- package/dist/charts-react/exact-sum.mjs +4 -7
- package/dist/charts-react/from-answer.mjs +9 -4
- package/dist/charts-react/index.d.mts +9 -2
- package/dist/charts-react/index.mjs +9 -2
- package/dist/charts-react/kinds/area.d.mts +4 -0
- package/dist/charts-react/kinds/area.mjs +38 -0
- package/dist/charts-react/kinds/bar.d.mts +4 -0
- package/dist/charts-react/kinds/bar.mjs +15 -0
- package/dist/charts-react/kinds/funnel.d.mts +4 -0
- package/dist/charts-react/kinds/funnel.mjs +13 -0
- package/dist/charts-react/kinds/heatmap.d.mts +4 -0
- package/dist/charts-react/kinds/heatmap.mjs +13 -0
- package/dist/charts-react/kinds/line.d.mts +4 -0
- package/dist/charts-react/kinds/line.mjs +20 -0
- package/dist/charts-react/kinds/multiples.d.mts +4 -0
- package/dist/charts-react/kinds/multiples.mjs +33 -0
- package/dist/charts-react/kinds/number.d.mts +5 -0
- package/dist/charts-react/kinds/number.mjs +86 -0
- package/dist/charts-react/plan-bars.mjs +15 -8
- package/dist/charts-react/plan-funnel.mjs +3 -1
- package/dist/charts-react/plan-grid.mjs +14 -5
- package/dist/charts-react/plan-of.mjs +17 -0
- package/dist/charts-react/plan-parts.mjs +16 -5
- package/dist/charts-react/plan-time.mjs +4 -53
- package/dist/charts-react/reader-page.d.mts +1 -1
- package/dist/charts-react/reader-page.mjs +19 -9
- package/dist/charts-react/renderers.d.mts +14 -0
- package/dist/charts-react/renderers.mjs +22 -0
- package/dist/charts-react/table.d.mts +1 -0
- package/dist/charts-react/table.mjs +108 -0
- package/dist/charts-react/tiles.mjs +21 -49
- package/dist/charts-react/useScene.mjs +45 -17
- package/dist/charts-react/words.mjs +19 -0
- package/dist/checks.mjs +97 -19
- package/dist/cli/add.mjs +4 -3
- package/dist/cli/doctor.mjs +2 -2
- package/dist/core/conformance/index.d.mts +5 -2
- package/dist/core/conformance/index.mjs +5 -2
- package/dist/core/conformance/memory/aggregate.mjs +11 -6
- package/dist/core/conformance/memory/rows.d.mts +7 -3
- package/dist/core/conformance/memory/rows.mjs +19 -13
- package/dist/core/conformance/memory/source.mjs +4 -4
- package/dist/core/document/control-fields.d.mts +20 -0
- package/dist/core/document/control-fields.mjs +117 -0
- package/dist/core/document/display-comparisons.d.mts +17 -0
- package/dist/core/document/display-comparisons.mjs +15 -4
- package/dist/core/document/display-entries.d.mts +14 -0
- package/dist/core/document/display-entries.mjs +25 -9
- package/dist/core/document/display-validation.d.mts +5 -1
- package/dist/core/document/display-validation.mjs +14 -7
- package/dist/core/document/display.d.mts +11 -8
- package/dist/core/document/display.mjs +26 -3
- package/dist/core/document/layout.d.mts +8 -9
- package/dist/core/document/layout.mjs +23 -6
- package/dist/core/document/stacked.d.mts +0 -7
- package/dist/core/document/types.mjs +8 -6
- package/dist/core/document/upgrade.d.mts +1 -0
- package/dist/core/document/upgrade.mjs +4 -2
- package/dist/core/engine/access.mjs +3 -3
- package/dist/core/engine/assert.mjs +4 -2
- package/dist/core/engine/bucket.mjs +2 -2
- package/dist/core/engine/checks.mjs +6 -7
- package/dist/core/engine/custom/ask.mjs +22 -2
- package/dist/core/engine/custom/cells.mjs +22 -22
- package/dist/core/engine/custom/level.mjs +12 -13
- package/dist/core/engine/custom/measures.mjs +12 -9
- package/dist/core/engine/custom/reader.mjs +3 -1
- package/dist/core/engine/custom/records.mjs +8 -7
- package/dist/core/engine/custom/unread.mjs +78 -0
- package/dist/core/engine/custom/where.mjs +15 -10
- package/dist/core/engine/index.d.mts +2 -13
- package/dist/core/engine/index.mjs +2 -12
- package/dist/core/engine/measure.mjs +1 -0
- package/dist/core/engine/members.mjs +7 -3
- package/dist/core/engine/nan.mjs +10 -1
- package/dist/core/engine/native.mjs +2 -20
- package/dist/core/engine/numbers.mjs +26 -14
- package/dist/core/engine/postgres.mjs +9 -5
- package/dist/core/engine/prepare.mjs +4 -4
- package/dist/core/engine/rank-sets.mjs +1 -1
- package/dist/core/engine/read.mjs +5 -4
- package/dist/core/engine/reader.d.mts +6 -0
- package/dist/core/engine/record-layout.mjs +3 -3
- package/dist/core/engine/run.mjs +77 -20
- package/dist/core/engine/segmented.d.mts +2 -1
- package/dist/core/engine/segmented.mjs +19 -12
- package/dist/core/engine/series.mjs +1 -1
- package/dist/core/engine/shape.mjs +8 -8
- package/dist/core/engine/sql-partition.mjs +2 -2
- package/dist/core/engine/sql-pass.mjs +3 -2
- package/dist/core/engine/sql-reader.mjs +13 -5
- package/dist/core/engine/sql-reads.mjs +2 -1
- package/dist/core/engine/sql-records.mjs +2 -2
- package/dist/core/engine/sql-split.mjs +1 -1
- package/dist/core/engine/sql-unread.mjs +70 -0
- package/dist/core/engine/time.mjs +2 -1
- package/dist/core/engine/types.d.mts +17 -0
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +24 -1
- package/dist/core/error/codes.mjs +23 -3
- package/dist/core/error/refusal.d.mts +8 -3
- package/dist/core/error/refusal.mjs +6 -1
- package/dist/core/exact/decimal.d.mts +1 -14
- package/dist/core/exact/decimal.mjs +9 -19
- package/dist/core/exact/stored.d.mts +9 -0
- package/dist/core/exact/stored.mjs +38 -0
- package/dist/core/exact/text.d.mts +16 -1
- package/dist/core/exact/text.mjs +50 -1
- package/dist/core/format/digits.mjs +55 -0
- package/dist/core/format/index.d.mts +16 -0
- package/dist/core/format/index.mjs +27 -0
- package/dist/core/format/number.d.mts +27 -0
- package/dist/core/format/number.mjs +158 -0
- package/dist/core/format/write.d.mts +6 -0
- package/dist/core/format/write.mjs +57 -0
- package/dist/core/index.d.mts +43 -33
- package/dist/core/index.mjs +31 -28
- package/dist/core/model/defaults.d.mts +18 -1
- package/dist/core/model/defaults.mjs +19 -1
- package/dist/core/model/define.d.mts +17 -8
- package/dist/core/model/define.mjs +2 -0
- package/dist/core/model/member.d.mts +5 -3
- package/dist/core/model/member.mjs +33 -6
- package/dist/core/model/storage.mjs +40 -12
- package/dist/core/model/types.d.mts +17 -1
- package/dist/core/model/types.mjs +5 -0
- package/dist/core/model/validate/expr.d.mts +1 -7
- package/dist/core/model/validate/fields.d.mts +2 -0
- package/dist/core/model/validate/fields.mjs +14 -7
- package/dist/core/model/validate/issues.mjs +5 -1
- package/dist/core/model/validate/known-members.mjs +6 -5
- package/dist/core/model/validate/shape.mjs +36 -3
- package/dist/core/model/validate/source.mjs +2 -2
- package/dist/core/oracle/data.d.mts +4 -2
- package/dist/core/oracle/evaluate.d.mts +19 -1
- package/dist/core/oracle/evaluate.mjs +56 -10
- package/dist/core/oracle/expr.mjs +1 -1
- package/dist/core/oracle/facts.mjs +12 -5
- package/dist/core/oracle/measure.mjs +1 -1
- package/dist/core/oracle/request.mjs +39 -4
- package/dist/core/oracle/segmented.d.mts +3 -1
- package/dist/core/oracle/segmented.mjs +19 -13
- package/dist/core/oracle/unread.mjs +32 -0
- package/dist/core/oracle/visibility.mjs +4 -3
- package/dist/core/policy/bind.d.mts +2 -11
- package/dist/core/policy/bind.mjs +1 -1
- package/dist/core/policy/match.mjs +1 -1
- package/dist/core/query/closure.d.mts +7 -2
- package/dist/core/query/closure.mjs +29 -12
- package/dist/core/query/compose-tile.d.mts +3 -2
- package/dist/core/query/compose-tile.mjs +32 -13
- package/dist/core/query/compose.d.mts +0 -5
- package/dist/core/query/drill/internal.d.mts +5 -5
- package/dist/core/query/drill/internal.mjs +11 -0
- package/dist/core/query/drill/links.d.mts +2 -3
- package/dist/core/query/drill/links.mjs +18 -4
- package/dist/core/query/drill/selection.d.mts +8 -2
- package/dist/core/query/drill/selection.mjs +14 -3
- package/dist/core/query/drill/synthetic.mjs +1 -1
- package/dist/core/query/drill/time.mjs +11 -10
- package/dist/core/query/filter.d.mts +1 -6
- package/dist/core/query/filter.mjs +1 -4
- package/dist/core/query/fold.mjs +23 -0
- package/dist/core/query/segments.mjs +42 -3
- package/dist/core/query/to-wire.d.mts +7 -0
- package/dist/core/query/to-wire.mjs +14 -2
- package/dist/core/query/types.d.mts +30 -13
- package/dist/core/result/columns.mjs +23 -13
- package/dist/core/result/number.mjs +3 -3
- package/dist/core/result/status.d.mts +13 -0
- package/dist/core/result/status.mjs +18 -0
- package/dist/core/result/time-axis.d.mts +14 -13
- package/dist/core/result/time-axis.mjs +20 -2
- package/dist/core/result/types.d.mts +33 -3
- package/dist/core/result/whole.d.mts +23 -0
- package/dist/core/result/whole.mjs +27 -0
- package/dist/core/schema/agent-query.d.mts +89 -0
- package/dist/core/schema/agent-query.mjs +115 -0
- package/dist/core/schema/aliases.mjs +1 -52
- package/dist/core/schema/answer-parts.mjs +17 -13
- package/dist/core/schema/answers.d.mts +787 -319
- package/dist/core/schema/commands.d.mts +33 -23
- package/dist/core/schema/commands.mjs +26 -18
- package/dist/core/schema/custom.mjs +46 -45
- package/dist/core/schema/document.d.mts +32 -27
- package/dist/core/schema/document.mjs +61 -81
- package/dist/core/schema/drill-answers.mjs +4 -1
- package/dist/core/schema/drill.d.mts +14 -9
- package/dist/core/schema/drill.mjs +23 -22
- package/dist/core/schema/index.d.mts +5 -3
- package/dist/core/schema/index.mjs +5 -3
- package/dist/core/schema/options.d.mts +92 -0
- package/dist/core/schema/options.mjs +104 -0
- package/dist/core/schema/picks.d.mts +2 -2
- package/dist/core/schema/picks.mjs +7 -6
- package/dist/core/schema/query.d.mts +9 -83
- package/dist/core/schema/query.mjs +49 -73
- package/dist/core/schema/strict.d.mts +3 -0
- package/dist/core/schema/strict.mjs +91 -0
- package/dist/core/schema/union-error.mjs +30 -7
- package/dist/core/schema/view.d.mts +4 -3
- package/dist/core/schema/view.mjs +16 -11
- package/dist/core/store/ddl.d.mts +0 -2
- package/dist/core/store/ddl.mjs +1 -5
- package/dist/core/time/bucket.d.mts +1 -18
- package/dist/core/time/bucket.mjs +12 -8
- package/dist/core/time/compare.mjs +3 -2
- package/dist/core/time/index.d.mts +7 -8
- package/dist/core/time/instant.d.mts +15 -9
- package/dist/core/time/instant.mjs +23 -9
- package/dist/core/time/range.d.mts +3 -15
- package/dist/core/time/range.mjs +17 -7
- package/dist/core/time/stored.d.mts +8 -5
- package/dist/core/time/stored.mjs +51 -15
- package/dist/core/time/temporal.d.mts +1 -5
- package/dist/core/time/temporal.mjs +9 -4
- package/dist/core/time/text-time.d.mts +31 -2
- package/dist/core/time/text-time.mjs +139 -22
- package/dist/core/time/zone.d.mts +6 -1
- package/dist/core/time/zone.mjs +13 -4
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/dashboard.d.mts +185 -0
- package/dist/core/types/dashboard.mjs +26 -0
- package/dist/core/types/drill-api.d.mts +14 -2
- package/dist/core/types/infer.d.mts +0 -4
- package/dist/core/types/options-check.d.mts +42 -0
- package/dist/core/types/options-check.mjs +90 -0
- package/dist/core/types/options.d.mts +14 -8
- package/dist/core/value/casefold.d.mts +1 -3
- package/dist/core/value/stored.d.mts +26 -0
- package/dist/core/value/stored.mjs +28 -0
- package/dist/cursor-seal.mjs +37 -9
- package/dist/dashboard-documents.d.mts +14 -6
- package/dist/dashboard-documents.mjs +32 -12
- package/dist/dashboards.mjs +10 -9
- package/dist/drill-access.mjs +6 -6
- package/dist/drill-change.mjs +18 -20
- package/dist/drill-comparison.mjs +2 -1
- package/dist/drill-crumbs.mjs +63 -28
- package/dist/drill-distinct.mjs +2 -1
- package/dist/drill-explain.mjs +1 -1
- package/dist/drill-items.mjs +1 -1
- package/dist/drill-open.mjs +39 -23
- package/dist/drill-seal.mjs +41 -13
- package/dist/drill-share.mjs +1 -1
- package/dist/drill-summary.mjs +2 -1
- package/dist/drill-targets.mjs +4 -4
- package/dist/drill-views.mjs +4 -3
- package/dist/drill.mjs +1 -1
- package/dist/editing.mjs +5 -3
- package/dist/endpoints/index.d.mts +29 -8
- package/dist/endpoints/index.mjs +4 -1
- package/dist/endpoints/meta.mjs +4 -3
- package/dist/endpoints/query.mjs +5 -2
- package/dist/endpoints/read.mjs +7 -6
- package/dist/endpoints/versions.mjs +2 -1
- package/dist/execute.d.mts +3 -0
- package/dist/execute.mjs +23 -12
- package/dist/grant.d.mts +9 -0
- package/dist/grant.mjs +43 -0
- package/dist/handler.mjs +8 -13
- package/dist/http.d.mts +6 -2
- package/dist/http.mjs +6 -2
- package/dist/index.d.mts +25 -4
- package/dist/index.mjs +91 -40
- package/dist/llms.txt +3 -3
- package/dist/mcp/api.mjs +2 -1
- package/dist/mcp/query.mjs +3 -8
- package/dist/mcp/resolve.mjs +9 -2
- package/dist/node/index.d.mts +36 -0
- package/dist/node/index.mjs +89 -0
- package/dist/node/request.d.mts +12 -0
- package/dist/node/request.mjs +119 -0
- package/dist/node/response.mjs +58 -0
- package/dist/principal.mjs +15 -7
- package/dist/react/Canvas.mjs +90 -69
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +15 -1
- package/dist/react/Dashboard.mjs +43 -42
- package/dist/react/DashboardList.mjs +9 -4
- package/dist/react/Editing.d.mts +9 -0
- package/dist/react/Editing.mjs +8 -3
- package/dist/react/Grid.mjs +1 -1
- package/dist/react/Header.mjs +25 -52
- package/dist/react/History.mjs +3 -2
- package/dist/react/LoadFailed.mjs +59 -0
- package/dist/react/Panel.d.mts +1 -1
- package/dist/react/Panel.mjs +1 -1
- package/dist/react/Parts.d.mts +34 -0
- package/dist/react/Parts.mjs +9 -6
- package/dist/react/ReviewPanel.mjs +1 -1
- package/dist/react/RowBody.d.mts +2 -0
- package/dist/react/RowBody.mjs +5 -1
- package/dist/react/Share.mjs +153 -0
- package/dist/react/TabStrip.mjs +37 -0
- package/dist/react/Tile.d.mts +3 -1
- package/dist/react/Tile.mjs +89 -92
- package/dist/react/TileState.mjs +117 -0
- package/dist/react/ago.mjs +45 -0
- package/dist/react/arrange.mjs +1 -1
- package/dist/react/board.mjs +2 -2
- package/dist/react/bucket-name.d.mts +8 -0
- package/dist/react/bucket-name.mjs +13 -0
- package/dist/react/builder/DisplayOptions.mjs +219 -0
- package/dist/react/builder/Preview.mjs +13 -13
- package/dist/react/builder/RangeEditor.mjs +4 -3
- package/dist/react/builder/WidgetBuilder.d.mts +1 -7
- package/dist/react/builder/WidgetBuilder.mjs +12 -3
- package/dist/react/builder/base.d.mts +13 -2
- package/dist/react/builder/base.mjs +70 -12
- package/dist/react/builder/display.d.mts +3 -0
- package/dist/react/builder/display.mjs +256 -0
- package/dist/react/builder/labels.mjs +19 -5
- package/dist/react/builder/options.mjs +11 -6
- package/dist/react/builder/state.mjs +25 -3
- package/dist/react/builder/useBuilder.d.mts +7 -1
- package/dist/react/builder/useBuilder.mjs +6 -9
- package/dist/react/builder/usePreview.mjs +3 -2
- package/dist/react/builder/words.d.mts +16 -1
- package/dist/react/builder/words.mjs +41 -1
- package/dist/react/change-text.mjs +149 -0
- package/dist/react/client.d.mts +9 -0
- package/dist/react/client.mjs +105 -14
- package/dist/react/columns.mjs +9 -1
- package/dist/react/context.d.mts +24 -3
- package/dist/react/context.mjs +23 -7
- package/dist/react/dates-shown.mjs +76 -0
- package/dist/react/draft.mjs +3 -2
- package/dist/react/drill/Bars.mjs +12 -16
- package/dist/react/drill/Comparison.mjs +1 -1
- package/dist/react/drill/DrillPanel.d.mts +1 -1
- package/dist/react/drill/DrillPanel.mjs +2 -1
- package/dist/react/drill/Header.mjs +65 -12
- package/dist/react/drill/Items.d.mts +1 -1
- package/dist/react/drill/Notes.mjs +10 -7
- package/dist/react/drill/PanelStates.mjs +8 -1
- package/dist/react/drill/Trend.mjs +10 -5
- package/dist/react/drill/board.d.mts +1 -1
- package/dist/react/drill/board.mjs +1 -0
- package/dist/react/drill/host.mjs +4 -1
- package/dist/react/drill/lazy.mjs +2 -27
- package/dist/react/drill/props.d.mts +19 -8
- package/dist/react/drill/props.mjs +62 -18
- package/dist/react/drill/state.d.mts +15 -5
- package/dist/react/drill/state.mjs +12 -3
- package/dist/react/drill/words.d.mts +46 -3
- package/dist/react/drill/words.mjs +30 -5
- package/dist/react/english.mjs +33 -8
- package/dist/react/export/ExportButton.mjs +4 -1
- package/dist/react/export/csv.d.mts +7 -2
- package/dist/react/export/csv.mjs +24 -7
- package/dist/react/failure-words.mjs +60 -0
- package/dist/react/filters/bar.d.mts +1 -1
- package/dist/react/filters/bar.mjs +4 -1
- package/dist/react/filters/calendar.mjs +23 -8
- package/dist/react/filters/chip.mjs +7 -3
- package/dist/react/filters/context.d.mts +13 -1
- package/dist/react/filters/context.mjs +1 -1
- package/dist/react/filters/dates-said.mjs +57 -0
- package/dist/react/filters/days.d.mts +3 -4
- package/dist/react/filters/days.mjs +10 -17
- package/dist/react/filters/hooks.d.mts +11 -0
- package/dist/react/filters/hooks.mjs +10 -6
- package/dist/react/filters/menu-search.mjs +17 -9
- package/dist/react/filters/menu.mjs +10 -8
- package/dist/react/filters/phone.mjs +41 -16
- package/dist/react/filters/place.mjs +40 -0
- package/dist/react/filters/popover.mjs +18 -13
- package/dist/react/filters/rules.d.mts +4 -3
- package/dist/react/filters/rules.mjs +3 -3
- package/dist/react/filters/sheet.mjs +7 -3
- package/dist/react/filters/state.mjs +6 -1
- package/dist/react/filters/values.mjs +24 -7
- package/dist/react/filters/words.d.mts +13 -0
- package/dist/react/filters/words.mjs +5 -0
- package/dist/react/format-time.d.mts +17 -6
- package/dist/react/format-time.mjs +152 -33
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +35 -122
- package/dist/react/headline.d.mts +12 -0
- package/dist/react/headline.mjs +107 -0
- package/dist/react/index.d.mts +20 -17
- package/dist/react/index.mjs +13 -10
- package/dist/react/lazy.mjs +38 -0
- package/dist/react/messages.d.mts +78 -2
- package/dist/react/now.mjs +38 -0
- package/dist/react/place.mjs +4 -2
- package/dist/react/read.d.mts +1 -0
- package/dist/react/read.mjs +140 -9
- package/dist/react/renderers/exact.mjs +31 -59
- package/dist/react/renderers/index.d.mts +27 -6
- package/dist/react/renderers/index.mjs +154 -92
- package/dist/react/renderers/list-parts.mjs +24 -0
- package/dist/react/renderers/list.d.mts +1 -0
- package/dist/react/renderers/list.mjs +99 -43
- package/dist/react/renderers/more-rows.mjs +75 -0
- package/dist/react/renderers/number-before.mjs +320 -0
- package/dist/react/renderers/number-period.mjs +54 -0
- package/dist/react/renderers/number-whole.mjs +29 -0
- package/dist/react/renderers/props.d.mts +24 -1
- package/dist/react/renderers/props.mjs +8 -0
- package/dist/react/renderers/table-cells.mjs +137 -31
- package/dist/react/renderers/table-fit.mjs +55 -10
- package/dist/react/renderers/table-measure.mjs +29 -9
- package/dist/react/renderers/table-row.mjs +14 -9
- package/dist/react/renderers/table-scale.mjs +2 -3
- package/dist/react/renderers/table-sort.mjs +3 -2
- package/dist/react/renderers/table-whole.mjs +37 -0
- package/dist/react/renderers/table.mjs +73 -53
- package/dist/react/review.d.mts +7 -0
- package/dist/react/review.mjs +35 -8
- package/dist/react/roving.d.mts +6 -0
- package/dist/react/roving.mjs +123 -0
- package/dist/react/says-dates.d.mts +7 -0
- package/dist/react/says-dates.mjs +51 -0
- package/dist/react/series.mjs +5 -6
- package/dist/react/stable.mjs +1 -1
- package/dist/react/tabs/EditTabs.mjs +125 -0
- package/dist/react/tabs/NameField.mjs +72 -0
- package/dist/react/tabs/TabMenu.mjs +175 -0
- package/dist/react/tabs/actions.mjs +37 -0
- package/dist/react/tabs/commands.mjs +76 -0
- package/dist/react/tabs/focus.mjs +22 -0
- package/dist/react/tabs/keys.mjs +28 -0
- package/dist/react/theme-unlayered.css +1 -1
- package/dist/react/theme.css +1 -1
- package/dist/react/tile-store.d.mts +4 -0
- package/dist/react/tile-store.mjs +93 -13
- package/dist/react/touch.d.mts +16 -0
- package/dist/react/touch.mjs +39 -0
- package/dist/react/useBoard.d.mts +6 -0
- package/dist/react/useBoard.mjs +1 -0
- package/dist/react/useDashboard.d.mts +2 -0
- package/dist/react/useDashboard.mjs +5 -2
- package/dist/react/useTiles.d.mts +3 -0
- package/dist/react/useTiles.mjs +73 -17
- package/dist/react/view-grid.mjs +2 -2
- package/dist/react/view.mjs +1 -1
- package/dist/recharts/axes.mjs +1 -1
- package/dist/recharts/axis.mjs +23 -73
- package/dist/recharts/bar.d.mts +2 -1
- package/dist/recharts/bar.mjs +140 -64
- package/dist/recharts/fit.mjs +33 -0
- package/dist/recharts/line.mjs +23 -17
- package/dist/recharts/marks.mjs +2 -1
- package/dist/recharts/parts.mjs +19 -14
- package/dist/recharts/table.mjs +8 -3
- package/dist/refusal.mjs +46 -0
- package/dist/registry/filter-bar.json +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +25 -9
- package/dist/tile-doc.mjs +1 -1
- package/package.json +21 -6
- package/dist/charts-react/plan.d.mts +0 -3
- package/dist/charts-react/plan.mjs +0 -37
- package/dist/charts-react/tiles.d.mts +0 -24
- package/dist/core/policy/match.d.mts +0 -16
- package/dist/core/schema/aliases.d.mts +0 -7
- package/dist/core/time/compare.d.mts +0 -30
- package/dist/react/EditBar.d.mts +0 -16
- package/dist/react/History.d.mts +0 -30
- package/dist/react/ReviewPanel.d.mts +0 -15
- package/dist/react/digits.mjs +0 -46
- package/dist/react/drill/trend-touch.mjs +0 -33
- package/dist/react/renderers/exact.d.mts +0 -6
|
@@ -1,28 +1,46 @@
|
|
|
1
1
|
import { keyOf } from "../data/rows.mjs";
|
|
2
2
|
import { MUTED, SURFACE } from "../scene/paint.mjs";
|
|
3
|
-
import { fitOrNone,
|
|
3
|
+
import { fitOrNone, fitted, wholeOf } from "../text/measure.mjs";
|
|
4
4
|
import { LINE, MARK, SPACE, TEXT } from "../theme.mjs";
|
|
5
5
|
import { rowName } from "./row-marks.mjs";
|
|
6
6
|
// src/kinds/grid-marks.ts
|
|
7
7
|
/** How far over the cells the middle of their columns' names sits: half a line of them. */
|
|
8
8
|
const OVER = LINE.tick / 2;
|
|
9
|
+
/** The fewest letters a cut name keeps before its ellipsis: fewer name nothing. */
|
|
10
|
+
const LEAST_LETTERS = 3;
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* Every column's name cut to its own column, for columns that are categories: a plan cannot be
|
|
13
|
+
* inferred from its neighbours as a date can. Nothing where a column has no room for the first
|
|
14
|
+
* letters of its name, or where two cut names would read alike, since a name that reads as
|
|
15
|
+
* another names neither.
|
|
12
16
|
*/
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const
|
|
17
|
+
function cutNames(names, room, env) {
|
|
18
|
+
const reads = (cut, name) => cut === name || cut.slice(0, cut.indexOf("…")).length >= LEAST_LETTERS;
|
|
19
|
+
const cuts = names.flatMap((name) => {
|
|
20
|
+
const cut = fitOrNone(name, {
|
|
21
|
+
width: room,
|
|
22
|
+
font: TEXT.tick,
|
|
23
|
+
measure: env.measure
|
|
24
|
+
});
|
|
25
|
+
return cut !== void 0 && reads(cut, name) ? [cut] : [];
|
|
26
|
+
});
|
|
27
|
+
return cuts.length === names.length && new Set(cuts).size === cuts.length ? cuts : void 0;
|
|
28
|
+
}
|
|
16
29
|
/**
|
|
17
|
-
* The columns' names over the cells: every one when they fit side by side
|
|
18
|
-
*
|
|
30
|
+
* The columns' names over the cells: every one when they fit side by side; for categories,
|
|
31
|
+
* every one cut to its column while each still reads (`cutNames`); else the first at the left
|
|
32
|
+
* and the last at the right, each cut to its half, so no two ever touch.
|
|
19
33
|
*/
|
|
20
|
-
function columnNames(data, layout,
|
|
34
|
+
function columnNames(data, layout, at) {
|
|
21
35
|
const { plot, step } = layout;
|
|
36
|
+
const { env } = at;
|
|
22
37
|
const wide = (text) => env.measure(text, TEXT.tick);
|
|
23
38
|
const names = data.columns.map((column) => column.label);
|
|
24
|
-
|
|
39
|
+
const room = step - MARK.hair;
|
|
40
|
+
const each = names.every((name) => wide(name) <= room) ? names : at.categories ? cutNames(names, room, env) : void 0;
|
|
41
|
+
if (each !== void 0) return each.map((text, i) => ({
|
|
25
42
|
text,
|
|
43
|
+
...wholeOf(text, names[i] ?? text),
|
|
26
44
|
x: plot.x + (i + .5) * step,
|
|
27
45
|
anchor: "middle"
|
|
28
46
|
}));
|
|
@@ -36,31 +54,51 @@ function columnNames(data, layout, env) {
|
|
|
36
54
|
const last = cut(names.length > 1 ? names.at(-1) : void 0);
|
|
37
55
|
return [...first === void 0 ? [] : [{
|
|
38
56
|
text: first,
|
|
57
|
+
...wholeOf(first, names[0] ?? first),
|
|
39
58
|
x: plot.x,
|
|
40
59
|
anchor: "start"
|
|
41
60
|
}], ...last === void 0 ? [] : [{
|
|
42
61
|
text: last,
|
|
62
|
+
...wholeOf(last, names.at(-1) ?? last),
|
|
43
63
|
x: plot.x + plot.width,
|
|
44
64
|
anchor: "end"
|
|
45
65
|
}]];
|
|
46
66
|
}
|
|
47
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* The words over the grid: the title over the names, the one over the sizes, the columns' names,
|
|
69
|
+
* and the word over those on a line of its own, from the first cell's left edge.
|
|
70
|
+
*/
|
|
48
71
|
function heads(data, options, at) {
|
|
49
72
|
const { layout, env } = at;
|
|
50
73
|
const { names } = layout.frame;
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
const { plot } = layout;
|
|
75
|
+
const fit = (text, room) => fitted(text, room, TEXT.tick, env.measure);
|
|
76
|
+
const titles = [
|
|
77
|
+
...options.columnTitle === void 0 ? [] : [{
|
|
78
|
+
...fit(options.columnTitle, plot.width),
|
|
79
|
+
x: plot.x,
|
|
80
|
+
y: plot.y - OVER - LINE.tick,
|
|
81
|
+
anchor: "start"
|
|
82
|
+
}],
|
|
83
|
+
...options.rowTitle === void 0 ? [] : [{
|
|
84
|
+
...fit(options.rowTitle, names),
|
|
85
|
+
x: 0,
|
|
86
|
+
anchor: "start"
|
|
87
|
+
}],
|
|
88
|
+
...options.sizeTitle === void 0 ? [] : [{
|
|
89
|
+
...fit(options.sizeTitle, layout.sizes - 14),
|
|
90
|
+
x: names + layout.sizes,
|
|
91
|
+
anchor: "end"
|
|
92
|
+
}]
|
|
93
|
+
];
|
|
94
|
+
const categories = options.time === void 0;
|
|
95
|
+
return [...titles, ...columnNames(data, layout, {
|
|
96
|
+
env,
|
|
97
|
+
categories
|
|
98
|
+
})].filter((word) => word.text !== "").map((word) => ({
|
|
61
99
|
kind: "text",
|
|
62
100
|
part: "column",
|
|
63
|
-
y:
|
|
101
|
+
y: plot.y - OVER,
|
|
64
102
|
...TEXT.tick,
|
|
65
103
|
...word
|
|
66
104
|
}));
|
|
@@ -104,12 +142,23 @@ const emptyNodes = (layout) => layout.empty.map(({ key, box }) => ({
|
|
|
104
142
|
}));
|
|
105
143
|
/** A cell's colour: the grid's one hue, whatever its value. What its stop's swatch wears too. */
|
|
106
144
|
const colorOf = (cell, at) => at.mixed && cell.value < 0 ? at.negative : at.own;
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
145
|
+
/**
|
|
146
|
+
* How strong a cell's hue is, from the palest to `deepest`, for its shade from 0 to 1: eased
|
|
147
|
+
* (`MARK.heatEase`), so low values lie further apart than high ones. A hue thinly laid over a
|
|
148
|
+
* surface, most of all a dark one, changes least where it is faintest, and a grid's low cells
|
|
149
|
+
* would otherwise read as one.
|
|
150
|
+
*/
|
|
151
|
+
const strengthOf = (shade, deepest) => MARK.palest + (deepest - MARK.palest) * shade ** MARK.heatEase;
|
|
152
|
+
/**
|
|
153
|
+
* How a cell holding a value is filled: its colour, as strong as its value is high. A cell with
|
|
154
|
+
* its number on it stops short of the full hue, so the ink reads on every cell in a light and a
|
|
155
|
+
* dark theme, which the palette law holds it to. The legend's steps are filled by this too.
|
|
156
|
+
*/
|
|
157
|
+
function fillOf(cell, at) {
|
|
158
|
+
const deepest = at.layout.write === void 0 ? MARK.deepestBare : at.deepest;
|
|
110
159
|
return {
|
|
111
160
|
fill: colorOf(cell, at),
|
|
112
|
-
opacity:
|
|
161
|
+
opacity: strengthOf(at.shade(cell.value), deepest)
|
|
113
162
|
};
|
|
114
163
|
}
|
|
115
164
|
/**
|
|
@@ -118,23 +167,23 @@ function shadeOf(cell, at) {
|
|
|
118
167
|
*/
|
|
119
168
|
function cellNodes(cell, at) {
|
|
120
169
|
const { box } = cell;
|
|
121
|
-
const
|
|
170
|
+
const { write } = at.layout;
|
|
122
171
|
return [{
|
|
123
172
|
kind: "rect",
|
|
124
173
|
part: "cell",
|
|
125
174
|
key: cell.key,
|
|
126
175
|
...box,
|
|
127
176
|
radius: MARK.round,
|
|
128
|
-
...
|
|
129
|
-
}, ...
|
|
177
|
+
...fillOf(cell, at)
|
|
178
|
+
}, ...write === void 0 ? [] : [{
|
|
130
179
|
kind: "text",
|
|
131
180
|
part: "value",
|
|
132
181
|
x: box.x + box.width / 2,
|
|
133
182
|
y: box.y + box.height / 2,
|
|
134
|
-
text,
|
|
183
|
+
text: write(cell),
|
|
135
184
|
...TEXT.value,
|
|
136
185
|
anchor: "middle",
|
|
137
186
|
baseline: "middle"
|
|
138
|
-
}]
|
|
187
|
+
}]];
|
|
139
188
|
}
|
|
140
|
-
export { cellNodes, colorOf, emptyNodes, heads, sides };
|
|
189
|
+
export { cellNodes, colorOf, emptyNodes, fillOf, heads, sides, strengthOf };
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import { ChartInputError } from "../data/input-error.mjs";
|
|
2
2
|
import { keyOf, pairKey } from "../data/rows.mjs";
|
|
3
|
-
import { wordsOf } from "../data/words.mjs";
|
|
3
|
+
import { periodNote, wordsOf } from "../data/words.mjs";
|
|
4
4
|
import { timeScale } from "../scale/time.mjs";
|
|
5
5
|
import { evenSize, meanIn, mergeOf, sizeFor } from "./columns-data.mjs";
|
|
6
6
|
// src/kinds/grid-time.ts
|
|
7
7
|
/** A heat cell needs three pixels including its gutter. Unlike a bar it fills its entire band. */
|
|
8
8
|
const CELL = 3;
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The columns of buckets, each a time chart's column: a bucket the data covers only part of
|
|
11
|
+
* says so ("so far"), as a stop over time does; stretches too many for the width are averaged
|
|
12
|
+
* as columns are, and a singleton keeps its exact text and drill key.
|
|
13
|
+
*/
|
|
14
|
+
function fitTimeGrid(given, time, env) {
|
|
15
|
+
if (given.columns.length !== time.buckets.length) throw new ChartInputError("columns", "Expected one grid column per time bucket.");
|
|
16
|
+
const words = wordsOf(env);
|
|
17
|
+
const data = {
|
|
18
|
+
...given,
|
|
19
|
+
columns: given.columns.map((column, i) => {
|
|
20
|
+
const note = periodNote(time.buckets[i], words) ?? column.note;
|
|
21
|
+
return note === void 0 ? column : {
|
|
22
|
+
...column,
|
|
23
|
+
note
|
|
24
|
+
};
|
|
25
|
+
})
|
|
26
|
+
};
|
|
12
27
|
const width = Math.max(1, env.width);
|
|
13
28
|
if (data.columns.length * CELL <= width) return data;
|
|
14
29
|
const scale = timeScale(time, {
|
|
@@ -19,7 +34,6 @@ function fitTimeGrid(data, time, env) {
|
|
|
19
34
|
const merge = mergeOf(time, size);
|
|
20
35
|
const { slots } = merge;
|
|
21
36
|
if (slots.length === data.columns.length) return data;
|
|
22
|
-
const words = wordsOf(env);
|
|
23
37
|
const columns = slots.map(({ from, to }) => {
|
|
24
38
|
const first = data.columns[from];
|
|
25
39
|
const last = data.columns[to - 1];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { topAsWritten } from "../data/format.mjs";
|
|
2
2
|
import { keyOf } from "../data/rows.mjs";
|
|
3
3
|
import { counted, noValue, shownOf, summary } from "../describe.mjs";
|
|
4
|
+
import { lazyStop } from "../scene/lazy.mjs";
|
|
5
|
+
import { cellText } from "./grid-data.mjs";
|
|
4
6
|
import { colorOf } from "./grid-marks.mjs";
|
|
5
7
|
// src/kinds/grid-words.ts
|
|
6
|
-
/** A cell's value as the host writes it, where it gave its own text for it. */
|
|
7
|
-
const writtenAt = (data, at) => said(data.texts?.[at.row]?.[at.column]);
|
|
8
8
|
/**
|
|
9
9
|
* What a pointer finds on a place in the grid: its row and column, as the data names them, and
|
|
10
10
|
* its value; with no value there, its name and nothing else, as a row with no value has a stop
|
|
@@ -18,60 +18,82 @@ function stopOf(place, data, at) {
|
|
|
18
18
|
y: place.box.y + place.box.height / 2
|
|
19
19
|
};
|
|
20
20
|
const value = "value" in place ? place : void 0;
|
|
21
|
-
|
|
21
|
+
const stop = {
|
|
22
22
|
key: place.key,
|
|
23
23
|
cell: [place.row, place.column],
|
|
24
24
|
...middle,
|
|
25
25
|
title: `${row} · ${column?.label ?? ""}`,
|
|
26
26
|
...column?.note === void 0 ? {} : { note: column.note },
|
|
27
|
-
band: place.box
|
|
28
|
-
items: value === void 0 ? [] : [{
|
|
29
|
-
key: "value",
|
|
30
|
-
label: at.measure.label,
|
|
31
|
-
value: writtenAt(data, place) ?? at.measure.text(value.value),
|
|
32
|
-
color: colorOf(value, at),
|
|
33
|
-
...middle
|
|
34
|
-
}]
|
|
27
|
+
band: place.box
|
|
35
28
|
};
|
|
29
|
+
return lazyStop(stop, () => value === void 0 ? [] : [{
|
|
30
|
+
key: "value",
|
|
31
|
+
label: at.measure.label,
|
|
32
|
+
value: cellText(data, at.measure, value),
|
|
33
|
+
color: colorOf(value, at),
|
|
34
|
+
...middle
|
|
35
|
+
}]);
|
|
36
36
|
}
|
|
37
37
|
/** Every place of the rows drawn, a cell or an empty one, in the grid's order: row by row. */
|
|
38
38
|
const stopsOf = (layout, data, at) => [...layout.filled, ...layout.empty].toSorted((a, b) => a.row - b.row || a.column - b.column).map((place) => stopOf(place, data, at));
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
39
|
+
/** Every cell with a value: its row, its column, its value, and its place. */
|
|
40
|
+
const valuedCells = (data) => data.rows.flatMap((row, r) => data.columns.flatMap((column, c) => {
|
|
41
|
+
const value = data.values[r]?.[c] ?? null;
|
|
42
|
+
return value === null ? [] : [{
|
|
43
|
+
row,
|
|
44
|
+
column,
|
|
45
|
+
value,
|
|
46
|
+
at: {
|
|
47
|
+
row: r,
|
|
48
|
+
column: c
|
|
49
|
+
}
|
|
50
|
+
}];
|
|
51
|
+
}));
|
|
52
|
+
/**
|
|
53
|
+
* The cell with the highest value (`way` 1) or the lowest (`way` -1) among `cells`, named as a
|
|
54
|
+
* pointer finds it; nothing when the two at that end read alike. The two are the ends the
|
|
55
|
+
* shades run between.
|
|
56
|
+
*/
|
|
57
|
+
function endOf(cells, at, way) {
|
|
58
|
+
const { data, measure } = at;
|
|
59
|
+
const end = topAsWritten(cells, (cell) => way * cell.value, (value) => measure.text(way * value));
|
|
60
|
+
if (end === void 0) return void 0;
|
|
61
|
+
const written = (cell) => cellText(data, measure, {
|
|
62
|
+
...cell.at,
|
|
63
|
+
value: cell.value
|
|
64
|
+
});
|
|
65
|
+
const words = written(end);
|
|
66
|
+
if (cells.some((cell) => cell !== end && written(cell) === words)) return void 0;
|
|
67
|
+
return `${way > 0 ? "Highest" : "Lowest"}: ${end.row.label} · ${end.column.label}, ${words}`;
|
|
57
68
|
}
|
|
58
|
-
/** The grid in words: what it is of, its rows and how many have room, its columns, its highest
|
|
69
|
+
/** The grid in words: what it is of, its rows and how many have room, its columns, its highest and lowest cells, and how many cells are empty. */
|
|
59
70
|
function describeGrid(data, at) {
|
|
60
71
|
const cells = data.rows.flatMap((_row, r) => data.columns.map((_column, c) => data.values[r]?.[c] ?? null));
|
|
72
|
+
const valued = valuedCells(data);
|
|
61
73
|
return summary([
|
|
62
74
|
`Heatmap of ${at.measure.label}`,
|
|
63
75
|
shownOf(data.rows.length, at.shown, "row"),
|
|
64
76
|
counted(data.columns.length, "column")
|
|
65
77
|
], [
|
|
66
78
|
data.mergeNote,
|
|
67
|
-
|
|
79
|
+
endOf(valued, {
|
|
80
|
+
data,
|
|
81
|
+
measure: at.measure
|
|
82
|
+
}, 1),
|
|
83
|
+
endOf(valued, {
|
|
84
|
+
data,
|
|
85
|
+
measure: at.measure
|
|
86
|
+
}, -1),
|
|
68
87
|
noValue(cells.filter((v) => v === null).length, "cell")
|
|
69
88
|
]);
|
|
70
89
|
}
|
|
71
|
-
/**
|
|
72
|
-
|
|
90
|
+
/**
|
|
91
|
+
* How the grid's one-cell stops are read as a table and traversed by keyboard. The table is
|
|
92
|
+
* headed as the picture is: the word over the rows' names and the word over the columns'.
|
|
93
|
+
*/
|
|
94
|
+
function matrixOf(data, rows, heads) {
|
|
73
95
|
return {
|
|
74
|
-
|
|
96
|
+
...heads,
|
|
75
97
|
rowMajor: true,
|
|
76
98
|
rows: rows.map((row) => ({
|
|
77
99
|
key: keyOf(row),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Env, Header, Measure, TimeX } from "../data/types.mjs";
|
|
1
|
+
import { Env, Header, Measure, TimeX, ValueIn } from "../data/types.mjs";
|
|
2
2
|
import { Scene } from "../scene/types.mjs";
|
|
3
|
-
import { GridData } from "./grid-data.mjs";
|
|
3
|
+
import { GridData as GridData$1 } from "./grid-data.mjs";
|
|
4
|
+
/** A grid as a host gives it: each value a number, decimal text, or null. */
|
|
5
|
+
export type GridData<V extends ValueIn = ValueIn> = GridData$1<V>;
|
|
4
6
|
export type GridOptions = Header & {
|
|
5
7
|
measure: Measure;
|
|
6
8
|
/** When each column is a time bucket, adjacent periods share cells at narrow widths. */
|
|
@@ -12,11 +14,12 @@ export type GridOptions = Header & {
|
|
|
12
14
|
sizeTitle?: string;
|
|
13
15
|
/** The word over the row names. */
|
|
14
16
|
rowTitle?: string;
|
|
17
|
+
/** The word over the column names, on a line of its own from the first cell's left edge. */
|
|
18
|
+
columnTitle?: string;
|
|
15
19
|
/** The values the shade runs between; the data's own lowest and highest when left out. */
|
|
16
20
|
range?: readonly [number, number];
|
|
17
21
|
/** The palette place of the grid's one colour. */
|
|
18
22
|
slot?: number;
|
|
19
23
|
};
|
|
20
24
|
/** A heatmap of one measure by two fields. */
|
|
21
|
-
export declare function gridChart(given: GridData, options: GridOptions, env: Env): Scene;
|
|
22
|
-
export type { GridData };
|
|
25
|
+
export declare function gridChart(given: GridData, options: GridOptions, env: Env): Scene;
|
|
@@ -1,18 +1,49 @@
|
|
|
1
|
+
import { HEADER, checkInput, keysOf } from "../data/clean.mjs";
|
|
1
2
|
import { bare, headerNodes } from "../layout/frame.mjs";
|
|
2
|
-
import { seriesPaint } from "../theme.mjs";
|
|
3
|
+
import { MARK, seriesPaint } from "../theme.mjs";
|
|
4
|
+
import { leftOf, leftOut } from "../marks/more.mjs";
|
|
3
5
|
import { rowsMore } from "./row-marks.mjs";
|
|
4
6
|
import { cleaned, colorsOf } from "./grid-data.mjs";
|
|
5
|
-
import { layoutOf } from "./grid-layout.mjs";
|
|
7
|
+
import { layoutOf, rowRule } from "./grid-layout.mjs";
|
|
8
|
+
import { legendNodes } from "./grid-legend.mjs";
|
|
6
9
|
import { cellNodes, emptyNodes, heads, sides } from "./grid-marks.mjs";
|
|
7
10
|
import { fitTimeGrid } from "./grid-time.mjs";
|
|
8
11
|
import { describeGrid, matrixOf, stopsOf } from "./grid-words.mjs";
|
|
9
|
-
import { hasRoom } from "./row-chart.mjs";
|
|
12
|
+
import { hasRoom, sizingOf, wantsOf } from "./row-chart.mjs";
|
|
10
13
|
// src/kinds/grid.ts
|
|
14
|
+
/** The keys gridChart takes: any other is refused, with the one it most likely meant. */
|
|
15
|
+
const KEYS = keysOf({
|
|
16
|
+
...HEADER,
|
|
17
|
+
measure: true,
|
|
18
|
+
time: true,
|
|
19
|
+
diverging: true,
|
|
20
|
+
sizes: true,
|
|
21
|
+
sizeTitle: true,
|
|
22
|
+
rowTitle: true,
|
|
23
|
+
columnTitle: true,
|
|
24
|
+
range: true,
|
|
25
|
+
slot: true
|
|
26
|
+
});
|
|
11
27
|
/** A heatmap of one measure by two fields. */
|
|
12
28
|
function gridChart(given, options, env) {
|
|
13
|
-
|
|
29
|
+
checkInput({
|
|
30
|
+
what: "grid",
|
|
31
|
+
data: given
|
|
32
|
+
}, options, env, {
|
|
33
|
+
known: KEYS,
|
|
34
|
+
needs: ["measure"]
|
|
35
|
+
});
|
|
36
|
+
const clean = cleaned(given, options.measure);
|
|
14
37
|
const data = options.time === void 0 ? clean : fitTimeGrid(clean, options.time, env);
|
|
15
|
-
|
|
38
|
+
if (env.sizing === true) {
|
|
39
|
+
const drawn = data.values.some((row) => row.some((value) => value !== null));
|
|
40
|
+
return sizingOf(env, rowRule(options, data, env), {
|
|
41
|
+
count: data.rows.length,
|
|
42
|
+
drawn
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const colors = colorsOf(data, options.range, options.diverging);
|
|
46
|
+
const layout = layoutOf(data, options, env, colors.ends);
|
|
16
47
|
const { measure } = options;
|
|
17
48
|
const { frame, plot } = layout;
|
|
18
49
|
const roomy = hasRoom(frame, layout.across, layout.drawn);
|
|
@@ -24,31 +55,42 @@ function gridChart(given, options, env) {
|
|
|
24
55
|
const at = {
|
|
25
56
|
layout,
|
|
26
57
|
measure,
|
|
27
|
-
...
|
|
58
|
+
...colors,
|
|
28
59
|
negative: seriesPaint((options.slot ?? 0) + 1),
|
|
29
60
|
own: seriesPaint(options.slot ?? 0),
|
|
61
|
+
deepest: (options.slot ?? 0) === 0 ? MARK.deepest : MARK.deepestAny,
|
|
30
62
|
env
|
|
31
63
|
};
|
|
64
|
+
const left = leftOut(data.rows, layout.kept);
|
|
65
|
+
const under = plot.y + plot.height + (left.length > 0 ? frame.rowHeight : 0);
|
|
32
66
|
return {
|
|
33
67
|
width: env.width,
|
|
34
68
|
height: env.height,
|
|
35
69
|
plot,
|
|
70
|
+
natural: frame.natural,
|
|
36
71
|
summary,
|
|
72
|
+
...leftOf(left),
|
|
73
|
+
...wantsOf(frame),
|
|
37
74
|
nodes: [
|
|
38
75
|
...headerNodes(env, options),
|
|
39
76
|
...heads(data, options, at),
|
|
40
77
|
...sides(options, at),
|
|
41
78
|
...emptyNodes(layout),
|
|
42
79
|
...layout.filled.flatMap((cell) => cellNodes(cell, at)),
|
|
43
|
-
...rowsMore(
|
|
80
|
+
...rowsMore(left, {
|
|
44
81
|
frame,
|
|
45
82
|
env
|
|
46
|
-
})
|
|
83
|
+
}),
|
|
84
|
+
...legendNodes(at, under)
|
|
47
85
|
],
|
|
48
86
|
hover: {
|
|
49
87
|
snap: "nearest",
|
|
50
88
|
stops: stopsOf(layout, data, at),
|
|
51
|
-
matrix: matrixOf(data, layout.kept,
|
|
89
|
+
matrix: matrixOf(data, layout.kept, {
|
|
90
|
+
heading: measure.label,
|
|
91
|
+
down: options.rowTitle,
|
|
92
|
+
across: options.columnTitle
|
|
93
|
+
})
|
|
52
94
|
}
|
|
53
95
|
};
|
|
54
96
|
}
|
|
@@ -1,20 +1,69 @@
|
|
|
1
1
|
import { drawable } from "../data/clean.mjs";
|
|
2
2
|
import { measure } from "../data/format.mjs";
|
|
3
3
|
import { least, most } from "../data/range.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { niceSpan, spanTicks } from "../scale/linear.mjs";
|
|
5
|
+
import { bisectLeft, quantileSorted, thresholdSturges } from "d3-array";
|
|
6
6
|
// src/kinds/histogram-data.ts
|
|
7
7
|
/** A bar is at least this wide: the histogram's own floor, so a bin is never a sliver. */
|
|
8
8
|
const THINNEST = 6;
|
|
9
|
+
const FINITE = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
const SORTED = /* @__PURE__ */ new WeakMap();
|
|
9
11
|
/** The values that can be drawn: missing and non-finite values are left out. */
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
function finiteOf(values) {
|
|
13
|
+
const known = FINITE.get(values);
|
|
14
|
+
if (known !== void 0) return known;
|
|
15
|
+
const finite = values.flatMap((v, i) => {
|
|
16
|
+
const value = drawable(v, "values[#]", i);
|
|
17
|
+
return value === null ? [] : [value];
|
|
18
|
+
});
|
|
19
|
+
FINITE.set(values, finite);
|
|
20
|
+
return finite;
|
|
21
|
+
}
|
|
22
|
+
/** Values ready to bin. */
|
|
23
|
+
function sortedOf(values) {
|
|
24
|
+
const known = SORTED.get(values);
|
|
25
|
+
if (known !== void 0) return known;
|
|
26
|
+
const sorted = {
|
|
27
|
+
low: least(values),
|
|
28
|
+
high: most(values),
|
|
29
|
+
sorted: Float64Array.from(values).sort()
|
|
30
|
+
};
|
|
31
|
+
SORTED.set(values, sorted);
|
|
32
|
+
return sorted;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* d3-array reads any array-like at run time; its types ask for an Array. A typed array is read
|
|
36
|
+
* in place, so the values are not copied a second time to satisfy the type.
|
|
37
|
+
*/
|
|
38
|
+
const asArray = (sorted) => sorted;
|
|
39
|
+
/** The values' median, read off their one sorted copy (`sortedOf`), never sorted again. */
|
|
40
|
+
const medianOf = (values) => quantileSorted(asArray(sortedOf(values).sorted), .5);
|
|
41
|
+
/**
|
|
42
|
+
* About how many bins the data asks for: Freedman–Diaconis (D3's `thresholdFreedmanDiaconis`,
|
|
43
|
+
* read off the sorted values), or Sturges when the middle half is flat.
|
|
44
|
+
*/
|
|
45
|
+
function wanted({ low, high, sorted }) {
|
|
46
|
+
const values = asArray(sorted);
|
|
47
|
+
const iqr = (quantileSorted(values, .75) ?? 0) - (quantileSorted(values, .25) ?? 0);
|
|
48
|
+
const n = sorted.length;
|
|
49
|
+
const spread = n > 0 && iqr !== 0 ? Math.ceil((high - low) / (2 * iqr * n ** (-1 / 3))) : 1;
|
|
50
|
+
return Number.isFinite(spread) && spread > 1 ? spread : thresholdSturges(sorted);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Each bin's count, as D3's `bin` counts with these thresholds: a value goes in the bin after
|
|
54
|
+
* the last threshold at or below it. Read off the sorted values by where each threshold falls,
|
|
55
|
+
* so no bin holds an array of its values.
|
|
56
|
+
*/
|
|
57
|
+
function counted(values, edges) {
|
|
58
|
+
const { sorted } = values;
|
|
59
|
+
const at = edges.slice(1, -1).map((t) => bisectLeft(sorted, t));
|
|
60
|
+
const starts = [0, ...at];
|
|
61
|
+
const ends = [...at, sorted.length];
|
|
62
|
+
return starts.map((start, i) => ({
|
|
63
|
+
from: edges[i] ?? values.low,
|
|
64
|
+
to: edges[i + 1] ?? values.high,
|
|
65
|
+
count: (ends[i] ?? start) - start
|
|
66
|
+
}));
|
|
18
67
|
}
|
|
19
68
|
/** A spread too fine for D3 to split reliably into round bins can still have distinct labels. */
|
|
20
69
|
function tooCloseToSplit(low, high) {
|
|
@@ -58,35 +107,28 @@ const fitting = (edges, at) => edges.length - 1 <= at.room && wide(edges, at) &&
|
|
|
58
107
|
* fit and read apart. Values that read alike are one bin, from the least to the greatest.
|
|
59
108
|
*/
|
|
60
109
|
function binsOf(values, at) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const high = most(values);
|
|
110
|
+
const { low, high, sorted } = values;
|
|
111
|
+
if (sorted.length === 0) return [];
|
|
64
112
|
const whole = [{
|
|
65
113
|
from: low,
|
|
66
114
|
to: high,
|
|
67
|
-
count:
|
|
115
|
+
count: sorted.length
|
|
68
116
|
}];
|
|
69
117
|
if (tooCloseToSplit(low, high) || readAlike(low, high, at.text)) return whole;
|
|
70
118
|
const room = Math.max(1, Math.floor(at.width / THINNEST));
|
|
71
|
-
const asked = at.bins !== void 0 && Number.isFinite(at.bins) ? at.bins : wanted(values
|
|
119
|
+
const asked = at.bins !== void 0 && Number.isFinite(at.bins) ? at.bins : wanted(values);
|
|
72
120
|
for (let ask = Math.max(1, Math.min(room, Math.round(asked))); ask >= 1; ask--) {
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const thresholds = scale.ticks(ask).filter((t) => t > from && t < to);
|
|
121
|
+
const [from, to] = niceSpan(low, high, ask);
|
|
122
|
+
const thresholds = spanTicks(from, to, ask).filter((t) => t > from && t < to);
|
|
76
123
|
const edges = [
|
|
77
124
|
Math.min(from, low),
|
|
78
125
|
...thresholds,
|
|
79
126
|
Math.max(to, high)
|
|
80
127
|
];
|
|
81
|
-
if (
|
|
128
|
+
if (fitting(edges, {
|
|
82
129
|
room,
|
|
83
130
|
...at
|
|
84
|
-
}))
|
|
85
|
-
return bin().domain([Math.min(from, low), Math.max(to, high)]).thresholds(thresholds)([...values]).map((b) => ({
|
|
86
|
-
from: b.x0 ?? from,
|
|
87
|
-
to: b.x1 ?? to,
|
|
88
|
-
count: b.length
|
|
89
|
-
}));
|
|
131
|
+
})) return counted(values, edges);
|
|
90
132
|
}
|
|
91
133
|
return whole;
|
|
92
134
|
}
|
|
@@ -139,4 +181,4 @@ const countReads = (env) => measure("", {
|
|
|
139
181
|
whole: true,
|
|
140
182
|
...env.locale === void 0 ? {} : { locale: env.locale }
|
|
141
183
|
});
|
|
142
|
-
export { binsOf, countReads, edgesOf, finiteOf, levelsOf, onePoint, spanAcross, taken };
|
|
184
|
+
export { binsOf, countReads, edgesOf, finiteOf, levelsOf, medianOf, onePoint, sortedOf, spanAcross, taken };
|
|
@@ -3,7 +3,7 @@ import { NOTE_LINE } from "../marks/notes.mjs";
|
|
|
3
3
|
import { placeOn } from "../scale/value.mjs";
|
|
4
4
|
import { spaced } from "../text/measure.mjs";
|
|
5
5
|
import { SPACE, TEXT } from "../theme.mjs";
|
|
6
|
-
import { binsOf, countReads, edgesOf, levelsOf, onePoint, spanAcross } from "./histogram-data.mjs";
|
|
6
|
+
import { binsOf, countReads, edgesOf, levelsOf, onePoint, sortedOf, spanAcross } from "./histogram-data.mjs";
|
|
7
7
|
import { valuePlot } from "./value-plot.mjs";
|
|
8
8
|
// src/kinds/histogram-layout.ts
|
|
9
9
|
/** Room at the right, so the last edge's name, centred on the last edge, stays near it. */
|
|
@@ -47,11 +47,12 @@ function layoutOf(values, options, env) {
|
|
|
47
47
|
reach: levels,
|
|
48
48
|
...options.bins === void 0 ? {} : { bins: options.bins }
|
|
49
49
|
};
|
|
50
|
-
const
|
|
50
|
+
const sorted = sortedOf(values);
|
|
51
|
+
const first = plotFor(binsOf(sorted, {
|
|
51
52
|
width: env.width,
|
|
52
53
|
...asked
|
|
53
54
|
}), options, env);
|
|
54
|
-
const bins = binsOf(
|
|
55
|
+
const bins = binsOf(sorted, {
|
|
55
56
|
width: first.plot.width,
|
|
56
57
|
...asked
|
|
57
58
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { least, most } from "../data/range.mjs";
|
|
2
2
|
import { wordsOf } from "../data/words.mjs";
|
|
3
3
|
import { counted, noValue, summary } from "../describe.mjs";
|
|
4
|
-
import { countReads } from "./histogram-data.mjs";
|
|
4
|
+
import { countReads, medianOf } from "./histogram-data.mjs";
|
|
5
5
|
import { runOf } from "./histogram-layout.mjs";
|
|
6
6
|
import { binKey, colorOf } from "./histogram-marks.mjs";
|
|
7
|
-
import { median } from "d3-array";
|
|
8
7
|
// src/kinds/histogram-words.ts
|
|
9
8
|
/** A stop for each bin: its range, its count, and its share of all values, keyed as its bar. */
|
|
10
9
|
function stopsOf(at) {
|
|
@@ -68,7 +67,7 @@ function rangeSaid(bins, at) {
|
|
|
68
67
|
function spread(values, at) {
|
|
69
68
|
const low = least(values);
|
|
70
69
|
if (at.point) return [`${values.length === 1 ? "Value" : "All values"}: ${at.text(low)}`];
|
|
71
|
-
return [`Median: ${at.text(
|
|
70
|
+
return [`Median: ${at.text(medianOf(values) ?? low)}`, `Range: ${at.text(low)} to ${at.text(most(values))}`];
|
|
72
71
|
}
|
|
73
72
|
/**
|
|
74
73
|
* What the chart shows, in words: how many values it was given and in how many bins it drew
|