@datagrok/api-samples 1.0.8 → 1.2.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.
Files changed (218) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/README.md +2 -2
  3. package/dist/package-test.js +1848 -2
  4. package/dist/package.js +30 -2
  5. package/files/viewer-events/bar-chart/on-category-clicked.js +1 -0
  6. package/files/viewer-events/grid/on-cell-clicked.js +1 -0
  7. package/files/viewer-events/pc-plot/on-line-clicked.js +1 -0
  8. package/files/viewer-events/pie-chart/on-segment-clicked.js +1 -0
  9. package/files/viewer-events/scatter-plot/on-point-clicked.js +1 -0
  10. package/files/viewer-events/scatter-plot/on-rendered.js +1 -0
  11. package/layouts/demog-table-layout.json +329 -181
  12. package/package.json +23 -20
  13. package/scripts/dapi/admin.js +5 -5
  14. package/scripts/dapi/applicable-layouts.js +3 -1
  15. package/scripts/dapi/fetch.js +8 -6
  16. package/scripts/dapi/files.js +45 -0
  17. package/scripts/dapi/projects-list.js +3 -3
  18. package/scripts/dapi/projects-open.js +4 -4
  19. package/scripts/dapi/sticky-meta-1-tags.js +54 -0
  20. package/scripts/dapi/sticky-meta-2-semtype.js +33 -0
  21. package/scripts/dapi/who-am-i.js +10 -10
  22. package/scripts/data-access/db/ad-hoc-query.js +16 -0
  23. package/scripts/data-access/db/db-edit.js +6 -9
  24. package/scripts/data-access/{parameterized-query.js → db/parameterized-query.js} +3 -2
  25. package/scripts/data-access/db/query_builder_join.js +15 -0
  26. package/scripts/data-access/db/query_builder_simple.js +15 -0
  27. package/scripts/data-access/db-master-details-manual.js +10 -12
  28. package/scripts/data-access/external/stock-prices.js +2 -2
  29. package/scripts/data-access/files/file-exists.js +10 -0
  30. package/scripts/data-access/files/read-file.js +19 -0
  31. package/scripts/data-access/load-csv.js +2 -2
  32. package/scripts/data-access/open-table-by-id.js +11 -3
  33. package/scripts/data-access/output-layouts.js +3 -1
  34. package/scripts/data-access/save-and-load-df.js +6 -5
  35. package/scripts/data-frame/advanced/data-frames-in-columns.js +4 -1
  36. package/scripts/data-frame/advanced/virtual-columns.js +1 -1
  37. package/scripts/data-frame/aggregation/unpivot.js +1 -1
  38. package/scripts/data-frame/column-access.js +5 -3
  39. package/scripts/data-frame/columns-ordering.js +4 -0
  40. package/scripts/data-frame/compare-tables.js +3 -2
  41. package/scripts/data-frame/construction/add-new-column.js +13 -0
  42. package/scripts/data-frame/construction/create-from-columns.js +4 -4
  43. package/scripts/data-frame/construction/create-from-csv-format.js +3 -3
  44. package/scripts/data-frame/construction/create-from-typed-arrays.js +7 -2
  45. package/scripts/data-frame/construction/date-time.js +24 -0
  46. package/scripts/data-frame/construction/export-to-csv-advanced.js +14 -4
  47. package/scripts/data-frame/construction/export-to-csv-molblock.js +3 -0
  48. package/scripts/data-frame/construction/export-to-csv.js +1 -1
  49. package/scripts/data-frame/events/calculated-columns/creation.js +1 -1
  50. package/scripts/data-frame/events/calculated-columns/deletion.js +1 -1
  51. package/scripts/data-frame/events/calculated-columns/update.js +1 -1
  52. package/scripts/data-frame/join-link/link-tables-dynamic.js +11 -12
  53. package/scripts/data-frame/join-link/link-tables.js +12 -8
  54. package/scripts/data-frame/metadata/dataframe-meta.js +1 -1
  55. package/scripts/data-frame/modification/add-columns.js +1 -1
  56. package/scripts/data-frame/modification/append.js +1 -1
  57. package/scripts/data-frame/modification/calculated-columns/edit-formula.js +2 -2
  58. package/scripts/data-frame/modification/double-precision.js +26 -0
  59. package/scripts/data-frame/modification/manipulate.js +3 -3
  60. package/scripts/demo/med-chem.js +103 -0
  61. package/scripts/demo/stock-broker.js +1 -1
  62. package/scripts/domains/chem/chem-benchmark.js +0 -5
  63. package/scripts/domains/chem/descriptors.js +2 -4
  64. package/scripts/domains/chem/diversity-search.js +2 -4
  65. package/scripts/domains/chem/mcs.js +3 -3
  66. package/scripts/domains/chem/r-group.js +3 -3
  67. package/scripts/domains/chem/similarity-scoring-scores.js +3 -5
  68. package/scripts/domains/chem/similarity-scoring-sorted.js +3 -5
  69. package/scripts/domains/chem/sketcher.js +2 -2
  70. package/scripts/domains/chem/substructure-search-smarts-molfile-als.js +11 -12
  71. package/scripts/domains/chem/substructure-search-smarts.js +4 -7
  72. package/scripts/domains/chem/substructure-search.js +5 -6
  73. package/scripts/domains/data-science/cluster.js +8 -10
  74. package/scripts/domains/data-science/missing-values-imputation.js +3 -3
  75. package/scripts/domains/data-science/pca.js +3 -3
  76. package/scripts/domains/data-science/predictive-model.js +4 -4
  77. package/scripts/domains/data-science/random-data.js +5 -6
  78. package/scripts/events/form-creation.js +2 -2
  79. package/scripts/events/function-events.js +1 -1
  80. package/scripts/events/global-events.js +1 -1
  81. package/scripts/events/layout-events.js +5 -6
  82. package/scripts/events/viewer-data-events.js +11 -0
  83. package/scripts/functions/caching-results.js +8 -9
  84. package/scripts/functions/calling.js +7 -10
  85. package/scripts/functions/func-call.js +9 -2
  86. package/scripts/functions/param-editor.js +1 -1
  87. package/scripts/functions/progress.js +2 -5
  88. package/scripts/functions/register-function.js +1 -1
  89. package/scripts/grid/advanced/cell-renderer.js +1 -1
  90. package/scripts/grid/advanced/column-groups.js +8 -0
  91. package/scripts/grid/advanced/dynamic-value-retrieval.js +12 -0
  92. package/scripts/grid/advanced/format-formula.js +7 -0
  93. package/scripts/grid/{hit-test.js → advanced/hit-test.js} +1 -1
  94. package/scripts/grid/advanced/link-click.js +3 -3
  95. package/scripts/grid/advanced/markup-link.js +6 -0
  96. package/scripts/grid/advanced/paint-counts.js +4 -1
  97. package/scripts/grid/cell-types/tags-multi-cell.js +18 -0
  98. package/scripts/grid/{color-coding-conditional.js → color-coding/color-coding-conditional.js} +17 -10
  99. package/scripts/grid/color-coding/color-coding.js +8 -9
  100. package/scripts/grid/color-coding/get-cell-color.js +3 -5
  101. package/scripts/grid/html-cells/html-table-cells.js +1 -1
  102. package/scripts/grid/styles/column-cell-styles.js +10 -0
  103. package/scripts/grid/{column-controlled-values.js → styles/column-controlled-values.js} +2 -2
  104. package/scripts/grid/{data-format.js → styles/data-format.js} +4 -4
  105. package/scripts/misc/audit/errors-summary.js +2 -2
  106. package/scripts/misc/audit/test-tracking.js +2 -2
  107. package/scripts/misc/audit/users-today.js +3 -5
  108. package/scripts/misc/package-credentials.js +2 -1
  109. package/scripts/misc/user-settings-storage.js +48 -0
  110. package/scripts/performance/all-chembl-structures.js +2 -1
  111. package/scripts/scripting/files-for-scripting.js +24 -0
  112. package/scripts/scripting/grok-scripting.js +2 -3
  113. package/scripts/scripting/package-scripting.js +8 -0
  114. package/scripts/shell/last-error.js +1 -1
  115. package/scripts/shell/ui-parts.js +9 -9
  116. package/scripts/shell/windows/browse/customize-tree.js +3 -0
  117. package/scripts/ui/apps/bioreactor.js +5 -5
  118. package/scripts/ui/components/accordion.js +3 -3
  119. package/scripts/ui/components/drop-down.js +8 -5
  120. package/scripts/ui/components/icons.js +7 -7
  121. package/scripts/ui/components/menu-advanced.js +85 -0
  122. package/scripts/ui/components/popup-menu.js +6 -5
  123. package/scripts/ui/components/summary-card.js +4 -3
  124. package/scripts/ui/components/tree-view-adv.js +4 -2
  125. package/scripts/ui/containers/splitters.js +12 -20
  126. package/scripts/ui/dialogs/wizard.js +8 -8
  127. package/scripts/ui/docking/docking.js +4 -1
  128. package/scripts/ui/handlers/markup-handlers.js +60 -0
  129. package/scripts/ui/inputs/advanced/all-input-types.js +47 -29
  130. package/scripts/ui/inputs/advanced/for-properties.js +1 -1
  131. package/scripts/ui/inputs/advanced/input-api.js +38 -0
  132. package/scripts/ui/inputs/advanced/input-events.js +10 -10
  133. package/scripts/ui/inputs/advanced/input-form.js +8 -8
  134. package/scripts/ui/inputs/choice-input.js +5 -5
  135. package/scripts/ui/inputs/column-combo-box.js +3 -3
  136. package/scripts/ui/inputs/column-inputs.js +3 -3
  137. package/scripts/ui/inputs/forms.js +15 -16
  138. package/scripts/ui/inputs/helm-input-ui.js +7 -0
  139. package/scripts/ui/inputs/inputs-events.js +8 -8
  140. package/scripts/ui/inputs/inputs-extended.js +2 -2
  141. package/scripts/ui/inputs/inputs.js +17 -15
  142. package/scripts/ui/inputs/molecule-input.js +1 -1
  143. package/scripts/ui/inputs/table-input.js +1 -1
  144. package/scripts/ui/inputs/tags-input.js +2 -2
  145. package/scripts/ui/inputs/typeahead-input.js +16 -17
  146. package/scripts/ui/inputs/validation/input-validators.js +11 -0
  147. package/scripts/ui/inputs/validation/parameter-expressions.js +9 -0
  148. package/scripts/ui/inputs/validation/parameter-validation.js +6 -0
  149. package/scripts/ui/interactivity/drag-and-drop.js +3 -3
  150. package/scripts/ui/rendering/render-items.js +9 -9
  151. package/scripts/ui/tooltips/tooltip-events.js +2 -1
  152. package/scripts/ui/tooltips/tooltips.js +11 -2
  153. package/scripts/ui/viewers/advanced/attached-properties.js +5 -5
  154. package/scripts/ui/viewers/advanced/default-axis-type.js +1 -1
  155. package/scripts/ui/viewers/advanced/descriptors.js +14 -0
  156. package/scripts/ui/viewers/advanced/init-function.js +21 -0
  157. package/scripts/ui/viewers/advanced/init-script.js +15 -0
  158. package/scripts/ui/viewers/filters/add-single-filter.js +5 -5
  159. package/scripts/ui/viewers/filters/custom-filters.js +7 -6
  160. package/scripts/ui/viewers/filters/filter-group.js +6 -1
  161. package/scripts/ui/viewers/filters/multi-value-filter.js +1 -1
  162. package/scripts/ui/viewers/js viewers/chord-viewer.js +1 -1
  163. package/scripts/ui/viewers/js viewers/globe-viewer.js +7 -7
  164. package/scripts/ui/viewers/js viewers/sankey-viewer.js +1 -1
  165. package/scripts/ui/viewers/js viewers/surface-plot.js +19 -1
  166. package/scripts/ui/viewers/js viewers/word-cloud.js +1 -1
  167. package/scripts/ui/viewers/scatter-plot-events.js +6 -1
  168. package/scripts/ui/viewers/trellis-plot-with-summary-viewer.js +3 -1
  169. package/scripts/ui/viewers/types/globe.js +2 -3
  170. package/scripts/ui/viewers/types/markup-advanced.js +2 -2
  171. package/scripts/ui/viewers/types/markup-eeg.js +5 -5
  172. package/scripts/ui/viewers/types/shape-map.js +4 -4
  173. package/scripts/ui/viewers/types/trellis-plot.js +13 -1
  174. package/scripts/ui/viewers/types/word-cloud.js +1 -1
  175. package/scripts/ui/viewers/viewer-tooltips.js +1 -1
  176. package/scripts/ui/views/default-views.js +8 -7
  177. package/scripts/ui/views/layouts.js +16 -17
  178. package/scripts/ui/views/multi-view.js +1 -1
  179. package/scripts/ui/widgets/widgets-tree.js +32 -0
  180. package/src/package-api.ts +8 -0
  181. package/src/package-test.ts +117 -14
  182. package/src/tests/owners.ts +8 -0
  183. package/test-console-output-1.log +6957 -0
  184. package/test-console-output-2.log +371 -0
  185. package/test-console-output-3.log +887 -0
  186. package/test-console-output-4.log +1085 -0
  187. package/test-console-output-5.log +944 -0
  188. package/test-console-output-6.log +2 -0
  189. package/test-record-1.mp4 +0 -0
  190. package/test-record-2.mp4 +0 -0
  191. package/test-record-3.mp4 +0 -0
  192. package/test-record-4.mp4 +0 -0
  193. package/test-record-5.mp4 +0 -0
  194. package/test-record-6.mp4 +0 -0
  195. package/to fix/dynamic-loading.js +13 -0
  196. package/tsconfig.json +1 -1
  197. package/webpack.config.js +4 -1
  198. package/files.js +0 -39
  199. package/scripts/misc/audit/activity-today.js +0 -4
  200. package/scripts/misc/user-data-storage.js +0 -49
  201. package/scripts/scripting/scripting.js +0 -6
  202. package/scripts/ui/handlers/dynamic-loading.js +0 -13
  203. /package/scripts/data-access/{dynamic-query.js → db/dynamic-query.js} +0 -0
  204. /package/scripts/grid/{cell-bounds.js → advanced/cell-bounds.js} +0 -0
  205. /package/scripts/grid/{category-colors.js → color-coding/category-colors.js} +0 -0
  206. /package/scripts/grid/{custom-cell-prepare.js → events/custom-cell-prepare.js} +0 -0
  207. /package/scripts/grid/{custom-cell-rendering-indexes.js → events/custom-cell-rendering-indexes.js} +0 -0
  208. /package/scripts/grid/{custom-cell-rendering.js → events/custom-cell-rendering.js} +0 -0
  209. /package/scripts/grid/{custom-cell-tooltip.js → events/custom-cell-tooltip.js} +0 -0
  210. /package/scripts/grid/{scroll-bars.js → navigate/scroll-bars.js} +0 -0
  211. /package/scripts/grid/{scroll-to-cell.js → navigate/scroll-to-cell.js} +0 -0
  212. /package/scripts/grid/{scroll-to-pixels.js → navigate/scroll-to-pixels.js} +0 -0
  213. /package/scripts/grid/{order-columns.js → order/order-columns.js} +0 -0
  214. /package/scripts/grid/{order-rows-by-comparer.js → order/order-rows-by-comparer.js} +0 -0
  215. /package/scripts/grid/{order-rows.js → order/order-rows.js} +0 -0
  216. /package/scripts/grid/{hide-columns.js → resize/hide-columns.js} +0 -0
  217. /package/scripts/grid/{resize-columns.js → resize/resize-columns.js} +0 -0
  218. /package/scripts/grid/{resize-events.js → resize/resize-events.js} +0 -0
@@ -1,4 +1,4 @@
1
- grok.events.onViewChanged.subscribe((v) => grok.shell.info(`${v.name}: changed`));
1
+ grok.events.onViewChanged.subscribe((v) => grok.shell.info(v.message));
2
2
  grok.events.onTableAdded.subscribe((args) => {
3
3
  grok.shell.info(args.args.dataFrame.name);
4
4
  });
@@ -1,12 +1,11 @@
1
- //tags: ViewLayout
2
1
  // open a table, then do View | Layout | Clone
3
2
 
4
- function info(action, layout) {
5
- grok.shell.info(`${action}: ${layout.viewState}`);
3
+ function showInfo(action, info) {
4
+ grok.shell.info(`${action}: ${info.viewState}`);
6
5
  }
7
6
 
8
- grok.events.onViewLayoutGenerated.subscribe((layout) => info('generated', layout));
7
+ grok.events.onViewLayoutGenerated.subscribe((info) => showInfo('generated', info));
9
8
 
10
- grok.events.onViewLayoutApplying.subscribe((layout) => info('applying', layout));
9
+ grok.events.onViewLayoutApplying.subscribe((info) => showInfo('applying', info));
11
10
 
12
- grok.events.onViewLayoutApplied.subscribe((layout) => info('applied', layout));
11
+ grok.events.onViewLayoutApplied.subscribe((info) => showInfo('applied', info));
@@ -0,0 +1,11 @@
1
+ //name: viewer-data-events
2
+ //language: javascript
3
+ //description: Handling viewer events: onDataEvent, onDataSelected, onDataHovered, onDataRowClicked.
4
+ let view = grok.shell.addTableView(grok.data.demo.demog());
5
+ let viewers = [view.scatterPlot(), view.histogram(), view.pieChart(), view.barChart(), view.pcPlot()];
6
+
7
+ for (let v of viewers)
8
+ v.onDataEvent.subscribe((e) =>
9
+ grok.shell.info(e.type + ': ' + (e.row ? (e.row + ' row') : (e.bitset.trueCount + ' rows'))));
10
+
11
+ grok.shell.info('Hover or click data to see event details. Different viewers provide different details.');
@@ -23,14 +23,13 @@ grok.functions.register({
23
23
  });
24
24
 
25
25
  // results are cached
26
- grok.functions.call('bar', {x: 7}).then((result) => grok.shell.info(result));
27
- grok.functions.call('bar', {x: 7}).then((result) => grok.shell.info(result));
28
- grok.functions.call('bar', {x: 7}).then((result) => grok.shell.info(result));
29
-
30
- grok.functions.call('bar', {x: 8}).then((result) => grok.shell.info(result));
31
- grok.functions.call('bar', {x: 8}).then((result) => grok.shell.info(result));
32
-
33
- grok.functions.call('foo', {x: 12}).then((result) => grok.shell.info(result));
34
- grok.functions.call('foo', {x: 12}).then((result) => grok.shell.info(result));
26
+ grok.shell.info(await grok.functions.call('bar', {x: 7}));
27
+ grok.shell.info(await grok.functions.call('bar', {x: 7}));
28
+ grok.shell.info(await grok.functions.call('bar', {x: 8}));
29
+ grok.shell.info(await grok.functions.call('bar', {x: 8}));
30
+ grok.shell.info(await grok.functions.call('bar', {x: 12}));
31
+ grok.shell.info(await grok.functions.call('bar', {x: 12}));
32
+ grok.shell.info(await grok.functions.call('bar', {x: 12}));
35
33
 
34
+ grok.shell.info(result);
36
35
  grok.shell.info(counts);
@@ -5,15 +5,12 @@
5
5
  // Calling "RDup" function that belongs to the "RSrcipts" package
6
6
  // It is implemented in R and returns a duplicated string
7
7
  // https://github.com/datagrok-ai/public/blob/master/packages/Samples/scripts/r/r_dup.R
8
- grok.functions
9
- .call("Samples:RDup", {s: "Foo"})
10
- .then((res) => {
11
- grok.shell.info(res);
12
- });
8
+ let res1 = await grok.functions
9
+ .call("Samples:RDup", {s: "Foo"});
10
+ grok.shell.info(res1);
11
+
13
12
 
14
13
  // This is a core function, package name could be omitted
15
- grok.functions
16
- .call("Sin", {x: 1.5})
17
- .then((res) => {
18
- grok.shell.info(res);
19
- });
14
+ let res2 = await grok.functions
15
+ .call("Sin", {x: 1.5});
16
+ grok.shell.info(res2);
@@ -6,7 +6,13 @@ let outputs = f.outputs.map(output => output.propertyType + ' ' + output.name);
6
6
  grok.shell.info(f.name + '(' + inputs + ')' + ': ' + outputs);
7
7
 
8
8
  // simple way: f.apply
9
- f.apply({x: 0.5}).then((result) => grok.shell.info(result));
9
+ // Any function can be called asynchronously
10
+ let result = await f.apply({x: 0.5});
11
+ grok.shell.info(result);
12
+
13
+ // If we know that this is sync function, AND it's either a core function or a plugin is loaded already,
14
+ // then we can call it synchronously using applySync:
15
+ grok.shell.info('Sync call: ' + f.applySync({x: 0.5}));
10
16
 
11
17
  // more complex: preparing a FuncCall that lets you track inputs and outputs, intercept execution, etc
12
18
  let fc = f.prepare({"x": 0.5});
@@ -15,4 +21,5 @@ grok.shell.info('Input name and type: ' + fc.inputParams['x'].name + ' ' + fc.in
15
21
  grok.shell.info('Input value:' + fc.inputs['x']);
16
22
 
17
23
  grok.shell.info(fc.inputs['x']);
18
- fc.call().then((call) => grok.shell.info(call.outputs['result']));
24
+ let call = await fc.call();
25
+ grok.shell.info(call.outputs['result'])
@@ -1,2 +1,2 @@
1
1
  let f = DG.Func.find({name: 'Sin'})[0];
2
- f.prepare().getEditor().then((editor) => grok.shell.o = editor);
2
+ grok.shell.o = await f.prepare().getEditor();
@@ -3,8 +3,5 @@ p.onProgressUpdated.subscribe((p) => grok.shell.info(p.percent));
3
3
  p.onLogUpdated.subscribe((line) => console.log(line));
4
4
  p.update(50, "Loading foo.csv");
5
5
 
6
- grok.functions.call("Samples:RDup",
7
- {s: "hi"}, true, p)
8
- .then((res) => {
9
- grok.shell.info(res);
10
- });
6
+ let res = await grok.functions.call("Samples:RDup", {s: "hi"}, true, p);
7
+ grok.shell.info(res);
@@ -7,7 +7,7 @@
7
7
  // To test jsWidget, create a new Dashboard, and click on "Widget" under "Widgets".
8
8
  //
9
9
  // See also https://datagrok.ai/help/datagrok/functions/function,
10
- // https://datagrok.ai/help/develop/js-api#registering-functions
10
+ // https://datagrok.ai/js-api#registering-functions
11
11
 
12
12
  grok.functions.register({
13
13
  signature: 'String jsConcat(int foo, int bar)',
@@ -1,7 +1,7 @@
1
1
  // Reusing core grid renderers
2
2
 
3
3
  let view = grok.shell.addTableView(grok.data.demo.molecules());
4
- view.dataFrame.col('logD').colors.setLinear();
4
+ view.dataFrame.col('logD').meta.colors.setLinear();
5
5
  let canvas = ui.canvas(300, 200);
6
6
 
7
7
  view.grid.onCurrentCellChanged.subscribe((gridCell) =>
@@ -0,0 +1,8 @@
1
+ let table = grok.data.demo.demog();
2
+ table.meta.setGroups(
3
+ {
4
+ 'Demographics' : { color: '#861616', columns: ['sex', 'race', 'age'] },
5
+ 'Biometrics': { color: '#1544A9FF', columns: ['height', 'weight'] }
6
+ })
7
+
8
+ let view = grok.shell.addTableView(table);
@@ -0,0 +1,12 @@
1
+ // Adds a virtual column with the renderer defined in the PowerGrid package (make sure the package is installed).
2
+
3
+ const grid = grok.shell.addTableView(grok.data.demo.demog()).grid;
4
+ //grid.columns.byName('age').onPrepareValueScript = 'return 42;';
5
+ //grid.columns.byName('sex').onPrepareValueScript = 'return "42";';
6
+
7
+ //grid.columns.add({gridColumnName: 'table', cellType: 'dataframe'})
8
+ // .onPrepareValueScript = 'return await grok.dapi.files.readCsv("System:DemoFiles/demog.csv")';
9
+
10
+ grid.columns.add({gridColumnName: 'plate', cellType: 'Plate'})
11
+ .onPrepareValueScript = 'return await grok.dapi.files.readCsv("System:DemoFiles/hts/plate-96-1.csv")';
12
+ //.onPrepareValueScript = 'return grok.data.demo.wells(96); ';
@@ -0,0 +1,7 @@
1
+ // Ability to render values from other columns (useful for hyperlinks, etc)
2
+ // Not that other than formatting, the column would still
3
+ // work just like the regular column when sorting, editing, etc
4
+ const view = grok.shell.addTableView( grok.data.demo.demog(5));
5
+ const df =view.dataFrame;
6
+ df.getCol('race').tags['%formatFormula'] = '${sex} text [${age}](https://google.com/search?q=${race})';
7
+
@@ -4,5 +4,5 @@ let table = grok.data.demo.demog();
4
4
  let view = grok.shell.addTableView(table);
5
5
  rxjs.fromEvent(view.grid.overlay, 'mousemove').subscribe((mm) => {
6
6
  let cell = view.grid.hitTest(mm.offsetX, mm.offsetY);
7
- grok.shell.o = cell.gridColumn.d;
7
+ grok.shell.o = cell.gridColumn;
8
8
  });
@@ -9,9 +9,9 @@ grok.shell.addTableView(df);
9
9
 
10
10
  // Setting the column tags
11
11
 
12
- df.col('open in new tab').tags[DG.TAGS.LINK_CLICK_BEHAVIOR] = 'Open in new tab';
13
- df.col('open in context panel').tags[DG.TAGS.LINK_CLICK_BEHAVIOR] = 'Open in context panel';
14
- df.col('custom').tags[DG.TAGS.LINK_CLICK_BEHAVIOR] = 'Custom';
12
+ df.col('open in new tab').meta.linkClickBehavior = DG.LINK_CLICK_BEHAVIOR.OPEN_IN_NEW_TAB;
13
+ df.col('open in context panel').meta.linkClickBehavior = DG.LINK_CLICK_BEHAVIOR.OPEN_IN_CONTEXT_PANEL;
14
+ df.col('custom').meta.linkClickBehavior = DG.LINK_CLICK_BEHAVIOR.CUSTOM;
15
15
 
16
16
  // Displaying the clicked link - global and local grid events
17
17
 
@@ -0,0 +1,6 @@
1
+ // Demonstrates markdown-like link in grid
2
+
3
+ const df = DG.DataFrame.fromColumns([
4
+ DG.Column.fromList(DG.TYPE.STRING, 'markdown link', ['To learn more about [Datagrok](https://datagrok.ai/) open the [platform help](https://datagrok.ai/help/home)']),
5
+ ]);
6
+ grok.shell.addTableView(df);
@@ -4,4 +4,7 @@ grid.onCellPrepare(function (gc) {
4
4
  let xy = `${gc.gridColumn.name}_${gc.gridRow}`;
5
5
  counts[xy] = counts[xy] == null ? 1 : counts[xy] + 1;
6
6
  gc.customText = `${counts[xy]}`;
7
- });
7
+ });
8
+
9
+ // here's how you can refresh a specific cell
10
+ setInterval(() => { grid.cell('race', 4).render() }, 1000);
@@ -0,0 +1,18 @@
1
+ // Additional cell types supported in the PowerPack package
2
+
3
+ const t = DG.DataFrame.create(2);
4
+
5
+ // MultiChoice: each cell becomes a list of checkboxes
6
+ const dis = t.columns.addNewString('disease');
7
+ dis.set(0, 'Anxiety, Glaucoma');
8
+ dis.set(1, 'Hepatitis A, Glaucoma');
9
+ dis.meta.choices = ['Anxiety', 'Hepatitis A', 'Glaucoma'];
10
+ dis.setTag(DG.TAGS.CELL_RENDERER, 'MultiChoice');
11
+
12
+ // Tags: renders each value as a colored tag
13
+ const site = t.columns.addNewString('site');
14
+ site.set(0, 'Buffalo, Orlando');
15
+ site.set(1, 'Buffalo, Los Angeles');
16
+ site.setTag(DG.TAGS.CELL_RENDERER, 'Tags');
17
+
18
+ grok.shell.addTableView(t);
@@ -1,17 +1,24 @@
1
+ // Set color coding
2
+
1
3
  let t = grok.data.demo.demog();
2
4
 
3
- t.col('height').tags[DG.TAGS.COLOR_CODING_TYPE] = 'Conditional';
4
- t.col('height').tags[DG.TAGS.COLOR_CODING_CONDITIONAL] = `{"20-170":"#00FF00","170-190":"#220505"}`;
5
+ // Linear or conditional color coding for numerical or datetime columns
6
+ t.col('height').meta.colors.setConditional({"20-170": "#00FF00", "170-190": "#220505"});
7
+ t.col('started').meta.colors.setLinear([DG.Color.white, DG.Color.red]);
8
+ t.col('age').meta.colors.setLinearAbsolute({19: '#bcbd22', 31.75: '#17becf', 44.50: '#ff9896', 70: '#c5b0d5'});
9
+ t.col('weight').meta.colors.setConditional({'<100': DG.Color.green, '100-200': '#ff0000'});
10
+
11
+ // Categorical for string columns
12
+ t.col('site').meta.colors.setCategorical({'New York': DG.Color.orange});
13
+
14
+ // Additional matching options for categorical
15
+ t.col('race').meta.colors.setCategorical(
16
+ {'sian': DG.Color.orange},
17
+ {fallbackColor: 'black', matchType: "regex"});
5
18
 
6
- t.col('age').tags[DG.TAGS.COLOR_CODING_TYPE] = 'Linear';
7
- t.col('age').tags[DG.TAGS.COLOR_CODING_LINEAR] = `[${DG.Color.orange}, ${DG.Color.green}]`;
19
+ grok.shell.addTableView(t);
8
20
 
21
+ // Get color coding programmatically
9
22
  grok.shell.info(`Column 'subj' color coding: ${t.col('subj').meta.colors.getType()}`); // Off
10
23
  grok.shell.info(`Column 'height' color coding: ${t.col('height').meta.colors.getType()}`); // Conditional
11
24
  grok.shell.info(`Column 'age' color coding: ${t.col('age').meta.colors.getType()}`); // Linear
12
-
13
- t.col('site').meta.colors.setCategorical({'New York': DG.Color.orange});
14
- t.col('started').meta.colors.setLinear([DG.Color.white, DG.Color.red]);
15
- t.col('weight').meta.colors.setConditional({'<100': DG.Color.green, '100-200': '#ff0000'});
16
-
17
- grok.shell.addTableView(t);
@@ -1,19 +1,18 @@
1
- let t = grok.data.demo.demog();
1
+ const t = grok.data.demo.demog();
2
2
 
3
3
  // Conditional color-coding for numerical columns
4
- t.col('height').tags[DG.TAGS.COLOR_CODING_TYPE] = 'Conditional';
5
- t.col('height').tags[DG.TAGS.COLOR_CODING_CONDITIONAL] = `{"20-170":"#00FF00","170-190":"#220505"}`;
4
+ t.col('height').meta.colors.setConditional({'20-170': '#00FF00', '170-190': "#220505"});
6
5
 
7
6
  // Linear color-coding for numerical columns
8
- t.col('age').tags[DG.TAGS.COLOR_CODING_TYPE] = 'Linear';
9
- t.col('age').tags[DG.TAGS.COLOR_CODING_LINEAR] = '["#ff0000", "#ffff00", "#00ff00"]';
7
+ t.col('age').meta.colors.setLinear(['#ff0000', '#ffff00', '#00ff00'], {min: 19, belowMinColor: '#ac3400', max: 70});
8
+
9
+ // Linear color-coding with absolute values for numerical columns
10
+ t.col('weight').meta.colors.setLinearAbsolute({58.31: '#73aff5', 137.65: '#ffa500', 177.32: '#50af28', 217: '#9467bd'}, {aboveMaxColor: '#ff0000'});
10
11
 
11
12
  // Categorical color-coding for string columns
12
- t.col('race').tags[DG.TAGS.COLOR_CODING_TYPE] = 'Categorical';
13
- t.col('race').tags[DG.TAGS.COLOR_CODING_CATEGORICAL] = `{"Asian":4278190335,"Black":4286578816}`;
13
+ t.col('race').meta.colors.setCategorical({'Asian': 4278190335, 'Black': 4286578816});
14
14
 
15
15
  grok.shell.addTableView(t);
16
16
 
17
17
  // To turn the color-coding off, use either approach:
18
- //t.col('height').tags[DG.TAGS.COLOR_CODING_TYPE] = 'Off';
19
- //delete t.col('height').tags[DG.TAGS.COLOR_CODING_TYPE];
18
+ // t.col('height').meta.colors.setDisabled();
@@ -1,15 +1,13 @@
1
1
  let t = grok.data.demo.demog();
2
2
 
3
3
  // Conditional color-coding for numerical columns
4
- t.col('height').tags['.color-coding-type'] = 'Conditional';
5
- t.col('height').tags['.color-coding-conditional'] = `{"20-170":"#00FF00","170-190":"#220505"}`;
4
+ t.col('height').meta.colors.setConditional({"20-170": "#00FF00", "170-190": "#220505"});
6
5
 
7
6
  // Linear color-coding for numerical columns
8
- t.col('age').tags['.color-coding-type'] = 'Linear';
7
+ t.col('age').meta.colors.setLinear();
9
8
 
10
9
  // Categorical color-coding for string columns
11
- t.col('race').tags['.color-coding-type'] = 'Categorical';
12
- t.col('race').tags['.category-colors'] = `{"Asian":4278190335,"Black":4286578816}`;
10
+ t.col('race').meta.colors.setCategorical({"Asian": 4278190335, "Black": 4286578816});
13
11
 
14
12
  let v = grok.shell.addTableView(t);
15
13
 
@@ -7,6 +7,6 @@ let t = DG.DataFrame.fromColumns([
7
7
  '<input type="range">'
8
8
  ])
9
9
  ]);
10
- t.col('test').tags['cell.renderer'] = 'html';
10
+ t.col('test').tags[DG.TAGS.CELL_RENDERER] = 'html';
11
11
 
12
12
  grok.shell.addTableView(t);
@@ -0,0 +1,10 @@
1
+ // Modifying grid column styles
2
+
3
+ let view = grok.shell.addTableView(grok.data.demo.demog());
4
+ let age = view.grid.columns.byName('age');
5
+
6
+ age.contentCellStyle.font = '10px Roboto, Roboto Local';
7
+ age.contentCellStyle.backColor = DG.Color.red;
8
+ age.contentCellStyle.horzAlign = 'center';
9
+
10
+ age.headerCellStyle.backColor = DG.Color.green;
@@ -2,5 +2,5 @@
2
2
  // When TAGS_TOOLTIP is set, a combo box will be shown as a cell editor.
3
3
 
4
4
  let view = grok.shell.addTableView(grok.data.demo.demog());
5
- view.table.getCol('race').setTag(DG.TAGS.CHOICES, '["Asian", "Black"]');
6
- view.table.getCol('race').setTag(DG.TAGS.AUTO_CHOICES, '["Asian", "Black"]');
5
+ view.table.getCol('race').meta.choices = ['Asian', 'Black', 'Other'];
6
+ view.table.getCol('race').meta.autoChoices = false;
@@ -5,10 +5,10 @@
5
5
  let df = grok.data.demo.demog();
6
6
  let view = grok.shell.addTableView(df);
7
7
 
8
- df.col('age').tags[DG.TAGS.FORMAT] = 'compact simple currency';
9
- df.col('height').tags[DG.TAGS.FORMAT] = 'scientific';
10
- df.col('weight').tags[DG.TAGS.FORMAT] = '#.0000';
11
- df.col('started').tags[DG.TAGS.FORMAT] = 'dd.MM.yyyy';
8
+ df.col('age').meta.format = 'compact simple currency';
9
+ df.col('height').meta.format = 'scientific';
10
+ df.col('weight').meta.format = '#.0000';
11
+ df.col('started').meta.format = 'dd.MM.yyyy';
12
12
 
13
13
  // NUMBER FORMATS (https://datagrok.ai/help/discover/tags#numbers)
14
14
  // The usual formats, such as "0.000" or "#.0000", are supported.
@@ -1,2 +1,2 @@
1
- grok.data.query('UsageAnalysis:TopPackageErrors', {date: 'this week', users: ['all']})
2
- .then((t) => grok.shell.addTableView(t));
1
+ let errors = await grok.data.query('UsageAnalysis:TopErrors', {date: 'this week'})
2
+ grok.shell.addTableView(errors)
@@ -1,2 +1,2 @@
1
- const df = await grok.data.query('UsageAnalysis:TestsToday');
2
- grok.shell.addTableView(df);
1
+ const df = await grok.data.query('UsageAnalysis:TestsDashboard', {instanceFilter: 'dev', lastBuildsNum: 5, packageFilter: null, showNotRun: false, showBenchmarks: false, showNotCiCd: false,versionFilter: null});
2
+ grok.shell.addTableView(df)
@@ -1,8 +1,6 @@
1
1
  //help-url: https://datagrok.ai/help/govern/user
2
2
  const view = grok.shell.newView('Usage');
3
3
 
4
- grok.data.query('UsageAnalysis:Usage', {date: 'today', users: ['all']})
5
- .then((t) => {
6
- const ids = new Set(t.getCol('user_id').toList());
7
- grok.dapi.getEntities([...ids]).then((users) => view.append(ui.list(users)));
8
- });
4
+ let t = await grok.data.query('UsageAnalysis:UniqueUsersList', {date: 'yesterday'});
5
+ const ids = new Set(t.getCol('id').toList());
6
+ grok.dapi.getEntities([...ids]).then((users) => view.append(ui.list(users)));
@@ -3,4 +3,5 @@
3
3
  // Read more about package credentials: https://datagrok.ai/help/develop/how-to/manage-credentials
4
4
 
5
5
  let p = await grok.dapi.packages.filter('Api Samples').first();
6
- p.getCredentials().then((c) => grok.shell.info(c ? c : 'Credentials are not set.'));
6
+ let c = await p.getCredentials();
7
+ grok.shell.info(c ? c.openParameters : 'Credentials are not set.');
@@ -0,0 +1,48 @@
1
+ // User settings storage demo: Saving values to storage
2
+
3
+ const STORAGE_NAME = 'user-data-storage-demo';
4
+
5
+ let v = grok.shell.newView('demo: user data storage');
6
+
7
+ let age = ui.input.int('Age', {value: 30});
8
+ let sex = ui.input.choice('Sex', {items: ['Male', 'Female'], value: 'Male'});
9
+ let music = ui.input.multiChoice('Music genres', {items: ['Classic', 'Rock', 'Pop', 'Jazz']});
10
+
11
+ let inputs = [age, sex, music];
12
+ v.append(ui.inputs(inputs));
13
+
14
+ let storageButton = ui.iconFA('database', () => {
15
+ let entities = grok.userSettings.get(STORAGE_NAME);
16
+ if (entities !== null && Object.keys(entities).length === 0)
17
+ grok.shell.info('Storage is empty. Try to post something to the storage');
18
+ else {
19
+ let menu = DG.Menu.popup();
20
+ for (let time of Object.keys(entities)) {
21
+ let values = JSON.parse(entities[time]);
22
+ menu.item(values.map(v => `${v.caption}: ${v.value}`).join(', '), () => {
23
+ for (let input of values)
24
+ inputs.find(i => i.caption === input.caption).load(input.value);
25
+ });
26
+ }
27
+ menu.show();
28
+ }
29
+
30
+ });
31
+ storageButton.style.margin = '8px 24px 0 24px';
32
+
33
+ let postButton = ui.button('Post to storage', () => {
34
+ grok.shell.info(inputs.map((i) => `${i.caption}: ${i.stringValue}`).join('<br>'));
35
+ grok.userSettings.add(STORAGE_NAME, `${Math.floor(Math.random() * Math.floor(1000))}`, JSON.stringify(inputs.map(i => {
36
+ return {caption: i.caption, value: i.save()};
37
+ })));
38
+ });
39
+
40
+ let clearButton = ui.button('Clear storage', () => {
41
+ grok.userSettings.delete(STORAGE_NAME, null);
42
+ });
43
+
44
+ v.append(ui.divH([
45
+ storageButton,
46
+ postButton,
47
+ clearButton
48
+ ]));
@@ -1,3 +1,4 @@
1
1
  // Retrieve all molecules from chembl (~2 millions), and visualize in the grid
2
2
 
3
- grok.data.query('Chembl:CbAllChemblStructures', {}).then(t => grok.shell.addTableView(t));
3
+ let t = await grok.data.query('Chembl:CbAllChemblStructures', {});
4
+ grok.shell.addTableView(t);
@@ -0,0 +1,24 @@
1
+ //tags: Script, Files
2
+ //help-url: https://datagrok.ai/help/compute/scripting
3
+ // An example of using files in a script
4
+
5
+ async function logFileContentAsString(fileInfo) {
6
+ let data = await fileInfo.readAsString();
7
+ grok.shell.info(data);
8
+ }
9
+
10
+ async function logFileContentAsBytes(fileInfo) {
11
+ let data = await fileInfo.readAsBytes();
12
+ grok.shell.info(data);
13
+ }
14
+
15
+ // these values are the same for utf-8
16
+ var line = 'test how script uses files'
17
+ var fileName = 'text.txt'
18
+ var bytes = new Uint8Array([0x74, 0x65, 0x73, 0x74, 0x20, 0x68, 0x6F, 0x77, 0x20, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x20, 0x75, 0x73, 0x65, 0x73, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x73])
19
+ var fileInfo = DG.FileInfo.fromString(fileName, line);
20
+ logFileContentAsString(fileInfo);
21
+ logFileContentAsBytes(fileInfo);
22
+ fileInfo = DG.FileInfo.fromBytes(fileName, bytes);
23
+ logFileContentAsString(fileInfo);
24
+ logFileContentAsBytes(fileInfo);
@@ -1,3 +1,2 @@
1
- grok.functions
2
- .eval('OpenServerFile("Samples:Files/beer.csv")')
3
- .then((t) => grok.shell.addTableView(t[0]));
1
+ let t = await grok.functions.eval('OpenServerFile("System:DemoFiles/beer.csv")');
2
+ grok.shell.addTableView(t[0]);
@@ -0,0 +1,8 @@
1
+ //tags: Script, Package
2
+ //help-url: https://datagrok.ai/help/compute/scripting
3
+ // An example of using scripting (R, Python etc.)
4
+
5
+ let result1 = await grok.functions.call('Samples:PythonDup', {'s': '1010'});
6
+ let result2 = await grok.functions.call('Samples:RDup', {'s': '0101'});
7
+ grok.shell.info(result1);
8
+ grok.shell.info(result2)
@@ -4,4 +4,4 @@
4
4
  // Then comment this bad line above and run the script again.
5
5
  // The alert will contain the error's text.
6
6
 
7
- alert(grok.shell.lastError);
7
+ alert(await grok.shell.lastError);
@@ -2,13 +2,13 @@
2
2
 
3
3
  let windows = grok.shell.windows;
4
4
  ui.dialog('Windows')
5
- .add(ui.boolInput('help', windows.showHelp, (x) => windows.showHelp = x))
6
- .add(ui.boolInput('sidebar', windows.showSidebar, (x) => windows.showSidebar = x))
7
- .add(ui.boolInput('toolbox', windows.showToolbox, (x) => windows.showToolbox = x))
8
- .add(ui.boolInput('status bar', windows.showStatusBar, (x) => windows.showStatusBar = x))
9
- .add(ui.boolInput('console', windows.showConsole, (x) => windows.showConsole = x))
10
- .add(ui.boolInput('properties', windows.showProperties, (x) => windows.showProperties = x))
11
- .add(ui.boolInput('tables', windows.showTables, (x) => windows.showTables = x))
12
- .add(ui.boolInput('columns', windows.showColumns, (x) => windows.showColumns = x))
13
- .add(ui.boolInput('variables', windows.showVariables, (x) => windows.showVariables = x))
5
+ .add(ui.input.bool('help', {value: windows.showHelp, onValueChanged: (x) => windows.showHelp = x}))
6
+ .add(ui.input.bool('sidebar', {value: windows.showSidebar, onValueChanged: (x) => windows.showSidebar = x}))
7
+ .add(ui.input.bool('toolbox', {value: windows.showToolbox, onValueChanged: (x) => windows.showToolbox = x}))
8
+ .add(ui.input.bool('status bar', {value: windows.showStatusBar, onValueChanged: (x) => windows.showStatusBar = x}))
9
+ .add(ui.input.bool('console', {value: windows.showConsole, onValueChanged: (x) => windows.showConsole = x}))
10
+ .add(ui.input.bool('properties', {value: windows.showProperties, onValueChanged: (x) => windows.showProperties = x}))
11
+ .add(ui.input.bool('tables', {value: windows.showTables, onValueChanged: (x) => windows.showTables = x}))
12
+ .add(ui.input.bool('columns', {value: windows.showColumns, onValueChanged: (x) => windows.showColumns = x}))
13
+ .add(ui.input.bool('variables', {value: windows.showVariables, onValueChanged: (x) => windows.showVariables = x}))
14
14
  .show();
@@ -0,0 +1,3 @@
1
+ grok.events.onBrowseNodeCreated
2
+ .pipe(rxjs.operators.filter(node => node.text === 'Spaces'))
3
+ .subscribe(node => node.item('Custom node'));
@@ -1,15 +1,15 @@
1
1
  // Bioreactor simulation wireframe
2
2
 
3
- let view = grok.shell.newView("Flowrate");
3
+ let view = grok.shell.newView('Flowrate');
4
4
  let progressDiv = ui.divText('Ready');
5
5
  view.setRibbonPanels([[progressDiv]]);
6
6
 
7
7
  let data = grok.data.demo.randomWalk();
8
8
 
9
- let reactorInput = ui.choiceInput('Reactor', 'Biotek 15kL SS', ['Biotek 15kL SS']);
10
- let productInput = ui.choiceInput('Product', 'BAR FOO56545', ['BAR FOO56545']);
11
- let controlRunInput = ui.choiceInput('Control Run', '15FDX006', ['15FDX006']);
12
- let daysInput = ui.intInput('Process days', 12);
9
+ let reactorInput = ui.input.choice('Reactor', {items: ['Biotek 15kL SS'], value: 'Biotek 15kL SS'});
10
+ let productInput = ui.input.choice('Product', {items: ['BAR FOO56545'], value: 'BAR FOO56545'});
11
+ let controlRunInput = ui.input.choice('Control Run', {items: ['15FDX006'], value: '15FDX006'});
12
+ let daysInput = ui.input.int('Process days', {value: 12});
13
13
 
14
14
  let topGrid = ui.divV([
15
15
  ui.divH([
@@ -53,15 +53,15 @@ acc.addPane('menus', () => ui.button('SHOW', () => {
53
53
  });
54
54
  }));
55
55
 
56
- acc.addPane('text area', () => ui.textInput('', 'multi\nline\ntext').root);
56
+ acc.addPane('text area', () => ui.input.textArea('', {value: 'multi\nline\ntext'}).root);
57
57
 
58
58
  acc.addPane('range ', () => ui.rangeSlider(0, 10, 2, 5).root);
59
59
 
60
60
  let persistentAcc = ui.accordion('keyThatGivesPersistence');
61
61
 
62
62
  persistentAcc.addPane('persistent pane', () =>
63
- ui.divText('If this pane is expanded, then it will be expanded next time'));
63
+ ui.divText('If this pane is expanded, then it will be expanded next time'));
64
64
 
65
65
  //v.root.appendChild(acc.root);
66
66
  v.append(acc.root);
67
- v.append(persistentAcc.root)
67
+ v.append(persistentAcc.root);
@@ -1,7 +1,10 @@
1
- const dropDown = ui.dropDown(ui.iconFA('plus'), () => ui.div('Element'));
2
- const dropDown2 = ui.dropDown(ui.iconFA('minus'), () => ui.list(['Element 1', 'Element 2', 'Element 3']));
1
+ ui.ribbonPanel([
2
+ ui.dropDown('Element', () => ui.div('Element')),
3
+ ui.dropDown('List', () => ui.list(['Element 1', 'Element 2', 'Element 3'])),
4
+ ui.dropDown('Menu', () => ui.popupMenu({
5
+ 'Foo': () => grok.shell.info('foo'),
6
+ 'Bar': () => {}
7
+ }, {show: false}).root)
8
+ ])
3
9
 
4
- dropDown.onElementClick.subscribe(() => grok.shell.info('Element click'));
5
- dropDown.onExpand.subscribe(() => grok.shell.info('expand event'));
6
10
 
7
- grok.shell.newView('DropDown', [ui.ribbonPanel([dropDown.root, dropDown2.root])]);