@datagrok/curves 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +13 -0
- package/.vscode/tasks.json +10 -0
- package/README.md +19 -0
- package/detectors.js +35 -0
- package/dist/package-test.js +591 -0
- package/dist/package-test.js.map +1 -0
- package/dist/package.js +15899 -0
- package/dist/package.js.map +1 -0
- package/package.json +53 -0
- package/package.png +0 -0
- package/src/fit/cell-render-viewer.js +33 -0
- package/src/fit/cell-render-viewer.js.map +1 -0
- package/src/fit/cell-render-viewer.ts +45 -0
- package/src/fit/fit-data.js +221 -0
- package/src/fit/fit-data.js.map +1 -0
- package/src/fit/fit-data.ts +335 -0
- package/src/fit/fit-demo.js +91 -0
- package/src/fit/fit-demo.js.map +1 -0
- package/src/fit/fit-demo.ts +98 -0
- package/src/fit/fit-grid-cell-handler.js +54 -0
- package/src/fit/fit-grid-cell-handler.js.map +1 -0
- package/src/fit/fit-grid-cell-handler.ts +70 -0
- package/src/fit/fit-parser.js +115 -0
- package/src/fit/fit-parser.js.map +1 -0
- package/src/fit/fit-parser.ts +144 -0
- package/src/fit/fit-renderer.js +167 -0
- package/src/fit/fit-renderer.js.map +1 -0
- package/src/fit/fit-renderer.ts +202 -0
- package/src/fit/multi-curve-viewer.js +67 -0
- package/src/fit/multi-curve-viewer.js.map +1 -0
- package/src/fit/multi-curve-viewer.ts +87 -0
- package/src/fit/transform.js +73 -0
- package/src/fit/transform.js.map +1 -0
- package/src/fit/transform.ts +101 -0
- package/src/package-test.js +26 -0
- package/src/package-test.js.map +1 -0
- package/src/package-test.ts +18 -0
- package/src/package.js +50 -0
- package/src/package.js.map +1 -0
- package/src/package.ts +48 -0
- package/src/tests/fit-viewer-test.js +16 -0
- package/src/tests/fit-viewer-test.js.map +1 -0
- package/src/tests/fit-viewer-test.ts +11 -0
- package/tsconfig.json +71 -0
- package/webpack.config.js +54 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const AXES = { x: 'xAxis', y: 'yAxis' };
|
|
2
|
+
const EXTREMUMS = { min: 'min', max: 'max' };
|
|
3
|
+
/** Constructs {@link IFitChartOptions} from grid and settings xml tags.
|
|
4
|
+
* @param {Element} grid XML grid tag
|
|
5
|
+
* @param {Element} settings XML settings tag
|
|
6
|
+
* @return {IFitChartOptions} IFitChartOptions for the fitted curve
|
|
7
|
+
*/
|
|
8
|
+
function getChartOptions(grid, settings) {
|
|
9
|
+
const fitChartOptions = {
|
|
10
|
+
minX: +grid.getElementsByTagName(AXES.x)[0].getAttribute(EXTREMUMS.min),
|
|
11
|
+
minY: +grid.getElementsByTagName(AXES.y)[0].getAttribute(EXTREMUMS.min),
|
|
12
|
+
maxX: +grid.getElementsByTagName(AXES.x)[0].getAttribute(EXTREMUMS.max),
|
|
13
|
+
maxY: +grid.getElementsByTagName(AXES.y)[0].getAttribute(EXTREMUMS.max),
|
|
14
|
+
xAxisName: settings.getAttribute('xLabel'),
|
|
15
|
+
yAxisName: settings.getAttribute('yLabel'),
|
|
16
|
+
logX: !!settings.getAttribute('logX'),
|
|
17
|
+
};
|
|
18
|
+
return fitChartOptions;
|
|
19
|
+
}
|
|
20
|
+
/** Constructs {@link IFitSeriesOptions} from the series xml tag.
|
|
21
|
+
* @param {Element} series XML series tag
|
|
22
|
+
* @return {IFitSeriesOptions} IFitSeriesOptions for the fitted curve
|
|
23
|
+
*/
|
|
24
|
+
function getSeriesOptions(series) {
|
|
25
|
+
var _a;
|
|
26
|
+
const params = (_a = (series.getElementsByTagName('params')[0].childNodes[0].nodeValue)) === null || _a === void 0 ? void 0 : _a.split(',').map(Number);
|
|
27
|
+
// params there are: [IC50, min, max, tan] (also log IC50) - so we place them correctly: [max, tan, IC50, min]
|
|
28
|
+
const newParams = [params[2], params[3], Math.log10(params[0]), params[1]];
|
|
29
|
+
let funcType = series.getElementsByTagName('function')[0].getAttribute('type');
|
|
30
|
+
funcType = funcType === 'sigif' ? 'Sigmoid' : funcType;
|
|
31
|
+
const markerColor = series.getElementsByTagName('settings')[0].getAttribute('markerColor');
|
|
32
|
+
const lineColor = series.getElementsByTagName('settings')[0].getAttribute('color');
|
|
33
|
+
const drawLine = !!series.getElementsByTagName('settings')[0].getAttribute('drawLine');
|
|
34
|
+
const seriesName = series.getAttribute('name');
|
|
35
|
+
const fitSeriesOptions = {
|
|
36
|
+
parameters: newParams,
|
|
37
|
+
fitFunction: funcType,
|
|
38
|
+
pointColor: markerColor,
|
|
39
|
+
fitLineColor: lineColor,
|
|
40
|
+
showFitLine: drawLine,
|
|
41
|
+
name: seriesName,
|
|
42
|
+
};
|
|
43
|
+
return fitSeriesOptions;
|
|
44
|
+
}
|
|
45
|
+
/** Constructs {@link IFitPoint} array from the grid series tag.
|
|
46
|
+
* @param {Element} series XML series tag
|
|
47
|
+
* @return {IFitPoint[]} IFitPoint array for current series
|
|
48
|
+
*/
|
|
49
|
+
function getPoints(series) {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const xCoords = (_a = (series.getElementsByTagName('x')[0].childNodes[0].nodeValue)) === null || _a === void 0 ? void 0 : _a.split(',');
|
|
52
|
+
const yCoords = (_b = (series.getElementsByTagName('y')[0].childNodes[0].nodeValue)) === null || _b === void 0 ? void 0 : _b.split(',');
|
|
53
|
+
// const mask = (series.getElementsByTagName('mask')[0].childNodes[0].nodeValue)?.split('')!;
|
|
54
|
+
const points = [];
|
|
55
|
+
for (let j = 0; j < xCoords.length; j++) {
|
|
56
|
+
points[j] = {
|
|
57
|
+
x: +xCoords[j],
|
|
58
|
+
y: +yCoords[j],
|
|
59
|
+
// outlier: !!mask[j],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return points;
|
|
63
|
+
}
|
|
64
|
+
/** Constructs {@link IFitSeries} from the grid series tag.
|
|
65
|
+
* @param {Element} series XML series tag
|
|
66
|
+
* @return {IFitSeries} IFitSeries for the current series
|
|
67
|
+
*/
|
|
68
|
+
function getSeries(series) {
|
|
69
|
+
const points = getPoints(series);
|
|
70
|
+
const currentFitSeriesOptions = getSeriesOptions(series);
|
|
71
|
+
const returnSeries = {
|
|
72
|
+
points: points,
|
|
73
|
+
};
|
|
74
|
+
Object.assign(series, currentFitSeriesOptions);
|
|
75
|
+
return returnSeries;
|
|
76
|
+
}
|
|
77
|
+
/** Constructs {@link IFitSeries} array from the seriesCollection xml tag.
|
|
78
|
+
* @param {Element} seriesCollection XML seriesCollection tag
|
|
79
|
+
* @return {IFitSeries[]} IFitSeries array for the fitted curve
|
|
80
|
+
*/
|
|
81
|
+
function getSeriesArray(seriesCollection) {
|
|
82
|
+
const fitSeries = [];
|
|
83
|
+
const seriesCollectionLength = seriesCollection.getElementsByTagName('series').length;
|
|
84
|
+
for (let i = 0; i < seriesCollectionLength; i++) {
|
|
85
|
+
const currentSeries = seriesCollection.getElementsByTagName('series')[i];
|
|
86
|
+
fitSeries[i] = getSeries(currentSeries);
|
|
87
|
+
}
|
|
88
|
+
return fitSeries;
|
|
89
|
+
}
|
|
90
|
+
/** Converts XML fitted curve chart document into {@link IFitChartData} interface.
|
|
91
|
+
* @param {string} xmlText XML document
|
|
92
|
+
* @return {IFitChartData} IFitChartData intefrace for the fitted curve
|
|
93
|
+
*/
|
|
94
|
+
export function convertXMLToIFitChartData(xmlText) {
|
|
95
|
+
const parser = new DOMParser();
|
|
96
|
+
const xmlDoc = parser.parseFromString(xmlText, 'text/xml');
|
|
97
|
+
// get IFitChartOptions from grid
|
|
98
|
+
const gridElement = xmlDoc.getElementsByTagName('grid')[0];
|
|
99
|
+
const settingsElement = xmlDoc.getElementsByTagName('settings')[0];
|
|
100
|
+
const fitChartOptions = getChartOptions(gridElement, settingsElement);
|
|
101
|
+
// get the whole series collection
|
|
102
|
+
const seriesCollection = xmlDoc.getElementsByTagName('seriesCollection')[0];
|
|
103
|
+
// get first series to make it the default options (IFitSeriesOptions)
|
|
104
|
+
const firstSeries = seriesCollection.getElementsByTagName('series')[0];
|
|
105
|
+
const fitSeriesOptions = getSeriesOptions(firstSeries);
|
|
106
|
+
// get IFitSeries[]
|
|
107
|
+
const fitSeries = getSeriesArray(seriesCollection);
|
|
108
|
+
const fitChartData = {
|
|
109
|
+
chartOptions: fitChartOptions,
|
|
110
|
+
seriesOptions: fitSeriesOptions,
|
|
111
|
+
series: fitSeries
|
|
112
|
+
};
|
|
113
|
+
return fitChartData;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=fit-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fit-parser.js","sourceRoot":"","sources":["fit-parser.ts"],"names":[],"mappings":"AAQA,MAAM,IAAI,GAAG,EAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAC,CAAC;AACtC,MAAM,SAAS,GAAG,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAC,CAAC;AAG3C;;;;EAIE;AACF,SAAS,eAAe,CAAC,IAAa,EAAE,QAAiB;IACvD,MAAM,eAAe,GAAqB;QACxC,IAAI,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAE;QACxE,IAAI,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAE;QACxE,IAAI,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAE;QACxE,IAAI,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAE;QAExE,SAAS,EAAE,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAE;QAC3C,SAA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AAC,WAAW,CAAC,CAAC;IAE1E,mBAAmB;IACnB,MAAM,SAAS,GAAG,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAEnD,MAAM,YAAY,GAAkB;QAClC,YAAY,EAAE,eAAe;QAC7B,aAAa,EAAE,gBAAgB;QAC/B,MAAM,EAAE,SAAS;KAClB,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IFitChartData,
|
|
3
|
+
IFitChartOptions,
|
|
4
|
+
IFitSeriesOptions,
|
|
5
|
+
IFitSeries,
|
|
6
|
+
IFitPoint
|
|
7
|
+
} from './fit-data';
|
|
8
|
+
|
|
9
|
+
const AXES = {x: 'xAxis', y: 'yAxis'};
|
|
10
|
+
const EXTREMUMS = {min: 'min', max: 'max'};
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/** Constructs {@link IFitChartOptions} from grid and settings xml tags.
|
|
14
|
+
* @param {Element} grid XML grid tag
|
|
15
|
+
* @param {Element} settings XML settings tag
|
|
16
|
+
* @return {IFitChartOptions} IFitChartOptions for the fitted curve
|
|
17
|
+
*/
|
|
18
|
+
function getChartOptions(grid: Element, settings: Element): IFitChartOptions {
|
|
19
|
+
const fitChartOptions: IFitChartOptions = {
|
|
20
|
+
minX: +grid.getElementsByTagName(AXES.x)[0].getAttribute(EXTREMUMS.min)!,
|
|
21
|
+
minY: +grid.getElementsByTagName(AXES.y)[0].getAttribute(EXTREMUMS.min)!,
|
|
22
|
+
maxX: +grid.getElementsByTagName(AXES.x)[0].getAttribute(EXTREMUMS.max)!,
|
|
23
|
+
maxY: +grid.getElementsByTagName(AXES.y)[0].getAttribute(EXTREMUMS.max)!,
|
|
24
|
+
|
|
25
|
+
xAxisName: settings.getAttribute('xLabel')!,
|
|
26
|
+
yAxisName: settings.getAttribute('yLabel')!,
|
|
27
|
+
logX: !!settings.getAttribute('logX')!,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return fitChartOptions;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Constructs {@link IFitSeriesOptions} from the series xml tag.
|
|
34
|
+
* @param {Element} series XML series tag
|
|
35
|
+
* @return {IFitSeriesOptions} IFitSeriesOptions for the fitted curve
|
|
36
|
+
*/
|
|
37
|
+
function getSeriesOptions(series: Element): IFitSeriesOptions {
|
|
38
|
+
const params = (series.getElementsByTagName('params')[0].childNodes[0].nodeValue)?.split(',')!.map(Number)!;
|
|
39
|
+
// params there are: [IC50, min, max, tan] (also log IC50) - so we place them correctly: [max, tan, IC50, min]
|
|
40
|
+
const newParams = [params[2], params[3], Math.log10(params[0]), params[1]];
|
|
41
|
+
let funcType = series.getElementsByTagName('function')[0].getAttribute('type')!;
|
|
42
|
+
funcType = funcType === 'sigif' ? 'Sigmoid': funcType;
|
|
43
|
+
const markerColor = series.getElementsByTagName('settings')[0].getAttribute('markerColor')!;
|
|
44
|
+
const lineColor = series.getElementsByTagName('settings')[0].getAttribute('color')!;
|
|
45
|
+
const drawLine = !!series.getElementsByTagName('settings')[0].getAttribute('drawLine')!;
|
|
46
|
+
const seriesName = series.getAttribute('name')!;
|
|
47
|
+
|
|
48
|
+
const fitSeriesOptions: IFitSeriesOptions = {
|
|
49
|
+
parameters: newParams,
|
|
50
|
+
fitFunction: funcType,
|
|
51
|
+
pointColor: markerColor,
|
|
52
|
+
fitLineColor: lineColor,
|
|
53
|
+
showFitLine: drawLine,
|
|
54
|
+
name: seriesName,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return fitSeriesOptions;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Constructs {@link IFitPoint} array from the grid series tag.
|
|
61
|
+
* @param {Element} series XML series tag
|
|
62
|
+
* @return {IFitPoint[]} IFitPoint array for current series
|
|
63
|
+
*/
|
|
64
|
+
function getPoints(series: Element): IFitPoint[] {
|
|
65
|
+
const xCoords = (series.getElementsByTagName('x')[0].childNodes[0].nodeValue)?.split(',')!;
|
|
66
|
+
const yCoords = (series.getElementsByTagName('y')[0].childNodes[0].nodeValue)?.split(',')!;
|
|
67
|
+
// const mask = (series.getElementsByTagName('mask')[0].childNodes[0].nodeValue)?.split('')!;
|
|
68
|
+
|
|
69
|
+
const points: IFitPoint[] = [];
|
|
70
|
+
for (let j = 0; j < xCoords.length; j++) {
|
|
71
|
+
points[j] = {
|
|
72
|
+
x: +xCoords[j],
|
|
73
|
+
y: +yCoords[j],
|
|
74
|
+
// outlier: !!mask[j],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return points;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Constructs {@link IFitSeries} from the grid series tag.
|
|
82
|
+
* @param {Element} series XML series tag
|
|
83
|
+
* @return {IFitSeries} IFitSeries for the current series
|
|
84
|
+
*/
|
|
85
|
+
function getSeries(series: Element): IFitSeries {
|
|
86
|
+
const points: IFitPoint[] = getPoints(series);
|
|
87
|
+
const currentFitSeriesOptions: IFitSeriesOptions = getSeriesOptions(series);
|
|
88
|
+
|
|
89
|
+
const returnSeries: IFitSeries = {
|
|
90
|
+
points: points,
|
|
91
|
+
};
|
|
92
|
+
Object.assign(series, currentFitSeriesOptions);
|
|
93
|
+
|
|
94
|
+
return returnSeries;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Constructs {@link IFitSeries} array from the seriesCollection xml tag.
|
|
98
|
+
* @param {Element} seriesCollection XML seriesCollection tag
|
|
99
|
+
* @return {IFitSeries[]} IFitSeries array for the fitted curve
|
|
100
|
+
*/
|
|
101
|
+
function getSeriesArray(seriesCollection: Element): IFitSeries[] {
|
|
102
|
+
const fitSeries: IFitSeries[] = [];
|
|
103
|
+
|
|
104
|
+
const seriesCollectionLength = seriesCollection.getElementsByTagName('series').length;
|
|
105
|
+
for (let i = 0; i < seriesCollectionLength; i++) {
|
|
106
|
+
const currentSeries = seriesCollection.getElementsByTagName('series')[i];
|
|
107
|
+
fitSeries[i] = getSeries(currentSeries);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return fitSeries;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
/** Converts XML fitted curve chart document into {@link IFitChartData} interface.
|
|
115
|
+
* @param {string} xmlText XML document
|
|
116
|
+
* @return {IFitChartData} IFitChartData intefrace for the fitted curve
|
|
117
|
+
*/
|
|
118
|
+
export function convertXMLToIFitChartData(xmlText: string): IFitChartData {
|
|
119
|
+
const parser = new DOMParser();
|
|
120
|
+
const xmlDoc = parser.parseFromString(xmlText, 'text/xml');
|
|
121
|
+
|
|
122
|
+
// get IFitChartOptions from grid
|
|
123
|
+
const gridElement = xmlDoc.getElementsByTagName('grid')[0];
|
|
124
|
+
const settingsElement = xmlDoc.getElementsByTagName('settings')[0];
|
|
125
|
+
const fitChartOptions: IFitChartOptions = getChartOptions(gridElement, settingsElement);
|
|
126
|
+
|
|
127
|
+
// get the whole series collection
|
|
128
|
+
const seriesCollection = xmlDoc.getElementsByTagName('seriesCollection')[0];
|
|
129
|
+
|
|
130
|
+
// get first series to make it the default options (IFitSeriesOptions)
|
|
131
|
+
const firstSeries = seriesCollection.getElementsByTagName('series')[0];
|
|
132
|
+
const fitSeriesOptions: IFitSeriesOptions = getSeriesOptions(firstSeries);
|
|
133
|
+
|
|
134
|
+
// get IFitSeries[]
|
|
135
|
+
const fitSeries = getSeriesArray(seriesCollection);
|
|
136
|
+
|
|
137
|
+
const fitChartData: IFitChartData = {
|
|
138
|
+
chartOptions: fitChartOptions,
|
|
139
|
+
seriesOptions: fitSeriesOptions,
|
|
140
|
+
series: fitSeries
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return fitChartData;
|
|
144
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import * as DG from 'datagrok-api/dg';
|
|
2
|
+
import * as grok from 'datagrok-api/grok';
|
|
3
|
+
import * as ui from 'datagrok-api/ui';
|
|
4
|
+
import { fitResultProperties } from "@datagrok-libraries/statistics/src/parameter-estimation/fit-curve";
|
|
5
|
+
import { StringUtils } from "@datagrok-libraries/utils/src/string-utils";
|
|
6
|
+
import { fitSeries, getChartData, getChartBounds, CONFIDENCE_INTERVAL_FILL_COLOR, CONFIDENCE_INTERVAL_STROKE_COLOR, CURVE_CONFIDENCE_INTERVAL_BOUNDS, TAG_FIT_CHART_FORMAT, TAG_FIT_CHART_FORMAT_3DX } from './fit-data';
|
|
7
|
+
import { convertXMLToIFitChartData } from './fit-parser';
|
|
8
|
+
import { Viewport } from "./transform";
|
|
9
|
+
import { MultiCurveViewer } from "./multi-curve-viewer";
|
|
10
|
+
/** Performs a chart layout, returning [viewport, xAxis, yAxis] */
|
|
11
|
+
function layoutChart(rect) {
|
|
12
|
+
if (rect.width < 100 || rect.height < 100)
|
|
13
|
+
return [rect, undefined, undefined];
|
|
14
|
+
return [
|
|
15
|
+
rect.cutLeft(30).cutBottom(30),
|
|
16
|
+
rect.getBottom(30).cutLeft(30),
|
|
17
|
+
rect.getLeft(30).cutBottom(30)
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
/** Performs a curve confidence interval drawing */
|
|
21
|
+
function drawConfidenceInterval(g, series, confidenceType, fitResult, transform) {
|
|
22
|
+
//const fitResult = fitSeries(series);
|
|
23
|
+
g.beginPath();
|
|
24
|
+
for (let i = 0; i < series.points.length; i++) {
|
|
25
|
+
const x = transform.xToScreen(series.points[i].x);
|
|
26
|
+
const y = confidenceType === CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP
|
|
27
|
+
? transform.yToScreen(fitResult.confidenceTop(series.points[i].x))
|
|
28
|
+
: transform.yToScreen(fitResult.confidenceBottom(series.points[i].x));
|
|
29
|
+
if (i === 0)
|
|
30
|
+
g.moveTo(x, y);
|
|
31
|
+
else
|
|
32
|
+
g.lineTo(x, y);
|
|
33
|
+
}
|
|
34
|
+
g.stroke();
|
|
35
|
+
}
|
|
36
|
+
/** Performs a curve confidence interval filling */
|
|
37
|
+
function fillConfidenceInterval(g, series, transform) {
|
|
38
|
+
const fitResult = fitSeries(series);
|
|
39
|
+
g.beginPath();
|
|
40
|
+
for (let i = 0; i < series.points.length; i++) {
|
|
41
|
+
const x = transform.xToScreen(series.points[i].x);
|
|
42
|
+
const y = transform.yToScreen(fitResult.confidenceTop(series.points[i].x));
|
|
43
|
+
if (i === 0)
|
|
44
|
+
g.moveTo(x, y);
|
|
45
|
+
else
|
|
46
|
+
g.lineTo(x, y);
|
|
47
|
+
}
|
|
48
|
+
// reverse traverse to make a shape of confidence interval to fill it
|
|
49
|
+
for (let i = series.points.length - 1; i >= 0; i--) {
|
|
50
|
+
const x = transform.xToScreen(series.points[i].x);
|
|
51
|
+
const y = transform.yToScreen(fitResult.confidenceBottom(series.points[i].x));
|
|
52
|
+
g.lineTo(x, y);
|
|
53
|
+
}
|
|
54
|
+
g.closePath();
|
|
55
|
+
g.fill();
|
|
56
|
+
}
|
|
57
|
+
export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
58
|
+
get name() { return 'fit'; }
|
|
59
|
+
get cellType() { return 'fit'; }
|
|
60
|
+
getDefaultSize(gridColumn) {
|
|
61
|
+
return { width: 160, height: 100 };
|
|
62
|
+
}
|
|
63
|
+
onClick(gridCell, e) {
|
|
64
|
+
grok.shell.o = gridCell;
|
|
65
|
+
}
|
|
66
|
+
onDoubleClick(gridCell, e) {
|
|
67
|
+
ui.dialog({ title: 'Edit chart' })
|
|
68
|
+
.add(MultiCurveViewer.fromChartData(getChartData(gridCell)).root)
|
|
69
|
+
.show();
|
|
70
|
+
}
|
|
71
|
+
renderCurves(g, x, y, w, h, data) {
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
73
|
+
g.save();
|
|
74
|
+
g.beginPath();
|
|
75
|
+
g.rect(x, y, w, h);
|
|
76
|
+
g.clip();
|
|
77
|
+
const screenBounds = new DG.Rect(x, y, w, h).inflate(-6, -6);
|
|
78
|
+
const [dataBox, xAxisBox, yAxisBox] = layoutChart(screenBounds);
|
|
79
|
+
const dataBounds = getChartBounds(data);
|
|
80
|
+
const viewport = new Viewport(dataBounds, dataBox, (_b = (_a = data.chartOptions) === null || _a === void 0 ? void 0 : _a.logX) !== null && _b !== void 0 ? _b : false, (_d = (_c = data.chartOptions) === null || _c === void 0 ? void 0 : _c.logY) !== null && _d !== void 0 ? _d : false);
|
|
81
|
+
const minSize = Math.min(dataBox.width, dataBox.height);
|
|
82
|
+
const ratio = minSize > 100 ? 1 : 0.2 + (minSize / 100) * 0.8;
|
|
83
|
+
viewport.drawCoordinateGrid(g, xAxisBox, yAxisBox);
|
|
84
|
+
for (const series of data.series) {
|
|
85
|
+
if ((_e = series.showPoints) !== null && _e !== void 0 ? _e : true) {
|
|
86
|
+
g.strokeStyle = (_f = series.pointColor) !== null && _f !== void 0 ? _f : '0xFF40699c';
|
|
87
|
+
for (let i = 0, candleStart = null; i < series.points.length; i++) {
|
|
88
|
+
const p = series.points[i];
|
|
89
|
+
const nextSame = i + 1 < series.points.length && series.points[i + 1].x == p.x;
|
|
90
|
+
if (!candleStart && nextSame)
|
|
91
|
+
candleStart = i;
|
|
92
|
+
else if (candleStart != null && !nextSame) {
|
|
93
|
+
let minY = series.points[candleStart].y;
|
|
94
|
+
let maxY = minY;
|
|
95
|
+
for (let j = candleStart; j < i; j++) {
|
|
96
|
+
minY = Math.min(minY, series.points[j].y);
|
|
97
|
+
maxY = Math.max(minY, series.points[j].y);
|
|
98
|
+
}
|
|
99
|
+
g.beginPath();
|
|
100
|
+
g.moveTo(viewport.xToScreen(p.x), viewport.yToScreen(minY));
|
|
101
|
+
g.lineTo(viewport.xToScreen(p.x), viewport.yToScreen(maxY));
|
|
102
|
+
g.stroke();
|
|
103
|
+
candleStart = null;
|
|
104
|
+
}
|
|
105
|
+
else if (!candleStart) {
|
|
106
|
+
DG.Paint.marker(g, p.outlier ? DG.MARKER_TYPE.OUTLIER : DG.MARKER_TYPE.CIRCLE, viewport.xToScreen(p.x), viewport.yToScreen(p.y), series.pointColor ? DG.Color.fromHtml(series.pointColor) : DG.Color.scatterPlotMarker, (p.outlier ? 6 : 4) * ratio);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
let fitRes;
|
|
111
|
+
if ((_g = series.showFitLine) !== null && _g !== void 0 ? _g : true) {
|
|
112
|
+
g.strokeStyle = (_h = series.fitLineColor) !== null && _h !== void 0 ? _h : 'black';
|
|
113
|
+
g.lineWidth = 2 * ratio;
|
|
114
|
+
fitRes = fitSeries(series);
|
|
115
|
+
const curve = fitRes.fittedCurve; //getFittedCurve(series);
|
|
116
|
+
g.beginPath();
|
|
117
|
+
for (let i = 0; i < series.points.length; i++) {
|
|
118
|
+
const x = viewport.xToScreen(series.points[i].x);
|
|
119
|
+
const y = viewport.yToScreen(curve(series.points[i].x));
|
|
120
|
+
if (i == 0)
|
|
121
|
+
g.moveTo(x, y);
|
|
122
|
+
else
|
|
123
|
+
g.lineTo(x, y);
|
|
124
|
+
}
|
|
125
|
+
g.stroke();
|
|
126
|
+
}
|
|
127
|
+
if (((_j = series.showFitLine) !== null && _j !== void 0 ? _j : true) && ((_k = series.showCurveConfidenceInterval) !== null && _k !== void 0 ? _k : true)) {
|
|
128
|
+
g.strokeStyle = (_l = series.confidenceIntervalColor) !== null && _l !== void 0 ? _l : CONFIDENCE_INTERVAL_STROKE_COLOR;
|
|
129
|
+
g.fillStyle = (_m = series.confidenceIntervalColor) !== null && _m !== void 0 ? _m : CONFIDENCE_INTERVAL_FILL_COLOR;
|
|
130
|
+
drawConfidenceInterval(g, series, CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP, fitRes, viewport);
|
|
131
|
+
drawConfidenceInterval(g, series, CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM, fitRes, viewport);
|
|
132
|
+
fillConfidenceInterval(g, series, viewport);
|
|
133
|
+
}
|
|
134
|
+
if ((_o = data.chartOptions) === null || _o === void 0 ? void 0 : _o.showStatistics) {
|
|
135
|
+
let fitResult = fitSeries(series, true);
|
|
136
|
+
for (let i = 0; i < data.chartOptions.showStatistics.length; i++) {
|
|
137
|
+
const statName = data.chartOptions.showStatistics[i];
|
|
138
|
+
const prop = fitResultProperties.find(p => p.name == statName);
|
|
139
|
+
if (prop) {
|
|
140
|
+
const s = StringUtils.formatNumber(prop.get(fitResult));
|
|
141
|
+
g.fillStyle = (_p = series.fitLineColor) !== null && _p !== void 0 ? _p : 'black';
|
|
142
|
+
g.textAlign = "left";
|
|
143
|
+
g.fillText(prop.name + ': ' + s, dataBox.x + 5, dataBox.y + 20 + 20 * i);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
g.restore();
|
|
149
|
+
}
|
|
150
|
+
render(g, x, y, w, h, gridCell, cellStyle) {
|
|
151
|
+
if (w < 20 || h < 10)
|
|
152
|
+
return;
|
|
153
|
+
const data = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX
|
|
154
|
+
? convertXMLToIFitChartData(gridCell.cell.value)
|
|
155
|
+
: getChartData(gridCell);
|
|
156
|
+
this.renderCurves(g, x, y, w, h, data);
|
|
157
|
+
}
|
|
158
|
+
onMouseMove(gridCell, e) {
|
|
159
|
+
if (gridCell.bounds.width < 50) {
|
|
160
|
+
const canvas = ui.canvas(300, 200);
|
|
161
|
+
this.render(canvas.getContext("2d"), 0, 0, 300, 200, gridCell, null);
|
|
162
|
+
const content = ui.divV([canvas]);
|
|
163
|
+
ui.tooltip.show(content, e.x, e.y);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=fit-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fit-renderer.js","sourceRoot":"","sources":["fit-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAA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,CAAC,KAAK,GAAG,EAAE,EAAE;YAC9B,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAW,CAAC,CAAC;YAC7E,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YAClC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SACpC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import * as DG from 'datagrok-api/dg';
|
|
2
|
+
import * as grok from 'datagrok-api/grok';
|
|
3
|
+
import * as ui from 'datagrok-api/ui';
|
|
4
|
+
import {GridColumn} from 'datagrok-api/dg';
|
|
5
|
+
|
|
6
|
+
import {FitResult, fitResultProperties} from "@datagrok-libraries/statistics/src/parameter-estimation/fit-curve";
|
|
7
|
+
import {StringUtils} from "@datagrok-libraries/utils/src/string-utils";
|
|
8
|
+
|
|
9
|
+
import {fitSeries, getChartData, getChartBounds, getFittedCurve,IFitChartData, IFitSeries,
|
|
10
|
+
CONFIDENCE_INTERVAL_FILL_COLOR, CONFIDENCE_INTERVAL_STROKE_COLOR, CURVE_CONFIDENCE_INTERVAL_BOUNDS,
|
|
11
|
+
TAG_FIT_CHART_FORMAT, TAG_FIT_CHART_FORMAT_3DX} from './fit-data';
|
|
12
|
+
import {convertXMLToIFitChartData} from './fit-parser';
|
|
13
|
+
import {Viewport} from "./transform";
|
|
14
|
+
import {MultiCurveViewer} from "./multi-curve-viewer";
|
|
15
|
+
|
|
16
|
+
/** Performs a chart layout, returning [viewport, xAxis, yAxis] */
|
|
17
|
+
function layoutChart(rect: DG.Rect): [DG.Rect, DG.Rect?, DG.Rect?] {
|
|
18
|
+
if (rect.width < 100 || rect.height < 100)
|
|
19
|
+
return [rect, undefined, undefined];
|
|
20
|
+
return [
|
|
21
|
+
rect.cutLeft(30).cutBottom(30),
|
|
22
|
+
rect.getBottom(30).cutLeft(30),
|
|
23
|
+
rect.getLeft(30).cutBottom(30)
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Performs a curve confidence interval drawing */
|
|
28
|
+
function drawConfidenceInterval(g: CanvasRenderingContext2D, series: IFitSeries, confidenceType: string, fitResult: FitResult, transform: Viewport) {
|
|
29
|
+
//const fitResult = fitSeries(series);
|
|
30
|
+
g.beginPath();
|
|
31
|
+
for (let i = 0; i < series.points.length!; i++) {
|
|
32
|
+
const x = transform.xToScreen(series.points[i].x);
|
|
33
|
+
const y = confidenceType === CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP
|
|
34
|
+
? transform.yToScreen(fitResult.confidenceTop(series.points[i].x))
|
|
35
|
+
: transform.yToScreen(fitResult.confidenceBottom(series.points[i].x));
|
|
36
|
+
if (i === 0)
|
|
37
|
+
g.moveTo(x, y);
|
|
38
|
+
else
|
|
39
|
+
g.lineTo(x, y);
|
|
40
|
+
}
|
|
41
|
+
g.stroke();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Performs a curve confidence interval filling */
|
|
45
|
+
function fillConfidenceInterval(g: CanvasRenderingContext2D, series: IFitSeries, transform: Viewport) {
|
|
46
|
+
const fitResult = fitSeries(series);
|
|
47
|
+
g.beginPath();
|
|
48
|
+
for (let i = 0; i < series.points.length!; i++) {
|
|
49
|
+
const x = transform.xToScreen(series.points[i].x);
|
|
50
|
+
const y = transform.yToScreen(fitResult.confidenceTop(series.points[i].x));
|
|
51
|
+
if (i === 0)
|
|
52
|
+
g.moveTo(x, y);
|
|
53
|
+
else
|
|
54
|
+
g.lineTo(x, y);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// reverse traverse to make a shape of confidence interval to fill it
|
|
58
|
+
for (let i = series.points.length! - 1; i >= 0; i--) {
|
|
59
|
+
const x = transform.xToScreen(series.points[i].x);
|
|
60
|
+
const y = transform.yToScreen(fitResult.confidenceBottom(series.points[i].x));
|
|
61
|
+
g.lineTo(x, y);
|
|
62
|
+
}
|
|
63
|
+
g.closePath();
|
|
64
|
+
g.fill();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class FitChartCellRenderer extends DG.GridCellRenderer {
|
|
68
|
+
get name() { return 'fit'; }
|
|
69
|
+
|
|
70
|
+
get cellType() { return 'fit'; }
|
|
71
|
+
|
|
72
|
+
getDefaultSize(gridColumn: GridColumn): {width?: number | null, height?: number | null} {
|
|
73
|
+
return {width: 160, height: 100};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
onClick(gridCell: DG.GridCell, e: MouseEvent): void {
|
|
77
|
+
grok.shell.o = gridCell;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onDoubleClick(gridCell: DG.GridCell, e: MouseEvent) {
|
|
81
|
+
ui.dialog({title: 'Edit chart'})
|
|
82
|
+
.add(MultiCurveViewer.fromChartData(getChartData(gridCell)).root)
|
|
83
|
+
.show();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
renderCurves(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, data: IFitChartData) {
|
|
87
|
+
g.save();
|
|
88
|
+
g.beginPath();
|
|
89
|
+
g.rect(x, y, w, h);
|
|
90
|
+
g.clip();
|
|
91
|
+
|
|
92
|
+
const screenBounds = new DG.Rect(x, y, w, h).inflate(-6, -6);
|
|
93
|
+
const [dataBox, xAxisBox, yAxisBox] = layoutChart(screenBounds);
|
|
94
|
+
|
|
95
|
+
const dataBounds = getChartBounds(data);
|
|
96
|
+
const viewport = new Viewport(dataBounds, dataBox, data.chartOptions?.logX ?? false, data.chartOptions?.logY ?? false);
|
|
97
|
+
const minSize = Math.min(dataBox.width, dataBox.height);
|
|
98
|
+
const ratio = minSize > 100 ? 1 : 0.2 + (minSize / 100) * 0.8;
|
|
99
|
+
|
|
100
|
+
viewport.drawCoordinateGrid(g, xAxisBox, yAxisBox);
|
|
101
|
+
|
|
102
|
+
for (const series of data.series!) {
|
|
103
|
+
if (series.showPoints ?? true) {
|
|
104
|
+
g.strokeStyle = series.pointColor ?? '0xFF40699c';
|
|
105
|
+
for (let i = 0, candleStart = null; i < series.points.length!; i++) {
|
|
106
|
+
const p = series.points[i];
|
|
107
|
+
const nextSame = i + 1 < series.points.length && series.points[i + 1].x == p.x;
|
|
108
|
+
if (!candleStart && nextSame)
|
|
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
|
+
}
|
|
117
|
+
|
|
118
|
+
g.beginPath();
|
|
119
|
+
g.moveTo(viewport.xToScreen(p.x), viewport.yToScreen(minY));
|
|
120
|
+
g.lineTo(viewport.xToScreen(p.x), viewport.yToScreen(maxY));
|
|
121
|
+
g.stroke();
|
|
122
|
+
|
|
123
|
+
candleStart = null;
|
|
124
|
+
}
|
|
125
|
+
else if (!candleStart) {
|
|
126
|
+
DG.Paint.marker(g,
|
|
127
|
+
p.outlier ? DG.MARKER_TYPE.OUTLIER : DG.MARKER_TYPE.CIRCLE,
|
|
128
|
+
viewport.xToScreen(p.x), viewport.yToScreen(p.y),
|
|
129
|
+
series.pointColor ? DG.Color.fromHtml(series.pointColor) : DG.Color.scatterPlotMarker,
|
|
130
|
+
(p.outlier ? 6 : 4) * ratio);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let fitRes: any;
|
|
136
|
+
if (series.showFitLine ?? true ) {
|
|
137
|
+
g.strokeStyle = series.fitLineColor ?? 'black';
|
|
138
|
+
g.lineWidth = 2 * ratio;
|
|
139
|
+
fitRes = fitSeries(series);
|
|
140
|
+
const curve = fitRes.fittedCurve;//getFittedCurve(series);
|
|
141
|
+
|
|
142
|
+
g.beginPath();
|
|
143
|
+
for (let i = 0; i < series.points.length!; i++) {
|
|
144
|
+
const x = viewport.xToScreen(series.points[i].x);
|
|
145
|
+
const y = viewport.yToScreen(curve(series.points[i].x));
|
|
146
|
+
if (i == 0)
|
|
147
|
+
g.moveTo(x, y);
|
|
148
|
+
else
|
|
149
|
+
g.lineTo(x, y);
|
|
150
|
+
}
|
|
151
|
+
g.stroke();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if ((series.showFitLine ?? true) && (series.showCurveConfidenceInterval ?? true)) {
|
|
155
|
+
g.strokeStyle = series.confidenceIntervalColor ?? CONFIDENCE_INTERVAL_STROKE_COLOR;
|
|
156
|
+
g.fillStyle = series.confidenceIntervalColor ?? CONFIDENCE_INTERVAL_FILL_COLOR;
|
|
157
|
+
|
|
158
|
+
drawConfidenceInterval(g, series, CURVE_CONFIDENCE_INTERVAL_BOUNDS.TOP, fitRes, viewport);
|
|
159
|
+
drawConfidenceInterval(g, series, CURVE_CONFIDENCE_INTERVAL_BOUNDS.BOTTOM, fitRes, viewport);
|
|
160
|
+
fillConfidenceInterval(g, series, viewport);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if (data.chartOptions?.showStatistics) {
|
|
165
|
+
let fitResult = fitSeries(series, true);
|
|
166
|
+
for (let i = 0; i < data.chartOptions.showStatistics.length; i++) {
|
|
167
|
+
const statName = data.chartOptions.showStatistics[i];
|
|
168
|
+
const prop = fitResultProperties.find(p => p.name == statName);
|
|
169
|
+
if (prop) {
|
|
170
|
+
const s = StringUtils.formatNumber(prop.get(fitResult));
|
|
171
|
+
g.fillStyle = series.fitLineColor ?? 'black';
|
|
172
|
+
g.textAlign = "left";
|
|
173
|
+
g.fillText(prop.name + ': ' + s, dataBox.x + 5, dataBox.y + 20 + 20 * i);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
g.restore();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
render(g: CanvasRenderingContext2D,
|
|
183
|
+
x: number, y: number, w: number, h: number,
|
|
184
|
+
gridCell: DG.GridCell, cellStyle: DG.GridCellStyle) {
|
|
185
|
+
if (w < 20 || h < 10) return;
|
|
186
|
+
|
|
187
|
+
const data = gridCell.cell.column.getTag(TAG_FIT_CHART_FORMAT) === TAG_FIT_CHART_FORMAT_3DX
|
|
188
|
+
? convertXMLToIFitChartData(gridCell.cell.value)
|
|
189
|
+
: getChartData(gridCell);
|
|
190
|
+
|
|
191
|
+
this.renderCurves(g, x, y, w, h, data);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
onMouseMove(gridCell: DG.GridCell, e: MouseEvent) {
|
|
195
|
+
if (gridCell.bounds.width < 50) {
|
|
196
|
+
const canvas = ui.canvas(300, 200);
|
|
197
|
+
this.render(canvas.getContext("2d")!, 0, 0, 300, 200, gridCell, null as any);
|
|
198
|
+
const content = ui.divV([canvas]);
|
|
199
|
+
ui.tooltip.show(content, e.x, e.y);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|