@datagrok/curves 1.1.0 → 1.2.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/.vscode/tasks.json +1 -1
- package/CHANGELOG.md +25 -0
- package/README.md +89 -10
- package/detectors.js +2 -2
- package/dist/package-test.js +2764 -1099
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +2007 -1455
- package/dist/package.js.map +1 -1
- package/img/curves.gif +0 -0
- package/img/custom-fit-function.gif +0 -0
- package/package.json +5 -5
- package/src/fit/fit-demo.js +13 -7
- package/src/fit/fit-demo.js.map +1 -1
- package/src/fit/fit-demo.ts +14 -8
- package/src/fit/fit-grid-cell-handler.js +23 -11
- package/src/fit/fit-grid-cell-handler.js.map +1 -1
- package/src/fit/fit-grid-cell-handler.ts +33 -14
- package/src/fit/fit-parser.js +19 -16
- package/src/fit/fit-parser.js.map +1 -1
- package/src/fit/fit-parser.ts +22 -20
- package/src/fit/fit-renderer.js +279 -70
- package/src/fit/fit-renderer.js.map +1 -1
- package/src/fit/fit-renderer.ts +335 -72
- package/src/fit/multi-curve-viewer.js +4 -3
- package/src/fit/multi-curve-viewer.js.map +1 -1
- package/src/fit/multi-curve-viewer.ts +4 -10
- package/src/package-test.js +3 -0
- package/src/package-test.js.map +1 -1
- package/src/package-test.ts +3 -0
- package/src/package.js +2 -7
- package/src/package.js.map +1 -1
- package/src/package.ts +2 -9
- package/src/tests/curves-cell-renderer-tests.js +103 -0
- package/src/tests/curves-cell-renderer-tests.js.map +1 -0
- package/src/tests/curves-cell-renderer-tests.ts +107 -0
- package/src/tests/detector-tests.js +2 -1
- package/src/tests/detector-tests.js.map +1 -1
- package/src/tests/detector-tests.ts +2 -1
- package/src/tests/fit-tests.js +82 -0
- package/src/tests/fit-tests.js.map +1 -0
- package/src/tests/fit-tests.ts +95 -0
- package/src/tests/transform-tests.js +26 -0
- package/src/tests/transform-tests.js.map +1 -0
- package/src/tests/transform-tests.ts +21 -0
- package/tsconfig.json +1 -1
- package/webpack.config.js +1 -0
- package/src/fit/fit-data.js +0 -215
- package/src/fit/fit-data.js.map +0 -1
- package/src/fit/fit-data.ts +0 -328
- package/src/fit/transform.js +0 -73
- package/src/fit/transform.js.map +0 -1
- package/src/fit/transform.ts +0 -99
package/src/fit/fit-renderer.ts
CHANGED
|
@@ -2,37 +2,190 @@ import * as DG from 'datagrok-api/dg';
|
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
statisticsProperties,
|
|
7
|
+
FitConfidenceIntervals,
|
|
8
|
+
IFitChartData,
|
|
9
|
+
CONFIDENCE_INTERVAL_FILL_COLOR,
|
|
10
|
+
CONFIDENCE_INTERVAL_STROKE_COLOR,
|
|
11
|
+
CURVE_CONFIDENCE_INTERVAL_BOUNDS,
|
|
12
|
+
FIT_CELL_TYPE,
|
|
13
|
+
IFitSeries,
|
|
14
|
+
FitStatistics,
|
|
15
|
+
fitChartDataProperties,
|
|
16
|
+
fitSeriesProperties,
|
|
17
|
+
} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
18
|
+
import {BoxPlotStatistics, calculateBoxPlotStatistics} from '@datagrok-libraries/statistics/src/box-plot-statistics';
|
|
19
|
+
import {Viewport} from '@datagrok-libraries/utils/src/transform';
|
|
6
20
|
import {StringUtils} from '@datagrok-libraries/utils/src/string-utils';
|
|
7
21
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
import {
|
|
23
|
+
fitSeries,
|
|
24
|
+
createDefaultChartData,
|
|
25
|
+
getChartBounds,
|
|
26
|
+
getSeriesFitFunction,
|
|
27
|
+
getSeriesConfidenceInterval,
|
|
28
|
+
getSeriesStatistics,
|
|
29
|
+
getCurve,
|
|
30
|
+
getColumnChartOptions,
|
|
31
|
+
} from '@datagrok-libraries/statistics/src/fit/fit-data';
|
|
32
|
+
|
|
11
33
|
import {convertXMLToIFitChartData} from './fit-parser';
|
|
12
|
-
import {Viewport} from './transform';
|
|
13
34
|
import {MultiCurveViewer} from './multi-curve-viewer';
|
|
14
35
|
|
|
36
|
+
|
|
37
|
+
export type LogOptions = {
|
|
38
|
+
logX: boolean | undefined,
|
|
39
|
+
logY: boolean | undefined
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const TAG_FIT_CHART_FORMAT = '.fitChartFormat';
|
|
43
|
+
export const TAG_FIT_CHART_FORMAT_3DX = '3dx';
|
|
44
|
+
const MIN_CELL_RENDERER_PX_WIDTH = 20;
|
|
45
|
+
const MIN_CELL_RENDERER_PX_HEIGHT = 10;
|
|
46
|
+
const MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH = 70;
|
|
47
|
+
const MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT = 45;
|
|
48
|
+
const OUTLIER_PX_SIZE = 12;
|
|
49
|
+
const POINT_PX_SIZE = 4;
|
|
50
|
+
const OUTLIER_HITBOX_RADIUS = 2;
|
|
51
|
+
const MIN_AXES_CELL_PX_WIDTH = 70;
|
|
52
|
+
const MIN_AXES_CELL_PX_HEIGHT = 55;
|
|
53
|
+
const MIN_X_AXIS_NAME_VISIBILITY_PX_WIDTH = 150;
|
|
54
|
+
const MIN_Y_AXIS_NAME_VISIBILITY_PX_HEIGHT = 100;
|
|
55
|
+
const AXES_LEFT_PX_MARGIN = 30;
|
|
56
|
+
const AXES_TOP_PX_MARGIN = 5;
|
|
57
|
+
const AXES_BOTTOM_PX_MARGIN = 15;
|
|
58
|
+
const CANDLESTICK_BORDER_PX_SIZE = 4;
|
|
59
|
+
const CANDLESTICK_MEDIAN_PX_SIZE = 3.5;
|
|
60
|
+
const CANDLESTICK_OUTLIER_PX_SIZE = 6;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
/** Merges properties of the two objects by iterating over the specified {@link properties}
|
|
64
|
+
* and assigning properties from {@link source} to {@link target} only when
|
|
65
|
+
* the property is not defined in target and is defined in source. */
|
|
66
|
+
export function mergeProperties(properties: DG.Property[], source: any, target: any): void {
|
|
67
|
+
if (!source || !target)
|
|
68
|
+
return;
|
|
69
|
+
|
|
70
|
+
for (const p of properties) {
|
|
71
|
+
if (!(p.name in target) && p.name in source)
|
|
72
|
+
target[p.name] = source[p.name];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Constructs {@link IFitChartData} from the grid cell, taking into account
|
|
77
|
+
* chart and fit settings potentially defined on the dataframe and column level. */
|
|
78
|
+
export function getChartData(gridCell: DG.GridCell): IFitChartData {
|
|
79
|
+
const cellChartData: IFitChartData = gridCell.cell?.column?.type === DG.TYPE.STRING ?
|
|
80
|
+
(gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX ?
|
|
81
|
+
convertXMLToIFitChartData(gridCell.cell.value) :
|
|
82
|
+
JSON.parse(gridCell.cell.value ?? '{}') ?? {}) : createDefaultChartData();
|
|
83
|
+
|
|
84
|
+
const columnChartOptions = getColumnChartOptions(gridCell.gridColumn);
|
|
85
|
+
|
|
86
|
+
cellChartData.series ??= [];
|
|
87
|
+
cellChartData.chartOptions ??= columnChartOptions.chartOptions;
|
|
88
|
+
|
|
89
|
+
// merge cell options with column options
|
|
90
|
+
mergeProperties(fitChartDataProperties, columnChartOptions.chartOptions, cellChartData.chartOptions);
|
|
91
|
+
for (const series of cellChartData.series)
|
|
92
|
+
mergeProperties(fitSeriesProperties, columnChartOptions.seriesOptions, series);
|
|
93
|
+
|
|
94
|
+
return cellChartData;
|
|
95
|
+
}
|
|
96
|
+
|
|
15
97
|
/** Performs a chart layout, returning [viewport, xAxis, yAxis] */
|
|
16
|
-
function layoutChart(rect: DG.Rect): [DG.Rect, DG.Rect?, DG.Rect?] {
|
|
17
|
-
if (rect.width <
|
|
98
|
+
export function layoutChart(rect: DG.Rect): [DG.Rect, DG.Rect?, DG.Rect?] {
|
|
99
|
+
if (rect.width < MIN_AXES_CELL_PX_WIDTH || rect.height < MIN_AXES_CELL_PX_HEIGHT)
|
|
18
100
|
return [rect, undefined, undefined];
|
|
19
101
|
return [
|
|
20
|
-
rect.cutLeft(
|
|
21
|
-
rect.getBottom(
|
|
22
|
-
rect.getLeft(
|
|
102
|
+
rect.cutLeft(AXES_LEFT_PX_MARGIN).cutBottom(AXES_BOTTOM_PX_MARGIN).cutTop(AXES_TOP_PX_MARGIN),
|
|
103
|
+
rect.getBottom(AXES_BOTTOM_PX_MARGIN).getTop(AXES_TOP_PX_MARGIN).cutLeft(AXES_LEFT_PX_MARGIN),
|
|
104
|
+
rect.getLeft(AXES_LEFT_PX_MARGIN).cutBottom(AXES_BOTTOM_PX_MARGIN).cutTop(AXES_TOP_PX_MARGIN)
|
|
23
105
|
];
|
|
24
106
|
}
|
|
25
107
|
|
|
108
|
+
/** Performs candlestick border drawing */
|
|
109
|
+
function drawCandlestickBorder(g: CanvasRenderingContext2D, x: number, adjacentValue: number, transform: Viewport): void {
|
|
110
|
+
g.moveTo(transform.xToScreen(x) - (CANDLESTICK_BORDER_PX_SIZE / 2), transform.yToScreen(adjacentValue));
|
|
111
|
+
g.lineTo(transform.xToScreen(x) + (CANDLESTICK_BORDER_PX_SIZE / 2), transform.yToScreen(adjacentValue));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Performs candlestick drawing */
|
|
115
|
+
function drawCandlestick(g: CanvasRenderingContext2D, x: number, boxPlotStats: BoxPlotStatistics,
|
|
116
|
+
transform: Viewport, ratio: number, markerColor: number): void {
|
|
117
|
+
drawCandlestickBorder(g, x, boxPlotStats.lowerAdjacentValue, transform);
|
|
118
|
+
g.moveTo(transform.xToScreen(x), transform.yToScreen(boxPlotStats.lowerAdjacentValue));
|
|
119
|
+
g.lineTo(transform.xToScreen(x), transform.yToScreen(boxPlotStats.upperAdjacentValue));
|
|
120
|
+
drawCandlestickBorder(g, x, boxPlotStats.upperAdjacentValue, transform);
|
|
121
|
+
DG.Paint.marker(g, DG.MARKER_TYPE.CIRCLE, transform.xToScreen(x), transform.yToScreen(boxPlotStats.q2),
|
|
122
|
+
markerColor, CANDLESTICK_MEDIAN_PX_SIZE * ratio);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Performs points drawing */
|
|
126
|
+
function drawPoints(g: CanvasRenderingContext2D, series: IFitSeries,
|
|
127
|
+
transform: Viewport, ratio: number, logOptions: LogOptions): void {
|
|
128
|
+
for (let i = 0; i < series.points.length!; i++) {
|
|
129
|
+
const p = series.points[i];
|
|
130
|
+
const color = p.outlier ? DG.Color.red :
|
|
131
|
+
series.pointColor ? DG.Color.fromHtml(series.pointColor) ?? DG.Color.scatterPlotMarker :
|
|
132
|
+
DG.Color.scatterPlotMarker;
|
|
133
|
+
DG.Paint.marker(g,
|
|
134
|
+
p.outlier ? DG.MARKER_TYPE.OUTLIER : (series.markerType as DG.MARKER_TYPE),
|
|
135
|
+
logOptions.logX ? transform.xToScreen(Math.pow(10, p.x)) : transform.xToScreen(p.x),
|
|
136
|
+
logOptions.logY ? transform.yToScreen(Math.pow(10, p.y)) : transform.yToScreen(p.y),
|
|
137
|
+
color, (p.outlier ? OUTLIER_PX_SIZE : POINT_PX_SIZE) * ratio);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Performs candles drawing */
|
|
142
|
+
function drawCandles(g: CanvasRenderingContext2D, series: IFitSeries,
|
|
143
|
+
transform: Viewport, ratio: number) : void {
|
|
144
|
+
for (let i = 0, candleStart = null; i < series.points.length!; i++) {
|
|
145
|
+
const p = series.points[i];
|
|
146
|
+
if (p.outlier)
|
|
147
|
+
continue;
|
|
148
|
+
const nextSame = i + 1 < series.points.length && series.points[i + 1].x === p.x;
|
|
149
|
+
if (!candleStart && nextSame)
|
|
150
|
+
candleStart = i;
|
|
151
|
+
else if (candleStart !== null && !nextSame) {
|
|
152
|
+
const values: number[] = [];
|
|
153
|
+
for (let j = candleStart, ind = 0; j <= i; j++, ind++) {
|
|
154
|
+
values[ind] = series.points[j].y;
|
|
155
|
+
}
|
|
156
|
+
const boxPlotStats = calculateBoxPlotStatistics(values);
|
|
157
|
+
|
|
158
|
+
g.beginPath();
|
|
159
|
+
drawCandlestick(g, p.x, boxPlotStats, transform, ratio, series.pointColor ?
|
|
160
|
+
DG.Color.fromHtml(series.pointColor) : DG.Color.scatterPlotMarker);
|
|
161
|
+
g.stroke();
|
|
162
|
+
|
|
163
|
+
if (series.showPoints === 'both') {
|
|
164
|
+
for (let ind = 0; ind < values.length; ind++) {
|
|
165
|
+
if (values[ind] < boxPlotStats.lowerAdjacentValue || values[ind] > boxPlotStats.upperAdjacentValue) {
|
|
166
|
+
DG.Paint.marker(g, DG.MARKER_TYPE.OUTLIER,
|
|
167
|
+
transform.xToScreen(p.x), transform.yToScreen(values[ind]),
|
|
168
|
+
series.pointColor ? DG.Color.fromHtml(series.pointColor) : DG.Color.scatterPlotMarker,
|
|
169
|
+
CANDLESTICK_OUTLIER_PX_SIZE * ratio);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
candleStart = null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
26
179
|
/** Performs a curve confidence interval drawing */
|
|
27
|
-
function drawConfidenceInterval(g: CanvasRenderingContext2D,
|
|
28
|
-
transform: Viewport, confidenceType: string): void {
|
|
180
|
+
function drawConfidenceInterval(g: CanvasRenderingContext2D, confIntervals: FitConfidenceIntervals,
|
|
181
|
+
screenBounds: DG.Rect, transform: Viewport, confidenceType: string): void {
|
|
29
182
|
g.beginPath();
|
|
30
|
-
for (let i =
|
|
31
|
-
const x =
|
|
183
|
+
for (let i = AXES_LEFT_PX_MARGIN; i <= screenBounds.width; i++) {
|
|
184
|
+
const x = screenBounds.x + i;
|
|
32
185
|
const y = confidenceType === CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP ?
|
|
33
|
-
transform.yToScreen(
|
|
34
|
-
transform.yToScreen(
|
|
35
|
-
if (i ===
|
|
186
|
+
transform.yToScreen(confIntervals.confidenceTop(transform.xToWorld(x))) :
|
|
187
|
+
transform.yToScreen(confIntervals.confidenceBottom(transform.xToWorld(x)));
|
|
188
|
+
if (i === AXES_LEFT_PX_MARGIN)
|
|
36
189
|
g.moveTo(x, y);
|
|
37
190
|
else
|
|
38
191
|
g.lineTo(x, y);
|
|
@@ -41,21 +194,22 @@ function drawConfidenceInterval(g: CanvasRenderingContext2D, series: IFitSeries,
|
|
|
41
194
|
}
|
|
42
195
|
|
|
43
196
|
/** Performs a curve confidence interval color filling */
|
|
44
|
-
function fillConfidenceInterval(g: CanvasRenderingContext2D,
|
|
197
|
+
function fillConfidenceInterval(g: CanvasRenderingContext2D, confIntervals: FitConfidenceIntervals,
|
|
198
|
+
screenBounds: DG.Rect, transform: Viewport): void {
|
|
45
199
|
g.beginPath();
|
|
46
|
-
for (let i =
|
|
47
|
-
const x =
|
|
48
|
-
const y = transform.yToScreen(
|
|
49
|
-
if (i ===
|
|
200
|
+
for (let i = AXES_LEFT_PX_MARGIN; i <= screenBounds.width; i++) {
|
|
201
|
+
const x = screenBounds.x + i;
|
|
202
|
+
const y = transform.yToScreen(confIntervals.confidenceTop(transform.xToWorld(x)));
|
|
203
|
+
if (i === AXES_LEFT_PX_MARGIN)
|
|
50
204
|
g.moveTo(x, y);
|
|
51
205
|
else
|
|
52
206
|
g.lineTo(x, y);
|
|
53
207
|
}
|
|
54
208
|
|
|
55
209
|
// reverse traverse to make a shape of confidence interval to fill it
|
|
56
|
-
for (let i =
|
|
57
|
-
const x =
|
|
58
|
-
const y = transform.yToScreen(
|
|
210
|
+
for (let i = screenBounds.width; i >= AXES_LEFT_PX_MARGIN; i--) {
|
|
211
|
+
const x = screenBounds.x + i;
|
|
212
|
+
const y = transform.yToScreen(confIntervals.confidenceBottom(transform.xToWorld(x)));
|
|
59
213
|
g.lineTo(x, y);
|
|
60
214
|
}
|
|
61
215
|
g.closePath();
|
|
@@ -63,22 +217,61 @@ function fillConfidenceInterval(g: CanvasRenderingContext2D, series: IFitSeries,
|
|
|
63
217
|
}
|
|
64
218
|
|
|
65
219
|
export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
66
|
-
get name() { return
|
|
220
|
+
get name() { return FIT_CELL_TYPE; }
|
|
67
221
|
|
|
68
|
-
get cellType() { return
|
|
222
|
+
get cellType() { return FIT_CELL_TYPE; }
|
|
69
223
|
|
|
70
224
|
getDefaultSize(gridColumn: DG.GridColumn): {width?: number | null, height?: number | null} {
|
|
71
|
-
return {width: 160, height:
|
|
225
|
+
return {width: 160, height: 120};
|
|
72
226
|
}
|
|
73
227
|
|
|
74
228
|
onClick(gridCell: DG.GridCell, e: MouseEvent): void {
|
|
75
229
|
grok.shell.o = gridCell;
|
|
230
|
+
|
|
231
|
+
const data = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX
|
|
232
|
+
? convertXMLToIFitChartData(gridCell.cell.value)
|
|
233
|
+
: getChartData(gridCell);
|
|
234
|
+
|
|
235
|
+
const screenBounds = gridCell.bounds.inflate(-6, -6);
|
|
236
|
+
const dataBox = layoutChart(screenBounds)[0];
|
|
237
|
+
const dataBounds = getChartBounds(data);
|
|
238
|
+
const viewport = new Viewport(dataBounds, dataBox, data.chartOptions?.logX ?? false, data.chartOptions?.logY ?? false);
|
|
239
|
+
|
|
240
|
+
for (let i = 0; i < data.series?.length!; i++) {
|
|
241
|
+
if (!data.series![i].clickToToggle || data.series![i].showPoints !== 'points')
|
|
242
|
+
continue;
|
|
243
|
+
for (let j = 0; j < data.series![i].points.length!; j++) {
|
|
244
|
+
const p = data.series![i].points[j];
|
|
245
|
+
const screenX = viewport.xToScreen(p.x);
|
|
246
|
+
const screenY = viewport.yToScreen(p.y);
|
|
247
|
+
const pxPerMarkerType = ((p.outlier ? OUTLIER_PX_SIZE : POINT_PX_SIZE) / 2) + OUTLIER_HITBOX_RADIUS;
|
|
248
|
+
if (e.offsetX >= screenX - pxPerMarkerType && e.offsetX <= screenX + pxPerMarkerType &&
|
|
249
|
+
e.offsetY >= screenY - pxPerMarkerType && e.offsetY <= screenY + pxPerMarkerType) {
|
|
250
|
+
p.outlier = !p.outlier;
|
|
251
|
+
const columns = gridCell.grid.dataFrame.columns.byTags({'.sourceColumn':
|
|
252
|
+
gridCell.cell.column.name, '.seriesNumber': i});
|
|
253
|
+
if (columns) {
|
|
254
|
+
const stats = getSeriesStatistics(data.series![i], getSeriesFitFunction(data.series![i]));
|
|
255
|
+
for (const column of columns) {
|
|
256
|
+
column.set(gridCell.cell.rowIndex, stats[column.name as keyof FitStatistics]);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// temporarily works only for JSON structure
|
|
260
|
+
if (gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) !== TAG_FIT_CHART_FORMAT_3DX) {
|
|
261
|
+
const gridCellValue = JSON.parse(gridCell.cell.value) as IFitChartData;
|
|
262
|
+
gridCellValue.series![i].points[j].outlier = p.outlier;
|
|
263
|
+
gridCell.cell.value = JSON.stringify(gridCellValue);
|
|
264
|
+
}
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
76
269
|
}
|
|
77
270
|
|
|
78
271
|
onDoubleClick(gridCell: DG.GridCell, e: MouseEvent): void {
|
|
79
272
|
ui.dialog({title: 'Edit chart'})
|
|
80
273
|
.add(MultiCurveViewer.fromChartData(getChartData(gridCell)).root)
|
|
81
|
-
.show();
|
|
274
|
+
.show({resizable: true});
|
|
82
275
|
}
|
|
83
276
|
|
|
84
277
|
renderCurves(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, data: IFitChartData): void {
|
|
@@ -94,54 +287,59 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
94
287
|
const viewport = new Viewport(dataBounds, dataBox, data.chartOptions?.logX ?? false, data.chartOptions?.logY ?? false);
|
|
95
288
|
const minSize = Math.min(dataBox.width, dataBox.height);
|
|
96
289
|
const ratio = minSize > 100 ? 1 : 0.2 + (minSize / 100) * 0.8;
|
|
290
|
+
const chartLogOptions: LogOptions = {logX: data.chartOptions?.logX, logY: data.chartOptions?.logY};
|
|
97
291
|
|
|
98
292
|
viewport.drawCoordinateGrid(g, xAxisBox, yAxisBox);
|
|
99
293
|
|
|
100
294
|
for (const series of data.series!) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
candleStart = i;
|
|
110
|
-
else if (candleStart !== null && !nextSame) {
|
|
111
|
-
let minY = series.points[candleStart].y;
|
|
112
|
-
let maxY = minY;
|
|
113
|
-
for (let j = candleStart; j < i; j++) {
|
|
114
|
-
minY = Math.min(minY, series.points[j].y);
|
|
115
|
-
maxY = Math.max(minY, series.points[j].y);
|
|
116
|
-
}
|
|
295
|
+
if (data.chartOptions?.logX || data.chartOptions?.logY) {
|
|
296
|
+
for (let i = 0; i < series.points.length; i++) {
|
|
297
|
+
if (data.chartOptions?.logX)
|
|
298
|
+
series.points[i].x = Math.log10(series.points[i].x);
|
|
299
|
+
if (data.chartOptions?.logY)
|
|
300
|
+
series.points[i].y = Math.log10(series.points[i].y);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
117
303
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
304
|
+
if (w < MIN_POINTS_AND_STATS_VISIBILITY_PX_WIDTH || h < MIN_POINTS_AND_STATS_VISIBILITY_PX_HEIGHT) {
|
|
305
|
+
series.showPoints = '';
|
|
306
|
+
if (data.chartOptions)
|
|
307
|
+
data.chartOptions.showStatistics = [];
|
|
308
|
+
}
|
|
309
|
+
series.points.sort((a, b) => a.x - b.x);
|
|
310
|
+
let userParamsFlag = true;
|
|
311
|
+
const fitFunc = getSeriesFitFunction(series);
|
|
312
|
+
let curve: (x: number) => number;
|
|
313
|
+
if (series.parameters) {
|
|
314
|
+
if (data.chartOptions?.logX)
|
|
315
|
+
series.parameters[2] = Math.log10(series.parameters[2]);
|
|
316
|
+
curve = getCurve(series, fitFunc);
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
const fitResult = fitSeries(series, fitFunc);
|
|
320
|
+
curve = fitResult.fittedCurve;
|
|
321
|
+
series.parameters = fitResult.parameters;
|
|
322
|
+
userParamsFlag = false;
|
|
323
|
+
}
|
|
122
324
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
series.pointColor ? DG.Color.fromHtml(series.pointColor) : DG.Color.scatterPlotMarker,
|
|
130
|
-
(p.outlier ? 6 : 4) * ratio);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
325
|
+
if (series.showPoints ?? 'points') {
|
|
326
|
+
g.strokeStyle = series.pointColor ?? '0xFF40699c';
|
|
327
|
+
if (series.showPoints === 'points')
|
|
328
|
+
drawPoints(g, series, viewport, ratio, chartLogOptions);
|
|
329
|
+
else if (['candlesticks', 'both'].includes(series.showPoints!))
|
|
330
|
+
drawCandles(g, series, viewport, ratio);
|
|
133
331
|
}
|
|
134
332
|
|
|
135
333
|
if (series.showFitLine ?? true) {
|
|
136
334
|
g.strokeStyle = series.fitLineColor ?? 'black';
|
|
137
335
|
g.lineWidth = 2 * ratio;
|
|
138
|
-
const curve = fitResult.fittedCurve;
|
|
139
336
|
|
|
140
337
|
g.beginPath();
|
|
141
|
-
for (let i =
|
|
142
|
-
const x =
|
|
143
|
-
const y = viewport.yToScreen(curve(
|
|
144
|
-
|
|
338
|
+
for (let i = AXES_LEFT_PX_MARGIN; i <= screenBounds.width; i++) {
|
|
339
|
+
const x = screenBounds.x + i;
|
|
340
|
+
const y = data.chartOptions?.logX ? viewport.yToScreen(Math.pow(10, curve(Math.log10(viewport.xToWorld(x))))) :
|
|
341
|
+
viewport.yToScreen(curve(viewport.xToWorld(x)));
|
|
342
|
+
if (i === AXES_LEFT_PX_MARGIN)
|
|
145
343
|
g.moveTo(x, y);
|
|
146
344
|
else
|
|
147
345
|
g.lineTo(x, y);
|
|
@@ -149,22 +347,24 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
149
347
|
g.stroke();
|
|
150
348
|
}
|
|
151
349
|
|
|
152
|
-
if ((series.showFitLine ?? true) && (series.showCurveConfidenceInterval ??
|
|
350
|
+
if ((series.showFitLine ?? true) && (series.showCurveConfidenceInterval ?? false)) {
|
|
153
351
|
g.strokeStyle = series.confidenceIntervalColor ?? CONFIDENCE_INTERVAL_STROKE_COLOR;
|
|
154
352
|
g.fillStyle = series.confidenceIntervalColor ?? CONFIDENCE_INTERVAL_FILL_COLOR;
|
|
155
353
|
|
|
156
|
-
|
|
157
|
-
drawConfidenceInterval(g,
|
|
158
|
-
|
|
354
|
+
const confidenceIntervals = getSeriesConfidenceInterval(series, fitFunc, userParamsFlag);
|
|
355
|
+
drawConfidenceInterval(g, confidenceIntervals, screenBounds, viewport, CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP);
|
|
356
|
+
drawConfidenceInterval(g, confidenceIntervals, screenBounds, viewport, CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM);
|
|
357
|
+
fillConfidenceInterval(g, confidenceIntervals, screenBounds, viewport);
|
|
159
358
|
}
|
|
160
359
|
|
|
161
360
|
|
|
162
361
|
if (data.chartOptions?.showStatistics) {
|
|
362
|
+
const statistics = getSeriesStatistics(series, fitFunc);
|
|
163
363
|
for (let i = 0; i < data.chartOptions.showStatistics.length; i++) {
|
|
164
364
|
const statName = data.chartOptions.showStatistics[i];
|
|
165
|
-
const prop =
|
|
365
|
+
const prop = statisticsProperties.find(p => p.name === statName);
|
|
166
366
|
if (prop) {
|
|
167
|
-
const s = StringUtils.formatNumber(prop.get(
|
|
367
|
+
const s = StringUtils.formatNumber(prop.get(statistics));
|
|
168
368
|
g.fillStyle = series.fitLineColor ?? 'black';
|
|
169
369
|
g.textAlign = 'left';
|
|
170
370
|
g.fillText(prop.name + ': ' + s, dataBox.x + 5, dataBox.y + 20 + 20 * i);
|
|
@@ -172,14 +372,14 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
172
372
|
}
|
|
173
373
|
}
|
|
174
374
|
}
|
|
175
|
-
|
|
176
375
|
g.restore();
|
|
177
376
|
}
|
|
178
377
|
|
|
179
378
|
render(g: CanvasRenderingContext2D,
|
|
180
379
|
x: number, y: number, w: number, h: number,
|
|
181
380
|
gridCell: DG.GridCell, cellStyle: DG.GridCellStyle): void {
|
|
182
|
-
if (w <
|
|
381
|
+
if (w < MIN_CELL_RENDERER_PX_WIDTH || h < MIN_CELL_RENDERER_PX_HEIGHT)
|
|
382
|
+
return;
|
|
183
383
|
|
|
184
384
|
const data = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX
|
|
185
385
|
? convertXMLToIFitChartData(gridCell.cell.value)
|
|
@@ -195,5 +395,68 @@ export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
|
195
395
|
const content = ui.divV([canvas]);
|
|
196
396
|
ui.tooltip.show(content, e.x, e.y);
|
|
197
397
|
}
|
|
398
|
+
|
|
399
|
+
// TODO: add caching
|
|
400
|
+
const data = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX
|
|
401
|
+
? convertXMLToIFitChartData(gridCell.cell.value)
|
|
402
|
+
: getChartData(gridCell);
|
|
403
|
+
|
|
404
|
+
const screenBounds = gridCell.bounds.inflate(-6, -6);
|
|
405
|
+
const dataBox = layoutChart(screenBounds)[0];
|
|
406
|
+
const dataBounds = getChartBounds(data);
|
|
407
|
+
const viewport = new Viewport(dataBounds, dataBox, data.chartOptions?.logX ?? false, data.chartOptions?.logY ?? false);
|
|
408
|
+
|
|
409
|
+
for (let i = 0; i < data.series?.length!; i++) {
|
|
410
|
+
if (!data.series![i].clickToToggle || data.series![i].showPoints !== 'points')
|
|
411
|
+
continue;
|
|
412
|
+
for (let j = 0; j < data.series![i].points.length!; j++) {
|
|
413
|
+
const p = data.series![i].points[j];
|
|
414
|
+
const screenX = viewport.xToScreen(p.x);
|
|
415
|
+
const screenY = viewport.yToScreen(p.y);
|
|
416
|
+
const pxPerMarkerType = ((p.outlier ? OUTLIER_PX_SIZE : POINT_PX_SIZE) / 2) + OUTLIER_HITBOX_RADIUS;
|
|
417
|
+
if (e.offsetX >= screenX - pxPerMarkerType && e.offsetX <= screenX + pxPerMarkerType &&
|
|
418
|
+
e.offsetY >= screenY - pxPerMarkerType && e.offsetY <= screenY + pxPerMarkerType) {
|
|
419
|
+
document.body.style.cursor = 'pointer';
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
document.body.style.cursor = 'default';
|
|
198
425
|
}
|
|
199
426
|
}
|
|
427
|
+
|
|
428
|
+
const sample: IFitChartData = {
|
|
429
|
+
// chartOptions could be retrieved either from the column, or from the cell
|
|
430
|
+
'chartOptions': {
|
|
431
|
+
'minX': 0, 'minY': 0, 'maxX': 5, 'maxY': 10,
|
|
432
|
+
'xAxisName': 'concentration',
|
|
433
|
+
'yAxisName': 'activity',
|
|
434
|
+
'logX': false,
|
|
435
|
+
'logY': false,
|
|
436
|
+
},
|
|
437
|
+
// These options are used as default options for the series. They could be overridden in series.
|
|
438
|
+
'seriesOptions': {
|
|
439
|
+
'fitFunction': 'sigmoid',
|
|
440
|
+
// parameters not specified -> auto-fitting by default
|
|
441
|
+
'pointColor': 'blue',
|
|
442
|
+
'fitLineColor': 'red',
|
|
443
|
+
'clickToToggle': true,
|
|
444
|
+
'showPoints': 'points',
|
|
445
|
+
'showFitLine': true,
|
|
446
|
+
'showCurveConfidenceInterval': true,
|
|
447
|
+
},
|
|
448
|
+
'series': [
|
|
449
|
+
{
|
|
450
|
+
'fitFunction': 'sigmoid',
|
|
451
|
+
// parameters specified -> use them, no autofitting
|
|
452
|
+
'parameters': [1.86011e-07, -0.900, 103.748, -0.001],
|
|
453
|
+
'points': [
|
|
454
|
+
{'x': 0, 'y': 0},
|
|
455
|
+
{'x': 1, 'y': 0.5},
|
|
456
|
+
{'x': 2, 'y': 1},
|
|
457
|
+
{'x': 3, 'y': 10, 'outlier': true},
|
|
458
|
+
{'x': 4, 'y': 0},
|
|
459
|
+
],
|
|
460
|
+
},
|
|
461
|
+
],
|
|
462
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CellRenderViewer } from
|
|
2
|
-
import { FitChartCellRenderer } from
|
|
3
|
-
import {
|
|
1
|
+
import { CellRenderViewer } from './cell-render-viewer';
|
|
2
|
+
import { FitChartCellRenderer } from './fit-renderer';
|
|
3
|
+
import { getChartData, mergeProperties } from '../fit/fit-renderer';
|
|
4
|
+
import { FIT_SEM_TYPE, FitChartData, fitChartDataProperties } from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
4
5
|
import { debounce } from 'rxjs/operators';
|
|
5
6
|
import { interval, merge } from 'rxjs';
|
|
6
7
|
export class MultiCurveViewer extends CellRenderViewer {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-curve-viewer.js","sourceRoot":"","sources":["multi-curve-viewer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"multi-curve-viewer.js","sourceRoot":"","sources":["multi-curve-viewer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAC,YAAY,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAC,YAAY,EAAE,YAAY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getChartData,
|
|
10
|
-
IFitChartData,
|
|
11
|
-
mergeProperties
|
|
12
|
-
} from "./fit-data";
|
|
3
|
+
import {CellRenderViewer} from './cell-render-viewer';
|
|
4
|
+
import {FitChartCellRenderer} from './fit-renderer';
|
|
5
|
+
import {getChartData, mergeProperties} from '../fit/fit-renderer';
|
|
6
|
+
import {FIT_SEM_TYPE, FitChartData, fitChartDataProperties, IFitChartData} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
13
7
|
|
|
14
8
|
import {debounce} from 'rxjs/operators';
|
|
15
9
|
import {interval, merge} from 'rxjs';
|
package/src/package-test.js
CHANGED
|
@@ -10,6 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import * as DG from "datagrok-api/dg";
|
|
11
11
|
import { runTests, tests } from '@datagrok-libraries/utils/src/test';
|
|
12
12
|
import './tests/detector-tests';
|
|
13
|
+
import './tests/curves-cell-renderer-tests';
|
|
14
|
+
import './tests/transform-tests';
|
|
15
|
+
import './tests/fit-tests';
|
|
13
16
|
export const _package = new DG.Package();
|
|
14
17
|
export { tests };
|
|
15
18
|
//name: test
|
package/src/package-test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-test.js","sourceRoot":"","sources":["package-test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEtC,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAc,MAAM,oCAAoC,CAAC;AAEhF,OAAO,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"package-test.js","sourceRoot":"","sources":["package-test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEtC,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAc,MAAM,oCAAoC,CAAC;AAEhF,OAAO,wBAAwB,CAAC;AAChC,OAAO,oCAAoC,CAAC;AAC5C,OAAO,yBAAyB,CAAC;AACjC,OAAO,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;AACzC,OAAO,EAAC,KAAK,EAAC,CAAC;AAEf,YAAY;AACZ,yCAAyC;AACzC,qCAAqC;AACrC,4CAA4C;AAC5C,0BAA0B;AAC1B,MAAM,UAAgB,IAAI,CAAC,QAAgB,EAAE,IAAY,EAAE,WAAwB;;QACjF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAC,CAAC,CAAC;QAC3D,OAAO,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAE,CAAC;IACzC,CAAC;CAAA"}
|
package/src/package-test.ts
CHANGED
|
@@ -3,6 +3,9 @@ import * as DG from "datagrok-api/dg";
|
|
|
3
3
|
import {runTests, tests, TestContext} from '@datagrok-libraries/utils/src/test';
|
|
4
4
|
|
|
5
5
|
import './tests/detector-tests';
|
|
6
|
+
import './tests/curves-cell-renderer-tests';
|
|
7
|
+
import './tests/transform-tests';
|
|
8
|
+
import './tests/fit-tests';
|
|
6
9
|
|
|
7
10
|
export const _package = new DG.Package();
|
|
8
11
|
export {tests};
|
package/src/package.js
CHANGED
|
@@ -8,12 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
/* Do not change these import lines to match external modules in webpack configuration */
|
|
11
|
-
import * as grok from 'datagrok-api/grok';
|
|
12
11
|
import * as DG from 'datagrok-api/dg';
|
|
13
12
|
import { FitGridCellHandler } from './fit/fit-grid-cell-handler';
|
|
14
13
|
import { FitChartCellRenderer } from './fit/fit-renderer';
|
|
15
14
|
import { MultiCurveViewer } from './fit/multi-curve-viewer';
|
|
16
|
-
import {
|
|
15
|
+
import { curveDemo } from './fit/fit-demo';
|
|
17
16
|
export const _package = new DG.Package();
|
|
18
17
|
//name: Fit
|
|
19
18
|
//tags: cellRenderer
|
|
@@ -30,14 +29,10 @@ export function fitCellRenderer() {
|
|
|
30
29
|
export function _FitViewer() {
|
|
31
30
|
return new MultiCurveViewer();
|
|
32
31
|
}
|
|
33
|
-
//tags: app
|
|
34
|
-
//name: Curves Demo
|
|
35
|
-
export function curveFitDemoApp() {
|
|
36
|
-
grok.shell.addTableView(createDemoDataFrame(30, 5, 2));
|
|
37
|
-
}
|
|
38
32
|
//name: Curve fitting
|
|
39
33
|
//description: Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points
|
|
40
34
|
//meta.demoPath: Curves | Curve fitting
|
|
35
|
+
//test: curveFitDemo() //wait: 2000
|
|
41
36
|
export function curveFitDemo() {
|
|
42
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
38
|
yield curveDemo();
|
package/src/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","sourceRoot":"","sources":["package.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yFAAyF;AACzF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["package.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yFAAyF;AACzF,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAGzC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;AAGzC,WAAW;AACX,oBAAoB;AACpB,oBAAoB;AACpB,oBAAoB;AACpB,mCAAmC;AACnC,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,oBAAoB,EAAE,CAAC;AACpC,CAAC;AAED,wBAAwB;AACxB,8EAA8E;AAC9E,cAAc;AACd,uBAAuB;AACvB,MAAM,UAAU,UAAU;IACxB,OAAO,IAAI,gBAAgB,EAAE,CAAC;AAChC,CAAC;AAED,qBAAqB;AACrB,+IAA+I;AAC/I,uCAAuC;AACvC,mCAAmC;AACnC,MAAM,UAAgB,YAAY;;QAChC,MAAM,SAAS,EAAE,CAAC;IACpB,CAAC;CAAA;AAED,iBAAiB;AACjB,MAAM,UAAU,WAAW;IACzB,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAC;AACtD,CAAC"}
|