@datagrok/curves 1.12.1 → 1.13.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/CLAUDE.md +118 -15
  3. package/README.md +51 -4
  4. package/dist/package-test.js +7963 -4867
  5. package/dist/package-test.js.map +1 -1
  6. package/dist/package.js +3411 -2024
  7. package/dist/package.js.map +1 -1
  8. package/files/demo/Assay_Curves.csv +43 -43
  9. package/package.json +5 -4
  10. package/scripts/calculateMSR.py +16 -7
  11. package/src/fit/curve-converter.ts +8 -1
  12. package/src/fit/data-to-curves.ts +10 -5
  13. package/src/fit/fit-chart-data.ts +323 -0
  14. package/src/fit/fit-grid-cell-handler.ts +98 -231
  15. package/src/fit/fit-inspection.ts +3 -3
  16. package/src/fit/fit-interaction.ts +181 -0
  17. package/src/fit/fit-layout.ts +64 -0
  18. package/src/fit/fit-legend.ts +292 -0
  19. package/src/fit/fit-options.ts +222 -0
  20. package/src/fit/fit-parser.ts +16 -5
  21. package/src/fit/fit-renderer.ts +180 -469
  22. package/src/fit/fit-statistics.ts +154 -0
  23. package/src/fit/multi-curve-viewer.ts +46 -20
  24. package/src/fit/render-utils.ts +208 -150
  25. package/src/package-api.ts +92 -14
  26. package/src/package-test.ts +6 -0
  27. package/src/package.g.ts +70 -15
  28. package/src/package.ts +121 -15
  29. package/src/tests/calculated-columns-tests.ts +299 -0
  30. package/src/tests/converter-tests.ts +29 -0
  31. package/src/tests/curve-data.ts +82 -0
  32. package/src/tests/fit-cache-tests.ts +128 -0
  33. package/src/tests/fit-tests.ts +310 -3
  34. package/src/tests/legend-tests.ts +243 -0
  35. package/src/tests/multi-curve-viewer-tests.ts +100 -0
  36. package/src/tests/panel-renderer-tests.ts +502 -0
  37. package/src/tests/project-tests.ts +99 -0
  38. package/src/tests/transform-tests.ts +3 -2
  39. package/test-console-output-1.log +357 -110
  40. package/test-record-1.mp4 +0 -0
@@ -0,0 +1,99 @@
1
+ import * as DG from 'datagrok-api/dg';
2
+ import * as grok from 'datagrok-api/grok';
3
+
4
+ import {awaitCheck, category, delay, expect, test} from '@datagrok-libraries/test/src/test';
5
+ import {changeCurvesOptions} from '../fit/fit-options';
6
+ import {getColumnChartOptions, getOrCreateParsedChartData} from '../fit/fit-chart-data';
7
+
8
+ const DEMO_FILE = 'curves-demo.csv';
9
+ // every cell of this column declares showCurveConfidenceInterval, so a column-level "off" only shows
10
+ // up if the option outranks the data rather than being written into it
11
+ const CURVE_COLUMN = 'multiple styled series';
12
+
13
+ async function createTableView(tableName: string): Promise<DG.TableView> {
14
+ const df = await grok.dapi.files.readCsv(`System:AppData/Curves/${tableName}`);
15
+ df.name = tableName.replace('.csv', '');
16
+ await grok.data.detectSemanticTypes(df);
17
+ return grok.shell.addTableView(df);
18
+ }
19
+
20
+ async function saveAndOpenProject(tv: DG.TableView, dataSync?: boolean): Promise<void> {
21
+ const project = DG.Project.create();
22
+ project.name = 'Curves test project';
23
+ const tableInfo = tv.dataFrame.getTableInfo();
24
+ if (dataSync) {
25
+ //@ts-ignore
26
+ tableInfo.tags[DG.Tags.DataSync] = 'sync';
27
+ //@ts-ignore
28
+ tableInfo.tags[DG.Tags.CreationScript] = tv.dataFrame.getTag(DG.Tags.CreationScript);
29
+ }
30
+ // saveLayout, not getInfo: only saveLayout runs saveSyncTags, which is what puts the column tags
31
+ // into the layout - without them a refetched table comes back with nothing but its own data
32
+ const layoutInfo = tv.saveLayout();
33
+ project.addChild(tableInfo);
34
+ project.addChild(layoutInfo);
35
+ await grok.dapi.tables.uploadDataFrame(tv.dataFrame);
36
+ await grok.dapi.tables.save(tableInfo);
37
+ await grok.dapi.views.save(layoutInfo);
38
+ await grok.dapi.projects.save(project);
39
+ const projId = project.id;
40
+ // the fit cell renderer keeps painting while the view tears down, and closeAll() surfaces that as
41
+ // an unhandled exception - let the grid settle first
42
+ await delay(500);
43
+ grok.shell.closeAll();
44
+ await delay(500);
45
+ const p = await grok.dapi.projects.find(projId);
46
+ await p.open();
47
+ }
48
+
49
+ async function dataFrameContainsColumn(colName: string): Promise<void> {
50
+ await awaitCheck(() => grok.shell.tv?.dataFrame?.col(colName) != null,
51
+ `${colName} is missing from the reopened project`, 30000);
52
+ }
53
+
54
+ function turnOffConfidenceIntervals(tv: DG.TableView): void {
55
+ if (tv.dataFrame.col(CURVE_COLUMN) === null)
56
+ throw new Error(`no ${CURVE_COLUMN} column - the table has: ${tv.dataFrame.columns.names().join(', ')}`);
57
+ changeCurvesOptions(tv.grid.cell(CURVE_COLUMN, 0),
58
+ {property: {name: 'showCurveConfidenceInterval'}, value: false} as unknown as DG.InputBase,
59
+ 'seriesOptions', 'Column');
60
+ }
61
+
62
+ async function runSaveAndOpenProjectTest(dataSync?: boolean): Promise<void> {
63
+ let tv: DG.TableView;
64
+ if (dataSync) {
65
+ await DG.Func.find({name: 'OpenFile'})[0].prepare({
66
+ fullPath: `System:AppData/Curves/${DEMO_FILE}`,
67
+ }).call(undefined, undefined, {processed: false});
68
+ tv = grok.shell.tv;
69
+ await grok.data.detectSemanticTypes(tv.dataFrame);
70
+ } else { tv = await createTableView(DEMO_FILE); }
71
+ await delay(100);
72
+ turnOffConfidenceIntervals(tv);
73
+ await delay(10);
74
+ await saveAndOpenProject(tv, dataSync);
75
+ await delay(10);
76
+ await dataFrameContainsColumn(CURVE_COLUMN);
77
+ // the tags are restored after the table, so wait for the option rather than for the column
78
+ await awaitCheck(() => getColumnChartOptions(grok.shell.tv.dataFrame.col(CURVE_COLUMN)!)
79
+ .seriesOptions?.showCurveConfidenceInterval === false,
80
+ 'the column tag did not come back with the project', 30000);
81
+
82
+ const df = grok.shell.tv.dataFrame;
83
+ expect(getOrCreateParsedChartData(df.cell(0, CURVE_COLUMN)).series![0].showCurveConfidenceInterval, false,
84
+ 'the column-level option did not outrank the data after reopening');
85
+ }
86
+
87
+ category('projects', () => {
88
+ test('column-level option survives a project', async () => {
89
+ await runSaveAndOpenProjectTest();
90
+ await delay(100);
91
+ }, {timeout: 120000});
92
+
93
+ test('column-level option survives a datasync project', async () => {
94
+ // the table is rebuilt from its creation script, so the cells come back declaring the interval
95
+ // and only the tag the layout carries can turn it off
96
+ await runSaveAndOpenProjectTest(true);
97
+ await delay(100);
98
+ }, {timeout: 120000});
99
+ });
@@ -1,7 +1,8 @@
1
1
  import * as DG from 'datagrok-api/dg';
2
2
 
3
3
  import {Viewport} from '@datagrok-libraries/utils/src/transform';
4
- import {FitChartCellRenderer, layoutChart} from '../fit/fit-renderer';
4
+ import {FitChartCellRenderer} from '../fit/fit-renderer';
5
+ import {layoutChart} from '../fit/fit-layout';
5
6
 
6
7
  import {category, expect, test} from '@datagrok-libraries/test/src/test';
7
8
  import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
@@ -10,7 +11,7 @@ import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
10
11
  category('viewport', () => {
11
12
  test('viewportMethods', async () => {
12
13
  const screenBounds = FitChartCellRenderer.inflateScreenBounds(new DG.Rect(120, 20, 160, 100));
13
- const [dataBox] = layoutChart(screenBounds, false, false);
14
+ const [dataBox] = layoutChart(screenBounds, false, false, false);
14
15
  const dataBounds = new DG.Rect(0.1, 0.06, 7, 5.94);
15
16
  const viewport = new Viewport(dataBounds, dataBox, false, false);
16
17