@datagrok/curves 1.10.13 → 1.10.15
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/detectors.js +0 -14
- package/dist/package-test.js +13 -147
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +13 -147
- package/dist/package.js.map +1 -1
- package/package.json +1 -1
- package/src/fit/render-utils.ts +5 -5
- package/src/package.g.ts +0 -9
- package/test-console-output-1.log +23 -24
- package/test-record-1.mp4 +0 -0
- package/src/pngRenderer.ts +0 -98
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/curves",
|
|
3
3
|
"friendlyName": "Curves",
|
|
4
|
-
"version": "1.10.
|
|
4
|
+
"version": "1.10.15",
|
|
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",
|
package/src/fit/render-utils.ts
CHANGED
|
@@ -482,11 +482,11 @@ function renderLegendSeries(g: CanvasRenderingContext2D, series: IFitSeries, ren
|
|
|
482
482
|
let pointsMarkerValue = series.points && series.points.length > 0 ? series.points[0].marker : null;
|
|
483
483
|
pointsMarkerValue = series.points && series.points.every((p) => p.marker === pointsMarkerValue && p.marker != null) ? pointsMarkerValue : null;
|
|
484
484
|
const marker = pointsMarkerValue != null ? pointsMarkerValue as DG.MARKER_TYPE : series.markerType ? series.markerType as DG.MARKER_TYPE : DG.MARKER_TYPE.CIRCLE;
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
485
|
+
const legendMarkerSize = Math.floor(FitConstants.POINT_PX_SIZE * ratio * 1.5);
|
|
486
|
+
DG.Paint.marker(g, marker,
|
|
487
|
+
dataBox.maxX - textWidth - FitConstants.LEGEND_RECORD_LINE_RIGHT_PX_MARGIN - FitConstants.LEGEND_RECORD_LINE_PX_WIDTH - legendMarkerSize,
|
|
488
|
+
dataBox.y + FitConstants.LEGEND_TOP_PX_MARGIN - FitConstants.LEGEND_RECORD_LINE_BOTTOM_PX_MARGIN + (showColumnLabel ? FitConstants.LEGEND_RECORD_PX_HEIGHT * (columnIdx + 1) : 0) + FitConstants.LEGEND_RECORD_PX_HEIGHT * drawnCurvesInLegend,
|
|
489
|
+
pointColor, legendMarkerSize);
|
|
490
490
|
g.fillStyle = fitLineColor;
|
|
491
491
|
g.fillText(nameToRender, dataBox.maxX - textWidth, dataBox.y + FitConstants.LEGEND_TOP_PX_MARGIN + (showColumnLabel ?
|
|
492
492
|
FitConstants.LEGEND_RECORD_PX_HEIGHT * (columnIdx + 1) : 0) + FitConstants.LEGEND_RECORD_PX_HEIGHT * drawnCurvesInLegend);
|
package/src/package.g.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {RawPNGRenderer} from './pngRenderer';
|
|
2
1
|
import {PackageFunctions} from './package';
|
|
3
2
|
import {MultiCurveViewer} from './fit/multi-curve-viewer';
|
|
4
3
|
import {FitChartCellRenderer} from './fit/fit-renderer';
|
|
@@ -87,11 +86,3 @@ export function addStatisticsColumn(table: DG.DataFrame, colName: string, propNa
|
|
|
87
86
|
export function addAggrStatisticsColumn(table: DG.DataFrame, colName: string, propName: string, aggrType: string) : any {
|
|
88
87
|
return PackageFunctions.addAggrStatisticsColumn(table, colName, propName, aggrType);
|
|
89
88
|
}
|
|
90
|
-
//name: rawPng
|
|
91
|
-
//tags: cellRenderer
|
|
92
|
-
//output: grid_cell_renderer renderer
|
|
93
|
-
//meta.cellType: rawPng
|
|
94
|
-
export function _RawPNGRenderer() {
|
|
95
|
-
return new RawPNGRenderer();
|
|
96
|
-
}
|
|
97
|
-
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
CONSOLE LOG REQUEST: 200, https://community.datagrok.ai/javascripts/embed-topics.js
|
|
2
|
-
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/packages/published/files/Curves/1.10.
|
|
3
|
-
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/packages/published/files/Curves/1.10.
|
|
2
|
+
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/packages/published/files/Curves/1.10.15.X-66d1f82f/jyinScQlIzTQ3ayayYm86DyzFCmpqo9J/1/dist/package.js
|
|
3
|
+
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/packages/published/files/Curves/1.10.15.X-66d1f82f/jyinScQlIzTQ3ayayYm86DyzFCmpqo9J/1/dist/package-test.js
|
|
4
4
|
CONSOLE LOG ENTRY: --------------------
|
|
5
|
-
CONSOLE LOG REQUEST: 200, http://localhost:8080/
|
|
6
|
-
CONSOLE LOG REQUEST: 200, http://localhost:8080/font/Roboto-LightItalic.woff2
|
|
7
|
-
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/funcs?text=package.id%2520%253D%2520%2522fa761820-ac70-11f0-bbe3-bb0c544e2346%2522
|
|
5
|
+
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/funcs?text=package.id%2520%253D%2520%252269a17f80-ac70-11f0-b9f7-95c4a042bee0%2522
|
|
8
6
|
CONSOLE LOG ENTRY: Running tests
|
|
9
7
|
CONSOLE LOG ENTRY: JSHandle@object
|
|
10
8
|
CONSOLE LOG ENTRY: Started creation category
|
|
11
9
|
CONSOLE LOG ENTRY: test false
|
|
12
10
|
CONSOLE LOG ENTRY: Started creation fit curve creation
|
|
13
|
-
CONSOLE LOG ENTRY: Creation took
|
|
14
|
-
CONSOLE LOG ENTRY: Finished creation fit curve creation for
|
|
11
|
+
CONSOLE LOG ENTRY: Creation took 120 ms
|
|
12
|
+
CONSOLE LOG ENTRY: Finished creation fit curve creation for 122 ms
|
|
15
13
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/images/ribbon/ribbon_sprite.svg
|
|
16
14
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/images/entities/view_layout.svg
|
|
17
15
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
16
|
+
CONSOLE LOG REQUEST: 200, http://localhost:8080/help/datagrok/datagrok.md
|
|
17
|
+
CONSOLE LOG REQUEST: 200, http://localhost:8080/font/Roboto-LightItalic.woff2
|
|
18
18
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
19
19
|
CONSOLE LOG ENTRY: --------------------
|
|
20
20
|
CONSOLE LOG ENTRY: Running tests
|
|
@@ -22,7 +22,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
22
22
|
CONSOLE LOG ENTRY: Started detectors category
|
|
23
23
|
CONSOLE LOG ENTRY: test false
|
|
24
24
|
CONSOLE LOG ENTRY: Started detectors detectFitCurves
|
|
25
|
-
CONSOLE LOG ENTRY: Finished detectors detectFitCurves for
|
|
25
|
+
CONSOLE LOG ENTRY: Finished detectors detectFitCurves for 16 ms
|
|
26
26
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
27
27
|
CONSOLE LOG ENTRY: Started Detectors category
|
|
28
28
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
@@ -32,13 +32,13 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
32
32
|
CONSOLE LOG ENTRY: Started detectors category
|
|
33
33
|
CONSOLE LOG ENTRY: test false
|
|
34
34
|
CONSOLE LOG ENTRY: Started detectors detectXMLCurveChart
|
|
35
|
-
CONSOLE LOG ENTRY: Finished detectors detectXMLCurveChart for
|
|
35
|
+
CONSOLE LOG ENTRY: Finished detectors detectXMLCurveChart for 6 ms
|
|
36
36
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
37
37
|
CONSOLE LOG ENTRY: Started Detectors category
|
|
38
38
|
CONSOLE LOG ENTRY: test false
|
|
39
39
|
CONSOLE LOG ENTRY: Started Detectors detectXMLCurveChart
|
|
40
40
|
CONSOLE LOG ENTRY: System:AppData/Curves/undefined
|
|
41
|
-
CONSOLE LOG ENTRY: Finished Detectors detectXMLCurveChart for
|
|
41
|
+
CONSOLE LOG ENTRY: Finished Detectors detectXMLCurveChart for 15 ms
|
|
42
42
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
43
43
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
44
44
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -56,7 +56,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
56
56
|
CONSOLE LOG ENTRY: Started fit category
|
|
57
57
|
CONSOLE LOG ENTRY: test false
|
|
58
58
|
CONSOLE LOG ENTRY: Started fit exponential
|
|
59
|
-
CONSOLE LOG ENTRY: Finished fit exponential for
|
|
59
|
+
CONSOLE LOG ENTRY: Finished fit exponential for 0 ms
|
|
60
60
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
61
61
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
62
62
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -65,7 +65,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
65
65
|
CONSOLE LOG ENTRY: Started fit category
|
|
66
66
|
CONSOLE LOG ENTRY: test false
|
|
67
67
|
CONSOLE LOG ENTRY: Started fit fitSeries exponential benchmark
|
|
68
|
-
CONSOLE LOG ENTRY: Finished fit fitSeries exponential benchmark for
|
|
68
|
+
CONSOLE LOG ENTRY: Finished fit fitSeries exponential benchmark for 13 ms
|
|
69
69
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
70
70
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
71
71
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -74,7 +74,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
74
74
|
CONSOLE LOG ENTRY: Started fit category
|
|
75
75
|
CONSOLE LOG ENTRY: test false
|
|
76
76
|
CONSOLE LOG ENTRY: Started fit fitSeries linear benchmark
|
|
77
|
-
CONSOLE LOG ENTRY: Finished fit fitSeries linear benchmark for
|
|
77
|
+
CONSOLE LOG ENTRY: Finished fit fitSeries linear benchmark for 12 ms
|
|
78
78
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
79
79
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
80
80
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -92,7 +92,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
92
92
|
CONSOLE LOG ENTRY: Started fit category
|
|
93
93
|
CONSOLE LOG ENTRY: test false
|
|
94
94
|
CONSOLE LOG ENTRY: Started fit fitSeries polynomial benchmark
|
|
95
|
-
CONSOLE LOG ENTRY: Finished fit fitSeries polynomial benchmark for
|
|
95
|
+
CONSOLE LOG ENTRY: Finished fit fitSeries polynomial benchmark for 15 ms
|
|
96
96
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
97
97
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
98
98
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -101,7 +101,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
101
101
|
CONSOLE LOG ENTRY: Started fit category
|
|
102
102
|
CONSOLE LOG ENTRY: test false
|
|
103
103
|
CONSOLE LOG ENTRY: Started fit fitSeries sigmoid benchmark
|
|
104
|
-
CONSOLE LOG ENTRY: Finished fit fitSeries sigmoid benchmark for
|
|
104
|
+
CONSOLE LOG ENTRY: Finished fit fitSeries sigmoid benchmark for 13 ms
|
|
105
105
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
106
106
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
107
107
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -110,7 +110,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
110
110
|
CONSOLE LOG ENTRY: Started fit category
|
|
111
111
|
CONSOLE LOG ENTRY: test false
|
|
112
112
|
CONSOLE LOG ENTRY: Started fit fitSeries
|
|
113
|
-
CONSOLE LOG ENTRY: Finished fit fitSeries for
|
|
113
|
+
CONSOLE LOG ENTRY: Finished fit fitSeries for 38 ms
|
|
114
114
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
115
115
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
116
116
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -119,7 +119,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
119
119
|
CONSOLE LOG ENTRY: Started fit category
|
|
120
120
|
CONSOLE LOG ENTRY: test false
|
|
121
121
|
CONSOLE LOG ENTRY: Started fit getCurve
|
|
122
|
-
CONSOLE LOG ENTRY: Finished fit getCurve for
|
|
122
|
+
CONSOLE LOG ENTRY: Finished fit getCurve for 1 ms
|
|
123
123
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
124
124
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
125
125
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -128,7 +128,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
128
128
|
CONSOLE LOG ENTRY: Started fit category
|
|
129
129
|
CONSOLE LOG ENTRY: test false
|
|
130
130
|
CONSOLE LOG ENTRY: Started fit getSeriesConfidenceInterval
|
|
131
|
-
CONSOLE LOG ENTRY: Finished fit getSeriesConfidenceInterval for
|
|
131
|
+
CONSOLE LOG ENTRY: Finished fit getSeriesConfidenceInterval for 1 ms
|
|
132
132
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
133
133
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
134
134
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -146,7 +146,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
146
146
|
CONSOLE LOG ENTRY: Started fit category
|
|
147
147
|
CONSOLE LOG ENTRY: test false
|
|
148
148
|
CONSOLE LOG ENTRY: Started fit getSeriesStatistics
|
|
149
|
-
CONSOLE LOG ENTRY: Finished fit getSeriesStatistics for
|
|
149
|
+
CONSOLE LOG ENTRY: Finished fit getSeriesStatistics for 1 ms
|
|
150
150
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
151
151
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
152
152
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -182,7 +182,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
182
182
|
CONSOLE LOG ENTRY: Started rendering category
|
|
183
183
|
CONSOLE LOG ENTRY: test false
|
|
184
184
|
CONSOLE LOG ENTRY: Started rendering rendering different fitChartData on canvas
|
|
185
|
-
CONSOLE LOG ENTRY: Finished rendering rendering different fitChartData on canvas for
|
|
185
|
+
CONSOLE LOG ENTRY: Finished rendering rendering different fitChartData on canvas for 12855 ms
|
|
186
186
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
187
187
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
188
188
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -191,9 +191,8 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
191
191
|
CONSOLE LOG ENTRY: Started rendering category
|
|
192
192
|
CONSOLE LOG ENTRY: test false
|
|
193
193
|
CONSOLE LOG ENTRY: Started rendering rendering in grid
|
|
194
|
-
CONSOLE LOG
|
|
195
|
-
CONSOLE LOG ENTRY:
|
|
196
|
-
CONSOLE LOG ENTRY: Finished rendering rendering in grid for 6083 ms
|
|
194
|
+
CONSOLE LOG ENTRY: curves rendering took 5380 ms
|
|
195
|
+
CONSOLE LOG ENTRY: Finished rendering rendering in grid for 6692 ms
|
|
197
196
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
198
197
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
199
198
|
CONSOLE LOG ENTRY: --------------------
|
|
@@ -202,7 +201,7 @@ CONSOLE LOG ENTRY: JSHandle@object
|
|
|
202
201
|
CONSOLE LOG ENTRY: Started rendering category
|
|
203
202
|
CONSOLE LOG ENTRY: test false
|
|
204
203
|
CONSOLE LOG ENTRY: Started rendering rendering same fitChartData on canvas
|
|
205
|
-
CONSOLE LOG ENTRY: Finished rendering rendering same fitChartData on canvas for
|
|
204
|
+
CONSOLE LOG ENTRY: Finished rendering rendering same fitChartData on canvas for 16043 ms
|
|
206
205
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
207
206
|
CONSOLE LOG REQUEST: 200, http://localhost:8080/api/log/tests/package?benchmark=false&ciCd=false
|
|
208
207
|
CONSOLE LOG ENTRY: --------------------
|
package/test-record-1.mp4
CHANGED
|
Binary file
|
package/src/pngRenderer.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
|
|
3
|
-
/* Do not change these import lines to match external modules in webpack configuration */
|
|
4
|
-
import * as grok from 'datagrok-api/grok';
|
|
5
|
-
import * as ui from 'datagrok-api/ui';
|
|
6
|
-
import * as DG from 'datagrok-api/dg';
|
|
7
|
-
@grok.decorators.cellRenderer({name: 'rawPng', cellType: 'rawPng'})
|
|
8
|
-
export class RawPNGRenderer extends DG.GridCellRenderer {
|
|
9
|
-
get name(): string { return 'rawPng'; }
|
|
10
|
-
|
|
11
|
-
get cellType(): string { return 'rawPng'; }
|
|
12
|
-
|
|
13
|
-
get defaultHeight(): number { return 200; }
|
|
14
|
-
|
|
15
|
-
get defaultWidth(): number { return 200; }
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Cell renderer function.
|
|
19
|
-
*
|
|
20
|
-
* @param {CanvasRenderingContext2D} g Canvas rendering context.
|
|
21
|
-
* @param {number} x x coordinate on the canvas.
|
|
22
|
-
* @param {number} y y coordinate on the canvas.
|
|
23
|
-
* @param {number} w width of the cell.
|
|
24
|
-
* @param {number} h height of the cell.
|
|
25
|
-
* @param {DG.GridCell} gridCell Grid cell.
|
|
26
|
-
* @param {DG.GridCellStyle} _cellStyle Cell style.
|
|
27
|
-
*/
|
|
28
|
-
render(
|
|
29
|
-
g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, gridCell: DG.GridCell,
|
|
30
|
-
_cellStyle: DG.GridCellStyle
|
|
31
|
-
): void {
|
|
32
|
-
if (gridCell.gridRow < 0 || !gridCell.cell.value) return;
|
|
33
|
-
|
|
34
|
-
const cacheKey = this.getCacheKey(gridCell);
|
|
35
|
-
if (cacheKey && this.imageCache.has(cacheKey)) {
|
|
36
|
-
const img = this.imageCache.get(cacheKey)!;
|
|
37
|
-
this.drawInBounds(g, x, y, w, h, gridCell, img);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const pngString: string = gridCell.cell.value;
|
|
41
|
-
const img = new Image();
|
|
42
|
-
|
|
43
|
-
img.src = 'data:image/png;base64,' + pngString;
|
|
44
|
-
img.onload = () => {
|
|
45
|
-
if (cacheKey) {
|
|
46
|
-
this.imageCache.set(cacheKey, img);
|
|
47
|
-
gridCell.render();
|
|
48
|
-
} else { this.drawInBounds(g, x, y, w, h, gridCell, img); }
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
getCacheKey(gridCell: DG.GridCell): string | null {
|
|
53
|
-
if (!gridCell?.cell?.value || !gridCell.cell.dataFrame || !gridCell.cell.dataFrame.id || !gridCell.cell.column?.name || (gridCell.cell.rowIndex ?? -1) < 0 || !gridCell.cell.column.version)
|
|
54
|
-
return null;
|
|
55
|
-
return `${gridCell.cell.dataFrame.id}-${gridCell.cell.column.name}-${gridCell.cell.rowIndex}-${gridCell.cell.column.version}`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
imageCache: DG.LruCache<string, HTMLImageElement> = new DG.LruCache<string, HTMLImageElement>(300);
|
|
59
|
-
|
|
60
|
-
drawInBounds(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, gridCell: DG.GridCell,
|
|
61
|
-
img: HTMLImageElement): void {
|
|
62
|
-
g.clearRect(x, y, w, h);
|
|
63
|
-
const minAxis = Math.min(w, h, (img.width ?? 0), (img.height ?? 0));
|
|
64
|
-
if (minAxis < 2)
|
|
65
|
-
return;
|
|
66
|
-
// image should be scaled such that it is in the center of the cell
|
|
67
|
-
const scaleBy = w < h ? (w - 4) / img.width : (h - 4) / img.height;
|
|
68
|
-
const imgWidth = img.width * scaleBy;
|
|
69
|
-
const imgHeight = img.height * scaleBy;
|
|
70
|
-
const xOffset = (w - imgWidth) / 2;
|
|
71
|
-
const yOffset = (h - imgHeight) / 2;
|
|
72
|
-
g.drawImage(img, x + xOffset, y + yOffset, imgWidth, imgHeight);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
onDoubleClick(gridCell: DG.GridCell<any>, e: MouseEvent): void {
|
|
76
|
-
if (gridCell.cell.value) {
|
|
77
|
-
const pngString: string = gridCell.cell.value;
|
|
78
|
-
const img = new Image();
|
|
79
|
-
img.src = 'data:image/png;base64,' + pngString;
|
|
80
|
-
const canvas = ui.canvas(600, 600);
|
|
81
|
-
canvas.width = 600;
|
|
82
|
-
canvas.height = 600;
|
|
83
|
-
|
|
84
|
-
const ctx = canvas.getContext('2d')!;
|
|
85
|
-
img.onload = () => this.drawInBounds(ctx, 0, 0, 600, 600, gridCell, img);
|
|
86
|
-
ui.dialog({title: 'PNG Image'})
|
|
87
|
-
.add(canvas)
|
|
88
|
-
.show({resizable: true});
|
|
89
|
-
e.preventDefault();
|
|
90
|
-
e.stopPropagation();
|
|
91
|
-
setTimeout(() => {
|
|
92
|
-
canvas.style.width = '100%';
|
|
93
|
-
canvas.style.height = '100%';
|
|
94
|
-
}, 300);
|
|
95
|
-
// d.sub(ui.onSizeChanged(canvas).subscribe(() => console.log(canvas.offsetHeight, canvas.offsetWidth)));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|