@czi-sds/data-viz 2.3.0 → 2.4.1
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/dist/HeatmapChart.cjs.d.ts +2 -0
- package/dist/HeatmapChart.cjs.js +8 -0
- package/dist/HeatmapChart.esm.d.ts +2 -0
- package/dist/HeatmapChart.esm.js +3 -0
- package/dist/ProteinStructureViewer.cjs.d.ts +2 -0
- package/dist/ProteinStructureViewer.cjs.js +14 -0
- package/dist/ProteinStructureViewer.esm.d.ts +2 -0
- package/dist/ProteinStructureViewer.esm.js +3 -0
- package/dist/StackedBarChart.cjs.d.ts +2 -0
- package/dist/StackedBarChart.cjs.js +8 -0
- package/dist/StackedBarChart.esm.d.ts +2 -0
- package/dist/StackedBarChart.esm.js +3 -0
- package/dist/colorScales.cjs.d.ts +2 -0
- package/dist/colorScales.cjs.js +6 -0
- package/dist/colorScales.esm.d.ts +2 -0
- package/dist/colorScales.esm.js +3 -0
- package/dist/index.cjs.d.ts +4 -772
- package/dist/index.cjs.js +16 -5765
- package/dist/index.esm.d.ts +4 -774
- package/dist/index.esm.js +4 -5719
- package/dist/shared/HeatmapChart.cjs.js +349 -0
- package/dist/shared/HeatmapChart.esm.js +342 -0
- package/dist/shared/ProteinStructureViewer.cjs.js +4790 -0
- package/dist/shared/ProteinStructureViewer.esm.js +4738 -0
- package/dist/shared/StackedBarChart.cjs.js +489 -0
- package/dist/shared/StackedBarChart.esm.js +483 -0
- package/dist/shared/colorScales.cjs.d.ts +45 -0
- package/dist/shared/colorScales.cjs.js +126 -0
- package/dist/shared/colorScales.esm.d.ts +45 -0
- package/dist/shared/colorScales.esm.js +103 -0
- package/dist/shared/index.cjs.d.ts +183 -0
- package/dist/shared/index.esm.d.ts +183 -0
- package/dist/shared/index2.cjs.d.ts +389 -0
- package/dist/shared/index2.esm.d.ts +391 -0
- package/dist/shared/index3.cjs.d.ts +166 -0
- package/dist/shared/index3.esm.d.ts +166 -0
- package/dist/shared/objectSpread2.cjs.js +124 -0
- package/dist/shared/objectSpread2.esm.js +85 -0
- package/package.json +65 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/common/colorScales.d.ts
|
|
2
|
+
/** RGB triplet with each channel in the range 0-255. */
|
|
3
|
+
type Rgb = [number, number, number];
|
|
4
|
+
/** A stop on a continuous color scale, positioned at `t` in the range 0-1. */
|
|
5
|
+
interface ContinuousColorStop {
|
|
6
|
+
t: number;
|
|
7
|
+
color: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A band on a stepped color scale. `threshold` is the upper bound of the band
|
|
11
|
+
* on the normalized 0-1 value range; `label` is rendered above the band in the
|
|
12
|
+
* legend.
|
|
13
|
+
*/
|
|
14
|
+
interface SteppedColorStop {
|
|
15
|
+
threshold: number;
|
|
16
|
+
color: string;
|
|
17
|
+
label: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* How values map to colors, both in a visualization and in its legend. A
|
|
21
|
+
* continuous scale interpolates between its stops and renders as a gradient
|
|
22
|
+
* bar; a stepped scale renders as discrete bands.
|
|
23
|
+
*/
|
|
24
|
+
type ColorScale = {
|
|
25
|
+
kind: "continuous";
|
|
26
|
+
stops: ContinuousColorStop[];
|
|
27
|
+
} | {
|
|
28
|
+
kind: "stepped";
|
|
29
|
+
stops: SteppedColorStop[];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Perceptually uniform sequential scale (matplotlib's plasma), the default for
|
|
33
|
+
* value overlays.
|
|
34
|
+
*/
|
|
35
|
+
declare const PLASMA_COLOR_SCALE: ColorScale;
|
|
36
|
+
/**
|
|
37
|
+
* Colors a raw value against a scale, normalizing it into `min`-`max` first.
|
|
38
|
+
* Returns null when the value sits at or below `min`, or when the range is
|
|
39
|
+
* degenerate, so callers can fall back to a neutral color.
|
|
40
|
+
*/
|
|
41
|
+
declare function sampleColorScale(scale: ColorScale, value: number, max: number, min?: number): Rgb | null;
|
|
42
|
+
/** CSS `linear-gradient` spanning a continuous scale, for the legend bar. */
|
|
43
|
+
declare function toCssGradient(stops: ContinuousColorStop[]): string;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { sampleColorScale as a, SteppedColorStop as i, ContinuousColorStop as n, toCssGradient as o, PLASMA_COLOR_SCALE as r, ColorScale as t };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/common/colorScales.ts
|
|
3
|
+
/**
|
|
4
|
+
* Perceptually uniform sequential scale (matplotlib's plasma), the default for
|
|
5
|
+
* value overlays.
|
|
6
|
+
*/
|
|
7
|
+
const PLASMA_COLOR_SCALE = {
|
|
8
|
+
kind: "continuous",
|
|
9
|
+
stops: [
|
|
10
|
+
{
|
|
11
|
+
color: "#0D0887",
|
|
12
|
+
t: 0
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
color: "#7E03A8",
|
|
16
|
+
t: .25
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
color: "#CC4778",
|
|
20
|
+
t: .5
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
color: "#F89441",
|
|
24
|
+
t: .75
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
color: "#F0F921",
|
|
28
|
+
t: 1
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
/** Parses `#RRGGBB` (or `RRGGBB`) into an RGB triplet. */
|
|
33
|
+
function hexToRgb(hex) {
|
|
34
|
+
const h = hex.replace("#", "");
|
|
35
|
+
return [
|
|
36
|
+
parseInt(h.substring(0, 2), 16),
|
|
37
|
+
parseInt(h.substring(2, 4), 16),
|
|
38
|
+
parseInt(h.substring(4, 6), 16)
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
/** Linearly interpolates a continuous scale at `t`, clamped to 0-1. */
|
|
42
|
+
function sampleContinuousScale(stops, t) {
|
|
43
|
+
if (stops.length === 0) return [
|
|
44
|
+
0,
|
|
45
|
+
0,
|
|
46
|
+
0
|
|
47
|
+
];
|
|
48
|
+
const first = stops[0];
|
|
49
|
+
const last = stops[stops.length - 1];
|
|
50
|
+
const clamped = Math.min(1, Math.max(0, t));
|
|
51
|
+
let lo = first;
|
|
52
|
+
let hi = last;
|
|
53
|
+
for (let i = 0; i < stops.length - 1; i++) {
|
|
54
|
+
const current = stops[i];
|
|
55
|
+
const next = stops[i + 1];
|
|
56
|
+
if (clamped >= current.t && clamped <= next.t) {
|
|
57
|
+
lo = current;
|
|
58
|
+
hi = next;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const loRgb = hexToRgb(lo.color);
|
|
63
|
+
const hiRgb = hexToRgb(hi.color);
|
|
64
|
+
const f = hi.t === lo.t ? 0 : (clamped - lo.t) / (hi.t - lo.t);
|
|
65
|
+
return [
|
|
66
|
+
Math.round(loRgb[0] + f * (hiRgb[0] - loRgb[0])),
|
|
67
|
+
Math.round(loRgb[1] + f * (hiRgb[1] - loRgb[1])),
|
|
68
|
+
Math.round(loRgb[2] + f * (hiRgb[2] - loRgb[2]))
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Picks the band a normalized value falls into on a stepped scale.
|
|
73
|
+
*
|
|
74
|
+
* A value lands in the first band whose threshold it falls short of, which puts
|
|
75
|
+
* each threshold at the bottom of the band above it: against thresholds of 0.5,
|
|
76
|
+
* 0.7 and 0.9, a value of exactly 0.7 reads as the 0.7-0.9 band, not the one
|
|
77
|
+
* below.
|
|
78
|
+
*/
|
|
79
|
+
function sampleSteppedScale(stops, t) {
|
|
80
|
+
for (const stop of stops) if (t < stop.threshold) return hexToRgb(stop.color);
|
|
81
|
+
const last = stops[stops.length - 1];
|
|
82
|
+
return last ? hexToRgb(last.color) : [
|
|
83
|
+
0,
|
|
84
|
+
0,
|
|
85
|
+
0
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Colors a raw value against a scale, normalizing it into `min`-`max` first.
|
|
90
|
+
* Returns null when the value sits at or below `min`, or when the range is
|
|
91
|
+
* degenerate, so callers can fall back to a neutral color.
|
|
92
|
+
*/
|
|
93
|
+
function sampleColorScale(scale, value, max, min = 0) {
|
|
94
|
+
if (max <= min || value <= min) return null;
|
|
95
|
+
const t = Math.min(1, (value - min) / (max - min));
|
|
96
|
+
return scale.kind === "continuous" ? sampleContinuousScale(scale.stops, t) : sampleSteppedScale(scale.stops, t);
|
|
97
|
+
}
|
|
98
|
+
/** CSS `linear-gradient` spanning a continuous scale, for the legend bar. */
|
|
99
|
+
function toCssGradient(stops) {
|
|
100
|
+
return `linear-gradient(to right, ${stops.map((stop) => `${stop.color} ${stop.t * 100}%`).join(", ")})`;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { toCssGradient as i, sampleColorScale as n, sampleSteppedScale as r, PLASMA_COLOR_SCALE as t };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
import { DatasetComponentOption, ECharts, EChartsOption, ScatterSeriesOption } from "echarts";
|
|
3
|
+
|
|
4
|
+
//#region src/core/HeatmapChart/hooks/utils.d.ts
|
|
5
|
+
interface CreateChartOptionsProps {
|
|
6
|
+
/**
|
|
7
|
+
* The crosshair following the pointer. One object applies to both axes; a
|
|
8
|
+
* two-entry array configures them separately.
|
|
9
|
+
* https://echarts.apache.org/en/option.html#axisPointer
|
|
10
|
+
*/
|
|
11
|
+
axisPointer?: EChartsOption["axisPointer"];
|
|
12
|
+
/**
|
|
13
|
+
* The cells, as a flat array of objects whose fields are named by `encode`.
|
|
14
|
+
* The data point object shape can be whatever you like, but it must be consistent with the `encode` option
|
|
15
|
+
* For example, if the data point shape is:
|
|
16
|
+
* {
|
|
17
|
+
* geneIndex: 0,
|
|
18
|
+
* cellTypeIndex: 0,
|
|
19
|
+
* percentage: 0.5
|
|
20
|
+
* }
|
|
21
|
+
* and you want geneIndex to be encoded to x axis and cellTypeIndex to be encoded to y axis, then make sure your encode option is:
|
|
22
|
+
* encode: {
|
|
23
|
+
* x: 'geneIndex',
|
|
24
|
+
* y: 'cellTypeIndex'
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
data: DatasetComponentOption["source"];
|
|
28
|
+
/**
|
|
29
|
+
* ECharts' dataZoom configuration for that window, merged over the defaults
|
|
30
|
+
* it sets. One object applies to both axes; a two-entry array configures them
|
|
31
|
+
* separately. It reaches the chart only while `camera.active` is true.
|
|
32
|
+
*
|
|
33
|
+
* The `dataZoom` prop is utilized for implementing zoom functionality within a
|
|
34
|
+
* specific area of the chart. This feature empowers users to inspect data in
|
|
35
|
+
* granular detail, obtain an overview of the entire dataset, or eliminate
|
|
36
|
+
* outlier points.
|
|
37
|
+
* By applying the `dataZoom` prop while locking the zoom level, the chart
|
|
38
|
+
* efficiently renders a confined portion of the heatmap. This selective
|
|
39
|
+
* rendering strategy becomes especially advantageous when dealing with
|
|
40
|
+
* extensive datasets. Instead of rendering the entire heatmap at once,
|
|
41
|
+
* the chart dynamically loads and renders specific segments as the user
|
|
42
|
+
* scrolls through the data. This approach optimizes performance and enables
|
|
43
|
+
* the creation of heatmaps with large amounts of data.
|
|
44
|
+
* https://echarts.apache.org/en/option.html#dataZoom
|
|
45
|
+
*/
|
|
46
|
+
dataZoom?: EChartsOption["dataZoom"];
|
|
47
|
+
/**
|
|
48
|
+
* Renders only a window of the grid, measured in cells, and lets the pointer
|
|
49
|
+
* pan it. Sizes are ignored unless `active` is true.
|
|
50
|
+
*
|
|
51
|
+
* The `camera` prop is utilized for implementing camera view port functionality
|
|
52
|
+
* within a specific area of the chart. This feature empowers users to render
|
|
53
|
+
* a confined portion of the heatmap. This selective rendering strategy becomes
|
|
54
|
+
* especially advantageous when dealing with extensive datasets. Instead of
|
|
55
|
+
* rendering the entire heatmap at once, the chart dynamically loads and renders
|
|
56
|
+
* specific segments as the user scrolls through the data. This approach optimizes
|
|
57
|
+
* performance and enables the creation of heatmaps with large amounts of data.
|
|
58
|
+
*
|
|
59
|
+
* The `height` and `width` properties are used to specify the dimensions of the
|
|
60
|
+
* camera view port. The `active` property is used to enable or disable the camera
|
|
61
|
+
* view port functionality.
|
|
62
|
+
*/
|
|
63
|
+
camera?: {
|
|
64
|
+
active: boolean;
|
|
65
|
+
height: number;
|
|
66
|
+
width: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* How a cell is drawn while the pointer is over it. Takes the same shape as
|
|
70
|
+
* `itemStyle`: color, border, opacity.
|
|
71
|
+
* https://echarts.apache.org/en/option.html#series-scatter.emphasis
|
|
72
|
+
*/
|
|
73
|
+
emphasis?: ScatterSeriesOption["emphasis"];
|
|
74
|
+
/**
|
|
75
|
+
* The categories along the x axis. A cell's encoded x value is an index into
|
|
76
|
+
* this array.
|
|
77
|
+
* For example:
|
|
78
|
+
* [{ value: "gene1", textStyle: { color: "red" } }, "gene2", "gene3"]
|
|
79
|
+
*/
|
|
80
|
+
xAxisData: CategoryAxisData;
|
|
81
|
+
/**
|
|
82
|
+
* The categories along the y axis.
|
|
83
|
+
* For example:
|
|
84
|
+
* [{ value: "cellType1", textStyle: { color: "red" } }, "cellType2", "cellType3"]
|
|
85
|
+
*/
|
|
86
|
+
yAxisData: CategoryAxisData;
|
|
87
|
+
/**
|
|
88
|
+
* Width of the chart in pixels. Must be greater than zero; the component
|
|
89
|
+
* throws otherwise.
|
|
90
|
+
*/
|
|
91
|
+
width: number;
|
|
92
|
+
/**
|
|
93
|
+
* Height of the chart in pixels, under the same rule.
|
|
94
|
+
*/
|
|
95
|
+
height: number;
|
|
96
|
+
/**
|
|
97
|
+
* Which fields of a data item place it on each axis. Omitting it leaves
|
|
98
|
+
* ECharts to guess from the field order.
|
|
99
|
+
* For example, if the data is:
|
|
100
|
+
* {
|
|
101
|
+
* geneIndex: 0,
|
|
102
|
+
* cellTypeIndex: 0,
|
|
103
|
+
* percentage: 0.5
|
|
104
|
+
* }
|
|
105
|
+
* and we want to encode `geneIndex` to x axis and `cellTypeIndex` to y axis, then
|
|
106
|
+
* encode: {
|
|
107
|
+
* x: 'geneIndex',
|
|
108
|
+
* y: 'cellTypeIndex'
|
|
109
|
+
* }
|
|
110
|
+
* https://echarts.apache.org/en/option.html#series-scatter.encode
|
|
111
|
+
*/
|
|
112
|
+
encode?: {
|
|
113
|
+
x: string;
|
|
114
|
+
y: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* How a cell is painted. Its color accepts a callback receiving the data
|
|
118
|
+
* item, which is how a value becomes a color.
|
|
119
|
+
* https://echarts.apache.org/en/option.html#series-scatter.itemStyle
|
|
120
|
+
*/
|
|
121
|
+
itemStyle?: ScatterSeriesOption["itemStyle"];
|
|
122
|
+
/**
|
|
123
|
+
* The shape of a cell. Circles turn the grid into a dot plot, where diameter
|
|
124
|
+
* can carry a second measurement.
|
|
125
|
+
*/
|
|
126
|
+
symbol?: "circle" | "rect" | "roundRect";
|
|
127
|
+
/**
|
|
128
|
+
* Cell size in pixels: one number, a [width, height] pair, or a callback
|
|
129
|
+
* given the data item. Set it to the cell pitch for a solid grid.
|
|
130
|
+
*
|
|
131
|
+
* `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.
|
|
132
|
+
*
|
|
133
|
+
* If size of symbols needs to be different, you can set with callback function in the following format:
|
|
134
|
+
*
|
|
135
|
+
* (value: Array|number, params: Object) => number|Array
|
|
136
|
+
*
|
|
137
|
+
* The first parameter value is the value in data, and the second parameter params is the rest parameters of data item.
|
|
138
|
+
* https://echarts.apache.org/en/option.html#series-scatter.symbolSize
|
|
139
|
+
*/
|
|
140
|
+
symbolSize?: ScatterSeriesOption["symbolSize"];
|
|
141
|
+
/**
|
|
142
|
+
* Where the plotting area sits inside the container. The function form
|
|
143
|
+
* receives the computed default, for insetting it without recomputing the
|
|
144
|
+
* size.
|
|
145
|
+
* https://echarts.apache.org/en/option.html#grid
|
|
146
|
+
*/
|
|
147
|
+
grid?: EChartsOption["grid"] | ((defaultOption: EChartsOption["grid"]) => EChartsOption["grid"]);
|
|
148
|
+
/**
|
|
149
|
+
* Anything else ECharts understands, merged over the generated options.
|
|
150
|
+
* https://echarts.apache.org/en/option.html
|
|
151
|
+
*/
|
|
152
|
+
options?: EChartsOption;
|
|
153
|
+
/**
|
|
154
|
+
* ECharts event listeners by name. Each handler gets the raw event, whose
|
|
155
|
+
* data property is the cell, and the chart instance.
|
|
156
|
+
* https://echarts.apache.org/en/api.html#events
|
|
157
|
+
*/
|
|
158
|
+
onEvents?: Record<string, (event: unknown, chart: ECharts) => void>;
|
|
159
|
+
}
|
|
160
|
+
type OrdinalRawValue = string | number;
|
|
161
|
+
/**
|
|
162
|
+
* (thuang): This copies echarts' CategoryAxisBaseOption["data"] type, since it's not exported
|
|
163
|
+
*/
|
|
164
|
+
type CategoryAxisData = (OrdinalRawValue | {
|
|
165
|
+
value: OrdinalRawValue;
|
|
166
|
+
/**
|
|
167
|
+
* (thuang): This should be echarts `TextCommonOption` type, but it's not exported
|
|
168
|
+
*/
|
|
169
|
+
textStyle?: never;
|
|
170
|
+
})[];
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/core/HeatmapChart/index.d.ts
|
|
173
|
+
interface HeatmapChartProps extends HTMLAttributes<HTMLDivElement>, CreateChartOptionsProps {
|
|
174
|
+
/**
|
|
175
|
+
* Which renderer ECharts initialises with. Canvas copes better with very
|
|
176
|
+
* large grids. Changing it rebuilds the chart.
|
|
177
|
+
* @default "svg"
|
|
178
|
+
*/
|
|
179
|
+
echartsRendererMode?: "svg" | "canvas";
|
|
180
|
+
}
|
|
181
|
+
declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<HeatmapChartProps & import("react").RefAttributes<HTMLDivElement>>>;
|
|
182
|
+
//#endregion
|
|
183
|
+
export { _default as n, HeatmapChartProps as t };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { DatasetComponentOption, ECharts, EChartsOption, ScatterSeriesOption } from "echarts";
|
|
2
|
+
import { HTMLAttributes } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/core/HeatmapChart/hooks/utils.d.ts
|
|
5
|
+
interface CreateChartOptionsProps {
|
|
6
|
+
/**
|
|
7
|
+
* The crosshair following the pointer. One object applies to both axes; a
|
|
8
|
+
* two-entry array configures them separately.
|
|
9
|
+
* https://echarts.apache.org/en/option.html#axisPointer
|
|
10
|
+
*/
|
|
11
|
+
axisPointer?: EChartsOption["axisPointer"];
|
|
12
|
+
/**
|
|
13
|
+
* The cells, as a flat array of objects whose fields are named by `encode`.
|
|
14
|
+
* The data point object shape can be whatever you like, but it must be consistent with the `encode` option
|
|
15
|
+
* For example, if the data point shape is:
|
|
16
|
+
* {
|
|
17
|
+
* geneIndex: 0,
|
|
18
|
+
* cellTypeIndex: 0,
|
|
19
|
+
* percentage: 0.5
|
|
20
|
+
* }
|
|
21
|
+
* and you want geneIndex to be encoded to x axis and cellTypeIndex to be encoded to y axis, then make sure your encode option is:
|
|
22
|
+
* encode: {
|
|
23
|
+
* x: 'geneIndex',
|
|
24
|
+
* y: 'cellTypeIndex'
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
data: DatasetComponentOption["source"];
|
|
28
|
+
/**
|
|
29
|
+
* ECharts' dataZoom configuration for that window, merged over the defaults
|
|
30
|
+
* it sets. One object applies to both axes; a two-entry array configures them
|
|
31
|
+
* separately. It reaches the chart only while `camera.active` is true.
|
|
32
|
+
*
|
|
33
|
+
* The `dataZoom` prop is utilized for implementing zoom functionality within a
|
|
34
|
+
* specific area of the chart. This feature empowers users to inspect data in
|
|
35
|
+
* granular detail, obtain an overview of the entire dataset, or eliminate
|
|
36
|
+
* outlier points.
|
|
37
|
+
* By applying the `dataZoom` prop while locking the zoom level, the chart
|
|
38
|
+
* efficiently renders a confined portion of the heatmap. This selective
|
|
39
|
+
* rendering strategy becomes especially advantageous when dealing with
|
|
40
|
+
* extensive datasets. Instead of rendering the entire heatmap at once,
|
|
41
|
+
* the chart dynamically loads and renders specific segments as the user
|
|
42
|
+
* scrolls through the data. This approach optimizes performance and enables
|
|
43
|
+
* the creation of heatmaps with large amounts of data.
|
|
44
|
+
* https://echarts.apache.org/en/option.html#dataZoom
|
|
45
|
+
*/
|
|
46
|
+
dataZoom?: EChartsOption["dataZoom"];
|
|
47
|
+
/**
|
|
48
|
+
* Renders only a window of the grid, measured in cells, and lets the pointer
|
|
49
|
+
* pan it. Sizes are ignored unless `active` is true.
|
|
50
|
+
*
|
|
51
|
+
* The `camera` prop is utilized for implementing camera view port functionality
|
|
52
|
+
* within a specific area of the chart. This feature empowers users to render
|
|
53
|
+
* a confined portion of the heatmap. This selective rendering strategy becomes
|
|
54
|
+
* especially advantageous when dealing with extensive datasets. Instead of
|
|
55
|
+
* rendering the entire heatmap at once, the chart dynamically loads and renders
|
|
56
|
+
* specific segments as the user scrolls through the data. This approach optimizes
|
|
57
|
+
* performance and enables the creation of heatmaps with large amounts of data.
|
|
58
|
+
*
|
|
59
|
+
* The `height` and `width` properties are used to specify the dimensions of the
|
|
60
|
+
* camera view port. The `active` property is used to enable or disable the camera
|
|
61
|
+
* view port functionality.
|
|
62
|
+
*/
|
|
63
|
+
camera?: {
|
|
64
|
+
active: boolean;
|
|
65
|
+
height: number;
|
|
66
|
+
width: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* How a cell is drawn while the pointer is over it. Takes the same shape as
|
|
70
|
+
* `itemStyle`: color, border, opacity.
|
|
71
|
+
* https://echarts.apache.org/en/option.html#series-scatter.emphasis
|
|
72
|
+
*/
|
|
73
|
+
emphasis?: ScatterSeriesOption["emphasis"];
|
|
74
|
+
/**
|
|
75
|
+
* The categories along the x axis. A cell's encoded x value is an index into
|
|
76
|
+
* this array.
|
|
77
|
+
* For example:
|
|
78
|
+
* [{ value: "gene1", textStyle: { color: "red" } }, "gene2", "gene3"]
|
|
79
|
+
*/
|
|
80
|
+
xAxisData: CategoryAxisData;
|
|
81
|
+
/**
|
|
82
|
+
* The categories along the y axis.
|
|
83
|
+
* For example:
|
|
84
|
+
* [{ value: "cellType1", textStyle: { color: "red" } }, "cellType2", "cellType3"]
|
|
85
|
+
*/
|
|
86
|
+
yAxisData: CategoryAxisData;
|
|
87
|
+
/**
|
|
88
|
+
* Width of the chart in pixels. Must be greater than zero; the component
|
|
89
|
+
* throws otherwise.
|
|
90
|
+
*/
|
|
91
|
+
width: number;
|
|
92
|
+
/**
|
|
93
|
+
* Height of the chart in pixels, under the same rule.
|
|
94
|
+
*/
|
|
95
|
+
height: number;
|
|
96
|
+
/**
|
|
97
|
+
* Which fields of a data item place it on each axis. Omitting it leaves
|
|
98
|
+
* ECharts to guess from the field order.
|
|
99
|
+
* For example, if the data is:
|
|
100
|
+
* {
|
|
101
|
+
* geneIndex: 0,
|
|
102
|
+
* cellTypeIndex: 0,
|
|
103
|
+
* percentage: 0.5
|
|
104
|
+
* }
|
|
105
|
+
* and we want to encode `geneIndex` to x axis and `cellTypeIndex` to y axis, then
|
|
106
|
+
* encode: {
|
|
107
|
+
* x: 'geneIndex',
|
|
108
|
+
* y: 'cellTypeIndex'
|
|
109
|
+
* }
|
|
110
|
+
* https://echarts.apache.org/en/option.html#series-scatter.encode
|
|
111
|
+
*/
|
|
112
|
+
encode?: {
|
|
113
|
+
x: string;
|
|
114
|
+
y: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* How a cell is painted. Its color accepts a callback receiving the data
|
|
118
|
+
* item, which is how a value becomes a color.
|
|
119
|
+
* https://echarts.apache.org/en/option.html#series-scatter.itemStyle
|
|
120
|
+
*/
|
|
121
|
+
itemStyle?: ScatterSeriesOption["itemStyle"];
|
|
122
|
+
/**
|
|
123
|
+
* The shape of a cell. Circles turn the grid into a dot plot, where diameter
|
|
124
|
+
* can carry a second measurement.
|
|
125
|
+
*/
|
|
126
|
+
symbol?: "circle" | "rect" | "roundRect";
|
|
127
|
+
/**
|
|
128
|
+
* Cell size in pixels: one number, a [width, height] pair, or a callback
|
|
129
|
+
* given the data item. Set it to the cell pitch for a solid grid.
|
|
130
|
+
*
|
|
131
|
+
* `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.
|
|
132
|
+
*
|
|
133
|
+
* If size of symbols needs to be different, you can set with callback function in the following format:
|
|
134
|
+
*
|
|
135
|
+
* (value: Array|number, params: Object) => number|Array
|
|
136
|
+
*
|
|
137
|
+
* The first parameter value is the value in data, and the second parameter params is the rest parameters of data item.
|
|
138
|
+
* https://echarts.apache.org/en/option.html#series-scatter.symbolSize
|
|
139
|
+
*/
|
|
140
|
+
symbolSize?: ScatterSeriesOption["symbolSize"];
|
|
141
|
+
/**
|
|
142
|
+
* Where the plotting area sits inside the container. The function form
|
|
143
|
+
* receives the computed default, for insetting it without recomputing the
|
|
144
|
+
* size.
|
|
145
|
+
* https://echarts.apache.org/en/option.html#grid
|
|
146
|
+
*/
|
|
147
|
+
grid?: EChartsOption["grid"] | ((defaultOption: EChartsOption["grid"]) => EChartsOption["grid"]);
|
|
148
|
+
/**
|
|
149
|
+
* Anything else ECharts understands, merged over the generated options.
|
|
150
|
+
* https://echarts.apache.org/en/option.html
|
|
151
|
+
*/
|
|
152
|
+
options?: EChartsOption;
|
|
153
|
+
/**
|
|
154
|
+
* ECharts event listeners by name. Each handler gets the raw event, whose
|
|
155
|
+
* data property is the cell, and the chart instance.
|
|
156
|
+
* https://echarts.apache.org/en/api.html#events
|
|
157
|
+
*/
|
|
158
|
+
onEvents?: Record<string, (event: unknown, chart: ECharts) => void>;
|
|
159
|
+
}
|
|
160
|
+
type OrdinalRawValue = string | number;
|
|
161
|
+
/**
|
|
162
|
+
* (thuang): This copies echarts' CategoryAxisBaseOption["data"] type, since it's not exported
|
|
163
|
+
*/
|
|
164
|
+
type CategoryAxisData = (OrdinalRawValue | {
|
|
165
|
+
value: OrdinalRawValue;
|
|
166
|
+
/**
|
|
167
|
+
* (thuang): This should be echarts `TextCommonOption` type, but it's not exported
|
|
168
|
+
*/
|
|
169
|
+
textStyle?: never;
|
|
170
|
+
})[];
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/core/HeatmapChart/index.d.ts
|
|
173
|
+
interface HeatmapChartProps extends HTMLAttributes<HTMLDivElement>, CreateChartOptionsProps {
|
|
174
|
+
/**
|
|
175
|
+
* Which renderer ECharts initialises with. Canvas copes better with very
|
|
176
|
+
* large grids. Changing it rebuilds the chart.
|
|
177
|
+
* @default "svg"
|
|
178
|
+
*/
|
|
179
|
+
echartsRendererMode?: "svg" | "canvas";
|
|
180
|
+
}
|
|
181
|
+
declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<HeatmapChartProps & import("react").RefAttributes<HTMLDivElement>>>;
|
|
182
|
+
//#endregion
|
|
183
|
+
export { _default as n, HeatmapChartProps as t };
|