@datagrok/curves 1.2.8 → 1.2.9
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/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +1 -1
- package/src/fit/fit-grid-cell-handler.ts +168 -29
- package/src/fit/fit-renderer.ts +24 -6
- package/src/package.ts +5 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/curves",
|
|
3
3
|
"friendlyName": "Curves",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.9",
|
|
5
5
|
"description": "Curves provides support for fitted curves (such as dose-response curves), including in-grid rendering, storing charts in cells, interactivity, and automatic fitting.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Dmytro Kovalyov",
|
|
@@ -7,15 +7,17 @@ import {
|
|
|
7
7
|
getSeriesStatistics,
|
|
8
8
|
getSeriesFitFunction,
|
|
9
9
|
getDataFrameChartOptions,
|
|
10
|
+
LogOptions,
|
|
10
11
|
} from '@datagrok-libraries/statistics/src/fit/fit-data';
|
|
11
|
-
import {statisticsProperties, fitSeriesProperties, fitChartDataProperties, FIT_CELL_TYPE, TAG_FIT, IFitChartData, IFitSeries, IFitChartOptions, FIT_SEM_TYPE, IFitSeriesOptions} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
12
|
-
import {TAG_FIT_CHART_FORMAT, TAG_FIT_CHART_FORMAT_3DX, getChartData, mergeProperties} from './fit-renderer';
|
|
13
|
-
import {
|
|
12
|
+
import {statisticsProperties, fitSeriesProperties, fitChartDataProperties, FIT_CELL_TYPE, TAG_FIT, IFitChartData, IFitSeries, IFitChartOptions, FIT_SEM_TYPE, IFitSeriesOptions, FitStatistics} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
13
|
+
import {TAG_FIT_CHART_FORMAT, TAG_FIT_CHART_FORMAT_3DX, getChartData, isColorValid, mergeProperties} from './fit-renderer';
|
|
14
|
+
import {CellRenderViewer} from './cell-render-viewer';
|
|
14
15
|
import {convertXMLToIFitChartData} from './fit-parser';
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
const SOURCE_COLUMN_TAG = '.sourceColumn';
|
|
18
19
|
const SERIES_NUMBER_TAG = '.seriesNumber';
|
|
20
|
+
const SERIES_AGGREGATION_TAG = '.seriesAggregation';
|
|
19
21
|
const STATISTICS_TAG = '.statistics';
|
|
20
22
|
const CHART_OPTIONS = 'chartOptions';
|
|
21
23
|
const SERIES_OPTIONS = 'seriesOptions';
|
|
@@ -24,23 +26,109 @@ enum MANIPULATION_LEVEL {
|
|
|
24
26
|
COLUMN = 'Column',
|
|
25
27
|
CELL = 'Cell'
|
|
26
28
|
};
|
|
29
|
+
const AGGREGATION_TYPES: {[key: string]: string} = {
|
|
30
|
+
'count': 'totalCount',
|
|
31
|
+
'nulls': 'missingValueCount',
|
|
32
|
+
'unique': 'uniqueCount',
|
|
33
|
+
'values': 'valueCount',
|
|
34
|
+
'min': 'min',
|
|
35
|
+
'max': 'max',
|
|
36
|
+
'sum': 'sum',
|
|
37
|
+
'avg': 'avg',
|
|
38
|
+
'stdev': 'stdev',
|
|
39
|
+
'variance': 'variance',
|
|
40
|
+
'skew': 'skew',
|
|
41
|
+
'kurt': 'kurt',
|
|
42
|
+
'med': 'med',
|
|
43
|
+
'q1': 'q1',
|
|
44
|
+
'q2': 'q2',
|
|
45
|
+
'q3': 'q3'
|
|
46
|
+
};
|
|
47
|
+
|
|
27
48
|
|
|
49
|
+
export function calculateSeriesStats(series: IFitSeries, chartLogOptions: LogOptions): FitStatistics {
|
|
50
|
+
const fitFunction = getSeriesFitFunction(series);
|
|
51
|
+
if (series.parameters) {
|
|
52
|
+
if (chartLogOptions.logX)
|
|
53
|
+
if (series.parameters[2] > 0)
|
|
54
|
+
series.parameters[2] = Math.log10(series.parameters[2]);
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
series.parameters = fitSeries(series, fitFunction, chartLogOptions).parameters;
|
|
58
|
+
|
|
59
|
+
const seriesStatistics = getSeriesStatistics(series, fitFunction);
|
|
60
|
+
return seriesStatistics;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getChartDataAggrStats(chartData: IFitChartData, aggrType: string): FitStatistics {
|
|
64
|
+
const chartLogOptions: LogOptions = {logX: chartData.chartOptions?.logX, logY: chartData.chartOptions?.logY};
|
|
65
|
+
const rSquaredValues: number[] = [], aucValues: number[] = [], interceptXValues: number[] = [], interceptYValues: number[] = [],
|
|
66
|
+
slopeValues: number[] = [], topValues: number[] = [], bottomValues: number[] = [];
|
|
67
|
+
for (let i = 0; i < chartData.series?.length!; i++) {
|
|
68
|
+
const seriesStats = calculateSeriesStats(chartData.series![i], chartLogOptions);
|
|
69
|
+
rSquaredValues[i] = seriesStats.rSquared!;
|
|
70
|
+
aucValues[i] = seriesStats.auc!;
|
|
71
|
+
interceptXValues[i] = seriesStats.interceptX;
|
|
72
|
+
interceptYValues[i] = seriesStats.interceptY;
|
|
73
|
+
slopeValues[i] = seriesStats.slope;
|
|
74
|
+
topValues[i] = seriesStats.top!;
|
|
75
|
+
bottomValues[i] = seriesStats.bottom!;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
rSquared: DG.Column.fromList(DG.COLUMN_TYPE.FLOAT, 'rSquared', rSquaredValues).stats[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
80
|
+
auc: DG.Column.fromList(DG.COLUMN_TYPE.FLOAT, 'auc', aucValues).stats[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
81
|
+
interceptX: DG.Column.fromList(DG.COLUMN_TYPE.FLOAT, 'interceptX', interceptXValues).stats[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
82
|
+
interceptY: DG.Column.fromList(DG.COLUMN_TYPE.FLOAT, 'interceptY', interceptYValues).stats[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
83
|
+
slope: DG.Column.fromList(DG.COLUMN_TYPE.FLOAT, 'slope', slopeValues).stats[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
84
|
+
top: DG.Column.fromList(DG.COLUMN_TYPE.FLOAT, 'top', topValues).stats[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number,
|
|
85
|
+
bottom: DG.Column.fromList(DG.COLUMN_TYPE.FLOAT, 'bottom', bottomValues).stats[AGGREGATION_TYPES[aggrType] as keyof DG.Stats] as number
|
|
86
|
+
};
|
|
87
|
+
}
|
|
28
88
|
|
|
29
|
-
function addStatisticsColumn(chartColumn: DG.GridColumn, p: DG.Property, seriesNumber: number): void {
|
|
89
|
+
function addStatisticsColumn(chartColumn: DG.GridColumn, p: DG.Property, series: IFitSeries, seriesNumber: number): void {
|
|
30
90
|
const grid = chartColumn.grid;
|
|
31
|
-
const column = DG.Column.float(p.name
|
|
91
|
+
const column = DG.Column.float(`${chartColumn.name}_${series.name}_${p.name}`, chartColumn.column?.length);
|
|
32
92
|
column.tags[SOURCE_COLUMN_TAG] = chartColumn.name;
|
|
33
93
|
column.tags[SERIES_NUMBER_TAG] = seriesNumber;
|
|
34
94
|
column.tags[STATISTICS_TAG] = p.name;
|
|
35
95
|
|
|
96
|
+
// accordions for runs
|
|
97
|
+
// combobox - series -> all or aggregated, in all we have all the series, then combobox with aggr
|
|
36
98
|
column
|
|
37
99
|
.init((i) => {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
100
|
+
const gridCell = DG.GridCell.fromColumnRow(grid, chartColumn.name, grid.tableRowToGrid(i));
|
|
101
|
+
if (gridCell.cell.value === '')
|
|
102
|
+
return null;
|
|
103
|
+
const chartData = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX ?
|
|
104
|
+
convertXMLToIFitChartData(gridCell.cell.value) : getChartData(gridCell);
|
|
105
|
+
if (chartData.series![seriesNumber] === undefined)
|
|
106
|
+
return null;
|
|
107
|
+
const chartLogOptions: LogOptions = {logX: chartData.chartOptions?.logX, logY: chartData.chartOptions?.logY};
|
|
108
|
+
const fitResult = calculateSeriesStats(chartData.series![seriesNumber], chartLogOptions);
|
|
41
109
|
return p.get(fitResult);
|
|
42
110
|
});
|
|
43
|
-
grid.dataFrame.columns.
|
|
111
|
+
grid.dataFrame.columns.insert(column, chartColumn.idx);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function addAggrStatisticsColumn(chartColumn: DG.GridColumn, p: DG.Property, aggrType: string): void {
|
|
115
|
+
const grid = chartColumn.grid;
|
|
116
|
+
const column = DG.Column.float(`${chartColumn.name}_${aggrType}_${p.name}`, chartColumn.column?.length);
|
|
117
|
+
column.tags[SOURCE_COLUMN_TAG] = chartColumn.name;
|
|
118
|
+
column.tags[SERIES_AGGREGATION_TAG] = aggrType;
|
|
119
|
+
column.tags[STATISTICS_TAG] = p.name;
|
|
120
|
+
|
|
121
|
+
column
|
|
122
|
+
.init((i) => {
|
|
123
|
+
const gridCell = DG.GridCell.fromColumnRow(grid, chartColumn.name, grid.tableRowToGrid(i));
|
|
124
|
+
if (gridCell.cell.value === '')
|
|
125
|
+
return null;
|
|
126
|
+
const chartData = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX ?
|
|
127
|
+
convertXMLToIFitChartData(gridCell.cell.value) : getChartData(gridCell);
|
|
128
|
+
const fitResult = getChartDataAggrStats(chartData, aggrType);
|
|
129
|
+
return p.get(fitResult);
|
|
130
|
+
});
|
|
131
|
+
grid.dataFrame.columns.insert(column, chartColumn.idx);
|
|
44
132
|
}
|
|
45
133
|
|
|
46
134
|
function changePlotOptions(chartData: IFitChartData, inputBase: DG.InputBase, options: string): void {
|
|
@@ -158,6 +246,8 @@ function changeCurvesOptions(gridCell: DG.GridCell, inputBase: DG.InputBase, opt
|
|
|
158
246
|
delete series[propertyName as keyof IFitSeriesOptions];
|
|
159
247
|
isSeriesChanged = true;
|
|
160
248
|
}
|
|
249
|
+
if (chartData.seriesOptions)
|
|
250
|
+
delete chartData.seriesOptions[propertyName as keyof IFitSeriesOptions];
|
|
161
251
|
if (!isSeriesChanged) return value;
|
|
162
252
|
}
|
|
163
253
|
return JSON.stringify(chartData);
|
|
@@ -202,6 +292,28 @@ export class FitGridCellHandler extends DG.ObjectHandler {
|
|
|
202
292
|
const chartOptionsRefresh = {onValueChanged: (inputBase: DG.InputBase) =>
|
|
203
293
|
changeCurvesOptions(gridCell, inputBase, CHART_OPTIONS, switchLevelInput.value)};
|
|
204
294
|
|
|
295
|
+
if (!isColorValid(dfChartOptions.seriesOptions?.pointColor) && !isColorValid(columnChartOptions.seriesOptions?.pointColor)) {
|
|
296
|
+
if (chartData.seriesOptions) {
|
|
297
|
+
if (!isColorValid(chartData.seriesOptions.pointColor))
|
|
298
|
+
chartData.seriesOptions.pointColor = DG.Color.toHtml(DG.Color.getCategoricalColor(0));
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
if (!isColorValid(chartData.series ? chartData.series![0].pointColor : ''))
|
|
302
|
+
chartData.series![0].pointColor = DG.Color.toHtml(DG.Color.getCategoricalColor(0));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!isColorValid(dfChartOptions.seriesOptions?.fitLineColor) && !isColorValid(columnChartOptions.seriesOptions?.fitLineColor)) {
|
|
307
|
+
if (chartData.seriesOptions) {
|
|
308
|
+
if (!isColorValid(chartData.seriesOptions.fitLineColor))
|
|
309
|
+
chartData.seriesOptions.fitLineColor = DG.Color.toHtml(DG.Color.getCategoricalColor(0));
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
if (!isColorValid(chartData.series ? chartData.series![0].fitLineColor : ''))
|
|
313
|
+
chartData.series![0].fitLineColor = DG.Color.toHtml(DG.Color.getCategoricalColor(0));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
205
317
|
mergeProperties(fitSeriesProperties, columnChartOptions.seriesOptions, chartData.seriesOptions ? chartData.seriesOptions :
|
|
206
318
|
chartData.series ? chartData.series[0] ?? {} : {});
|
|
207
319
|
mergeProperties(fitSeriesProperties, dfChartOptions.seriesOptions, chartData.seriesOptions ? chartData.seriesOptions :
|
|
@@ -219,32 +331,59 @@ export class FitGridCellHandler extends DG.ObjectHandler {
|
|
|
219
331
|
ui.input.form(chartData.chartOptions, fitChartDataProperties, chartOptionsRefresh),
|
|
220
332
|
]));
|
|
221
333
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
334
|
+
const seriesStatsProperty = DG.Property.js('series', DG.TYPE.STRING,
|
|
335
|
+
{description: 'Controls whether to show series statistics or aggregated statistics',
|
|
336
|
+
defaultValue: 'All', choices: ['all', 'aggregated'], nullable: false});
|
|
337
|
+
const seriesStatsInput = ui.input.forProperty(seriesStatsProperty, null, {onValueChanged(input) {
|
|
338
|
+
acc.getPane('Fit').root.lastElementChild!.replaceChildren(createFitPane());
|
|
339
|
+
}});
|
|
340
|
+
const aggrTypeProperty = DG.Property.js('aggregation type', DG.TYPE.STRING,
|
|
341
|
+
{description: 'Controls which aggregation to use on the series statistics',
|
|
342
|
+
defaultValue: 'med', choices: Object.values(DG.STATS), nullable: false});
|
|
343
|
+
const aggrTypeInput = ui.input.forProperty(aggrTypeProperty, null, {onValueChanged(input) {
|
|
344
|
+
acc.getPane('Fit').root.lastElementChild!.replaceChildren(createFitPane());
|
|
345
|
+
}});
|
|
346
|
+
|
|
347
|
+
function createFitPane(): HTMLElement {
|
|
348
|
+
const host = ui.divV(seriesStatsInput.stringValue === 'aggregated' ? [seriesStatsInput.root, aggrTypeInput.root] : [seriesStatsInput.root]);
|
|
349
|
+
if (seriesStatsInput.stringValue === 'all') {
|
|
350
|
+
const chartLogOptions: LogOptions = {logX: chartData.chartOptions?.logX, logY: chartData.chartOptions?.logY};
|
|
351
|
+
for (let i = 0; i < chartData.series!.length; i++) {
|
|
352
|
+
const series = chartData.series![i];
|
|
353
|
+
const seriesStatistics = calculateSeriesStats(series, chartLogOptions);
|
|
354
|
+
|
|
355
|
+
const color = series.fitLineColor ? DG.Color.fromHtml(series.fitLineColor) ?
|
|
356
|
+
series.fitLineColor : DG.Color.toHtml(DG.Color.getCategoricalColor(i)) : DG.Color.toHtml(DG.Color.getCategoricalColor(i));
|
|
357
|
+
host.appendChild(ui.panel([
|
|
358
|
+
ui.h1(series.name ?? 'series ' + i, {style: {color: color}}),
|
|
359
|
+
ui.input.form(seriesStatistics, statisticsProperties, {
|
|
360
|
+
onCreated: (input) => input.root.appendChild(
|
|
361
|
+
ui.iconFA('plus', () => addStatisticsColumn(gridCell.gridColumn, input.property, series, i),
|
|
362
|
+
`Calculate ${input.property.name} for the whole column`))
|
|
363
|
+
})
|
|
364
|
+
]));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
const seriesStatistics = getChartDataAggrStats(chartData, aggrTypeInput.stringValue);
|
|
233
369
|
host.appendChild(ui.panel([
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
]));
|
|
370
|
+
ui.h1(`series ${aggrTypeInput.stringValue}`),
|
|
371
|
+
ui.input.form(seriesStatistics, statisticsProperties, {
|
|
372
|
+
onCreated: (input) => input.root.appendChild(
|
|
373
|
+
ui.iconFA('plus', () => addAggrStatisticsColumn(gridCell.gridColumn, input.property, aggrTypeInput.stringValue),
|
|
374
|
+
`Calculate ${input.property.name} for the whole column`))
|
|
375
|
+
})
|
|
376
|
+
]));
|
|
242
377
|
}
|
|
243
378
|
|
|
244
379
|
return host;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
acc.addPane('Fit', () => {
|
|
383
|
+
return createFitPane();
|
|
245
384
|
});
|
|
246
385
|
|
|
247
|
-
acc.addPane('Chart', () =>
|
|
386
|
+
acc.addPane('Chart', () => CellRenderViewer.fromGridCell(gridCell).root);
|
|
248
387
|
|
|
249
388
|
return acc.root;
|
|
250
389
|
}
|
package/src/fit/fit-renderer.ts
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
|
|
35
35
|
import {convertXMLToIFitChartData} from './fit-parser';
|
|
36
36
|
import {CellRenderViewer} from './cell-render-viewer';
|
|
37
|
+
import { calculateSeriesStats, getChartDataAggrStats } from './fit-grid-cell-handler';
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
export const TAG_FIT_CHART_FORMAT = '.fitChartFormat';
|
|
@@ -122,6 +123,13 @@ export function layoutChart(rect: DG.Rect, showAxesLabels: boolean, showTitle: b
|
|
|
122
123
|
];
|
|
123
124
|
}
|
|
124
125
|
|
|
126
|
+
/** Checks if the color is valid */
|
|
127
|
+
export function isColorValid(color: string | null | undefined): boolean {
|
|
128
|
+
if (color === undefined || color === null || color === '')
|
|
129
|
+
return false;
|
|
130
|
+
return DG.Color.fromHtml(color) !== undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
125
133
|
/** Performs candlestick border drawing */
|
|
126
134
|
function drawCandlestickBorder(g: CanvasRenderingContext2D, x: number, adjacentValue: number, transform: Viewport): void {
|
|
127
135
|
g.moveTo(transform.xToScreen(x) - (CANDLESTICK_BORDER_PX_SIZE / 2), transform.yToScreen(adjacentValue));
|
|
@@ -272,12 +280,15 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
272
280
|
if (!gridCell.cell.value)
|
|
273
281
|
return;
|
|
274
282
|
|
|
275
|
-
grok.shell.o = gridCell;
|
|
276
|
-
|
|
277
283
|
const data = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX
|
|
278
284
|
? convertXMLToIFitChartData(gridCell.cell.value)
|
|
279
285
|
: getChartData(gridCell);
|
|
280
286
|
|
|
287
|
+
if (data.series?.some((series) => series.points.length === 0))
|
|
288
|
+
return;
|
|
289
|
+
|
|
290
|
+
grok.shell.o = gridCell;
|
|
291
|
+
|
|
281
292
|
const screenBounds = gridCell.bounds.inflate(INFLATE_SIZE / 2, INFLATE_SIZE / 2);
|
|
282
293
|
const showAxesLabels = gridCell.bounds.width >= MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH && gridCell.bounds.height >= MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT;
|
|
283
294
|
const showTitle = gridCell.bounds.width >= MIN_TITLE_PX_WIDTH && gridCell.bounds.height >= MIN_TITLE_PX_HEIGHT;
|
|
@@ -297,14 +308,19 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
297
308
|
if (e.offsetX >= screenX - pxPerMarkerType && e.offsetX <= screenX + pxPerMarkerType &&
|
|
298
309
|
e.offsetY >= screenY - pxPerMarkerType && e.offsetY <= screenY + pxPerMarkerType) {
|
|
299
310
|
p.outlier = !p.outlier;
|
|
300
|
-
const columns = gridCell.grid.dataFrame.columns.byTags({'.sourceColumn':
|
|
301
|
-
gridCell.cell.column.name, '.seriesNumber': i});
|
|
311
|
+
const columns = gridCell.grid.dataFrame.columns.byTags({'.sourceColumn': gridCell.cell.column.name});
|
|
302
312
|
if (columns) {
|
|
303
|
-
const stats = getSeriesStatistics(data.series![i], getSeriesFitFunction(data.series![i]));
|
|
304
313
|
for (const column of columns) {
|
|
305
|
-
|
|
314
|
+
const chartLogOptions: LogOptions = {logX: data.chartOptions?.logX, logY: data.chartOptions?.logY};
|
|
315
|
+
const stats = column.tags['.seriesAggregation'] !== null ?
|
|
316
|
+
getChartDataAggrStats(data, column.tags['.seriesAggregation']) :
|
|
317
|
+
column.tags['.seriesNumber'] === i ? calculateSeriesStats(data.series![i], chartLogOptions) : null;
|
|
318
|
+
if (stats === null)
|
|
319
|
+
continue;
|
|
320
|
+
column.set(gridCell.cell.rowIndex, stats[column.tags['.statistics'] as keyof FitStatistics]);
|
|
306
321
|
}
|
|
307
322
|
}
|
|
323
|
+
|
|
308
324
|
// temporarily works only for JSON structure
|
|
309
325
|
if (gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) !== TAG_FIT_CHART_FORMAT_3DX) {
|
|
310
326
|
const gridCellValue = JSON.parse(gridCell.cell.value) as IFitChartData;
|
|
@@ -351,6 +367,7 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
351
367
|
|
|
352
368
|
const screenBounds = new DG.Rect(x, y, w, h).inflate(INFLATE_SIZE / 2, INFLATE_SIZE / 2);
|
|
353
369
|
const showAxes = screenBounds.width >= MIN_AXES_CELL_PX_WIDTH && screenBounds.height >= MIN_AXES_CELL_PX_HEIGHT;
|
|
370
|
+
// make bigger sizes
|
|
354
371
|
const showAxesLabels = w >= MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH && h >= MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT
|
|
355
372
|
&& !!data.chartOptions?.xAxisName && !!data.chartOptions.yAxisName;
|
|
356
373
|
const showTitle = w >= MIN_TITLE_PX_WIDTH && h >= MIN_TITLE_PX_HEIGHT && !!data.chartOptions?.title;
|
|
@@ -361,6 +378,7 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
361
378
|
if (dataBounds.y <= 0 && data.chartOptions) data.chartOptions.logY = false;
|
|
362
379
|
const viewport = new Viewport(dataBounds, dataBox, data.chartOptions?.logX ?? false, data.chartOptions?.logY ?? false);
|
|
363
380
|
const minSize = Math.min(dataBox.width, dataBox.height);
|
|
381
|
+
// make thinner
|
|
364
382
|
const ratio = minSize > 100 ? 1 : 0.2 + (minSize / 100) * 0.8;
|
|
365
383
|
const chartLogOptions: LogOptions = {logX: data.chartOptions?.logX, logY: data.chartOptions?.logY};
|
|
366
384
|
|
package/src/package.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const _package = new DG.Package();
|
|
|
15
15
|
//meta.cellType: fit
|
|
16
16
|
//meta.virtual: true
|
|
17
17
|
//output: grid_cell_renderer result
|
|
18
|
-
export function fitCellRenderer() {
|
|
18
|
+
export function fitCellRenderer(): FitChartCellRenderer {
|
|
19
19
|
return new FitChartCellRenderer();
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ export function fitCellRenderer() {
|
|
|
23
23
|
//description: A viewer that superimposes multiple in-cell curves on one chart
|
|
24
24
|
//tags: viewer
|
|
25
25
|
//output: viewer result
|
|
26
|
-
export function _FitViewer() {
|
|
26
|
+
export function _FitViewer(): MultiCurveViewer {
|
|
27
27
|
return new MultiCurveViewer();
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -31,11 +31,11 @@ export function _FitViewer() {
|
|
|
31
31
|
//description: Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points
|
|
32
32
|
//meta.demoPath: Curves | Curve fitting
|
|
33
33
|
//test: curveFitDemo() //wait: 2000
|
|
34
|
-
export async function curveFitDemo() {
|
|
34
|
+
export async function curveFitDemo(): Promise<void> {
|
|
35
35
|
await curveDemo();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
//tags:
|
|
39
|
-
export function
|
|
38
|
+
//tags: init
|
|
39
|
+
export function _initCurves(): void {
|
|
40
40
|
DG.ObjectHandler.register(new FitGridCellHandler());
|
|
41
41
|
}
|