derive-dashboards 0.1.1 → 0.3.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.
Files changed (202) hide show
  1. package/README.md +5 -3
  2. package/dist/cache.mjs +2 -1
  3. package/dist/cli/add.mjs +130 -0
  4. package/dist/cli/cli.mjs +14 -12
  5. package/dist/cli/config.mjs +12 -1
  6. package/dist/cli/doctor.mjs +162 -0
  7. package/dist/cli/init.mjs +3 -2
  8. package/dist/cli/json.mjs +21 -0
  9. package/dist/cli/layers.mjs +33 -0
  10. package/dist/core/document/display.d.mts +63 -0
  11. package/dist/core/document/display.mjs +139 -0
  12. package/dist/core/document/layout.mjs +1 -1
  13. package/dist/core/document/view-layout.d.mts +14 -0
  14. package/dist/core/document/view-layout.mjs +157 -0
  15. package/dist/core/engine/filter.mjs +2 -2
  16. package/dist/core/engine/leaf.mjs +9 -4
  17. package/dist/core/engine/members.mjs +1 -1
  18. package/dist/core/engine/version.d.mts +5 -4
  19. package/dist/core/engine/version.mjs +5 -4
  20. package/dist/core/error/codes.d.mts +4 -1
  21. package/dist/core/error/codes.mjs +4 -1
  22. package/dist/core/index.d.mts +12 -8
  23. package/dist/core/index.mjs +11 -7
  24. package/dist/core/model/member.mjs +5 -2
  25. package/dist/core/model/types.d.mts +13 -13
  26. package/dist/core/model/validate/drill.mjs +6 -15
  27. package/dist/core/model/validate/fields.mjs +130 -0
  28. package/dist/core/model/validate/index.mjs +11 -3
  29. package/dist/core/model/validate/known-members.mjs +133 -0
  30. package/dist/core/model/validate/known-nested.mjs +85 -0
  31. package/dist/core/model/validate/known.mjs +94 -0
  32. package/dist/core/model/validate/members.mjs +7 -4
  33. package/dist/core/model/validate/source.mjs +8 -1
  34. package/dist/core/policy/bind-query.d.mts +12 -0
  35. package/dist/core/policy/bind-query.mjs +53 -0
  36. package/dist/core/query/alias.mjs +11 -1
  37. package/dist/core/query/drill/selection.d.mts +7 -2
  38. package/dist/core/query/drill/selection.mjs +18 -15
  39. package/dist/core/query/filter.d.mts +6 -0
  40. package/dist/core/query/picks.d.mts +8 -2
  41. package/dist/core/query/picks.mjs +11 -4
  42. package/dist/core/query/segments.mjs +2 -1
  43. package/dist/core/result/columns.d.mts +10 -1
  44. package/dist/core/result/columns.mjs +27 -5
  45. package/dist/core/result/time-axis.d.mts +23 -0
  46. package/dist/core/result/time-axis.mjs +72 -0
  47. package/dist/core/result/types.d.mts +36 -1
  48. package/dist/core/schema/aliases.d.mts +7 -0
  49. package/dist/core/schema/aliases.mjs +77 -0
  50. package/dist/core/schema/answer-parts.mjs +23 -1
  51. package/dist/core/schema/answers.d.mts +204 -0
  52. package/dist/core/schema/answers.mjs +2 -0
  53. package/dist/core/schema/index.d.mts +3 -2
  54. package/dist/core/schema/index.mjs +3 -2
  55. package/dist/core/schema/query.d.mts +81 -0
  56. package/dist/core/schema/query.mjs +9 -5
  57. package/dist/core/schema/tools.d.mts +2 -0
  58. package/dist/core/schema/tools.mjs +27 -1
  59. package/dist/core/time/bucket.mjs +8 -2
  60. package/dist/core/types/api.d.mts +7 -1
  61. package/dist/core/types/api.mjs +1 -1
  62. package/dist/dashboards.mjs +4 -0
  63. package/dist/drill-change.mjs +1 -1
  64. package/dist/drill-seal.mjs +1 -0
  65. package/dist/editing.mjs +2 -2
  66. package/dist/endpoints/dashboards.mjs +17 -2
  67. package/dist/endpoints/index.d.mts +15 -2
  68. package/dist/endpoints/meta.mjs +10 -1
  69. package/dist/execute.mjs +32 -17
  70. package/dist/handler.mjs +5 -1
  71. package/dist/index.mjs +6 -1
  72. package/dist/llms.txt +22 -0
  73. package/dist/mcp/format.mjs +42 -8
  74. package/dist/mcp/query.mjs +34 -4
  75. package/dist/postgres-store.mjs +1 -0
  76. package/dist/react/Canvas.mjs +28 -5
  77. package/dist/react/Cell.mjs +2 -1
  78. package/dist/react/Dashboard.d.mts +4 -0
  79. package/dist/react/Dashboard.mjs +27 -4
  80. package/dist/react/DashboardList.mjs +22 -22
  81. package/dist/react/DashboardListRow.mjs +49 -0
  82. package/dist/react/Discard.mjs +5 -2
  83. package/dist/react/Editing.mjs +19 -5
  84. package/dist/react/FilterBar.d.mts +7 -9
  85. package/dist/react/Grid.mjs +7 -19
  86. package/dist/react/Header.mjs +1 -1
  87. package/dist/react/History.mjs +5 -0
  88. package/dist/react/ReadFailed.mjs +23 -0
  89. package/dist/react/Spaces.mjs +15 -1
  90. package/dist/react/Tile.d.mts +2 -0
  91. package/dist/react/Tile.mjs +45 -10
  92. package/dist/react/_virtual/_rolldown/runtime.mjs +12 -0
  93. package/dist/react/arrange-steps.mjs +16 -13
  94. package/dist/react/arrange.mjs +10 -3
  95. package/dist/react/builder/Calcs.mjs +35 -11
  96. package/dist/react/builder/FilterEditor.mjs +196 -0
  97. package/dist/react/builder/Filters.mjs +172 -116
  98. package/dist/react/builder/Formula.mjs +82 -0
  99. package/dist/react/builder/Groups.mjs +1 -0
  100. package/dist/react/builder/Preview.mjs +1 -1
  101. package/dist/react/builder/RangeEditor.mjs +184 -0
  102. package/dist/react/builder/Sections.mjs +41 -6
  103. package/dist/react/builder/Time.mjs +138 -60
  104. package/dist/react/builder/Values.mjs +85 -0
  105. package/dist/react/builder/WidgetBuilder.mjs +50 -49
  106. package/dist/react/builder/base.d.mts +5 -0
  107. package/dist/react/builder/base.mjs +33 -8
  108. package/dist/react/builder/calc.mjs +15 -1
  109. package/dist/react/builder/escape.d.mts +1 -0
  110. package/dist/react/builder/escape.mjs +62 -0
  111. package/dist/react/builder/filter-tree.d.mts +9 -0
  112. package/dist/react/builder/filter-tree.mjs +186 -0
  113. package/dist/react/builder/formula-parse.d.mts +18 -0
  114. package/dist/react/builder/formula-parse.mjs +136 -0
  115. package/dist/react/builder/labels.d.mts +1 -1
  116. package/dist/react/builder/state.d.mts +2 -1
  117. package/dist/react/builder/state.mjs +23 -37
  118. package/dist/react/builder/useBuilder.d.mts +12 -1
  119. package/dist/react/builder/useBuilder.mjs +6 -3
  120. package/dist/react/builder/words.d.mts +59 -0
  121. package/dist/react/builder/words.mjs +73 -0
  122. package/dist/react/context.d.mts +15 -1
  123. package/dist/react/context.mjs +9 -3
  124. package/dist/react/drill/Bars.mjs +2 -2
  125. package/dist/react/drill/props.mjs +2 -1
  126. package/dist/react/drill/useDrill.d.mts +1 -1
  127. package/dist/react/drill/words.d.mts +3 -0
  128. package/dist/react/drill/words.mjs +2 -0
  129. package/dist/react/english.mjs +20 -5
  130. package/dist/react/filters/bar.d.mts +12 -0
  131. package/dist/react/filters/bar.mjs +135 -0
  132. package/dist/react/filters/calendar.mjs +193 -0
  133. package/dist/react/filters/chip.mjs +174 -0
  134. package/dist/react/filters/context.d.mts +22 -0
  135. package/dist/react/filters/context.mjs +78 -0
  136. package/dist/react/filters/dates.mjs +89 -0
  137. package/dist/react/filters/days.d.mts +36 -0
  138. package/dist/react/filters/days.mjs +87 -0
  139. package/dist/react/filters/field-step.mjs +81 -0
  140. package/dist/react/filters/hooks.d.mts +34 -0
  141. package/dist/react/filters/hooks.mjs +94 -0
  142. package/dist/react/filters/listbox.mjs +131 -0
  143. package/dist/react/filters/logic.d.mts +59 -0
  144. package/dist/react/filters/logic.mjs +109 -0
  145. package/dist/react/filters/menu-search.mjs +211 -0
  146. package/dist/react/filters/menu.mjs +85 -0
  147. package/dist/react/filters/number.mjs +127 -0
  148. package/dist/react/filters/numbers.d.mts +47 -0
  149. package/dist/react/filters/numbers.mjs +151 -0
  150. package/dist/react/filters/operator.mjs +104 -0
  151. package/dist/react/filters/phone.mjs +104 -0
  152. package/dist/react/filters/popover.d.mts +19 -0
  153. package/dist/react/filters/popover.mjs +153 -0
  154. package/dist/react/filters/rules.d.mts +8 -0
  155. package/dist/react/filters/rules.mjs +55 -0
  156. package/dist/react/filters/sheet.mjs +196 -0
  157. package/dist/react/filters/state.mjs +132 -0
  158. package/dist/react/filters/suggest.d.mts +47 -0
  159. package/dist/react/filters/suggest.mjs +97 -0
  160. package/dist/react/filters/values.mjs +166 -0
  161. package/dist/react/filters/words.d.mts +81 -0
  162. package/dist/react/filters/words.mjs +73 -0
  163. package/dist/react/format.mjs +11 -4
  164. package/dist/react/index.d.mts +15 -6
  165. package/dist/react/index.mjs +10 -4
  166. package/dist/react/messages.d.mts +34 -2
  167. package/dist/react/place.mjs +7 -3
  168. package/dist/react/renderers/index.d.mts +3 -21
  169. package/dist/react/renderers/index.mjs +68 -6
  170. package/dist/react/renderers/list.d.mts +2 -1
  171. package/dist/react/renderers/list.mjs +9 -12
  172. package/dist/react/renderers/props.d.mts +26 -0
  173. package/dist/react/scope.d.mts +4 -0
  174. package/dist/react/scope.mjs +19 -2
  175. package/dist/react/series-slots.d.mts +37 -0
  176. package/dist/react/series-slots.mjs +71 -0
  177. package/dist/react/series.d.mts +39 -9
  178. package/dist/react/series.mjs +144 -47
  179. package/dist/react/theme.css +930 -19
  180. package/dist/react/useBoard.d.mts +2 -0
  181. package/dist/react/useDashboard.d.mts +3 -0
  182. package/dist/react/useDashboard.mjs +6 -0
  183. package/dist/react/view-grid.mjs +16 -0
  184. package/dist/recharts/axes.mjs +28 -0
  185. package/dist/recharts/axis.mjs +84 -0
  186. package/dist/recharts/bar.d.mts +7 -0
  187. package/dist/recharts/bar.mjs +141 -0
  188. package/dist/recharts/charts.d.mts +4 -5
  189. package/dist/recharts/charts.mjs +2 -208
  190. package/dist/recharts/index.d.mts +3 -1
  191. package/dist/recharts/index.mjs +4 -1
  192. package/dist/recharts/line.d.mts +2 -0
  193. package/dist/recharts/line.mjs +112 -0
  194. package/dist/recharts/marks.mjs +47 -18
  195. package/dist/recharts/parts.mjs +103 -0
  196. package/dist/recharts/table.mjs +71 -0
  197. package/dist/records-read.mjs +1 -1
  198. package/dist/registry/filter-bar.json +26 -0
  199. package/dist/skills/derive-dashboards/SKILL.md +69 -0
  200. package/dist/store/apply.mjs +3 -1
  201. package/package.json +6 -2
  202. package/dist/react/FilterBar.mjs +0 -119
@@ -4,14 +4,21 @@ import { Builder, useBuilder } from "./builder/useBuilder.mjs";
4
4
  import { WidgetBuilder, WidgetBuilderProps } from "./builder/WidgetBuilder.mjs";
5
5
  import { DashboardsError, DashboardsErrorCode } from "./errors.mjs";
6
6
  import { ClientOptions, DashboardsClient, DashboardsServer, TypedCall, createDashboardsClient } from "./client.mjs";
7
- import { DashboardsProvider, DashboardsProviderProps, LinkComponent, LinkProps, useDashboards } from "./context.mjs";
7
+ import { Components, DashboardsProvider, DashboardsProviderProps, LinkComponent, LinkProps, useDashboards } from "./context.mjs";
8
+ import { ENGLISH_FILTERS, FilterWords } from "./filters/words.mjs";
9
+ import { FilterBarOptions, FilterIcon } from "./filters/context.mjs";
10
+ import { FilterBarProps, fieldOf, useControlValues, useFilterFields } from "./filters/hooks.mjs";
11
+ import { FilterBar } from "./filters/bar.mjs";
12
+ import { Popover } from "./filters/popover.mjs";
13
+ import { rules_d_exports } from "./filters/rules.mjs";
8
14
  import { Dashboard, DashboardProps } from "./Dashboard.mjs";
9
15
  import { DashboardList } from "./DashboardList.mjs";
10
- import { ENGLISH } from "./english.mjs";
11
16
  import { Attempt, DraftClosed, DraftEditor, DraftStatus, useDraft } from "./draft.mjs";
17
+ import { ENGLISH } from "./english.mjs";
12
18
  import { DashboardDrillProps, DrillEvent } from "./drill/board.mjs";
13
19
  import { DashboardTile, DashboardTileProps } from "./drill/DashboardTile.mjs";
14
20
  import { DrillPanelProps } from "./drill/DrillPanel.mjs";
21
+ import { TileRenderer, TileRendererProps } from "./renderers/props.mjs";
15
22
  import { ItemHelpers, ItemOptions } from "./drill/Items.mjs";
16
23
  import { DrillPanel } from "./drill/lazy.mjs";
17
24
  import { DrillMarkProps, TileDrill } from "./drill/props.mjs";
@@ -19,18 +26,20 @@ import { DrillChange, DrillHistory, drillFrom } from "./drill/state.mjs";
19
26
  import { DrillController, DrillOptions, useDrill } from "./drill/useDrill.mjs";
20
27
  import { DrillMessages, ENGLISH_DRILL } from "./drill/words.mjs";
21
28
  import { EditBar } from "./EditBar.mjs";
22
- import { FilterBar } from "./FilterBar.mjs";
29
+ import "./FilterBar.mjs";
23
30
  import { formatBucket, formatCell, formatInstant, formatTick, plotValue } from "./format.mjs";
24
31
  import { HistoryPanel, VersionBar } from "./History.mjs";
25
32
  import { CellFormat, Messages } from "./messages.mjs";
26
33
  import { ChangeList, Panel } from "./Panel.mjs";
27
34
  import { ReviewPanel } from "./ReviewPanel.mjs";
28
35
  import { ClientSchemas } from "./read.mjs";
29
- import { NumberTile, TableTile, TileRenderer, TileRendererProps } from "./renderers/index.mjs";
36
+ import { NumberTile, TableTile } from "./renderers/index.mjs";
30
37
  import { ListDisplay, ListTile } from "./renderers/list.mjs";
31
38
  import { Moved, Review, useReview } from "./review.mjs";
32
39
  import { ENGLISH_REVIEW, ReviewMessages } from "./review-words.mjs";
33
- import { Drawn, OTHER_KEY, Point, Series, rowAt, toSeries } from "./series.mjs";
40
+ import { SeriesSlotsContext } from "./scope.mjs";
41
+ import { Drawn, OTHER_KEY, Point, Series, lastBucketOpen, rowAt, toSeries } from "./series.mjs";
42
+ import { SeriesSlots, SplitSeries, chartColors, seriesSlots } from "./series-slots.mjs";
34
43
  import { Tile } from "./Tile.mjs";
35
44
  import { useBoard } from "./useBoard.mjs";
36
45
  import { useDashboard } from "./useDashboard.mjs";
@@ -47,4 +56,4 @@ export interface Register {}
47
56
  export type Item = Register extends {
48
57
  server: infer S;
49
58
  } ? ItemFor<S> : DrillItem;
50
- export { type Attempt, type Builder, type CellFormat, ChangeList, type ClientOptions, type ClientSchemas, Dashboard, type DashboardDrillProps, DashboardList, type DashboardProps, DashboardTile, type DashboardTileProps, type DashboardsClient, DashboardsError, type DashboardsErrorCode, DashboardsProvider, type DashboardsProviderProps, type DashboardsServer, type DraftClosed, type DraftEditor, type DraftStatus, type Drawn, type DrillChange, type DrillController, type DrillEvent, type DrillHistory, type DrillMarkProps, type DrillMessages, type DrillOptions, DrillPanel, type DrillPanelProps, ENGLISH, ENGLISH_DRILL, ENGLISH_REVIEW, EditBar, FilterBar, HistoryPanel, type ItemFor, type ItemHelpers, type ItemOptions, type LinkComponent, type LinkProps, type ListDisplay, ListTile, type Messages, type Moved, NumberTile, OTHER_KEY, Panel, type Point, type Review, type ReviewMessages, ReviewPanel, type Series, TableTile, Tile, type TileDrill, type TileRenderer, type TileRendererProps, type TypedCall, VersionBar, type ViewChange, WidgetBuilder, type WidgetBuilderProps, WidgetPreview, createDashboardsClient, drillFrom, formatBucket, formatCell, formatInstant, formatTick, plotValue, rowAt, toSeries, useBoard, useBuilder, useDashboard, useDashboards, useDraft, useDrill, useReview, useTiles };
59
+ export { type Attempt, type Builder, type CellFormat, ChangeList, type ClientOptions, type ClientSchemas, type Components, Dashboard, type DashboardDrillProps, DashboardList, type DashboardProps, DashboardTile, type DashboardTileProps, type DashboardsClient, DashboardsError, type DashboardsErrorCode, DashboardsProvider, type DashboardsProviderProps, type DashboardsServer, type DraftClosed, type DraftEditor, type DraftStatus, type Drawn, type DrillChange, type DrillController, type DrillEvent, type DrillHistory, type DrillMarkProps, type DrillMessages, type DrillOptions, DrillPanel, type DrillPanelProps, ENGLISH, ENGLISH_DRILL, ENGLISH_FILTERS, ENGLISH_REVIEW, EditBar, FilterBar, type FilterBarOptions, type FilterBarProps, type FilterIcon, type FilterWords, HistoryPanel, type ItemFor, type ItemHelpers, type ItemOptions, type LinkComponent, type LinkProps, type ListDisplay, ListTile, type Messages, type Moved, NumberTile, OTHER_KEY, Panel, type Point, Popover, type Review, type ReviewMessages, ReviewPanel, type Series, type SeriesSlots, SeriesSlotsContext, type SplitSeries, TableTile, Tile, type TileDrill, type TileRenderer, type TileRendererProps, type TypedCall, VersionBar, type ViewChange, WidgetBuilder, type WidgetBuilderProps, WidgetPreview, chartColors, createDashboardsClient, drillFrom, fieldOf, rules_d_exports as filterRules, formatBucket, formatCell, formatInstant, formatTick, lastBucketOpen, plotValue, rowAt, seriesSlots, toSeries, useBoard, useBuilder, useControlValues, useDashboard, useDashboards, useDraft, useDrill, useFilterFields, useReview, useTiles };
@@ -6,7 +6,6 @@ import { createDashboardsClient } from "./client.mjs";
6
6
  import { DashboardsProvider, useDashboards } from "./context.mjs";
7
7
  import { Dashboard } from "./Dashboard.mjs";
8
8
  import { DashboardList } from "./DashboardList.mjs";
9
- import { DashboardsError } from "./errors.mjs";
10
9
  import { useDraft } from "./draft.mjs";
11
10
  import { DashboardTile } from "./drill/DashboardTile.mjs";
12
11
  import { DrillPanel } from "./drill/lazy.mjs";
@@ -14,7 +13,12 @@ import { drillFrom } from "./drill/state.mjs";
14
13
  import { useDrill } from "./drill/useDrill.mjs";
15
14
  import { ENGLISH_DRILL } from "./drill/words.mjs";
16
15
  import { EditBar } from "./EditBar.mjs";
17
- import { FilterBar } from "./FilterBar.mjs";
16
+ import { DashboardsError } from "./errors.mjs";
17
+ import { ENGLISH_FILTERS } from "./filters/words.mjs";
18
+ import { FilterBar } from "./filters/bar.mjs";
19
+ import { fieldOf, useControlValues, useFilterFields } from "./filters/hooks.mjs";
20
+ import { rules_exports } from "./filters/rules.mjs";
21
+ import { Popover } from "./filters/popover.mjs";
18
22
  import { formatBucket, formatCell, formatInstant, formatTick, plotValue } from "./format.mjs";
19
23
  import { HistoryPanel, VersionBar } from "./History.mjs";
20
24
  import { ENGLISH } from "./english.mjs";
@@ -24,9 +28,11 @@ import { NumberTile, TableTile } from "./renderers/index.mjs";
24
28
  import { ListTile } from "./renderers/list.mjs";
25
29
  import { useReview } from "./review.mjs";
26
30
  import { ENGLISH_REVIEW } from "./review-words.mjs";
27
- import { OTHER_KEY, rowAt, toSeries } from "./series.mjs";
31
+ import { SeriesSlotsContext } from "./scope.mjs";
32
+ import { OTHER_KEY, lastBucketOpen, rowAt, toSeries } from "./series.mjs";
33
+ import { chartColors, seriesSlots } from "./series-slots.mjs";
28
34
  import { Tile } from "./Tile.mjs";
29
35
  import { useBoard } from "./useBoard.mjs";
30
36
  import { useDashboard } from "./useDashboard.mjs";
31
37
  import { useTiles } from "./useTiles.mjs";
32
- export { ChangeList, Dashboard, DashboardList, DashboardTile, DashboardsError, DashboardsProvider, DrillPanel, ENGLISH, ENGLISH_DRILL, ENGLISH_REVIEW, EditBar, FilterBar, HistoryPanel, ListTile, NumberTile, OTHER_KEY, Panel, ReviewPanel, TableTile, Tile, VersionBar, WidgetBuilder, WidgetPreview, createDashboardsClient, drillFrom, formatBucket, formatCell, formatInstant, formatTick, plotValue, rowAt, toSeries, useBoard, useBuilder, useDashboard, useDashboards, useDraft, useDrill, useReview, useTiles };
38
+ export { ChangeList, Dashboard, DashboardList, DashboardTile, DashboardsError, DashboardsProvider, DrillPanel, ENGLISH, ENGLISH_DRILL, ENGLISH_FILTERS, ENGLISH_REVIEW, EditBar, FilterBar, HistoryPanel, ListTile, NumberTile, OTHER_KEY, Panel, Popover, ReviewPanel, SeriesSlotsContext, TableTile, Tile, VersionBar, WidgetBuilder, WidgetPreview, chartColors, createDashboardsClient, drillFrom, fieldOf, rules_exports as filterRules, formatBucket, formatCell, formatInstant, formatTick, lastBucketOpen, plotValue, rowAt, seriesSlots, toSeries, useBoard, useBuilder, useControlValues, useDashboard, useDashboards, useDraft, useDrill, useFilterFields, useReview, useTiles };
@@ -1,4 +1,6 @@
1
+ import { BuilderMessages } from "./builder/words.mjs";
1
2
  import { DrillMessages } from "./drill/words.mjs";
3
+ import { FilterWords } from "./filters/words.mjs";
2
4
  import { ReviewMessages } from "./review-words.mjs";
3
5
  import { ENGLISH } from "./english.mjs";
4
6
  import { RelativeRange } from "derive-dashboards/core";
@@ -6,7 +8,7 @@ import { RelativeRange } from "derive-dashboards/core";
6
8
  * Every word the built-in components show. English by default; pass `messages` to the
7
9
  * provider to change any of them, for another language or another house style.
8
10
  */
9
- export type Messages = ReviewMessages & DrillMessages & {
11
+ export type Messages = ReviewMessages & DrillMessages & BuilderMessages & {
10
12
  /** A dimension cell for the values a limit left out. */
11
13
  other: string;
12
14
  /** A dimension cell for every value: a total row. */
@@ -19,6 +21,8 @@ export type Messages = ReviewMessages & DrillMessages & {
19
21
  noAccess: string;
20
22
  noData: string;
21
23
  noRows: string;
24
+ /** Beside the last time bucket while it is still running: its value is not final yet. */
25
+ soFar: string;
22
26
  dashboardFailed: string;
23
27
  /** A dashboard already shown, while the server cannot be reached. */
24
28
  dashboardUnreachable: string;
@@ -32,10 +36,12 @@ export type Messages = ReviewMessages & DrillMessages & {
32
36
  /** How many rows the rows panel shows, and whether there are more. */
33
37
  rowsShowing: (n: number, more: boolean) => string;
34
38
  reset: string;
39
+ /** The filter bar's words; any subset, the rest stay English. */
40
+ filterBar?: Partial<FilterWords>;
35
41
  rowsBehind: (title: string) => string;
36
42
  notFilteredBy: (controls: readonly string[]) => string;
37
43
  firstRows: (count: number) => string;
38
- /** A date-range preset: "Last 7 days", "This month", "Last 3 complete months". */
44
+ /** A date-range preset: "Today", "Last 7 days", "This month", "Last month", "Previous 3 months". */
39
45
  range: (range: RelativeRange) => string;
40
46
  untitledWidget: string;
41
47
  save: string;
@@ -87,6 +93,24 @@ export type Messages = ReviewMessages & DrillMessages & {
87
93
  refOf: Record<"total" | "bucket" | "previous", string>;
88
94
  /** Under Over time: calcs a change of time removed, since they no longer fit. */
89
95
  removedCalcs: (names: readonly string[]) => string;
96
+ /** Under a chart: the values it does not draw, which the table shows. */
97
+ notDrawn: (labels: readonly string[]) => string;
98
+ /** A chart's data table caption, read by screen readers in place of the picture. */
99
+ chartTable: (chart: {
100
+ title: string;
101
+ kind: "line" | "bar";
102
+ points: number;
103
+ }) => string;
104
+ /** The name of a chart's list of points to open; arrow keys move along it. */
105
+ chartPoints: string;
106
+ /** What the builder keeps as it was, though it cannot edit it. */
107
+ keptAside: (kept: {
108
+ display: boolean;
109
+ queries: readonly string[];
110
+ fields: readonly string[];
111
+ }) => string;
112
+ /** A widget the builder cannot open: it has no main query to edit. */
113
+ noMainQuery: (title: string) => string;
90
114
  /** Under the chart kinds: which dashboard filters the widget will follow. */
91
115
  followsFilters: (labels: readonly string[]) => string;
92
116
  /** The grip that reorders a group. */
@@ -98,6 +122,8 @@ export type Messages = ReviewMessages & DrillMessages & {
98
122
  editing: string;
99
123
  publish: string;
100
124
  discard: string;
125
+ /** Leaving edit mode with no changes: nothing to discard, so nothing is asked. */
126
+ doneEditing: string;
101
127
  addWidget: string;
102
128
  addToDashboard: string;
103
129
  /** Screen-reader names of a tile's Edit and Remove, which say which tile. */
@@ -132,6 +158,12 @@ export type Messages = ReviewMessages & DrillMessages & {
132
158
  removedTile: (title: string) => string;
133
159
  /** A tile whose request failed before any answer came. */
134
160
  tileUnreachable: string;
161
+ /** A list (a field's values, the history) that could not be read; with drillRetry beside it. */
162
+ readFailed: string;
163
+ /** A field with no values this viewer can see (or none matching the search). */
164
+ noValues: string;
165
+ /** Copy refused by the browser: the text is shown to copy by hand. */
166
+ copyByHand: string;
135
167
  /** Said once a draft is discarded, as focus returns to Edit. */
136
168
  changesDiscarded: string;
137
169
  /** Draft refusals, in words that say what to do. */
@@ -1,10 +1,14 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  // src/place.ts
3
3
  const overlaps = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
4
- /** Where a box is drawn on the 12-column CSS grid. */
4
+ /**
5
+ * Where a box is drawn on the 12-column CSS grid, as variables the theme places it by: a rule
6
+ * (the one-column phone layout, or a host's own) can then place it otherwise, which an inline
7
+ * grid position would always beat.
8
+ */
5
9
  const placeOf = (box) => ({
6
- gridColumn: `${box.x + 1} / span ${box.w}`,
7
- gridRow: `${box.y + 1} / span ${box.h}`
10
+ "--dd-at-column": `${String(box.x + 1)} / span ${String(box.w)}`,
11
+ "--dd-at-row": `${String(box.y + 1)} / span ${String(box.h)}`
8
12
  });
9
13
  /** Brings an element into view when asked, without motion if the viewer asked for none. */
10
14
  function useBringIntoView(wanted) {
@@ -1,27 +1,9 @@
1
- import { LinkComponent } from "../context.mjs";
2
- import { TileDrill } from "../drill/props.mjs";
3
- import { Messages } from "../messages.mjs";
4
- import { ReactNode } from "react";
5
- import { TileAnswer, Widget } from "derive-dashboards/core";
6
- /**
7
- * What a renderer draws, and how: pass the props as `formatCell`'s format to use both. `drill`
8
- * is there when drilling is on: spread `drill.props(row, entry)` on a mark to make it open.
9
- */
10
- export type TileRendererProps = {
11
- answer: TileAnswer;
12
- widget: Widget;
13
- locale?: string;
14
- messages: Messages;
15
- drill?: TileDrill;
16
- /** The provider's link component, for a renderer that links rows into the app. */
17
- link?: LinkComponent;
18
- };
19
- /** Draws one tile's answer. Register more by widget kind on the provider. */
20
- export type TileRenderer = (props: TileRendererProps) => ReactNode;
1
+ import { TileRenderer, TileRendererProps } from "./props.mjs";
21
2
  /**
22
3
  * The first calc or value column, large, from the total row when there is one, else the first row;
23
4
  * a change calc (a signed column) sits under it.
24
5
  */
25
6
  export declare function NumberTile(props: TileRendererProps): import("react").JSX.Element;
26
7
  /** Every row and column: the groups, then Other and the total under them. */
27
- export declare function TableTile(props: TileRendererProps): import("react").JSX.Element;
8
+ export declare function TableTile(props: TileRendererProps): import("react").JSX.Element;
9
+ export type { TileRenderer, TileRendererProps };
@@ -1,13 +1,13 @@
1
1
  import { formatCell } from "../format.mjs";
2
2
  import { ListTile } from "./list.mjs";
3
- import { isMark } from "derive-dashboards/core";
3
+ import { isMark, roleOf } from "derive-dashboards/core";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  // src/renderers/index.tsx
6
- const isMeasure = (column) => column.id.startsWith("m") || column.id.startsWith("c");
6
+ const isMeasure = (column) => roleOf(column) === "measure" || roleOf(column) === "calc";
7
7
  const isAll = (cell) => isMark(cell) && cell.mark === "all";
8
8
  /** A calc is what the query was built to show (a share, a rate); else its first value. */
9
9
  const shownIndex = (columns) => {
10
- const calc = columns.findIndex((c) => c.id.startsWith("c") && c.signed !== true);
10
+ const calc = columns.findIndex((c) => roleOf(c) === "calc" && c.signed !== true);
11
11
  return calc === -1 ? columns.findIndex((c) => isMeasure(c)) : calc;
12
12
  };
13
13
  /**
@@ -42,14 +42,76 @@ function NumberTile(props) {
42
42
  ]
43
43
  });
44
44
  }
45
- /** The value of the period before, when the answer compares: it opens that period's rows. */
45
+ /** A cell as a number, for the change against the period before. */
46
+ const numberOf = (cell) => {
47
+ if (typeof cell === "number") return cell;
48
+ if (cell !== null && typeof cell === "object" && "v" in cell) return Number(cell.v);
49
+ };
50
+ const PLAIN_DECIMAL = /^-?\d+(\.\d+)?$/u;
51
+ /** A cell's exact digits ("12.50"), when it has them: exact cells, and whole JS numbers. */
52
+ const digitsOf = (cell) => {
53
+ if (typeof cell === "number") return Number.isSafeInteger(cell) ? String(cell) : void 0;
54
+ if (cell !== null && typeof cell === "object" && "v" in cell && typeof cell.v === "string") return PLAIN_DECIMAL.test(cell.v) ? cell.v : void 0;
55
+ };
56
+ /** A decimal as an integer of `scale` fraction digits: "12.5" at scale 2 is 1250n. */
57
+ const scaled = (digits, scale) => {
58
+ const negative = digits.startsWith("-");
59
+ const [whole = "0", fraction = ""] = digits.replace("-", "").split(".");
60
+ return BigInt(`${negative ? "-" : ""}${whole}${fraction.padEnd(scale, "0")}`);
61
+ };
62
+ /** now − was in floats, for values that are not exact digits. */
63
+ function floatDifference(now, was) {
64
+ const [x, y] = [numberOf(now), numberOf(was)];
65
+ if (x === void 0 || y === void 0) return void 0;
66
+ return {
67
+ sign: Math.sign(x - y),
68
+ size: Math.abs(x - y)
69
+ };
70
+ }
71
+ /** a − b of two decimal strings, exactly, as a cell of `type`. */
72
+ function exactDifference(a, b, type) {
73
+ const scale = Math.max(a.split(".")[1]?.length ?? 0, b.split(".")[1]?.length ?? 0);
74
+ const d = scaled(a, scale) - scaled(b, scale);
75
+ const abs = (d < 0n ? -d : d).toString().padStart(scale + 1, "0");
76
+ const v = scale === 0 ? abs : `${abs.slice(0, -scale)}.${abs.slice(-scale)}`;
77
+ return {
78
+ sign: d === 0n ? 0 : d > 0n ? 1 : -1,
79
+ size: {
80
+ t: type,
81
+ v
82
+ }
83
+ };
84
+ }
85
+ /**
86
+ * now − was, exactly when both are exact (a 2^53 amount that moved by 1 moved by 1), else in
87
+ * floats; its sign and its size as a cell to format. Undefined when either is not a number.
88
+ */
89
+ function difference(now, was) {
90
+ const [a, b] = [digitsOf(now), digitsOf(was)];
91
+ if (a === void 0 || b === void 0) return floatDifference(now, was);
92
+ return exactDifference(a, b, typeof now === "object" && now !== null && "t" in now ? now.t : "decimal");
93
+ }
94
+ /** What the period before says: "+17 from 0", "No change from 12", or the bare value when it is not a number. */
95
+ function beforeText(props, column, now, was) {
96
+ const wasText = formatCell(was, column, props);
97
+ const delta = difference(now, was);
98
+ if (delta === void 0) return props.messages.drillBefore(wasText);
99
+ if (delta.sign === 0) return props.messages.beforeSame(wasText);
100
+ const change = `${delta.sign > 0 ? "+" : "−"}${formatCell(delta.size, column, props)}`;
101
+ return props.messages.beforeChange(change, wasText);
102
+ }
103
+ /**
104
+ * The change against the period before, when the answer compares ("+17 from 0"): it opens that
105
+ * period's rows. No value before (a rate over no rows) says nothing, so it is left out.
106
+ */
46
107
  function Before(props) {
47
108
  const { answer, index } = props;
48
109
  const before = answer.compare?.rows[0];
49
110
  const column = answer.columns[index];
50
- if (before === void 0 || column === void 0) return null;
111
+ const was = before?.[index] ?? null;
112
+ if (before === void 0 || column === void 0 || was === null) return null;
51
113
  const marks = props.drill?.props(before, column.id);
52
- const text = props.messages.drillBefore(formatCell(before[index] ?? null, column, props));
114
+ const text = beforeText(props, column, answer.rows[0]?.[index], was);
53
115
  const named = marks === void 0 ? marks : {
54
116
  ...marks,
55
117
  "aria-label": props.messages.drillMark(text)
@@ -1,4 +1,5 @@
1
- import { TileRendererProps } from "./index.mjs";
1
+ import { TileRendererProps } from "./props.mjs";
2
+ import "./index.mjs";
2
3
  /**
3
4
  * How a list draws its rows, by the query's entry ids. Every key is optional: with none, the
4
5
  * first group is the title, the other groups the subtitle, and the last value the number.
@@ -1,12 +1,10 @@
1
1
  import { formatCell } from "../format.mjs";
2
2
  import { RowBody } from "../RowBody.mjs";
3
- import { isMark } from "derive-dashboards/core";
3
+ import { displayOf, isMark, roleOf } from "derive-dashboards/core";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  // src/renderers/list.tsx
6
6
  const initials = (text) => text.split(/[\s._@-]+/u).filter(Boolean).slice(0, 2).map((word) => word[0]?.toUpperCase()).join("");
7
- const asText = (value) => typeof value === "string" ? value : void 0;
8
- const asList = (value) => Array.isArray(value) && value.every((v) => typeof v === "string") ? value : void 0;
9
- const isValue = (c) => c.id.startsWith("m") || c.id.startsWith("c");
7
+ const isValue = (c) => roleOf(c) === "measure" || roleOf(c) === "calc";
10
8
  /** With no display, the first group is the title, the others the subtitle, the last value the number. */
11
9
  function defaults(columns) {
12
10
  const groups = columns.filter((c) => !isValue(c)).map((c) => c.id);
@@ -22,7 +20,7 @@ function defaults(columns) {
22
20
  * server runs it; `display` names them as the widget's query does. This maps one to the other.
23
21
  */
24
22
  function answerIds(widget) {
25
- const query = widget.queries["main"];
23
+ const query = widget.queries.main;
26
24
  if (query === void 0) return /* @__PURE__ */ new Map();
27
25
  return new Map([
28
26
  ...query.measures.map((entry, i) => [entry.id, `m${String(i + 1)}`]),
@@ -31,17 +29,16 @@ function answerIds(widget) {
31
29
  ]);
32
30
  }
33
31
  function readDisplay(widget, columns) {
34
- const display = widget.display ?? {};
32
+ const display = displayOf("list", widget.display);
35
33
  const ids = answerIds(widget);
36
34
  const id = (entry) => entry === void 0 ? void 0 : ids.get(entry) ?? entry;
37
35
  const fallback = defaults(columns);
38
- const href = asText(display["href"]);
39
36
  return {
40
- title: id(asText(display["title"])) ?? fallback.title,
41
- subtitle: asList(display["subtitle"])?.map((entry) => id(entry) ?? entry) ?? fallback.subtitle,
42
- avatar: id(asText(display["avatar"])),
43
- meta: id(asText(display["meta"])) ?? fallback.meta,
44
- href: href?.replaceAll(/\{([^}]+)\}/gu, (_, entry) => `{${id(entry) ?? entry}}`)
37
+ title: id(display.title) ?? fallback.title,
38
+ subtitle: display.subtitle?.map((entry) => id(entry) ?? entry) ?? fallback.subtitle,
39
+ avatar: id(display.avatar),
40
+ meta: id(display.meta) ?? fallback.meta,
41
+ href: display.href?.replaceAll(/\{([^}]+)\}/gu, (_, entry) => `{${id(entry) ?? entry}}`)
45
42
  };
46
43
  }
47
44
  const text = ({ cells, at, props }, id) => {
@@ -0,0 +1,26 @@
1
+ import { LinkComponent } from "../context.mjs";
2
+ import { TileDrill } from "../drill/props.mjs";
3
+ import { Messages } from "../messages.mjs";
4
+ import { SeriesSlots } from "../series-slots.mjs";
5
+ import { ReactNode } from "react";
6
+ import { TileAnswer, Widget } from "derive-dashboards/core";
7
+ /**
8
+ * What a renderer draws, and how: pass the props as `formatCell`'s format to use both. `drill`
9
+ * is there when drilling is on: spread `drill.props(row, entry)` on a mark to make it open.
10
+ */
11
+ export type TileRendererProps = {
12
+ answer: TileAnswer;
13
+ widget: Widget;
14
+ locale?: string;
15
+ messages: Messages;
16
+ drill?: TileDrill;
17
+ /** The provider's link component, for a renderer that links rows into the app. */
18
+ link?: LinkComponent;
19
+ /**
20
+ * The dashboard's book of palette places: pass it to `toSeries`, and each series' `slot` is the
21
+ * same on every tile and under every filter.
22
+ */
23
+ slots?: SeriesSlots;
24
+ };
25
+ /** Draws one tile's answer. Register more by widget kind on the provider. */
26
+ export type TileRenderer = (props: TileRendererProps) => ReactNode;
@@ -0,0 +1,4 @@
1
+ import { SeriesSlots } from "./series-slots.mjs";
2
+ import { Picks } from "derive-dashboards/core";
3
+ /** The dashboard's book of palette places, for every chart drawn in it; none outside a dashboard. */
4
+ export declare const SeriesSlotsContext: import("react").Context<SeriesSlots | undefined>;
@@ -1,4 +1,21 @@
1
- import { createContext } from "react";
1
+ import { seriesSlots } from "./series-slots.mjs";
2
+ import { createContext, useState } from "react";
2
3
  // src/scope.tsx
3
4
  const ScopeContext = createContext(null);
4
- export { ScopeContext };
5
+ /** The dashboard's book of palette places, for every chart drawn in it; none outside a dashboard. */
6
+ const SeriesSlotsContext = createContext(void 0);
7
+ /** One book per dashboard shown: a new one when the dashboard changes, the same one otherwise. */
8
+ function useSeriesSlots(dashboardId) {
9
+ const [book, setBook] = useState(() => ({
10
+ id: dashboardId,
11
+ slots: seriesSlots()
12
+ }));
13
+ if (book.id === dashboardId) return book.slots;
14
+ const next = {
15
+ id: dashboardId,
16
+ slots: seriesSlots()
17
+ };
18
+ setBook(next);
19
+ return next.slots;
20
+ }
21
+ export { ScopeContext, SeriesSlotsContext, useSeriesSlots };
@@ -0,0 +1,37 @@
1
+ import { ResultCell, ResultColumn } from "derive-dashboards/core";
2
+ /** A series that is one value of the fields a chart splits by. */
3
+ export type SplitSeries = {
4
+ /** The columns the chart splits by, after its x axis. */
5
+ by: readonly ResultColumn[];
6
+ /** The series' key: its raw values, as `toSeries` keys them. */
7
+ key: string;
8
+ /** Its raw cells, one per column of `by`. */
9
+ cells: readonly ResultCell[];
10
+ };
11
+ /** A book of palette places: the same value of the same field, the same place, every time it is asked. */
12
+ export type SeriesSlots = {
13
+ of: (series: SplitSeries) => number;
14
+ };
15
+ /**
16
+ * A new book. A value whose field declares its values in the model takes its place among them,
17
+ * so its colour is the same on every dashboard and every load. Any other value takes the next
18
+ * free place of its field the first time it is drawn, and keeps it while the book lives: a
19
+ * dashboard keeps one book, so a filter never repaints a series and every tile agrees.
20
+ *
21
+ * Known gap: a field that declares no values has no place that outlives the page, so after a
22
+ * reload its values are placed again in the order they are first drawn. Declare the field's
23
+ * `values` in the model, or a widget's `display.colors`, to fix a colour for good. A chart
24
+ * split by two fields places each pair of values, and series that are measures go by position.
25
+ */
26
+ export declare function seriesSlots(): SeriesSlots;
27
+ /**
28
+ * The palette colour of each series of one chart, as an index into a palette of `size`
29
+ * colours; none for a series with no slot (Other). A series takes its slot's colour. Two slots
30
+ * a palette apart would take the same one, so when the chart has a colour to spare the series
31
+ * with the higher slot takes the first colour no series of the chart has: within one chart
32
+ * colours stay apart for as long as the palette allows, as they did when colour went by
33
+ * position. Only past the palette's size do two series share a colour.
34
+ */
35
+ export declare function chartColors(series: readonly {
36
+ slot?: number;
37
+ }[], size: number): (number | undefined)[];
@@ -0,0 +1,71 @@
1
+ // src/series-slots.ts
2
+ /** The place the model gives a value: its index among the values its field declares, in the model's order. */
3
+ function declaredSlot(series) {
4
+ const [column, ...more] = series.by;
5
+ const [cell] = series.cells;
6
+ if (column?.values === void 0 || more.length > 0 || typeof cell !== "string") return void 0;
7
+ const index = column.values.indexOf(cell);
8
+ return index === -1 ? void 0 : index;
9
+ }
10
+ /** The lowest place no value of the field has, at or after the places its declared values hold. */
11
+ function freeSlot(taken, from) {
12
+ const used = new Set(taken.values());
13
+ let slot = from;
14
+ while (used.has(slot)) slot += 1;
15
+ return slot;
16
+ }
17
+ /**
18
+ * A new book. A value whose field declares its values in the model takes its place among them,
19
+ * so its colour is the same on every dashboard and every load. Any other value takes the next
20
+ * free place of its field the first time it is drawn, and keeps it while the book lives: a
21
+ * dashboard keeps one book, so a filter never repaints a series and every tile agrees.
22
+ *
23
+ * Known gap: a field that declares no values has no place that outlives the page, so after a
24
+ * reload its values are placed again in the order they are first drawn. Declare the field's
25
+ * `values` in the model, or a widget's `display.colors`, to fix a colour for good. A chart
26
+ * split by two fields places each pair of values, and series that are measures go by position.
27
+ */
28
+ function seriesSlots() {
29
+ const fields = /* @__PURE__ */ new Map();
30
+ return { of(series) {
31
+ const field = series.by.map((c) => c.member ?? c.id).join("|");
32
+ const taken = fields.get(field) ?? /* @__PURE__ */ new Map();
33
+ fields.set(field, taken);
34
+ const had = declaredSlot(series) ?? taken.get(series.key);
35
+ if (had !== void 0) {
36
+ taken.set(series.key, had);
37
+ return had;
38
+ }
39
+ const slot = freeSlot(taken, series.by.length === 1 ? series.by[0]?.values?.length ?? 0 : 0);
40
+ taken.set(series.key, slot);
41
+ return slot;
42
+ } };
43
+ }
44
+ /**
45
+ * The palette colour of each series of one chart, as an index into a palette of `size`
46
+ * colours; none for a series with no slot (Other). A series takes its slot's colour. Two slots
47
+ * a palette apart would take the same one, so when the chart has a colour to spare the series
48
+ * with the higher slot takes the first colour no series of the chart has: within one chart
49
+ * colours stay apart for as long as the palette allows, as they did when colour went by
50
+ * position. Only past the palette's size do two series share a colour.
51
+ */
52
+ function chartColors(series, size) {
53
+ const bySlot = series.flatMap((s, at) => s.slot === void 0 ? [] : [{
54
+ at,
55
+ slot: s.slot
56
+ }]).toSorted((a, b) => a.slot - b.slot);
57
+ const colors = /* @__PURE__ */ new Map();
58
+ const used = /* @__PURE__ */ new Set();
59
+ const take = (at, color) => {
60
+ colors.set(at, color);
61
+ used.add(color);
62
+ };
63
+ const waiting = bySlot.filter(({ at, slot }) => {
64
+ if (used.has(slot % size)) return true;
65
+ take(at, slot % size);
66
+ return false;
67
+ });
68
+ for (const { at, slot } of waiting) take(at, Array.from({ length: size }, (_v, i) => i).find((i) => !used.has(i)) ?? slot % size);
69
+ return series.map((_s, at) => colors.get(at));
70
+ }
71
+ export { chartColors, seriesSlots };
@@ -1,37 +1,67 @@
1
1
  import { CellFormat } from "./messages.mjs";
2
- import { ResultColumn, TileAnswer } from "derive-dashboards/core";
3
- /** One point of a chart: its x label and a number per series key. */
2
+ import { SeriesSlots } from "./series-slots.mjs";
3
+ import { ResultColumn, TileAnswer, TimeBucket } from "derive-dashboards/core";
4
+ /** One point of a chart: its x label, its place (`#`, never an entry id) and a number per series key. */
4
5
  export type Point = {
5
6
  x: string;
6
7
  } & Record<string, number | string | null>;
8
+ /**
9
+ * A drawn series: its key in each point, its label and the column it reads. `axis` is the side
10
+ * of the chart its scale is read on: values in another unit than the first get the right axis.
11
+ * `slot` is its place in the palette, which follows the series and not its position: a value of
12
+ * a field keeps its slot whatever else is drawn (`seriesSlots`). Other has none: it is the grey.
13
+ */
7
14
  export type Series = {
8
15
  key: string;
9
16
  label: string;
10
17
  column: ResultColumn;
18
+ axis: "left" | "right";
19
+ slot?: number;
11
20
  };
12
21
  /** The series key a dimension's Other draws as. */
13
22
  export declare const OTHER_KEY = "other";
14
23
  /**
15
- * Chart data from an answer. The first non-value column is the x axis (the time bucket when
16
- * there is one). With a second key column, the first value is split into one series per
17
- * value of it, and Other in that column is one more series; otherwise every value column is
18
- * its own series. Other on the x axis is one more point; totals are not drawn.
24
+ * Chart data from an answer. Key columns (in any order) are the x axis (the first, a time bucket
25
+ * when there is one) and, after it, what splits the series; value columns are what is drawn.
26
+ * With split keys, the first value (the first calc, when there are calcs) becomes one series per
27
+ * combination of the keys ("Design · High"), Other one more. Without, every value is a series.
28
+ * Values in a second unit are read on a right axis; a third unit, or more values than a split can
29
+ * draw, are not drawn and are named in `notDrawn`, never silently dropped. Points and series are
30
+ * keyed by raw values, so two that read alike stay apart. Totals are not drawn.
31
+ *
32
+ * `slots` is the dashboard's book of palette places, so a value has one colour on every tile;
33
+ * left out, the chart keeps a book of its own.
19
34
  */
20
- export declare function toSeries(answer: Pick<TileAnswer, "columns" | "rows">, format?: CellFormat): Drawn;
35
+ export declare function toSeries(answer: Answer, format?: CellFormat, slots?: SeriesSlots): Drawn;
21
36
  /**
22
37
  * What a chart draws, and the way back from any chart kit's point to the answer's row:
23
38
  * `rowAt(point, seriesKey)` gives the row's index in `answer.rows` (for a drill), or undefined
24
- * for a point no row stands behind.
39
+ * for a point no row stands behind. `notDrawn` lists the values the chart leaves to the table.
25
40
  */
26
41
  export type Drawn = {
27
42
  points: Point[];
28
43
  series: Series[];
29
44
  split: boolean;
45
+ notDrawn: ResultColumn[];
46
+ /**
47
+ * When the x axis is time: each point's bucket as instants, in the points' order, with
48
+ * `partial` on one whose value is not whole (the week still running). What a chart draws
49
+ * time on; the points' `x` is only the bucket's name.
50
+ */
51
+ buckets?: readonly (TimeBucket | undefined)[];
30
52
  rowAt: (point: number | Point, seriesKey: string) => number | undefined;
31
53
  };
54
+ type Answer = Pick<TileAnswer, "columns" | "rows" | "time">;
32
55
  /**
33
56
  * The row of the answer behind a point of any chart kit's series, by the point's place (or the
34
57
  * point) and the series key; undefined for a point no row stands behind. Pass it to
35
58
  * `drill.open(row, series.column.id)` to open what is behind the point.
36
59
  */
37
- export declare const rowAt: (drawn: Drawn, point: number | Point, seriesKey: string) => number | undefined;
60
+ export declare const rowAt: (drawn: Drawn, point: number | Point, seriesKey: string) => number | undefined;
61
+ /**
62
+ * Whether the answer's last time bucket is still running: the range ends before the bucket
63
+ * does, as this week does on its Monday. Its value is not final, so a chart marks it rather
64
+ * than draw it as a fall. The server says so (`answer.time`), by the engine's own calendar.
65
+ */
66
+ export declare function lastBucketOpen(answer: Pick<TileAnswer, "columns" | "rows" | "time">): boolean;
67
+ export {};