@czi-sds/data-viz 1.0.1 → 2.0.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@czi-sds/data-viz`
2
2
 
3
- Data visualization components for the [Science Design System (SDS)](https://sds.czi.design/), primarily built on [Apache ECharts](https://echarts.apache.org/). Shares the same Material UI v9 peer dependencies as `@czi-sds/components`.
3
+ Data visualization components for the [Science Design System (SDS)](https://chanzuckerberg.github.io/sci-components/), primarily built on [Apache ECharts](https://echarts.apache.org/). Shares the same Material UI v9 peer dependencies as `@czi-sds/components`.
4
4
 
5
5
  Full documentation (usage, scripts, contributing) lives in the [repository README](https://github.com/chanzuckerberg/sci-components#readme).
6
6
 
@@ -36,7 +36,7 @@ The `@czi-sds/data-viz` release that ships with SDS `24.0.0` also requires Mater
36
36
 
37
37
  ## Links
38
38
 
39
- - [Design docs (Zeroheight)](https://sds.czi.design/)
39
+ - [Design system documentation](https://chanzuckerberg.github.io/sci-components/)
40
40
  - [Full repo docs](https://github.com/chanzuckerberg/sci-components#readme)
41
41
  - [npm package](https://www.npmjs.com/package/@czi-sds/data-viz)
42
42
  - [ECharts documentation](https://echarts.apache.org/en/index.html)
@@ -6,12 +6,13 @@ import { DiscreteColorGeneratorOptions, TooltipTableContentProps } from "@czi-sd
6
6
  //#region src/core/HeatmapChart/hooks/utils.d.ts
7
7
  interface CreateChartOptionsProps {
8
8
  /**
9
- * Display reference line and axis value under mouse pointer
9
+ * The crosshair following the pointer. One object applies to both axes; a
10
+ * two-entry array configures them separately.
10
11
  * https://echarts.apache.org/en/option.html#axisPointer
11
12
  */
12
13
  axisPointer?: EChartsOption["axisPointer"];
13
14
  /**
14
- * The data array to be visualized
15
+ * The cells, as a flat array of objects whose fields are named by `encode`.
15
16
  * The data point object shape can be whatever you like, but it must be consistent with the `encode` option
16
17
  * For example, if the data point shape is:
17
18
  * {
@@ -27,6 +28,10 @@ interface CreateChartOptionsProps {
27
28
  */
28
29
  data: DatasetComponentOption["source"];
29
30
  /**
31
+ * ECharts' dataZoom configuration for that window, merged over the defaults
32
+ * it sets. One object applies to both axes; a two-entry array configures them
33
+ * separately. It reaches the chart only while `camera.active` is true.
34
+ *
30
35
  * The `dataZoom` prop is utilized for implementing zoom functionality within a
31
36
  * specific area of the chart. This feature empowers users to inspect data in
32
37
  * granular detail, obtain an overview of the entire dataset, or eliminate
@@ -42,6 +47,9 @@ interface CreateChartOptionsProps {
42
47
  */
43
48
  dataZoom?: EChartsOption["dataZoom"];
44
49
  /**
50
+ * Renders only a window of the grid, measured in cells, and lets the pointer
51
+ * pan it. Sizes are ignored unless `active` is true.
52
+ *
45
53
  * The `camera` prop is utilized for implementing camera view port functionality
46
54
  * within a specific area of the chart. This feature empowers users to render
47
55
  * a confined portion of the heatmap. This selective rendering strategy becomes
@@ -60,32 +68,36 @@ interface CreateChartOptionsProps {
60
68
  width: number;
61
69
  };
62
70
  /**
63
- * Customize the style of each cell item when mouse hovers on it, such as color, border, opacity, etc.
71
+ * How a cell is drawn while the pointer is over it. Takes the same shape as
72
+ * `itemStyle`: color, border, opacity.
64
73
  * https://echarts.apache.org/en/option.html#series-scatter.emphasis
65
74
  */
66
75
  emphasis?: ScatterSeriesOption["emphasis"];
67
76
  /**
68
- * The data for the x axis
77
+ * The categories along the x axis. A cell's encoded x value is an index into
78
+ * this array.
69
79
  * For example:
70
80
  * [{ value: "gene1", textStyle: { color: "red" } }, "gene2", "gene3"]
71
81
  */
72
82
  xAxisData: CategoryAxisData;
73
83
  /**
74
- * The data for the y axis
84
+ * The categories along the y axis.
75
85
  * For example:
76
86
  * [{ value: "cellType1", textStyle: { color: "red" } }, "cellType2", "cellType3"]
77
87
  */
78
88
  yAxisData: CategoryAxisData;
79
89
  /**
80
- * The width of the chart in pixels
90
+ * Width of the chart in pixels. Must be greater than zero; the component
91
+ * throws otherwise.
81
92
  */
82
93
  width: number;
83
94
  /**
84
- * The height of the chart in pixels
95
+ * Height of the chart in pixels, under the same rule.
85
96
  */
86
97
  height: number;
87
98
  /**
88
- * Provide a mapping of data key to x/y axis encoding
99
+ * Which fields of a data item place it on each axis. Omitting it leaves
100
+ * ECharts to guess from the field order.
89
101
  * For example, if the data is:
90
102
  * {
91
103
  * geneIndex: 0,
@@ -104,15 +116,20 @@ interface CreateChartOptionsProps {
104
116
  y: string;
105
117
  };
106
118
  /**
107
- * Customize the style of each cell item, such as color, border, opacity, etc.
119
+ * How a cell is painted. Its color accepts a callback receiving the data
120
+ * item, which is how a value becomes a color.
108
121
  * https://echarts.apache.org/en/option.html#series-scatter.itemStyle
109
122
  */
110
123
  itemStyle?: ScatterSeriesOption["itemStyle"];
111
124
  /**
112
- * The shape of the symbol.
125
+ * The shape of a cell. Circles turn the grid into a dot plot, where diameter
126
+ * can carry a second measurement.
113
127
  */
114
128
  symbol?: "circle" | "rect" | "roundRect";
115
129
  /**
130
+ * Cell size in pixels: one number, a [width, height] pair, or a callback
131
+ * given the data item. Set it to the cell pitch for a solid grid.
132
+ *
116
133
  * `symbolSize` can be set to single numbers like 10, or use an array to represent width and height. For example, [20, 10] means symbol width is 20, and height is 10.
117
134
  *
118
135
  * If size of symbols needs to be different, you can set with callback function in the following format:
@@ -124,16 +141,20 @@ interface CreateChartOptionsProps {
124
141
  */
125
142
  symbolSize?: ScatterSeriesOption["symbolSize"];
126
143
  /**
144
+ * Where the plotting area sits inside the container. The function form
145
+ * receives the computed default, for insetting it without recomputing the
146
+ * size.
127
147
  * https://echarts.apache.org/en/option.html#grid
128
148
  */
129
149
  grid?: EChartsOption["grid"] | ((defaultOption: EChartsOption["grid"]) => EChartsOption["grid"]);
130
150
  /**
131
- * The options object to be passed to echarts.setOption()
151
+ * Anything else ECharts understands, merged over the generated options.
132
152
  * https://echarts.apache.org/en/option.html
133
153
  */
134
154
  options?: EChartsOption;
135
155
  /**
136
- * Event listeners for the chart
156
+ * ECharts event listeners by name. Each handler gets the raw event, whose
157
+ * data property is the cell, and the chart instance.
137
158
  * https://echarts.apache.org/en/api.html#events
138
159
  */
139
160
  onEvents?: Record<string, (event: unknown, chart: ECharts) => void>;
@@ -152,6 +173,11 @@ type CategoryAxisData = (OrdinalRawValue | {
152
173
  //#endregion
153
174
  //#region src/core/HeatmapChart/index.d.ts
154
175
  interface HeatmapChartProps extends HTMLAttributes<HTMLDivElement>, CreateChartOptionsProps {
176
+ /**
177
+ * Which renderer ECharts initialises with. Canvas copes better with very
178
+ * large grids. Changing it rebuilds the chart.
179
+ * @default "svg"
180
+ */
155
181
  echartsRendererMode?: "svg" | "canvas";
156
182
  }
157
183
  declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<HeatmapChartProps & import("react").RefAttributes<HTMLDivElement>>>;
@@ -159,152 +185,157 @@ declare const _default: import("react").MemoExoticComponent<import("react").Forw
159
185
  //#region src/core/StackedBarChart/StackedBarChart.types.d.ts
160
186
  interface StackedBarChartDataItem {
161
187
  /**
162
- * Display name for the segment
188
+ * The segment's label in the legend, and the key the animations track it by.
189
+ * Must be unique within the chart.
163
190
  */
164
191
  name: string;
165
192
  /**
166
- * Numeric value for the segment
193
+ * The quantity the segment stands for.
167
194
  */
168
195
  value: number;
169
196
  /**
170
- * Color for the segment (hex or CSS color)
171
- * If not provided, colors will be automatically generated using cubehelix palette
197
+ * Any CSS color. Without it the segment takes a generated palette color,
198
+ * which can shift as categories come and go.
172
199
  */
173
200
  color?: string;
174
201
  /**
175
- * Unit label to display with the value in cumulative mode (e.g., "GB", "datasets", "MB")
176
- * Only shown in legend when mode is "cumulative"
202
+ * A unit for this item's counted value, for data that mixes units across
203
+ * categories.
177
204
  */
178
205
  unit?: string;
179
206
  /**
180
- * Disable the item (prevents all events on the corresponding legend item and bar segment)
207
+ * Takes the segment and its legend item out of every interaction: no hover,
208
+ * no tooltip, no selection.
181
209
  * @default false
182
210
  */
183
211
  disabled?: boolean;
184
212
  /**
185
- * Optional tooltip to display when hovering over the segment
213
+ * Content for a TooltipTable shown above the segment on hover. Use it for the
214
+ * breakdown behind the number; a segment without it has no tooltip.
186
215
  */
187
216
  tooltip?: TooltipTableContentProps;
188
217
  }
189
218
  interface StackedBarChartProps extends HTMLAttributes<HTMLDivElement> {
190
219
  /**
191
- * Title to display above the chart
220
+ * A heading above the bar. It is also what makes room for the badge; with no
221
+ * title, no badge is drawn.
192
222
  */
193
223
  title?: string;
194
224
  /**
195
- * Badge text to display next to the title
196
- * If not provided, defaults to showing item count based on selection:
197
- * - No selection: total count (e.g., "5")
198
- * - Partial selection: selected count (e.g., "3 of 5")
199
- * - All selected: "All"
225
+ * Overrides the badge text, which otherwise counts the data and the selection
226
+ * ("7", or "3 of 7").
200
227
  */
201
228
  badge?: string;
202
229
  /**
203
- * Hide the badge when true
230
+ * Removes the badge, leaving the title on its own.
204
231
  * @default false
205
232
  */
206
233
  hideBadge?: boolean;
207
234
  /**
208
- * Array of data items to display in the stacked bar
235
+ * The segments, in the order they are drawn.
209
236
  */
210
237
  data: StackedBarChartDataItem[];
211
238
  /**
212
- * Width of the chart - accepts any CSS width value (e.g., "100%", "20vw", "300px", or number for pixels)
239
+ * Any CSS width; a number is read as pixels. It sets the width of the whole
240
+ * chart, legend included.
213
241
  * @default 100%
214
242
  */
215
243
  width?: number | string;
216
244
  /**
217
- * Height of the bar in pixels (minimum 1px)
245
+ * Height of the bar in pixels. Values below 1 are clamped to 1, so the bar
246
+ * cannot disappear.
218
247
  * @default 16
219
248
  */
220
249
  barHeight?: number;
221
250
  /**
222
- * Whether to show the legend below the chart
251
+ * Draws the legend below the bar. It is the only place segment names appear,
252
+ * and the only part of the chart a keyboard can reach.
223
253
  * @default true
224
254
  */
225
255
  showLegend?: boolean;
226
256
  /**
227
- * Whether to show percentage values in the legend
257
+ * Shows each item's value beside its name in the legend.
228
258
  * @default true
229
259
  */
230
260
  showLegendValues?: boolean;
231
261
  /**
232
- * Format for legend values
233
- * - "percentage": Shows percentage of the item in the bar chart (e.g., "20%")
234
- * - "count": Shows the count from the data object with the unit defined by the unit prop
262
+ * "percentage" shows the segment's share of the bar, rounded. "count" shows
263
+ * the raw value followed by the item's unit, or the chart's unit if the item
264
+ * has none.
235
265
  * @default "percentage"
236
266
  */
237
267
  legendValueFormat?: "percentage" | "count";
238
268
  /**
239
- * Array of selected item indices (controlled component)
269
+ * Indices into data that are currently selected. The chart is controlled: it
270
+ * draws this and never changes it.
240
271
  */
241
272
  selectedIndices?: number[];
242
273
  /**
243
- * Callback when legend selection changes
274
+ * Called with the next selection when a segment or legend item is clicked.
275
+ * Without it, clicking selects nothing.
244
276
  */
245
277
  onSelectionChange?: (selectedIndices: number[], selectedData: StackedBarChartDataItem[]) => void;
246
278
  /**
247
- * Callback when mouse enters a bar segment
279
+ * Called when the pointer enters a segment. The chart already syncs its own
280
+ * hover highlight between bar and legend, so this is for driving something
281
+ * outside it.
248
282
  */
249
283
  onSegmentMouseEnter?: (item: StackedBarChartDataItem, index: number) => void;
250
284
  /**
251
- * Callback when mouse leaves a bar segment
285
+ * Called when the pointer leaves a segment.
252
286
  */
253
287
  onSegmentMouseLeave?: (item: StackedBarChartDataItem, index: number) => void;
254
288
  /**
255
- * Callback when mouse enters a legend item
289
+ * Called when the pointer enters a legend item.
256
290
  */
257
291
  onLegendItemMouseEnter?: (item: StackedBarChartDataItem, index: number) => void;
258
292
  /**
259
- * Callback when mouse leaves a legend item
293
+ * Called when the pointer leaves a legend item.
260
294
  */
261
295
  onLegendItemMouseLeave?: (item: StackedBarChartDataItem, index: number) => void;
262
296
  /**
263
- * Callback when a bar segment is clicked
297
+ * Fires on a segment click, alongside any selection change rather than
298
+ * instead of it.
264
299
  */
265
300
  onSegmentClick?: (item: StackedBarChartDataItem, index: number) => void;
266
301
  /**
267
- * Callback when a legend item is clicked
302
+ * The same, for a click on a legend item.
268
303
  */
269
304
  onLegendItemClick?: (item: StackedBarChartDataItem, index: number) => void;
270
305
  /**
271
- * Behavior to apply when items are selected
272
- * - "dim": Non-selected segments become semi-transparent (20% opacity)
273
- * - "hide": Non-selected segments are hidden from the bar chart
306
+ * What a selection does to the unselected segments: fade them to 20% opacity,
307
+ * or drop them from the bar and let the rest take the space.
274
308
  * @default "dim"
275
309
  */
276
310
  selectionBehavior?: "dim" | "hide";
277
311
  /**
278
- * Chart mode - controls how segments are calculated
279
- * - "proportional": Segments fill entire bar (100%), proportional to their values
280
- * - "cumulative": Segments sized based on actual values relative to maxAmount
312
+ * Whether the bar shows a breakdown of the data (segments always fill it) or
313
+ * progress towards maxAmount.
281
314
  * @default "proportional"
282
315
  */
283
316
  mode?: "proportional" | "cumulative";
284
317
  /**
285
- * Maximum amount for the bar (used only in "cumulative" mode)
286
- * If not provided, defaults to sum of all values (no remaining segment)
287
- * If provided and sum < maxAmount, shows gray "remaining" segment
318
+ * Cumulative mode only. The value the full bar represents. Any difference
319
+ * between it and the sum of the data is drawn as the Remaining segment.
288
320
  */
289
321
  maxAmount?: number;
290
322
  /**
291
- * Label for the remaining/unknown segment in cumulative mode
323
+ * Name of the grey gap segment in cumulative mode.
292
324
  * @default "Remaining"
293
325
  */
294
326
  remainingLabel?: string;
295
327
  /**
296
- * Unit to display with the remaining segment value in cumulative mode
297
- * If not provided, uses the unit from the first data item (if available)
328
+ * A unit for the Remaining segment's value alone.
298
329
  */
299
330
  remainingUnit?: string;
300
331
  /**
301
- * Global unit to display with values in cumulative mode (e.g., "GB", "datasets", "K")
302
- * Individual data items can override this with their own unit property
303
- * Only shown when mode is "cumulative"
332
+ * The unit appended to counted values, for items that do not carry one of
333
+ * their own.
304
334
  */
305
335
  unit?: string;
306
336
  /**
307
- * Options for the color generator
337
+ * Tunes the generated palette (start hue, rotations, lightness range, gamma).
338
+ * Items with their own color are untouched by it.
308
339
  */
309
340
  colorGeneratorOptions?: DiscreteColorGeneratorOptions;
310
341
  }
package/dist/index.cjs.js CHANGED
@@ -245,7 +245,7 @@ function generateDefaultValues(props) {
245
245
  //#endregion
246
246
  //#region src/core/HeatmapChart/hooks/useUpdateChart.ts
247
247
  const UPDATE_THROTTLE_MS = 100;
248
- function useUpdateChart({ axisPointer, camera, chart, data, emphasis, xAxisData, yAxisData, width, height, encode, itemStyle, symbol, symbolSize, grid, options, onEvents }) {
248
+ function useUpdateChart({ axisPointer, camera, chart, data, dataZoom, emphasis, xAxisData, yAxisData, width, height, encode, itemStyle, symbol, symbolSize, grid, options, onEvents }) {
249
249
  const throttledUpdateChart = (0, react.useMemo)(() => {
250
250
  return (0, lodash.throttle)(() => {
251
251
  if (!chart || !data || !xAxisData || !yAxisData) return;
@@ -254,6 +254,7 @@ function useUpdateChart({ axisPointer, camera, chart, data, emphasis, xAxisData,
254
254
  axisPointer,
255
255
  camera,
256
256
  data,
257
+ dataZoom,
257
258
  emphasis,
258
259
  encode,
259
260
  grid,
@@ -285,6 +286,7 @@ function useUpdateChart({ axisPointer, camera, chart, data, emphasis, xAxisData,
285
286
  camera,
286
287
  chart,
287
288
  data,
289
+ dataZoom,
288
290
  emphasis,
289
291
  xAxisData,
290
292
  yAxisData,
@@ -308,6 +310,7 @@ function useUpdateChart({ axisPointer, camera, chart, data, emphasis, xAxisData,
308
310
  camera,
309
311
  chart,
310
312
  data,
313
+ dataZoom,
311
314
  emphasis,
312
315
  xAxisData,
313
316
  yAxisData,
@@ -342,6 +345,7 @@ const _excluded$1 = [
342
345
  "height",
343
346
  "echartsRendererMode",
344
347
  "camera",
348
+ "dataZoom",
345
349
  "onEvents",
346
350
  "xAxisData",
347
351
  "yAxisData",
@@ -355,7 +359,7 @@ const _excluded$1 = [
355
359
  "options"
356
360
  ];
357
361
  const HeatmapChart = (0, react.forwardRef)((props, ref) => {
358
- const { axisPointer, width, height, echartsRendererMode = "svg", camera, onEvents, xAxisData, yAxisData, data, encode, emphasis, itemStyle, symbol, symbolSize = 5, grid, options } = props, rest = _objectWithoutProperties(props, _excluded$1);
362
+ const { axisPointer, width, height, echartsRendererMode = "svg", camera, dataZoom, onEvents, xAxisData, yAxisData, data, encode, emphasis, itemStyle, symbol, symbolSize = 5, grid, options } = props, rest = _objectWithoutProperties(props, _excluded$1);
359
363
  if (!width || !height) throw Error("Heatmap must have width and height bigger than Zero!");
360
364
  const innerRef = (0, react.useRef)(null);
361
365
  /**
@@ -408,6 +412,7 @@ const HeatmapChart = (0, react.forwardRef)((props, ref) => {
408
412
  camera,
409
413
  chart,
410
414
  data,
415
+ dataZoom,
411
416
  emphasis,
412
417
  encode,
413
418
  grid,
@@ -660,7 +665,6 @@ const renderBarSegment = (item, options) => {
660
665
  title: null,
661
666
  componentSlot: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_czi_sds_components.TooltipTable, _objectSpread2({}, item.tooltip)),
662
667
  placement: "top",
663
- hasInvertedStyle: false,
664
668
  open: hoveredIndex === item.originalIndex && !isHidden,
665
669
  disableInteractive: true,
666
670
  slotProps: { popper: {
@@ -6,12 +6,13 @@ import { DiscreteColorGeneratorOptions, TooltipTableContentProps } from "@czi-sd
6
6
  //#region src/core/HeatmapChart/hooks/utils.d.ts
7
7
  interface CreateChartOptionsProps {
8
8
  /**
9
- * Display reference line and axis value under mouse pointer
9
+ * The crosshair following the pointer. One object applies to both axes; a
10
+ * two-entry array configures them separately.
10
11
  * https://echarts.apache.org/en/option.html#axisPointer
11
12
  */
12
13
  axisPointer?: EChartsOption["axisPointer"];
13
14
  /**
14
- * The data array to be visualized
15
+ * The cells, as a flat array of objects whose fields are named by `encode`.
15
16
  * The data point object shape can be whatever you like, but it must be consistent with the `encode` option
16
17
  * For example, if the data point shape is:
17
18
  * {
@@ -27,6 +28,10 @@ interface CreateChartOptionsProps {
27
28
  */
28
29
  data: DatasetComponentOption["source"];
29
30
  /**
31
+ * ECharts' dataZoom configuration for that window, merged over the defaults
32
+ * it sets. One object applies to both axes; a two-entry array configures them
33
+ * separately. It reaches the chart only while `camera.active` is true.
34
+ *
30
35
  * The `dataZoom` prop is utilized for implementing zoom functionality within a
31
36
  * specific area of the chart. This feature empowers users to inspect data in
32
37
  * granular detail, obtain an overview of the entire dataset, or eliminate
@@ -42,6 +47,9 @@ interface CreateChartOptionsProps {
42
47
  */
43
48
  dataZoom?: EChartsOption["dataZoom"];
44
49
  /**
50
+ * Renders only a window of the grid, measured in cells, and lets the pointer
51
+ * pan it. Sizes are ignored unless `active` is true.
52
+ *
45
53
  * The `camera` prop is utilized for implementing camera view port functionality
46
54
  * within a specific area of the chart. This feature empowers users to render
47
55
  * a confined portion of the heatmap. This selective rendering strategy becomes
@@ -60,32 +68,36 @@ interface CreateChartOptionsProps {
60
68
  width: number;
61
69
  };
62
70
  /**
63
- * Customize the style of each cell item when mouse hovers on it, such as color, border, opacity, etc.
71
+ * How a cell is drawn while the pointer is over it. Takes the same shape as
72
+ * `itemStyle`: color, border, opacity.
64
73
  * https://echarts.apache.org/en/option.html#series-scatter.emphasis
65
74
  */
66
75
  emphasis?: ScatterSeriesOption["emphasis"];
67
76
  /**
68
- * The data for the x axis
77
+ * The categories along the x axis. A cell's encoded x value is an index into
78
+ * this array.
69
79
  * For example:
70
80
  * [{ value: "gene1", textStyle: { color: "red" } }, "gene2", "gene3"]
71
81
  */
72
82
  xAxisData: CategoryAxisData;
73
83
  /**
74
- * The data for the y axis
84
+ * The categories along the y axis.
75
85
  * For example:
76
86
  * [{ value: "cellType1", textStyle: { color: "red" } }, "cellType2", "cellType3"]
77
87
  */
78
88
  yAxisData: CategoryAxisData;
79
89
  /**
80
- * The width of the chart in pixels
90
+ * Width of the chart in pixels. Must be greater than zero; the component
91
+ * throws otherwise.
81
92
  */
82
93
  width: number;
83
94
  /**
84
- * The height of the chart in pixels
95
+ * Height of the chart in pixels, under the same rule.
85
96
  */
86
97
  height: number;
87
98
  /**
88
- * Provide a mapping of data key to x/y axis encoding
99
+ * Which fields of a data item place it on each axis. Omitting it leaves
100
+ * ECharts to guess from the field order.
89
101
  * For example, if the data is:
90
102
  * {
91
103
  * geneIndex: 0,
@@ -104,15 +116,20 @@ interface CreateChartOptionsProps {
104
116
  y: string;
105
117
  };
106
118
  /**
107
- * Customize the style of each cell item, such as color, border, opacity, etc.
119
+ * How a cell is painted. Its color accepts a callback receiving the data
120
+ * item, which is how a value becomes a color.
108
121
  * https://echarts.apache.org/en/option.html#series-scatter.itemStyle
109
122
  */
110
123
  itemStyle?: ScatterSeriesOption["itemStyle"];
111
124
  /**
112
- * The shape of the symbol.
125
+ * The shape of a cell. Circles turn the grid into a dot plot, where diameter
126
+ * can carry a second measurement.
113
127
  */
114
128
  symbol?: "circle" | "rect" | "roundRect";
115
129
  /**
130
+ * Cell size in pixels: one number, a [width, height] pair, or a callback
131
+ * given the data item. Set it to the cell pitch for a solid grid.
132
+ *
116
133
  * `symbolSize` can be set to single numbers like 10, or use an array to represent width and height. For example, [20, 10] means symbol width is 20, and height is 10.
117
134
  *
118
135
  * If size of symbols needs to be different, you can set with callback function in the following format:
@@ -124,16 +141,20 @@ interface CreateChartOptionsProps {
124
141
  */
125
142
  symbolSize?: ScatterSeriesOption["symbolSize"];
126
143
  /**
144
+ * Where the plotting area sits inside the container. The function form
145
+ * receives the computed default, for insetting it without recomputing the
146
+ * size.
127
147
  * https://echarts.apache.org/en/option.html#grid
128
148
  */
129
149
  grid?: EChartsOption["grid"] | ((defaultOption: EChartsOption["grid"]) => EChartsOption["grid"]);
130
150
  /**
131
- * The options object to be passed to echarts.setOption()
151
+ * Anything else ECharts understands, merged over the generated options.
132
152
  * https://echarts.apache.org/en/option.html
133
153
  */
134
154
  options?: EChartsOption;
135
155
  /**
136
- * Event listeners for the chart
156
+ * ECharts event listeners by name. Each handler gets the raw event, whose
157
+ * data property is the cell, and the chart instance.
137
158
  * https://echarts.apache.org/en/api.html#events
138
159
  */
139
160
  onEvents?: Record<string, (event: unknown, chart: ECharts) => void>;
@@ -152,6 +173,11 @@ type CategoryAxisData = (OrdinalRawValue | {
152
173
  //#endregion
153
174
  //#region src/core/HeatmapChart/index.d.ts
154
175
  interface HeatmapChartProps extends HTMLAttributes<HTMLDivElement>, CreateChartOptionsProps {
176
+ /**
177
+ * Which renderer ECharts initialises with. Canvas copes better with very
178
+ * large grids. Changing it rebuilds the chart.
179
+ * @default "svg"
180
+ */
155
181
  echartsRendererMode?: "svg" | "canvas";
156
182
  }
157
183
  declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<HeatmapChartProps & import("react").RefAttributes<HTMLDivElement>>>;
@@ -159,152 +185,157 @@ declare const _default: import("react").MemoExoticComponent<import("react").Forw
159
185
  //#region src/core/StackedBarChart/StackedBarChart.types.d.ts
160
186
  interface StackedBarChartDataItem {
161
187
  /**
162
- * Display name for the segment
188
+ * The segment's label in the legend, and the key the animations track it by.
189
+ * Must be unique within the chart.
163
190
  */
164
191
  name: string;
165
192
  /**
166
- * Numeric value for the segment
193
+ * The quantity the segment stands for.
167
194
  */
168
195
  value: number;
169
196
  /**
170
- * Color for the segment (hex or CSS color)
171
- * If not provided, colors will be automatically generated using cubehelix palette
197
+ * Any CSS color. Without it the segment takes a generated palette color,
198
+ * which can shift as categories come and go.
172
199
  */
173
200
  color?: string;
174
201
  /**
175
- * Unit label to display with the value in cumulative mode (e.g., "GB", "datasets", "MB")
176
- * Only shown in legend when mode is "cumulative"
202
+ * A unit for this item's counted value, for data that mixes units across
203
+ * categories.
177
204
  */
178
205
  unit?: string;
179
206
  /**
180
- * Disable the item (prevents all events on the corresponding legend item and bar segment)
207
+ * Takes the segment and its legend item out of every interaction: no hover,
208
+ * no tooltip, no selection.
181
209
  * @default false
182
210
  */
183
211
  disabled?: boolean;
184
212
  /**
185
- * Optional tooltip to display when hovering over the segment
213
+ * Content for a TooltipTable shown above the segment on hover. Use it for the
214
+ * breakdown behind the number; a segment without it has no tooltip.
186
215
  */
187
216
  tooltip?: TooltipTableContentProps;
188
217
  }
189
218
  interface StackedBarChartProps extends HTMLAttributes<HTMLDivElement> {
190
219
  /**
191
- * Title to display above the chart
220
+ * A heading above the bar. It is also what makes room for the badge; with no
221
+ * title, no badge is drawn.
192
222
  */
193
223
  title?: string;
194
224
  /**
195
- * Badge text to display next to the title
196
- * If not provided, defaults to showing item count based on selection:
197
- * - No selection: total count (e.g., "5")
198
- * - Partial selection: selected count (e.g., "3 of 5")
199
- * - All selected: "All"
225
+ * Overrides the badge text, which otherwise counts the data and the selection
226
+ * ("7", or "3 of 7").
200
227
  */
201
228
  badge?: string;
202
229
  /**
203
- * Hide the badge when true
230
+ * Removes the badge, leaving the title on its own.
204
231
  * @default false
205
232
  */
206
233
  hideBadge?: boolean;
207
234
  /**
208
- * Array of data items to display in the stacked bar
235
+ * The segments, in the order they are drawn.
209
236
  */
210
237
  data: StackedBarChartDataItem[];
211
238
  /**
212
- * Width of the chart - accepts any CSS width value (e.g., "100%", "20vw", "300px", or number for pixels)
239
+ * Any CSS width; a number is read as pixels. It sets the width of the whole
240
+ * chart, legend included.
213
241
  * @default 100%
214
242
  */
215
243
  width?: number | string;
216
244
  /**
217
- * Height of the bar in pixels (minimum 1px)
245
+ * Height of the bar in pixels. Values below 1 are clamped to 1, so the bar
246
+ * cannot disappear.
218
247
  * @default 16
219
248
  */
220
249
  barHeight?: number;
221
250
  /**
222
- * Whether to show the legend below the chart
251
+ * Draws the legend below the bar. It is the only place segment names appear,
252
+ * and the only part of the chart a keyboard can reach.
223
253
  * @default true
224
254
  */
225
255
  showLegend?: boolean;
226
256
  /**
227
- * Whether to show percentage values in the legend
257
+ * Shows each item's value beside its name in the legend.
228
258
  * @default true
229
259
  */
230
260
  showLegendValues?: boolean;
231
261
  /**
232
- * Format for legend values
233
- * - "percentage": Shows percentage of the item in the bar chart (e.g., "20%")
234
- * - "count": Shows the count from the data object with the unit defined by the unit prop
262
+ * "percentage" shows the segment's share of the bar, rounded. "count" shows
263
+ * the raw value followed by the item's unit, or the chart's unit if the item
264
+ * has none.
235
265
  * @default "percentage"
236
266
  */
237
267
  legendValueFormat?: "percentage" | "count";
238
268
  /**
239
- * Array of selected item indices (controlled component)
269
+ * Indices into data that are currently selected. The chart is controlled: it
270
+ * draws this and never changes it.
240
271
  */
241
272
  selectedIndices?: number[];
242
273
  /**
243
- * Callback when legend selection changes
274
+ * Called with the next selection when a segment or legend item is clicked.
275
+ * Without it, clicking selects nothing.
244
276
  */
245
277
  onSelectionChange?: (selectedIndices: number[], selectedData: StackedBarChartDataItem[]) => void;
246
278
  /**
247
- * Callback when mouse enters a bar segment
279
+ * Called when the pointer enters a segment. The chart already syncs its own
280
+ * hover highlight between bar and legend, so this is for driving something
281
+ * outside it.
248
282
  */
249
283
  onSegmentMouseEnter?: (item: StackedBarChartDataItem, index: number) => void;
250
284
  /**
251
- * Callback when mouse leaves a bar segment
285
+ * Called when the pointer leaves a segment.
252
286
  */
253
287
  onSegmentMouseLeave?: (item: StackedBarChartDataItem, index: number) => void;
254
288
  /**
255
- * Callback when mouse enters a legend item
289
+ * Called when the pointer enters a legend item.
256
290
  */
257
291
  onLegendItemMouseEnter?: (item: StackedBarChartDataItem, index: number) => void;
258
292
  /**
259
- * Callback when mouse leaves a legend item
293
+ * Called when the pointer leaves a legend item.
260
294
  */
261
295
  onLegendItemMouseLeave?: (item: StackedBarChartDataItem, index: number) => void;
262
296
  /**
263
- * Callback when a bar segment is clicked
297
+ * Fires on a segment click, alongside any selection change rather than
298
+ * instead of it.
264
299
  */
265
300
  onSegmentClick?: (item: StackedBarChartDataItem, index: number) => void;
266
301
  /**
267
- * Callback when a legend item is clicked
302
+ * The same, for a click on a legend item.
268
303
  */
269
304
  onLegendItemClick?: (item: StackedBarChartDataItem, index: number) => void;
270
305
  /**
271
- * Behavior to apply when items are selected
272
- * - "dim": Non-selected segments become semi-transparent (20% opacity)
273
- * - "hide": Non-selected segments are hidden from the bar chart
306
+ * What a selection does to the unselected segments: fade them to 20% opacity,
307
+ * or drop them from the bar and let the rest take the space.
274
308
  * @default "dim"
275
309
  */
276
310
  selectionBehavior?: "dim" | "hide";
277
311
  /**
278
- * Chart mode - controls how segments are calculated
279
- * - "proportional": Segments fill entire bar (100%), proportional to their values
280
- * - "cumulative": Segments sized based on actual values relative to maxAmount
312
+ * Whether the bar shows a breakdown of the data (segments always fill it) or
313
+ * progress towards maxAmount.
281
314
  * @default "proportional"
282
315
  */
283
316
  mode?: "proportional" | "cumulative";
284
317
  /**
285
- * Maximum amount for the bar (used only in "cumulative" mode)
286
- * If not provided, defaults to sum of all values (no remaining segment)
287
- * If provided and sum < maxAmount, shows gray "remaining" segment
318
+ * Cumulative mode only. The value the full bar represents. Any difference
319
+ * between it and the sum of the data is drawn as the Remaining segment.
288
320
  */
289
321
  maxAmount?: number;
290
322
  /**
291
- * Label for the remaining/unknown segment in cumulative mode
323
+ * Name of the grey gap segment in cumulative mode.
292
324
  * @default "Remaining"
293
325
  */
294
326
  remainingLabel?: string;
295
327
  /**
296
- * Unit to display with the remaining segment value in cumulative mode
297
- * If not provided, uses the unit from the first data item (if available)
328
+ * A unit for the Remaining segment's value alone.
298
329
  */
299
330
  remainingUnit?: string;
300
331
  /**
301
- * Global unit to display with values in cumulative mode (e.g., "GB", "datasets", "K")
302
- * Individual data items can override this with their own unit property
303
- * Only shown when mode is "cumulative"
332
+ * The unit appended to counted values, for items that do not carry one of
333
+ * their own.
304
334
  */
305
335
  unit?: string;
306
336
  /**
307
- * Options for the color generator
337
+ * Tunes the generated palette (start hue, rotations, lightness range, gamma).
338
+ * Items with their own color are untouched by it.
308
339
  */
309
340
  colorGeneratorOptions?: DiscreteColorGeneratorOptions;
310
341
  }
package/dist/index.esm.js CHANGED
@@ -221,7 +221,7 @@ function generateDefaultValues(props) {
221
221
  //#endregion
222
222
  //#region src/core/HeatmapChart/hooks/useUpdateChart.ts
223
223
  const UPDATE_THROTTLE_MS = 100;
224
- function useUpdateChart({ axisPointer, camera, chart, data, emphasis, xAxisData, yAxisData, width, height, encode, itemStyle, symbol, symbolSize, grid, options, onEvents }) {
224
+ function useUpdateChart({ axisPointer, camera, chart, data, dataZoom, emphasis, xAxisData, yAxisData, width, height, encode, itemStyle, symbol, symbolSize, grid, options, onEvents }) {
225
225
  const throttledUpdateChart = useMemo(() => {
226
226
  return throttle(() => {
227
227
  if (!chart || !data || !xAxisData || !yAxisData) return;
@@ -230,6 +230,7 @@ function useUpdateChart({ axisPointer, camera, chart, data, emphasis, xAxisData,
230
230
  axisPointer,
231
231
  camera,
232
232
  data,
233
+ dataZoom,
233
234
  emphasis,
234
235
  encode,
235
236
  grid,
@@ -261,6 +262,7 @@ function useUpdateChart({ axisPointer, camera, chart, data, emphasis, xAxisData,
261
262
  camera,
262
263
  chart,
263
264
  data,
265
+ dataZoom,
264
266
  emphasis,
265
267
  xAxisData,
266
268
  yAxisData,
@@ -284,6 +286,7 @@ function useUpdateChart({ axisPointer, camera, chart, data, emphasis, xAxisData,
284
286
  camera,
285
287
  chart,
286
288
  data,
289
+ dataZoom,
287
290
  emphasis,
288
291
  xAxisData,
289
292
  yAxisData,
@@ -318,6 +321,7 @@ const _excluded$1 = [
318
321
  "height",
319
322
  "echartsRendererMode",
320
323
  "camera",
324
+ "dataZoom",
321
325
  "onEvents",
322
326
  "xAxisData",
323
327
  "yAxisData",
@@ -331,7 +335,7 @@ const _excluded$1 = [
331
335
  "options"
332
336
  ];
333
337
  var HeatmapChart_default = memo(forwardRef((props, ref) => {
334
- const { axisPointer, width, height, echartsRendererMode = "svg", camera, onEvents, xAxisData, yAxisData, data, encode, emphasis, itemStyle, symbol, symbolSize = 5, grid, options } = props, rest = _objectWithoutProperties(props, _excluded$1);
338
+ const { axisPointer, width, height, echartsRendererMode = "svg", camera, dataZoom, onEvents, xAxisData, yAxisData, data, encode, emphasis, itemStyle, symbol, symbolSize = 5, grid, options } = props, rest = _objectWithoutProperties(props, _excluded$1);
335
339
  if (!width || !height) throw Error("Heatmap must have width and height bigger than Zero!");
336
340
  const innerRef = useRef(null);
337
341
  /**
@@ -384,6 +388,7 @@ var HeatmapChart_default = memo(forwardRef((props, ref) => {
384
388
  camera,
385
389
  chart,
386
390
  data,
391
+ dataZoom,
387
392
  emphasis,
388
393
  encode,
389
394
  grid,
@@ -635,7 +640,6 @@ const renderBarSegment = (item, options) => {
635
640
  title: null,
636
641
  componentSlot: /* @__PURE__ */ jsx(TooltipTable, _objectSpread2({}, item.tooltip)),
637
642
  placement: "top",
638
- hasInvertedStyle: false,
639
643
  open: hoveredIndex === item.originalIndex && !isHidden,
640
644
  disableInteractive: true,
641
645
  slotProps: { popper: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@czi-sds/data-viz",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "main": "dist/index.cjs.js",
5
5
  "types": "dist/index.cjs.d.ts",
6
6
  "module": "dist/index.esm.js",
@@ -69,13 +69,12 @@
69
69
  "@types/react-dom": "^18.2.18",
70
70
  "d3-scale-chromatic": "^3.0.0",
71
71
  "react-redux": "^9.1.0",
72
- "simplex-noise": "^4.0.1",
73
- "style-dictionary": "^4.1.0"
72
+ "simplex-noise": "^4.0.1"
74
73
  },
75
74
  "dependencies": {
76
75
  "chroma-js": "^3.1.2",
77
76
  "echarts": "^6.0.0",
78
77
  "lodash": "^4.17.21"
79
78
  },
80
- "gitHead": "99222cf64e2dcf5d41d771396ffba16393663bfd"
79
+ "gitHead": "86ab08f76d3b95b09ac6709b17f6c6d65b10d9e5"
81
80
  }