@datagrok/curves 1.13.1 → 1.13.3

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/package.json CHANGED
@@ -1,55 +1,23 @@
1
1
  {
2
2
  "name": "@datagrok/curves",
3
3
  "friendlyName": "Curves",
4
- "version": "1.13.1",
4
+ "version": "1.13.3",
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",
8
8
  "email": "dkovalyov@datagrok.ai"
9
9
  },
10
10
  "dependencies": {
11
- "@datagrok-libraries/statistics": "^1.12.13",
12
- "@datagrok-libraries/test": "^1.2.0",
13
- "@datagrok-libraries/utils": "^4.6.5",
14
- "@types/wu": "^2.1.42",
15
- "@typescript-eslint/eslint-plugin": "^5.62.0",
16
- "@typescript-eslint/parser": "^5.62.0",
17
- "cash-dom": "^8.0.0",
11
+ "@datagrok-libraries/test": "1.4.1",
12
+ "@types/wu": "^2.1.44",
13
+ "cash-dom": "8.1.5",
18
14
  "datagrok-api": "^1.27.0",
19
- "dayjs": "^1.11.7",
20
- "eslint": "^8.1.0",
21
- "eslint-config-google": "^0.14.0",
22
- "exceljs": "^4.3.0",
15
+ "dayjs": "1.11.23",
16
+ "exceljs": "4.4.0",
23
17
  "jstat": "^1.9.6",
24
- "rxjs": "^6.5.5"
25
- },
26
- "devDependencies": {
27
- "css-loader": "^5.0.0",
28
- "datagrok-tools": "^6.1.6",
29
- "source-map-loader": "^4.0.1",
30
- "style-loader": "^2.0.0",
31
- "ts-loader": "^9.5.1",
32
- "typescript": "^5.6.3",
33
- "webpack": "^5.95.0",
34
- "webpack-cli": "^5.1.4"
35
- },
36
- "overrides": {
37
- "datagrok-api": "$datagrok-api",
38
- "uuid": "^11.1.1"
39
- },
40
- "scripts": {
41
- "link-all": "npm link datagrok-api @datagrok-libraries/utils @datagrok-libraries/statistics",
42
- "debug-curves": "webpack && grok publish",
43
- "release-curves": "webpack && grok publish --release",
44
- "build-curves": "webpack",
45
- "build": "grok api && grok check --soft && webpack",
46
- "debug-curves-dev": "webpack && grok publish dev",
47
- "release-curves-dev": "webpack && grok publish dev --release",
48
- "debug-curves-public": "webpack && grok publish public",
49
- "release-curves-public": "webpack && grok publish public --release",
50
- "debug-curves-local": "webpack && grok publish local",
51
- "test": "grok test",
52
- "build-all": "npm --prefix ./../../js-api run build && npm --prefix ./../../libraries/utils run build && npm --prefix ./../../libraries/statistics run build && npm run build"
18
+ "rxjs": "6.6.7",
19
+ "@datagrok-libraries/statistics": "^1.12.14",
20
+ "@datagrok-libraries/utils": "^4.7.9"
53
21
  },
54
22
  "canEdit": [
55
23
  "Administrators"
@@ -62,5 +30,11 @@
62
30
  "url": "https://github.com/datagrok-ai/public.git",
63
31
  "directory": "packages/Curves"
64
32
  },
65
- "category": "Visualizations"
66
- }
33
+ "category": "Visualizations",
34
+ "scripts": {
35
+ "build": "grok build",
36
+ "typecheck": "grok tsc --noEmit -p tsconfig.json",
37
+ "lint": "eslint --ext .ts,.tsx src",
38
+ "test": "grok test"
39
+ }
40
+ }
@@ -272,16 +272,16 @@ export function getOrCreateCachedCurvesDataPoints(series: IFitSeries, idx: numbe
272
272
  /** Reads a level's options, migrating a value stored under the pre-`.%` tag name so that only one of
273
273
  * the two ever holds the options. */
274
274
  function readChartOptions(tags: any): IFitChartData {
275
- // an empty tag parsed to an exception on every cell of the column
276
- const stored = tags[FitConstants.TAG_FIT];
277
- if (stored)
278
- return JSON.parse(stored);
279
- const legacy = tags[FitConstants.TAG_FIT_LEGACY];
280
- const migrated = !!legacy;
281
- tags[FitConstants.TAG_FIT] = migrated ? legacy : JSON.stringify(createDefaultChartData());
282
- if (migrated)
283
- delete tags[FitConstants.TAG_FIT_LEGACY];
284
- return JSON.parse(tags[FitConstants.TAG_FIT]);
275
+ // TODO: once Curves requires platform 1.28, move '.fit' onto '.%fit' on read again, so an old
276
+ // table's options travel with its layouts without waiting for the next option change
277
+ return JSON.parse(tags[FitConstants.TAG_FIT] || tags[FitConstants.TAG_FIT_LEGACY] ||
278
+ JSON.stringify(createDefaultChartData()));
279
+ }
280
+
281
+ /** Stores a level's options, dropping the legacy copy so only one of the two tags ever holds them. */
282
+ export function storeChartOptions(tags: any, chartOptions: IFitChartData): void {
283
+ tags[FitConstants.TAG_FIT] = JSON.stringify(chartOptions);
284
+ delete tags[FitConstants.TAG_FIT_LEGACY];
285
285
  }
286
286
 
287
287
  /** Returns existing, or creates new dataframe default chart options. */
@@ -11,7 +11,7 @@ import {
11
11
  } from '@datagrok-libraries/statistics/src/fit/fit-curve';
12
12
  import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
13
13
  import {fitFunctions, fitFunctionDescriptions, fitSeriesProperties, getStatisticProperty, DEFAULT_FIT_FUNCTION} from '@datagrok-libraries/statistics/src/fit/fit-engine';
14
- import {getColumnChartOptions, getDataFrameChartOptions, CHART_OPTIONS, SERIES_OPTIONS} from './fit-chart-data';
14
+ import {getColumnChartOptions, getDataFrameChartOptions, storeChartOptions, CHART_OPTIONS, SERIES_OPTIONS} from './fit-chart-data';
15
15
  import {isNativeFormat} from './curve-converter';
16
16
 
17
17
  // Options a statistic can depend on; everything else only repaints. errorModel weights the objective
@@ -172,10 +172,10 @@ export function changeCurvesOptions(gridCell: DG.GridCell, inputBase: DG.InputBa
172
172
 
173
173
  let columns: DG.Column[];
174
174
  if (manipulationLevel === MANIPULATION_LEVEL.DATAFRAME) {
175
- gridCell.cell.dataFrame.tags[FitConstants.TAG_FIT] = JSON.stringify(chartOptions);
175
+ storeChartOptions(gridCell.cell.dataFrame.tags, chartOptions);
176
176
  columns = gridCell.cell.dataFrame.columns.bySemTypeAll(FitConstants.FIT_SEM_TYPE);
177
177
  } else {
178
- gridCell.cell.column.tags[FitConstants.TAG_FIT] = JSON.stringify(chartOptions);
178
+ storeChartOptions(gridCell.cell.column.tags, chartOptions);
179
179
  columns = [gridCell.cell.column];
180
180
  }
181
181
 
@@ -186,7 +186,7 @@ export function changeCurvesOptions(gridCell: DG.GridCell, inputBase: DG.InputBa
186
186
  if (section)
187
187
  delete (section as any)[propertyName];
188
188
  unclaim(columnChartOptions, options, propertyName);
189
- column.tags[FitConstants.TAG_FIT] = JSON.stringify(columnChartOptions);
189
+ storeChartOptions(column.tags, columnChartOptions);
190
190
  }
191
191
  if (!isNativeFormat(column))
192
192
  continue;
@@ -246,7 +246,7 @@ category('panel and renderer', () => {
246
246
  }
247
247
  });
248
248
 
249
- test('options stored under the legacy tag are read and migrate onto the layout-carried one', async () => {
249
+ test('options stored under the legacy tag are read, and move onto the layout-carried one when written', async () => {
250
250
  // only '.%' tags reach a layout, so options in '.fit' never travelled to a fresh table
251
251
  expect(FitConstants.TAG_FIT.startsWith('.%'), true, 'the fit tag is no longer carried by layouts');
252
252
 
@@ -255,8 +255,15 @@ category('panel and renderer', () => {
255
255
  col.setTag(FitConstants.TAG_FIT_LEGACY, JSON.stringify({chartOptions: {logX: true}}));
256
256
 
257
257
  expect(getColumnChartOptions(col).chartOptions!.logX, true, 'options under the legacy tag were ignored');
258
- expect(JSON.parse(col.getTag(FitConstants.TAG_FIT)).chartOptions.logX, true,
259
- 'reading did not migrate the options onto the layout-carried tag');
258
+ expect(col.getTag(FitConstants.TAG_FIT) == null, true, 'reading the options wrote a tag');
259
+
260
+ changeCurvesOptions(DG.Viewer.grid(df).cell('curve', 0),
261
+ {property: {name: 'showCurveConfidenceInterval'}, value: false} as unknown as DG.InputBase,
262
+ 'seriesOptions', 'Column');
263
+ const stored = JSON.parse(col.getTag(FitConstants.TAG_FIT)) as IFitChartData;
264
+ expect(stored.chartOptions!.logX, true, 'the legacy options were lost when the column was written');
265
+ expect(stored.seriesOptions!.showCurveConfidenceInterval, false, 'the change was not stored');
266
+ expect(col.getTag(FitConstants.TAG_FIT_LEGACY) == null, true, 'both tags now hold the options');
260
267
  });
261
268
 
262
269
  test('the panel offers the label names the cell carries', async () => {
@@ -2,6 +2,8 @@ import * as DG from 'datagrok-api/dg';
2
2
  import * as grok from 'datagrok-api/grok';
3
3
 
4
4
  import {awaitCheck, category, delay, expect, test} from '@datagrok-libraries/test/src/test';
5
+ import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
6
+ import {createDefaultChartData} from '@datagrok-libraries/statistics/src/fit/fit-data';
5
7
  import {changeCurvesOptions} from '../fit/fit-options';
6
8
  import {getColumnChartOptions, getOrCreateParsedChartData} from '../fit/fit-chart-data';
7
9
 
@@ -90,6 +92,28 @@ category('projects', () => {
90
92
  await delay(100);
91
93
  }, {timeout: 120000});
92
94
 
95
+ test('painting a table leaves its dataframe tags alone, so its layout saves', async () => {
96
+ // platforms up to 1.27.x fail to encode a layout whose table carries a dataframe '.%' tag
97
+ const df = await grok.dapi.files.readCsv(`System:AppData/Curves/${DEMO_FILE}`);
98
+ df.name = 'curvesPaintedLayout';
99
+ // what Curves before 1.13 left on every table it painted
100
+ df.setTag(FitConstants.TAG_FIT_LEGACY, JSON.stringify(createDefaultChartData()));
101
+ await grok.data.detectSemanticTypes(df);
102
+ const tv = grok.shell.addTableView(df);
103
+ let layout: DG.ViewLayout | null = null;
104
+ try {
105
+ for (const col of df.columns.bySemTypeAll(FitConstants.FIT_SEM_TYPE))
106
+ getOrCreateParsedChartData(df.cell(0, col.name), false);
107
+ await delay(500);
108
+ expect(df.getTag(FitConstants.TAG_FIT) == null, true, 'reading the options tagged the dataframe');
109
+ layout = await grok.dapi.layouts.save(tv.saveLayout());
110
+ } finally {
111
+ if (layout)
112
+ await grok.dapi.layouts.delete(layout);
113
+ tv.close();
114
+ }
115
+ }, {timeout: 60000});
116
+
93
117
  test('column-level option survives a datasync project', async () => {
94
118
  // the table is rebuilt from its creation script, so the cells come back declaring the interval
95
119
  // and only the tag the layout carries can turn it off