@datagrok/curves 1.12.2 → 1.13.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/CLAUDE.md +118 -15
  3. package/README.md +51 -4
  4. package/dist/package-test.js +8819 -5223
  5. package/dist/package-test.js.map +1 -1
  6. package/dist/package.js +3014 -1659
  7. package/dist/package.js.map +1 -1
  8. package/files/demo/Assay_Curves.csv +43 -43
  9. package/package.json +2 -2
  10. package/scripts/calculateMSR.py +16 -7
  11. package/src/fit/data-to-curves.ts +11 -6
  12. package/src/fit/fit-chart-data.ts +330 -0
  13. package/src/fit/fit-grid-cell-handler.ts +102 -235
  14. package/src/fit/fit-inspection.ts +3 -3
  15. package/src/fit/fit-interaction.ts +181 -0
  16. package/src/fit/fit-layout.ts +64 -0
  17. package/src/fit/fit-legend.ts +292 -0
  18. package/src/fit/fit-options.ts +222 -0
  19. package/src/fit/fit-parser.ts +16 -5
  20. package/src/fit/fit-renderer.ts +180 -469
  21. package/src/fit/fit-statistics.ts +154 -0
  22. package/src/fit/multi-curve-viewer.ts +48 -22
  23. package/src/fit/render-utils.ts +208 -150
  24. package/src/package-api.ts +78 -0
  25. package/src/package-test.ts +7 -0
  26. package/src/package.g.ts +59 -11
  27. package/src/package.ts +97 -18
  28. package/src/tests/calculated-columns-tests.ts +299 -0
  29. package/src/tests/converter-tests.ts +23 -0
  30. package/src/tests/curve-data.ts +82 -0
  31. package/src/tests/fit-cache-tests.ts +128 -0
  32. package/src/tests/fit-tests.ts +344 -4
  33. package/src/tests/legend-tests.ts +243 -0
  34. package/src/tests/multi-curve-viewer-tests.ts +100 -0
  35. package/src/tests/panel-renderer-tests.ts +502 -0
  36. package/src/tests/project-tests.ts +99 -0
  37. package/src/tests/statistics-tests.ts +127 -0
  38. package/src/tests/transform-tests.ts +3 -2
  39. package/test-console-output-1.log +410 -109
  40. package/test-record-1.mp4 +0 -0
@@ -1,313 +1,97 @@
1
1
  /* eslint-disable max-len */
2
2
  import * as DG from 'datagrok-api/dg';
3
3
  import * as grok from 'datagrok-api/grok';
4
- import * as ui from 'datagrok-api/ui';
5
4
 
6
- import {
7
- IFitChartData,
8
- IFitSeries,
9
- fitChartDataProperties, IFitChartOptions, IFitPoint, FitCurve,
10
- FitStatistics,
11
- } from '@datagrok-libraries/statistics/src/fit/fit-curve';
5
+ import {IFitChartData, IFitChartOptions, IFitSeries, LogOptions} from '@datagrok-libraries/statistics/src/fit/fit-curve';
12
6
  import {Viewport} from '@datagrok-libraries/utils/src/transform';
13
7
 
14
8
  import {
15
- fitSeries,
16
- createDefaultChartData,
17
9
  getChartBounds,
18
10
  getSeriesFitFunction,
19
11
  getCurve,
20
- LogOptions, getDataPoints,
12
+ seriesInFitSpace,
21
13
  } from '@datagrok-libraries/statistics/src/fit/fit-data';
22
14
 
23
15
  import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
24
- import {parseCellValue, isNativeFormat} from './curve-converter';
16
+ import {FitFunction} from '@datagrok-libraries/statistics/src/fit/fit-engine';
25
17
  import {
26
18
  renderAxesLabels,
27
19
  renderConfidenceIntervals, renderConnectDots,
28
20
  renderDroplines,
29
- renderFitLine, renderLegend,
30
- renderPoints, renderStatistics, renderTitle
21
+ renderFitLine,
22
+ renderPoints, renderStatistics, renderTitle, renderLabels, getSeriesColor, ColorType, CURVE_SAMPLE_PX_STEP
31
23
  } from './render-utils';
32
- import {merge} from 'rxjs';
33
- import {calculateSeriesStats, getChartDataAggrStats} from './fit-grid-cell-handler';
34
- import {Fit, FitFunction, FitFunctionTypes, fitSeriesProperties} from '@datagrok-libraries/statistics/src/fit/new-fit-API';
35
-
24
+ import {isLegendVisible, renderLegend} from './fit-legend';
25
+ import {getChartDataAggrStats} from './fit-statistics';
26
+ import {
27
+ fittedCurves, parsedCurves, curvesDataPoints, getOrCreateParsedChartData, getOrCreateCachedFitCurve,
28
+ getOrCreateCachedCurvesDataPoints, mergeSeries, substituteZeroes
29
+ } from './fit-chart-data';
30
+ import {
31
+ areAxesLabelsShown, areAxesShown, areDroplineLabelsShown, areDroplinesShown, inflateScreenBounds, isTitleShown,
32
+ layoutChart, shownAxesNames,
33
+ } from './fit-layout';
34
+ import {handleClick, handleMouseMove, inspectCurve} from './fit-interaction';
36
35
 
37
36
  function clamp(value: number, min: number, max: number): number {
38
37
  return Math.min(Math.max(value, min), max);
39
38
  }
40
39
 
41
- function showIncorrectFitCell(g: CanvasRenderingContext2D, screenBounds: DG.Rect): void {
42
- DG.Paint.marker(g, DG.MARKER_TYPE.OUTLIER, screenBounds.midX, screenBounds.midY, DG.Color.red,
43
- clamp(Math.min(screenBounds.width, screenBounds.height) * 0.8, 0, 30));
44
- }
45
-
46
- /** Merges properties of the two objects by iterating over the specified {@link properties}
47
- * and assigning properties from {@link source} to {@link target} only when
48
- * the property is not defined in target and is defined in source. */
49
- export function mergeProperties(properties: DG.Property[], source: any, target: any): void {
50
- if (!source || !target)
51
- return;
52
-
53
- for (const p of properties) {
54
- if (!(p.name in target) && p.name in source)
55
- target[p.name] = source[p.name];
56
- }
57
- }
58
-
59
- export function mergeChartOptions(chartOptions: IFitChartOptions[]): IFitChartOptions {
60
- if (chartOptions.length === 0)
61
- return {};
62
-
63
- let minX = Number.MAX_VALUE;
64
- let minY = Number.MAX_VALUE;
65
- let maxX = Number.MIN_VALUE;
66
- let maxY = Number.MIN_VALUE;
67
- let xAxisName: string | undefined;
68
- let yAxisName: string | undefined;
69
- let title: string | undefined;
70
- let logX: boolean = false;
71
- let logY: boolean = false;
72
- let allowXZeroes: boolean = false;
73
-
74
- for (const options of chartOptions) {
75
- if (options.minX !== null && options.minX !== undefined)
76
- minX = Math.min(minX, options.minX);
77
- if (options.minY !== null && options.minY !== undefined)
78
- minY = Math.min(minY, options.minY);
79
- if (options.maxX !== null && options.maxX !== undefined)
80
- maxX = Math.max(maxX, options.maxX);
81
- if (options.maxY !== null && options.maxY !== undefined)
82
- maxY = Math.max(maxY, options.maxY);
83
- if (options.title !== null && options.title !== undefined)
84
- title ??= options.title;
85
- if (options.xAxisName !== null && options.xAxisName !== undefined)
86
- xAxisName ??= options.xAxisName;
87
- if (options.yAxisName !== null && options.yAxisName !== undefined)
88
- yAxisName ??= options.yAxisName;
89
- if (options.logX !== null && options.logX !== undefined && options.logX)
90
- logX = true;
91
- if (options.logY !== null && options.logY !== undefined && options.logY)
92
- logY = true;
93
- if (options.allowXZeroes !== null && options.allowXZeroes !== undefined && options.allowXZeroes)
94
- allowXZeroes = true;
95
- }
96
-
97
- return {
98
- minX: minX === Number.MAX_VALUE ? undefined : minX,
99
- minY: minY === Number.MAX_VALUE ? undefined : minY,
100
- maxX: maxX === Number.MIN_VALUE ? undefined : maxX,
101
- maxY: maxY === Number.MIN_VALUE ? undefined : maxY,
102
- title: title,
103
- xAxisName: xAxisName,
104
- yAxisName: yAxisName,
105
- logX: logX,
106
- logY: logY,
107
- allowXZeroes: allowXZeroes,
108
- };
109
- }
110
-
111
- export function mergeSeries(series: IFitSeries[]): IFitSeries | null {
112
- if (series.length === 0)
113
- return null;
114
- const mergedSeries: IFitSeries = {
115
- points: [],
116
- name: series[0].name,
117
- fitFunction: series[0].fitFunction,
118
- markerType: series[0].markerType,
119
- lineStyle: series[0].lineStyle,
120
- pointColor: series[0].pointColor,
121
- fitLineColor: series[0].fitLineColor,
122
- confidenceIntervalColor: series[0].confidenceIntervalColor,
123
- outlierColor: series[0].outlierColor,
124
- connectDots: series[0].connectDots,
125
- showFitLine: series[0].showFitLine,
126
- showPoints: series[0].showPoints,
127
- showOutliers: series[0].showOutliers,
128
- showCurveConfidenceInterval: series[0].showCurveConfidenceInterval,
129
- errorModel: series[0].errorModel,
130
- clickToToggle: series[0].clickToToggle,
131
- labels: series[0].labels,
132
- droplines: series[0].droplines,
133
- columnName: series[0].columnName,
134
- };
135
- for (const s of series)
136
- mergedSeries.points = [...mergedSeries.points, ...s.points];
137
- return mergedSeries;
138
- }
139
-
140
- /** Returns either cached or constructed chart data for the specified table cell. */
141
- export function getOrCreateParsedChartData(tableCell: DG.Cell, useCache = true): IFitChartData {
142
- const column = tableCell?.column;
143
- return (useCache && column && tableCell) ?
144
- FitChartCellRenderer.parsedCurves.getOrCreate(`tableId: ${column.dataFrame.id} || tableName: ${column.dataFrame.name} || colName: ${column.name} || colVersion: ${column.version} || rowIdx: ${tableCell?.rowIndex}`, () => {
145
- return getChartData(tableCell);
146
- }) : getChartData(tableCell);
147
- }
148
-
149
- /** Constructs {@link IFitChartData} from the table cell, taking into account
150
- * chart and fit settings potentially defined on the dataframe and column level. */
151
- function getChartData(tableCell: DG.Cell): IFitChartData {
152
- // removing '|' from JSON (how did it get here?)
153
- let cellValue = tableCell.value as string;
154
- if (cellValue.includes('|'))
155
- cellValue = cellValue.replaceAll('|', '');
156
- const column = tableCell.column;
157
- const cellChartData: IFitChartData = column ? (column.type === DG.TYPE.STRING ?
158
- parseCellValue(cellValue, column) :
159
- createDefaultChartData()) : JSON.parse(cellValue ?? '{}') ?? {};
160
-
161
- const columnChartOptions = tableCell.column ? getColumnChartOptions(tableCell.column) : {};
162
- const dfChartOptions = tableCell.column ? getDataFrameChartOptions(tableCell.dataFrame) : {};
163
-
164
- cellChartData.series ??= [];
165
- cellChartData.chartOptions ??= columnChartOptions.chartOptions;
166
-
167
- // merge cell options with column options
168
- mergeProperties(fitChartDataProperties, columnChartOptions.chartOptions, cellChartData.chartOptions);
169
- mergeProperties(fitChartDataProperties, dfChartOptions.chartOptions, cellChartData.chartOptions);
170
- for (const series of cellChartData.series) {
171
- mergeProperties(fitSeriesProperties, cellChartData.seriesOptions, series);
172
- mergeProperties(fitSeriesProperties, columnChartOptions.seriesOptions, series);
173
- mergeProperties(fitSeriesProperties, dfChartOptions.seriesOptions, series);
174
- }
175
-
176
- return cellChartData;
177
- }
178
-
179
- /** Returns existing, or fits curve for the specified grid cell and series. */
180
- export function getOrCreateCachedFitCurve(series: IFitSeries, seriesIdx: number, fitFunc: FitFunction<Fit>,
181
- chartLogOptions: LogOptions, tableCell?: DG.Cell, useCache = true): FitCurve {
182
- const dataPoints = getOrCreateCachedCurvesDataPoints(series, seriesIdx, chartLogOptions, false, tableCell, useCache);
183
- // don't refit when just rerender - using LruCache with key `cellValue_colName_colVersion`
184
- const column = tableCell?.column;
185
- return (useCache && column && tableCell) ?
186
- FitChartCellRenderer.fittedCurves.getOrCreate(`tableId: ${column.dataFrame.id} || tableName: ${column.dataFrame.name} || colName: ${column.name} || colVersion: ${column.version} || rowIdx: ${tableCell.rowIndex} || idx: ${seriesIdx}`, () => {
187
- return fitSeries(series, fitFunc, dataPoints, chartLogOptions);
188
- }) : fitSeries(series, fitFunc, dataPoints, chartLogOptions);
189
- }
190
-
191
- /** Returns existing, or maps new data points for the specified series. */
192
- export function getOrCreateCachedCurvesDataPoints(series: IFitSeries, idx: number, logOptions?: LogOptions,
193
- userParamsFlag?: boolean, tableCell?: DG.Cell, useCache = true): {x: number[], y: number[]} {
194
- const column = tableCell?.column;
195
- return (useCache && column && tableCell) ?
196
- FitChartCellRenderer.curvesDataPoints.getOrCreate(`tableId: ${column.dataFrame.id} || tableName: ${column.dataFrame.name} || colName: ${column.name} || colVersion: ${column.version} || rowIdx: ${tableCell.rowIndex} || idx: ${idx} || userParamsFlag: ${userParamsFlag}`, () => {
197
- return getDataPoints(series, logOptions, userParamsFlag);
198
- }) : getDataPoints(series, logOptions, userParamsFlag);
199
- }
200
-
201
- /** Returns existing, or creates new dataframe default chart options. */
202
- export function getDataFrameChartOptions(df: DG.DataFrame): IFitChartData {
203
- return JSON.parse(df.tags[FitConstants.TAG_FIT] ??= JSON.stringify(createDefaultChartData()));
204
- }
205
-
206
- /** Returns existing, or creates new column default chart options. */
207
- export function getColumnChartOptions(column: DG.Column): IFitChartData {
208
- return JSON.parse(column.tags[FitConstants.TAG_FIT] ??= JSON.stringify(createDefaultChartData()));
209
- }
210
-
211
- /** Performs a chart layout, returning [viewport, xAxis, yAxis] */
212
- export function layoutChart(rect: DG.Rect, showAxesLabels: boolean, showTitle: boolean): [DG.Rect, DG.Rect?, DG.Rect?] {
213
- if (rect.width < FitConstants.MIN_AXES_CELL_PX_WIDTH || rect.height < FitConstants.MIN_AXES_CELL_PX_HEIGHT)
214
- return [rect, undefined, undefined];
215
- const axesLeftPxMargin = showAxesLabels ? FitConstants.AXES_LEFT_PX_MARGIN_WITH_AXES_LABELS : FitConstants.AXES_LEFT_PX_MARGIN;
216
- const axesBottomPxMargin = showAxesLabels ? FitConstants.AXES_BOTTOM_PX_MARGIN_WITH_AXES_LABELS : FitConstants.AXES_BOTTOM_PX_MARGIN;
217
- const axesTopPxMargin = showTitle ? FitConstants.AXES_TOP_PX_MARGIN_WITH_TITLE : FitConstants.AXES_TOP_PX_MARGIN;
218
- return [
219
- rect.cutLeft(axesLeftPxMargin).cutBottom(axesBottomPxMargin).cutTop(axesTopPxMargin).cutRight(FitConstants.AXES_RIGHT_PX_MARGIN),
220
- rect.getBottom(axesBottomPxMargin).getTop(axesTopPxMargin).cutLeft(axesLeftPxMargin).cutRight(FitConstants.AXES_RIGHT_PX_MARGIN),
221
- rect.getLeft(axesLeftPxMargin).getRight(FitConstants.AXES_RIGHT_PX_MARGIN).cutBottom(axesBottomPxMargin).cutTop(axesTopPxMargin)
222
- ];
223
- }
224
-
225
- /** Checks if the color is valid */
226
- export function isColorValid(color: string | null | undefined): boolean {
227
- if (color === undefined || color === null || color === '')
228
- return false;
229
- return DG.Color.fromHtml(color) !== undefined;
230
- }
231
-
232
- /** Performs x zeroes substitution if log x */
233
- export function substituteZeroes(data: IFitChartData): void {
234
- for (let i = 0; i < data.series?.length!; i++) {
235
- const series = data.series![i];
236
- if (series.points.every((p) => p.x !== 0))
40
+ /** How far past its data a curve may stretch the axis before it is left cut instead. */
41
+ const CURVE_HEADROOM = 0.15;
42
+
43
+ /** The plot has to hold the curves it draws, not only the points they were fitted to. */
44
+ function withCurvesInView(bounds: DG.Rect, curves: (((x: number) => number) | null)[],
45
+ options: IFitChartOptions | undefined): DG.Rect {
46
+ const logX = options?.logX ?? false;
47
+ const logY = options?.logY ?? false;
48
+ const SAMPLES = 100;
49
+ let min = bounds.minY;
50
+ let max = bounds.maxY;
51
+ for (const curve of curves) {
52
+ if (!curve)
237
53
  continue;
238
- let minNonZeroX = Number.MAX_VALUE;
239
- let maxNonZeroX = 0;
240
- let countOfDistNonZeroX = 0;
241
- const uniqueArr: number[] = [];
242
- for (let j = 0; j < series.points.length; j++) {
243
- if (series.points[j].x < minNonZeroX && series.points[j].x !== 0)
244
- minNonZeroX = series.points[j].x;
245
- if (series.points[j].x > maxNonZeroX && series.points[j].x !== 0)
246
- maxNonZeroX = series.points[j].x;
247
- if (!uniqueArr.includes(series.points[j].x)) {
248
- uniqueArr[uniqueArr.length] = series.points[j].x;
249
- countOfDistNonZeroX++;
54
+ for (let k = 0; k <= SAMPLES; k++) {
55
+ const t = k / SAMPLES;
56
+ const x = logX ? bounds.minX * Math.pow(bounds.maxX / bounds.minX, t) : bounds.minX + bounds.width * t;
57
+ const raw = curve(logX ? Math.log10(x) : x);
58
+ const y = logY ? Math.pow(10, raw) : raw;
59
+ if (isFinite(y)) {
60
+ min = Math.min(min, y);
61
+ max = Math.max(max, y);
250
62
  }
251
63
  }
252
- const zeroSubstitute = Math.pow(10, Math.log10(minNonZeroX) - (Math.log10(maxNonZeroX) - Math.log10(minNonZeroX) / (countOfDistNonZeroX - 1)));
253
- for (let j = 0; j < series.points.length; j++) {
254
- if (series.points[j].x === 0)
255
- series.points[j].x = zeroSubstitute;
256
- }
257
64
  }
258
- }
259
-
260
- export function setOutlier(gridCell: DG.GridCell, p: IFitPoint, seriesIdx: number, pointIdx: number, _data?: IFitChartData) {
261
- p.outlier = !p.outlier;
262
- // outlier toggling works only for native JSON format (no converter)
263
- if (isNativeFormat(gridCell.cell.column)) {
264
- const gridCellValue = JSON.parse(gridCell.cell.value) as IFitChartData;
265
- gridCellValue.series![seriesIdx].points[pointIdx].outlier = p.outlier;
266
- gridCell.cell.column.set(gridCell.cell.rowIndex, JSON.stringify(gridCellValue), true);
267
- grok.events.fireCustomEvent('fit-cell-outlier-toggle', {
268
- gridCell: gridCell,
269
- series: gridCellValue.series![seriesIdx],
270
- seriesIdx: seriesIdx,
271
- pointIdx: pointIdx,
272
- });
273
- // const g = gridCell.grid.canvas.getContext('2d')!;
274
- // gridCell.render({context: g, bounds: gridCell.bounds});
275
- }
276
- const columns = gridCell.grid.dataFrame.columns.byTags({'.sourceColumn': gridCell.cell.column.name});
277
- if (columns) {
278
- _data ??= getOrCreateParsedChartData(gridCell.cell);
279
- for (const column of columns) {
280
- const chartLogOptions: LogOptions = {logX: _data.chartOptions?.logX, logY: _data.chartOptions?.logY};
281
- const stats = column.tags['.seriesAggregation'] !== null ?
282
- getChartDataAggrStats(_data, column.tags['.seriesAggregation'], gridCell.cell) :
283
- column.tags['.seriesNumber'] === seriesIdx.toString() ? calculateSeriesStats(_data.series![seriesIdx], seriesIdx, chartLogOptions, gridCell.cell) : null;
284
- if (stats === null)
285
- continue;
286
- column.set(gridCell.cell.rowIndex, stats[column.tags['.statistics'] as unknown as keyof FitStatistics]);
287
- }
65
+ // a bound the user set is the area they asked for, so a curve outside it stays cut
66
+ if (options?.minY != null)
67
+ min = bounds.minY;
68
+ if (options?.maxY != null)
69
+ max = bounds.maxY;
70
+ if (min >= bounds.minY && max <= bounds.maxY)
71
+ return bounds;
72
+ // worth showing whole while it stays near its data; one that runs away is left cut instead
73
+ if (logY && bounds.minY > 0) {
74
+ const room = (Math.log10(bounds.maxY) - Math.log10(bounds.minY)) * CURVE_HEADROOM;
75
+ min = Math.max(min, Math.pow(10, Math.log10(bounds.minY) - room));
76
+ max = Math.min(max, Math.pow(10, Math.log10(bounds.maxY) + room));
77
+ } else {
78
+ min = Math.max(min, bounds.minY - bounds.height * CURVE_HEADROOM);
79
+ max = Math.min(max, bounds.maxY + bounds.height * CURVE_HEADROOM);
288
80
  }
81
+ if (min >= bounds.minY && max <= bounds.maxY)
82
+ return bounds;
83
+ const span = max - min;
84
+ const bottom = min < bounds.minY ? (logY && min > 0 ? min / 1.05 : min - span * 0.05) : bounds.minY;
85
+ const top = max > bounds.maxY ? (logY ? max * 1.05 : max + span * 0.05) : bounds.maxY;
86
+ return new DG.Rect(bounds.x, bottom, bounds.width, top - bottom);
289
87
  }
290
88
 
291
- export function inspectCurve(gridCell: DG.GridCell, size?: Partial<DG.Size>, rerenderOnChange: boolean = false): void {
292
- if (!gridCell.cell.value)
293
- return;
294
-
295
- const gridCellWidget = DG.GridCellWidget.fromGridCell(gridCell);
296
- gridCellWidget.root.style.removeProperty('aspectRatio');
297
- gridCellWidget.root.style.height = '100%';
298
- gridCellWidget.canvas.style.removeProperty('height');
299
- gridCellWidget.canvas.style.removeProperty('width');
300
- gridCellWidget.canvas.style.left = '18px';
301
- gridCellWidget.canvas.style.top = '18px';
302
-
303
- const dlg = ui.dialog({title: 'Edit chart'})
304
- .add(gridCellWidget.root)
305
- .show({resizable: true, width: size?.width ?? 500, height: size?.height ?? 430});
306
- dlg.getButton('CANCEL').textContent = 'Close';
307
- if (rerenderOnChange)
308
- dlg.sub(merge(gridCell.grid.dataFrame.onDataChanged, gridCell.grid.dataFrame.onMetadataChanged).subscribe(() => gridCellWidget.render()));
89
+ function showIncorrectFitCell(g: CanvasRenderingContext2D, screenBounds: DG.Rect): void {
90
+ DG.Paint.marker(g, DG.MARKER_TYPE.OUTLIER, screenBounds.midX, screenBounds.midY, DG.Color.red,
91
+ clamp(Math.min(screenBounds.width, screenBounds.height) * 0.8, 0, 30));
309
92
  }
310
93
 
94
+
311
95
  @grok.decorators.cellRenderer({
312
96
  name: 'Fit',
313
97
  cellType: 'fit',
@@ -326,50 +110,17 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
326
110
  return {width: FitConstants.CELL_DEFAULT_WIDTH, height: FitConstants.CELL_DEFAULT_HEIGHT};
327
111
  }
328
112
 
329
- static fittedCurves: DG.LruCache<string, FitCurve> = new DG.LruCache<string, FitCurve>(1000);
330
- static parsedCurves: DG.LruCache<string, IFitChartData> = new DG.LruCache<string, IFitChartData>(1000);
331
- static curvesDataPoints: DG.LruCache<string, {x: number[], y: number[]}> = new DG.LruCache<string, {x: number[], y: number[]}>(2000);
113
+ // kept as aliases of the shared caches - these are public surface
114
+ static fittedCurves = fittedCurves;
115
+ static parsedCurves = parsedCurves;
116
+ static curvesDataPoints = curvesDataPoints;
332
117
 
333
118
  static inflateScreenBounds(rect: DG.Rect): DG.Rect {
334
- return rect.inflate(rect.width < FitConstants.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH ? FitConstants.MIN_INFLATE_SIZE : FitConstants.INFLATE_SIZE,
335
- rect.height < FitConstants.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT ? FitConstants.MIN_INFLATE_SIZE : FitConstants.INFLATE_SIZE);
119
+ return inflateScreenBounds(rect);
336
120
  }
337
121
 
338
122
  onClick(gridCell: DG.GridCell, e: MouseEvent): void {
339
- if (!gridCell.cell.value || !gridCell.cell.column)
340
- return;
341
-
342
- const data = getOrCreateParsedChartData(gridCell.cell, false);
343
-
344
- for (const [message, condition] of Object.entries(FitConstants.CONDITION_MAP)) {
345
- if (condition(data.series)) {
346
- grok.shell.o = ui.divText(message, {style: {color: 'red'}});
347
- return;
348
- }
349
- }
350
-
351
- grok.shell.o = gridCell;
352
-
353
- const screenBounds = FitChartCellRenderer.inflateScreenBounds(gridCell.bounds);
354
- const dataBox = layoutChart(screenBounds, this.areAxesLabelsShown(screenBounds, data),
355
- this.isTitleShown(screenBounds, data))[0];
356
- const dataBounds = getChartBounds(data);
357
- const viewport = new Viewport(dataBounds, dataBox, data.chartOptions?.logX ?? false, data.chartOptions?.logY ?? false);
358
-
359
- for (let i = 0; i < data.series?.length!; i++) {
360
- if (data.series![i].connectDots || !data.series![i].clickToToggle || data.series![i].showPoints !== 'points' ||
361
- screenBounds.width < FitConstants.MIN_AXES_CELL_PX_WIDTH || screenBounds.height < FitConstants.MIN_AXES_CELL_PX_HEIGHT)
362
- continue;
363
- for (let j = 0; j < data.series![i].points.length!; j++) {
364
- const p = data.series![i].points[j];
365
- if (p.outlier && !data.series![i].showOutliers)
366
- continue;
367
- if (this.hitTest(e, p, viewport)) {
368
- setOutlier(gridCell, p, i, j, data);
369
- return;
370
- }
371
- }
372
- }
123
+ handleClick(gridCell, e);
373
124
  }
374
125
 
375
126
  onDoubleClick(gridCell: DG.GridCell, _e: MouseEvent): void {
@@ -378,106 +129,153 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
378
129
  _e.stopPropagation();
379
130
  }
380
131
 
381
- areAxesShown(screenBounds: DG.Rect): boolean {
382
- return screenBounds.width >= FitConstants.MIN_AXES_CELL_PX_WIDTH && screenBounds.height >= FitConstants.MIN_AXES_CELL_PX_HEIGHT;
383
- }
384
-
385
- areAxesLabelsShown(screenBounds: DG.Rect, data: IFitChartData): boolean {
386
- // TODO: make bigger sizes
387
- return screenBounds.width >= FitConstants.MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH &&
388
- screenBounds.height >= FitConstants.MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT && !!data.chartOptions?.xAxisName && !!data.chartOptions.yAxisName;
389
- }
390
-
391
- isTitleShown(screenBounds: DG.Rect, data: IFitChartData): boolean {
392
- return screenBounds.width >= FitConstants.MIN_TITLE_PX_WIDTH && screenBounds.height >= FitConstants.MIN_TITLE_PX_HEIGHT && !!data.chartOptions?.title;
393
- }
394
-
395
- isLegendShown(screenBounds: DG.Rect): boolean {
396
- return screenBounds.width >= FitConstants.MIN_LEGEND_PX_WIDTH && screenBounds.height >= FitConstants.MIN_LEGEND_PX_HEIGHT;
397
- }
398
-
399
- areDroplinesShown(screenBounds: DG.Rect): boolean {
400
- return screenBounds.width >= FitConstants.MIN_DROPLINES_VISIBILITY_PX_WIDTH && screenBounds.height >= FitConstants.MIN_DROPLINES_VISIBILITY_PX_HEIGHT;
132
+ onMouseMove(gridCell: DG.GridCell, e: MouseEvent): void {
133
+ handleMouseMove(gridCell, e, this);
401
134
  }
402
135
 
403
- renderCurves(g: CanvasRenderingContext2D, screenBounds: DG.Rect, data: IFitChartData, gridCell?: DG.GridCell): void {
136
+ /** [fitIdentities] key the fits for a caller with no grid cell; only here are the log options final. */
137
+ renderCurves(g: CanvasRenderingContext2D, screenBounds: DG.Rect, data: IFitChartData, gridCell?: DG.GridCell,
138
+ fitIdentities?: (string | undefined)[]): void {
404
139
  g.save();
405
140
  g.beginPath();
406
141
  g.rect(screenBounds.x, screenBounds.y, screenBounds.width, screenBounds.height);
407
142
  g.clip();
408
143
 
409
144
  const isRenderedOnGrid = gridCell?.grid && gridCell?.grid.dart && g.canvas === gridCell?.grid?.canvas; // only use cache for grid, because there is no guarantee that rowIdx will be correct for other places
145
+ // a merged series is fitted at index 0, the key real series 0 uses
146
+ const useFitCache = isRenderedOnGrid && !data.chartOptions?.mergeSeries;
410
147
  const tableCell = gridCell?.cell;
411
148
  if (data.chartOptions?.allowXZeroes && data.chartOptions?.logX &&
412
149
  data.series?.some((series) => series.points.some((p) => p.x === 0)))
413
150
  substituteZeroes(data);
151
+ const axesNames = shownAxesNames(screenBounds, data);
414
152
  const [dataBox, xAxisBox, yAxisBox] = layoutChart(screenBounds,
415
- this.areAxesLabelsShown(screenBounds, data), this.isTitleShown(screenBounds, data));
153
+ axesNames.x, axesNames.y, isTitleShown(screenBounds, data));
416
154
 
417
- const dataBounds = getChartBounds(data);
155
+ let dataBounds = getChartBounds(data);
418
156
  if ((dataBounds.x < 0 && data.chartOptions) || (dataBounds.x === 0 && data.chartOptions && !data.chartOptions.allowXZeroes))
419
157
  data.chartOptions.logX = false;
420
158
  if (dataBounds.y <= 0 && data.chartOptions)
421
159
  data.chartOptions.logY = false;
422
- const viewport = new Viewport(dataBounds, dataBox, data.chartOptions?.logX ?? false, data.chartOptions?.logY ?? false);
423
- const minSize = Math.min(dataBox.width, dataBox.height);
424
- // TODO: make thinner
425
- const ratio = minSize > 100 ? 1 : 0.2 + (minSize / 100) * 0.8;
426
160
  const chartLogOptions: LogOptions = {logX: data.chartOptions?.logX, logY: data.chartOptions?.logY};
427
-
428
- g.save();
429
- g.font = '11px Roboto, "Roboto Local"';
430
- viewport.drawCoordinateGrid(g, xAxisBox, yAxisBox);
431
- g.restore();
432
-
161
+ // fitted before the plot is scaled, so that a curve sitting above every point is still in view
162
+ const fits: ({fitFunc: FitFunction, curve: ((x: number) => number) | null, fitSpaceSeries: IFitSeries,
163
+ userParamsFlag: boolean} | null)[] = [];
433
164
  for (let i = 0; i < data.series?.length!; i++) {
434
165
  const series = data.series![i];
435
- const containsParams = series.parameters && series.parameters.length > 0;
436
- if (series.points.some((point) => point.x === undefined || point.y === undefined) || series.points.length <= 1)
166
+ if (series.points.some((point) => point.x === undefined || point.y === undefined) || series.points.length <= 1) {
167
+ fits.push(null);
437
168
  continue;
169
+ }
438
170
  series.points.sort((a, b) => a.x - b.x);
439
-
440
- let userParamsFlag = true;
441
171
  const fitFunc = getSeriesFitFunction(series);
442
172
  let curve: ((x: number) => number) | null = null;
443
- if (!(series.connectDots && !series.showFitLine)) {
173
+ // everything downstream needs fit-space parameters; the cached series keeps its data-space ones
174
+ let fitSpaceSeries = series;
175
+ let userParamsFlag = true;
176
+ if (!(series.connectDots && !(series.showFitLine ?? true))) {
444
177
  if (series.parameters) {
445
- if (data.chartOptions?.logX) {
446
- if (series.parameters[2] > 0) // check if sigmoid, then log
447
- series.parameters[2] = Math.log10(series.parameters[2]);
448
- }
449
- curve = getCurve(series, fitFunc);
178
+ fitSpaceSeries = seriesInFitSpace(series, chartLogOptions);
179
+ curve = getCurve(fitSpaceSeries, fitFunc);
450
180
  } else {
451
- const fitResult = getOrCreateCachedFitCurve(series, i, fitFunc, chartLogOptions, tableCell, isRenderedOnGrid);
181
+ const fitResult = getOrCreateCachedFitCurve(series, i, fitFunc, chartLogOptions, tableCell, useFitCache,
182
+ fitIdentities?.[i]);
452
183
  curve = fitResult.fittedCurve;
453
- const params = [...fitResult.parameters];
454
- series.parameters = params;
184
+ fitSpaceSeries = {...series, parameters: [...fitResult.parameters]};
455
185
  userParamsFlag = false;
456
186
  }
457
187
  }
188
+ fits.push({fitFunc, curve, fitSpaceSeries, userParamsFlag});
189
+ }
190
+ // only a curve that levels off at both ends: an unbounded one is an exponent under a log axis,
191
+ // so fitting the plot around it would bury the data
192
+ dataBounds = withCurvesInView(dataBounds,
193
+ fits.map((fit) => fit?.fitFunc.hasAsymptotes ? fit.curve : null), data.chartOptions);
458
194
 
459
- renderFitLine(g, series, {viewport, ratio, logOptions: chartLogOptions, showAxes: this.areAxesShown(screenBounds),
460
- showAxesLabels: this.areAxesLabelsShown(screenBounds, data), screenBounds, curveFunc: curve!, seriesIdx: i});
195
+ const viewport = new Viewport(dataBounds, dataBox, data.chartOptions?.logX ?? false, data.chartOptions?.logY ?? false);
196
+ const minSize = Math.min(dataBox.width, dataBox.height);
197
+ // TODO: make thinner
198
+ const ratio = minSize > 100 ? 1 : 0.2 + (minSize / 100) * 0.8;
199
+ // where the curves and points land, so the legend can take a corner they leave free
200
+ const drawnAt = isLegendVisible(data, screenBounds) ? [] as DG.Point[] : undefined;
201
+
202
+ g.save();
203
+ g.font = '11px Roboto, "Roboto Local"';
204
+ viewport.drawCoordinateGrid(g, xAxisBox, yAxisBox);
205
+ g.restore();
206
+
207
+ // statistics and labels of every series share one column, so each continues below the previous.
208
+ // Plot-level labels come first and once, since they describe the cell rather than any one curve
209
+ let statisticsLine = renderLabels(g, data.chartOptions?.labels, {names: data.chartOptions?.showLabels,
210
+ color: FitConstants.PLOT_LABEL_COLOR, dataBox, screenBounds, startLine: 0, drawnAt});
211
+
212
+ // with a single series the aggregate is just that series' own value, so the mode only applies to
213
+ // a cell holding several curves
214
+ const mode = (data.series?.length ?? 0) > 1 ? data.chartOptions?.statisticsMode ?? 'series' : 'series';
215
+ const statistics = data.chartOptions?.showStatistics;
216
+ if (statistics?.length && mode !== 'series') {
217
+ const aggrType = data.chartOptions?.aggrType ?? 'med';
218
+ const stats = getChartDataAggrStats(data, aggrType, tableCell);
219
+ const summarised = Object.fromEntries(statistics.map((name) => [`${aggrType} ${name}`, stats[name]]));
220
+ statisticsLine += renderLabels(g, summarised as {[key: string]: number}, {names: Object.keys(summarised),
221
+ color: FitConstants.PLOT_LABEL_COLOR, dataBox, screenBounds, startLine: statisticsLine, drawnAt});
222
+ }
223
+ for (let i = 0; i < data.series?.length!; i++) {
224
+ const series = data.series![i];
225
+ const fit = fits[i];
226
+ if (!fit)
227
+ continue;
228
+ const {fitFunc, curve, fitSpaceSeries, userParamsFlag} = fit;
229
+ const pointHalfSize = FitConstants.POINT_PX_SIZE * ratio / 2;
230
+ // so that extreme points are not cut
231
+ const pfDataBox = dataBox.inflate(pointHalfSize, pointHalfSize);
232
+ // a bound narrows the plot, and what falls outside it is out of view rather than out of bounds
233
+ g.save();
234
+ g.beginPath();
235
+ g.rect(pfDataBox.x, pfDataBox.y, pfDataBox.width, pfDataBox.height);
236
+ g.clip();
237
+ renderFitLine(g, series, {viewport, ratio, logOptions: chartLogOptions, showAxes: areAxesShown(screenBounds),
238
+ showAxesLabels: areAxesLabelsShown(screenBounds, data), screenBounds, curveFunc: curve!, seriesIdx: i, drawnAt});
461
239
  renderConnectDots(g, series, {viewport, ratio, seriesIdx: i});
462
240
  renderPoints(g, series, {viewport, ratio, screenBounds, seriesIdx: i});
463
- renderConfidenceIntervals(g, series, {viewport, logOptions: chartLogOptions, showAxes: this.areAxesShown(screenBounds),
464
- showAxesLabels: this.areAxesLabelsShown(screenBounds, data), screenBounds, fitFunc, userParamsFlag,
465
- dataPoints: getOrCreateCachedCurvesDataPoints(series, i, chartLogOptions, userParamsFlag, tableCell, isRenderedOnGrid)});
466
- if (series.parameters) {
467
- renderDroplines(g, series, {viewport, ratio, showDroplines: this.areDroplinesShown(screenBounds),
468
- xValue: series.parameters![2], dataBounds, curveFunc: curve!, logOptions: chartLogOptions});
241
+ // the points and the path they trace, however they are drawn - markers, candlesticks or
242
+ // connected dots. Sampled like a fit line, so a series is not mistaken for a free corner
243
+ if (drawnAt) {
244
+ let previous: DG.Point | null = null;
245
+ for (const point of series.points) {
246
+ if (point.outlier && !(series.showOutliers ?? true))
247
+ continue;
248
+ const at = new DG.Point(viewport.xToScreen(point.x), viewport.yToScreen(point.y));
249
+ drawnAt.push(at);
250
+ if (previous) {
251
+ const steps = Math.floor(Math.abs(at.x - previous.x) / CURVE_SAMPLE_PX_STEP);
252
+ for (let step = 1; step < steps; step++) {
253
+ drawnAt.push(new DG.Point(previous.x + (at.x - previous.x) * step / steps,
254
+ previous.y + (at.y - previous.y) * step / steps));
255
+ }
256
+ }
257
+ previous = at;
258
+ }
469
259
  }
470
- renderStatistics(g, series, {statistics: data.chartOptions?.showStatistics, fitFunc,
471
- logOptions: chartLogOptions, dataBox, screenBounds, seriesIdx: i});
472
- if (!containsParams)
473
- delete series.parameters;
260
+ renderConfidenceIntervals(g, fitSpaceSeries, {viewport, logOptions: chartLogOptions, showAxes: areAxesShown(screenBounds),
261
+ showAxesLabels: areAxesLabelsShown(screenBounds, data), screenBounds, fitFunc, userParamsFlag, drawnAt,
262
+ dataPoints: getOrCreateCachedCurvesDataPoints(series, i, chartLogOptions, userParamsFlag, tableCell, useFitCache)});
263
+ renderDroplines(g, fitSpaceSeries, {viewport, ratio, showDroplines: areDroplinesShown(screenBounds),
264
+ showDroplineLabels: areDroplineLabelsShown(screenBounds), fitFunc, dataBounds, curveFunc: curve!,
265
+ logOptions: chartLogOptions, drawnAt});
266
+ g.restore();
267
+ statisticsLine += renderStatistics(g, fitSpaceSeries, {statistics: mode === 'aggregated' ? [] : statistics, fitFunc,
268
+ logOptions: chartLogOptions, dataBox, screenBounds, seriesIdx: i, startLine: statisticsLine, drawnAt});
269
+ statisticsLine += renderLabels(g, series.labels, {names: data.chartOptions?.showLabels,
270
+ color: getSeriesColor(series, i, ColorType.FIT_LINE), dataBox, screenBounds, startLine: statisticsLine, drawnAt});
474
271
  }
475
272
 
476
- renderTitle(g, {showTitle: this.isTitleShown(screenBounds, data), title: data.chartOptions?.title, dataBox, screenBounds});
477
- renderAxesLabels(g, {showTitle: this.isTitleShown(screenBounds, data), dataBox, screenBounds,
478
- showAxesLabels: this.areAxesLabelsShown(screenBounds, data), xAxisName: data.chartOptions?.xAxisName,
273
+ renderTitle(g, {showTitle: isTitleShown(screenBounds, data), title: data.chartOptions?.title, dataBox, screenBounds});
274
+ renderAxesLabels(g, {showTitle: isTitleShown(screenBounds, data), dataBox, screenBounds,
275
+ showAxesLabels: areAxesLabelsShown(screenBounds, data), xAxisName: data.chartOptions?.xAxisName,
479
276
  yAxisName: data.chartOptions?.yAxisName});
480
- renderLegend(g, data, {showLegend: this.isLegendShown(screenBounds), dataBox, ratio});
277
+ if (drawnAt)
278
+ renderLegend(g, data, dataBox, ratio, drawnAt);
481
279
 
482
280
  g.restore();
483
281
  }
@@ -493,7 +291,7 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
493
291
  return;
494
292
 
495
293
  const isRenderedOnGrid = gridCell?.grid && gridCell?.grid.dart && g.canvas === gridCell?.grid?.canvas; // only use cache for grid, because there is no guarantee that rowIdx will be correct for other places
496
- const data = getOrCreateParsedChartData(gridCell.cell, isRenderedOnGrid);
294
+ let data = getOrCreateParsedChartData(gridCell.cell, isRenderedOnGrid);
497
295
  const screenBounds = FitChartCellRenderer.inflateScreenBounds(new DG.Rect(x, y, w, h));
498
296
 
499
297
  for (const [_message, condition] of Object.entries(FitConstants.CONDITION_MAP)) {
@@ -505,98 +303,11 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
505
303
 
506
304
  if (gridCell.cell.column?.name)
507
305
  data.series?.forEach((series) => series.columnName = gridCell.cell.column.name);
306
+ // on a copy: this chart data is cached and shared with the statistics
508
307
  if (data.chartOptions?.mergeSeries)
509
- data.series = [mergeSeries(data.series!)!];
308
+ data = {...data, series: [mergeSeries(data.series!)!]};
510
309
 
511
310
  g.clearRect(screenBounds.x, screenBounds.y, screenBounds.width, screenBounds.height);
512
311
  this.renderCurves(g, screenBounds, data, gridCell);
513
312
  }
514
-
515
- hitTest(e: MouseEvent, point: IFitPoint, viewport: Viewport): boolean {
516
- const screenX = viewport.xToScreen(point.x);
517
- const screenY = viewport.yToScreen(point.y);
518
- const pxPerMarkerType = ((point.outlier ? FitConstants.OUTLIER_PX_SIZE : FitConstants.POINT_PX_SIZE) / 2) + FitConstants.OUTLIER_HITBOX_RADIUS;
519
- const pointRect = new DG.Rect(screenX - pxPerMarkerType, screenY - pxPerMarkerType,
520
- 2 * pxPerMarkerType, 2 * pxPerMarkerType);
521
- return pointRect.containsPoint(new DG.Point(e.offsetX, e.offsetY));
522
- }
523
-
524
- onMouseMove(gridCell: DG.GridCell, e: MouseEvent): void {
525
- if (!gridCell?.cell?.value)
526
- return;
527
-
528
- const screenBounds = FitChartCellRenderer.inflateScreenBounds(gridCell.bounds);
529
- if (screenBounds.width < FitConstants.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH ||
530
- screenBounds.height < FitConstants.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT) {
531
- const canvas = ui.canvas(300, 200);
532
- this.render(canvas.getContext('2d')!, 0, 0, 300, 200, gridCell, null as any);
533
- const content = ui.divV([canvas]);
534
- ui.tooltip.show(content, e.x, e.y);
535
- }
536
-
537
- const data = getOrCreateParsedChartData(gridCell?.cell);
538
-
539
- if (screenBounds.width >= FitConstants.MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH &&
540
- screenBounds.height >= FitConstants.MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT) {
541
- const dataBox = layoutChart(screenBounds, this.areAxesLabelsShown(screenBounds, data), this.isTitleShown(screenBounds, data))[0];
542
- const dataBounds = getChartBounds(data);
543
- const viewport = new Viewport(dataBounds, dataBox, data.chartOptions?.logX ?? false, data.chartOptions?.logY ?? false);
544
-
545
- for (let i = 0; i < data.series?.length!; i++) {
546
- if (data.series![i].showPoints !== 'points')
547
- continue;
548
- for (let j = 0; j < data.series![i].points.length!; j++) {
549
- const p = data.series![i].points[j];
550
- if (p.outlier && !data.series![i].showOutliers)
551
- continue;
552
- if (this.hitTest(e, p, viewport)) {
553
- ui.tooltip.show(ui.divV([ui.divText(`${data.chartOptions?.xAxisName ?? 'x'}: ${DG.format(p.x, !data.chartOptions?.logX ? '#0.000' : 'scientific')}`),
554
- ui.divText(`${data.chartOptions?.yAxisName ?? 'y'}: ${DG.format(p.y, !data.chartOptions?.logY ? '#0.000' : 'scientific')}`)]), e.x + 16, e.y + 16);
555
- if (!data.series![i].connectDots && data.series![i].clickToToggle && screenBounds.width >= FitConstants.MIN_AXES_CELL_PX_WIDTH &&
556
- screenBounds.height >= FitConstants.MIN_AXES_CELL_PX_HEIGHT)
557
- document.body.style.cursor = 'pointer';
558
- return;
559
- }
560
- }
561
- }
562
- ui.tooltip.hide();
563
- }
564
- document.body.style.cursor = 'default';
565
- }
566
313
  }
567
-
568
- const _sample: IFitChartData = {
569
- // chartOptions could be retrieved either from the column, or from the cell
570
- 'chartOptions': {
571
- 'minX': 0, 'minY': 0, 'maxX': 5, 'maxY': 10,
572
- 'xAxisName': 'concentration',
573
- 'yAxisName': 'activity',
574
- 'logX': false,
575
- 'logY': false,
576
- },
577
- // These options are used as default options for the series. They could be overridden in series.
578
- 'seriesOptions': {
579
- 'fitFunction': 'sigmoid',
580
- // parameters not specified -> auto-fitting by default
581
- 'pointColor': 'blue',
582
- 'fitLineColor': 'red',
583
- 'clickToToggle': true,
584
- 'showPoints': 'points',
585
- 'showFitLine': true,
586
- 'showCurveConfidenceInterval': true,
587
- },
588
- 'series': [
589
- {
590
- 'fitFunction': 'sigmoid',
591
- // parameters specified -> use them, no autofitting
592
- 'parameters': [1.86011e-07, -0.900, 103.748, -0.001],
593
- 'points': [
594
- {'x': 0, 'y': 0},
595
- {'x': 1, 'y': 0.5},
596
- {'x': 2, 'y': 1},
597
- {'x': 3, 'y': 10, 'outlier': true},
598
- {'x': 4, 'y': 0},
599
- ],
600
- },
601
- ],
602
- };