@datagrok/api-samples 1.0.5 → 1.0.7

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 (165) hide show
  1. package/.eslintrc.json +47 -0
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +11 -9
  4. package/dist/package-test.js +2 -519
  5. package/dist/package.js +2 -30
  6. package/layouts/demog-table-layout.json +236 -0
  7. package/package.json +15 -13
  8. package/scripts/dapi/files.js +12 -12
  9. package/scripts/dapi/groups.js +3 -0
  10. package/scripts/dapi/users.js +1 -1
  11. package/scripts/data-access/db/db-edit.js +27 -0
  12. package/scripts/data-access/db-master-details-manual.js +3 -3
  13. package/scripts/data-access/dynamic-query.js +13 -0
  14. package/scripts/data-access/output-layouts.js +5 -0
  15. package/scripts/data-access/parameterized-query.js +3 -3
  16. package/scripts/data-frame/bitset/similarity-metrics.js +3 -3
  17. package/scripts/data-frame/construction/create-from-csv-format.js +3 -3
  18. package/scripts/data-frame/events/calculated-columns/update.js +1 -1
  19. package/scripts/data-frame/join-link/join-tables.js +5 -6
  20. package/scripts/data-frame/modification/remove-where.js +8 -0
  21. package/scripts/data-frame/row-matching/patterns.js +1 -3
  22. package/scripts/domains/chem/chem-benchmark.js +26 -26
  23. package/scripts/domains/chem/descriptors.js +1 -2
  24. package/scripts/domains/chem/diversity-search.js +3 -5
  25. package/scripts/domains/chem/inspect-molecule.js +1 -1
  26. package/scripts/domains/chem/mcs.js +2 -3
  27. package/scripts/domains/chem/mol-atoms-bonds.js +1 -2
  28. package/scripts/domains/chem/mol-panel.js +0 -1
  29. package/scripts/domains/chem/mol-rendering-canvas.js +4 -6
  30. package/scripts/domains/chem/mol-rendering.js +0 -1
  31. package/scripts/domains/chem/r-group.js +3 -5
  32. package/scripts/domains/chem/similarity-scoring-scores.js +0 -3
  33. package/scripts/domains/chem/similarity-scoring-sorted.js +0 -3
  34. package/scripts/domains/chem/substructure-search-benchmark.js +5 -8
  35. package/scripts/domains/chem/substructure-search-smarts-molfile-als.js +6 -9
  36. package/scripts/domains/chem/substructure-search-smarts.js +4 -7
  37. package/scripts/domains/chem/substructure-search.js +1 -4
  38. package/scripts/domains/data-science/predictive-model.js +2 -3
  39. package/scripts/functions/caching-results.js +36 -0
  40. package/scripts/functions/calling.js +2 -2
  41. package/scripts/functions/discover-functions.js +1 -1
  42. package/scripts/functions/func-call.js +18 -0
  43. package/scripts/functions/progress.js +2 -7
  44. package/scripts/grid/advanced/charts-in-cells.js +16 -14
  45. package/scripts/grid/advanced/link-click.js +19 -0
  46. package/scripts/grid/advanced/pinned-columns.js +7 -0
  47. package/scripts/grid/advanced/pinned-rows.js +8 -0
  48. package/scripts/grid/advanced/visible-cells.js +3 -4
  49. package/scripts/grid/scroll-to-pixels.js +9 -4
  50. package/scripts/misc/audit/activity-today.js +3 -3
  51. package/scripts/misc/audit/errors-summary.js +2 -4
  52. package/scripts/misc/audit/test-tracking.js +2 -4
  53. package/scripts/misc/audit/users-today.js +6 -7
  54. package/scripts/misc/package-credentials.js +2 -4
  55. package/scripts/misc/paint/paint.js +14 -0
  56. package/scripts/misc/sdtm.js +8 -10
  57. package/scripts/misc/utils/hide-empty-columns.js +19 -0
  58. package/scripts/scripting/grok-scripting.js +1 -1
  59. package/scripts/scripting/scripting.js +2 -2
  60. package/scripts/shell/current-object.js +1 -1
  61. package/scripts/shell/last-error.js +0 -4
  62. package/scripts/shell/windows/shell-windows.js +6 -0
  63. package/scripts/ui/components/balloons.js +9 -0
  64. package/scripts/ui/components/breadcrumbs.js +4 -0
  65. package/scripts/ui/{elements → components}/color-palettes.js +4 -4
  66. package/scripts/ui/components/drop-down.js +7 -0
  67. package/scripts/ui/components/html-tables.js +27 -0
  68. package/scripts/ui/components/loading-indicators.js +4 -6
  69. package/scripts/ui/components/menu-customization.js +18 -0
  70. package/scripts/ui/components/property-grid.js +10 -10
  71. package/scripts/ui/{layouts → containers}/splitters.js +3 -3
  72. package/scripts/ui/css.js +20 -0
  73. package/scripts/ui/docking/README.md +3 -3
  74. package/scripts/ui/handlers/handlers.js +1 -1
  75. package/scripts/ui/inputs/advanced/all-input-types.js +47 -0
  76. package/scripts/ui/inputs/{for-properties.js → advanced/for-properties.js} +17 -2
  77. package/scripts/ui/inputs/advanced/input-form.js +10 -0
  78. package/scripts/ui/inputs/forms.js +35 -0
  79. package/scripts/ui/inputs/grid-input.js +14 -0
  80. package/scripts/ui/inputs/inputs.js +24 -0
  81. package/scripts/ui/{elements/inputs → inputs}/table-input.js +1 -2
  82. package/scripts/ui/inputs/tags-input.js +12 -0
  83. package/scripts/ui/inputs/typeahead-input.js +19 -0
  84. package/scripts/ui/interactivity/hints.js +25 -0
  85. package/scripts/ui/interactivity/wizard-hints.js +15 -0
  86. package/scripts/ui/viewers/advanced/sketch-form.js +9 -0
  87. package/scripts/ui/viewers/custom-scatterplot-rendering.js +1 -1
  88. package/scripts/ui/viewers/custom-viewer-properties.js +5 -5
  89. package/scripts/ui/viewers/filters/custom-filters.js +8 -3
  90. package/scripts/ui/viewers/js viewers/chord-viewer.js +3 -0
  91. package/scripts/ui/viewers/js viewers/globe-viewer.js +13 -0
  92. package/scripts/ui/viewers/js viewers/radar-viewer.js +9 -0
  93. package/scripts/ui/viewers/js viewers/sankey-viewer.js +4 -0
  94. package/scripts/ui/viewers/js viewers/sunburst-viewer.js +3 -0
  95. package/scripts/ui/viewers/js viewers/surface-plot.js +2 -0
  96. package/scripts/ui/viewers/js viewers/timelines-viewer.js +3 -0
  97. package/scripts/ui/viewers/js viewers/tree-viewer.js +3 -0
  98. package/scripts/ui/viewers/js viewers/word-cloud.js +5 -0
  99. package/scripts/ui/viewers/trellis-plot-with-summary-viewer.js +14 -0
  100. package/scripts/ui/viewers/types/form-advanced.js +7 -0
  101. package/scripts/ui/views/currently-open-views.js +5 -5
  102. package/src/package-test.ts +31 -1
  103. package/tsconfig.json +1 -1
  104. package/scripts/misc/audit/errors.js +0 -4
  105. package/scripts/misc/audit/event-types-summary.js +0 -4
  106. package/scripts/misc/audit/rolling-events.js +0 -11
  107. package/scripts/ui/apps/color-checker.js +0 -328
  108. package/scripts/ui/components/panels.js +0 -19
  109. package/scripts/ui/elements/html-tables.js +0 -24
  110. package/scripts/ui/elements/inputs/inputs.js +0 -46
  111. package/scripts/ui/layouts/templates/2 Column.js +0 -14
  112. package/scripts/ui/layouts/templates/3 Column.js +0 -15
  113. package/scripts/ui/layouts/templates/Flex box.js +0 -16
  114. package/scripts/ui/layouts/templates/Fluid layout.js +0 -19
  115. package/scripts/ui/layouts/templates/Gallery grid.js +0 -18
  116. package/scripts/ui/layouts/templates/Splitter (1 Column 2 Row).js +0 -19
  117. package/scripts/ui/layouts/templates/Splitter (2 Column).js +0 -16
  118. package/scripts/ui/layouts/templates/Splitter (2 Row).js +0 -18
  119. package/scripts/ui/layouts/templates/Splitter (2-3 Column).js +0 -23
  120. package/scripts/ui/layouts/templates/Tabs 2 column.js +0 -19
  121. package/scripts/ui/layouts/templates/Tabs navbar.js +0 -16
  122. package/scripts/ui/viewers/types/google-map.js +0 -5
  123. package/scripts/ux/Dialogs/add-new-column-dlg.js +0 -58
  124. package/scripts/ux/Dialogs/link-table-dlg.js +0 -23
  125. package/scripts/ux/Filters/data-filtering.js +0 -99
  126. package/scripts/ux/Input forms/form-types.js +0 -133
  127. package/scripts/ux/Input forms/misc.js +0 -52
  128. package/scripts/ux/Interactivity/hints.js +0 -22
  129. package/scripts/ux/Layouts/example-1.js +0 -50
  130. package/scripts/ux/Layouts/example-2.js +0 -63
  131. package/scripts/ux/Layouts/example-3.js +0 -192
  132. package/scripts/ux/Layouts/example-4.js +0 -51
  133. package/scripts/ux/Managing Collections/datasource-view.js +0 -47
  134. package/scripts/ux/Views/property-panel.js +0 -120
  135. package/scripts/ux/Views/toolbar.js +0 -146
  136. package/scripts/ux/Views/toolbox.js +0 -124
  137. /package/scripts/ui/{elements → components}/buttons.js +0 -0
  138. /package/scripts/ui/{elements → components}/icons.js +0 -0
  139. /package/scripts/ui/{elements → components}/image.js +0 -0
  140. /package/scripts/ui/{elements → components}/list.js +0 -0
  141. /package/scripts/ui/{elements → components}/range-slider.js +0 -0
  142. /package/scripts/ui/{cards → components}/summary-card.js +0 -0
  143. /package/scripts/ui/{elements → components}/typography.js +0 -0
  144. /package/scripts/ui/{layouts → containers}/blocks.js +0 -0
  145. /package/scripts/ui/{layouts → containers}/box.js +0 -0
  146. /package/scripts/ui/{layouts → containers}/containers.js +0 -0
  147. /package/scripts/ui/{layouts → containers}/flexbox.js +0 -0
  148. /package/scripts/ui/{layouts → containers}/panels.js +0 -0
  149. /package/scripts/ui/inputs/{custom-inputs.js → advanced/custom-inputs.js} +0 -0
  150. /package/scripts/ui/inputs/{for-columns.js → advanced/for-columns.js} +0 -0
  151. /package/scripts/ui/inputs/{input-events.js → advanced/input-events.js} +0 -0
  152. /package/scripts/ui/inputs/{master-details.js → advanced/master-details.js} +0 -0
  153. /package/scripts/ui/{elements/inputs → inputs}/choice-input.js +0 -0
  154. /package/scripts/ui/{elements/inputs → inputs}/column-combo-box.js +0 -0
  155. /package/scripts/ui/{elements/inputs → inputs}/column-inputs.js +0 -0
  156. /package/scripts/ui/{elements/inputs → inputs}/inputs-events.js +0 -0
  157. /package/scripts/ui/{elements/inputs → inputs}/inputs-extended.js +0 -0
  158. /package/scripts/ui/{elements/inputs → inputs}/molecule-input.js +0 -0
  159. /package/scripts/{ux/Interactivity → ui/interactivity}/drag-and-drop.js +0 -0
  160. /package/scripts/{ux/Rendering → ui/rendering}/render-items.js +0 -0
  161. /package/scripts/ui/{components/tooltips → tooltips}/row-group-tooltips.js +0 -0
  162. /package/scripts/ui/{components/tooltips → tooltips}/tooltip-events.js +0 -0
  163. /package/scripts/ui/{components/tooltips → tooltips}/tooltips.js +0 -0
  164. /package/scripts/{ux/Navigations → ui/views}/navigation.js +0 -0
  165. /package/scripts/{ux/Managing Collections → ui/views}/virtual-view.js +0 -0
@@ -1,25 +1,23 @@
1
1
  let links = {
2
- ae: { key: 'USUBJID', start: 'AESTDY', end: 'AEENDY', event: 'AETERM'},
3
- cm: { key: 'USUBJID', start: 'VISITDY', event: 'CMTRT'},
4
- ex: { key: 'USUBJID', start: 'EXSTDY', end: 'EXENDY', event: 'EXTRT'},
5
- lb: { key: 'USUBJID', start: 'LBDY', event: 'LBTEST'}
2
+ ae: {key: 'USUBJID', start: 'AESTDY', end: 'AEENDY', event: 'AETERM'},
3
+ sv: {key: 'USUBJID', start: 'VISITDY', event: 'VISIT'},
4
+ lb: {key: 'USUBJID', start: 'LBDY', event: 'LBTEST'}
6
5
  };
7
6
 
8
7
  let result = null;
9
8
 
10
- let getTable = function(domain) {
9
+ let getTable = async function(domain) {
11
10
  let info = links[domain];
12
- let t = grok.shell
13
- .tableByName(domain)
14
- .clone(null, Object.keys(info).map(e => info[e]));
11
+ let df = await grok.data.files.openTable(`System:AppData/ClinicalCase/${domain}.csv`);
12
+ let t = df.clone(null, Object.keys(info).map(e => info[e]));
15
13
  t.columns.addNew('domain', DG.TYPE.STRING).init(domain);
16
14
  for (let name in info)
17
15
  t.col(info[name]).name = name;
18
16
  return t;
19
- }
17
+ };
20
18
 
21
19
  for (let domain in links) {
22
- let t = getTable(domain);
20
+ let t = await getTable(domain);
23
21
  if (result == null)
24
22
  result = t;
25
23
  else
@@ -0,0 +1,19 @@
1
+ // Hides completely empty columns
2
+
3
+ let table = DG.DataFrame.fromCsv(
4
+ `make, model, cylinders, volume, price
5
+ Honda, Civic, , 1.4, 15000
6
+ Honda, Accord, , 1.8, 20000
7
+ BMW, 328i, , 1.7, 60000
8
+ BMW, 535i, , 1.5, 35000
9
+ Tesla, Roadster, , 1.6, 100000
10
+ Tesla, Model S, , 1.6, 120000`);
11
+
12
+ let tv = grok.shell.addTableView(table);
13
+
14
+ setTimeout(() => {
15
+ for (let c of tv.dataFrame.columns) {
16
+ if (c.stats.missingValueCount === tv.dataFrame.rowCount)
17
+ tv.grid.col(c.name).visible = false;
18
+ }
19
+ }, 1000);
@@ -1,3 +1,3 @@
1
1
  grok.functions
2
- .eval('OpenServerFile("Skalkin:DatagrokData/formats/xslx/beer.xlsx")')
2
+ .eval('OpenServerFile("Demo:Files/beer.csv")')
3
3
  .then((t) => grok.shell.addTableView(t[0]));
@@ -2,5 +2,5 @@
2
2
  //help-url: https://datagrok.ai/help/compute/scripting
3
3
  // An example of using scripting (R, Python etc.)
4
4
 
5
- grok.functions.call('DemoScripts:PythonDup', {'s': '1010'}).then(result => grok.shell.info(result));
6
- grok.functions.call('DemoScripts:RDup', {'s': '0101'}).then(result => grok.shell.info(result));
5
+ grok.functions.call('Demo:PythonDup', {'s': '1010'}).then(result => grok.shell.info(result));
6
+ grok.functions.call('Demo:RDup', {'s': '0101'}).then(result => grok.shell.info(result));
@@ -1,3 +1,3 @@
1
- // Current object gets shown in the property panel on the right.
1
+ // Current object gets shown in the context panel on the right.
2
2
 
3
3
  grok.shell.o = grok.shell.user;
@@ -1,7 +1,3 @@
1
- //name: shellLastError
2
- //description: Hello world script
3
- //language: javascript
4
-
5
1
  // First uncomment this errorneous line in the script:
6
2
  // 2 ++ 2;
7
3
  // Hit save the script like that, you should now see an error.
@@ -0,0 +1,6 @@
1
+ // Basic manipulations with the standard panels
2
+
3
+ grok.shell.windows.help.visible = true;
4
+ grok.shell.windows.help.showHelp(ui.h1('Custom help element'));
5
+
6
+ grok.shell.windows.context.visible = true;
@@ -0,0 +1,9 @@
1
+ /// Different way of showing balloons
2
+
3
+ grok.shell.info('Just a string');
4
+ grok.shell.warning('Warning ballon');
5
+ grok.shell.error(ui.div([
6
+ ui.divText('Actionable hint'),
7
+ ui.bigButton('RUN', () => {}),
8
+ ui.button('Cancel', ()=>{})
9
+ ]));
@@ -0,0 +1,4 @@
1
+ const breadcrumbs = ui.breadcrumbs(['dev', 'datagrok', 'ai', 'apps', 'Curves']);
2
+ breadcrumbs.onPathClick.subscribe((value) => grok.shell.info(value));
3
+
4
+ grok.shell.newView('Breadcrumbs', [breadcrumbs.root]);
@@ -3,7 +3,7 @@
3
3
  let v = grok.shell.newView('palettes');
4
4
 
5
5
  function getBlock(c) {
6
- let block = ui.divText(DG.Color.toRgb(c));
6
+ let block = ui.div([DG.Color.toRgb(c),' hex:', DG.Color.toHtml(c)]);
7
7
  block.style.backgroundColor = DG.Color.toRgb(c);
8
8
  block.style.color = DG.Color.toRgb(DG.Color.getContrastColor(c));
9
9
  return block;
@@ -12,6 +12,6 @@ function getBlock(c) {
12
12
  v.appendAll([
13
13
  ui.h1('Categorical palette with contrast text color'),
14
14
  ui.div(DG.Color.categoricalPalette.map(getBlock)),
15
- ui.h1('Category colors (looping over the palette)'),
16
- ui.div(DG.utils.identity(30).map(DG.Color.getCategoricalColor).map(getBlock))
17
- ]);
15
+ ui.h1('Get contrast color from white'),
16
+ ui.div(getBlock(DG.Color.getContrastColor(DG.Color.white)))
17
+ ]);
@@ -0,0 +1,7 @@
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']));
3
+
4
+ dropDown.onElementClick.subscribe(() => grok.shell.info('Element click'));
5
+ dropDown.onExpand.subscribe(() => grok.shell.info('expand event'));
6
+
7
+ grok.shell.newView('DropDown', [ui.ribbonPanel([dropDown.root, dropDown2.root])]);
@@ -0,0 +1,27 @@
1
+ // Creating HTML-driven tables
2
+ // For high-performance grid, check out samples under /grid
3
+
4
+ var users = [
5
+ {name: 'Mike', surname: 'Moore', age: 30, sex: 'Male'},
6
+ {name: 'Kate', surname: 'Jackson', age: 27, sex: 'Female'},
7
+ {name: 'John', surname: 'Stone', age: 32, sex: 'Male'},
8
+ ];
9
+
10
+ let table1 = ui.tableFromMap({
11
+ user: grok.shell.user.toMarkup(),
12
+ project: grok.shell.project.toMarkup(),
13
+ time: new Date(),
14
+ });
15
+
16
+ let table2 = DG.HtmlTable.create(users, (item) => [item.name, item.surname, item.age, item.sex]);
17
+
18
+ let table3 = ui.table(users, (item) => [item.name, item.surname, item.age, item.sex],
19
+ ['First name', 'Last name', 'Age', 'Sex']);
20
+
21
+ let view = grok.shell.newView('table with renderer', [
22
+ table1,
23
+ table2,
24
+ table3,
25
+ ]);
26
+
27
+ table2.remove(users[2]);
@@ -1,7 +1,7 @@
1
1
  //wait, waitBox, loader
2
2
 
3
- async function sleep() {
4
- return new Promise(resolve => setTimeout(resolve, 2000));
3
+ async function sleep(time) {
4
+ return new Promise(resolve => setTimeout(resolve, time));
5
5
  }
6
6
 
7
7
  //load indicator
@@ -9,16 +9,14 @@ let loader = ui.loader();
9
9
 
10
10
  //wait container
11
11
  let wait = ui.wait(async () => {
12
- await sleep();
12
+ await sleep(500);
13
13
  return ui.divText('ui.wait element');
14
14
  })
15
15
 
16
16
  //wait container. Recommend to use inside tabControl, accordion, box, view.box
17
17
  let waitBox = ui.waitBox(async () => {
18
- await sleep();
18
+ await sleep(1000);
19
19
  return ui.divText('ui.waitBox element');
20
20
  })
21
21
 
22
- wait.style.border = '1px solid var(--grey-1)';
23
- waitBox.style.border = '1px solid var(--grey-1)';
24
22
  grok.shell.newView('Demo, loader, wait, waitBox', [wait, waitBox, loader]);
@@ -0,0 +1,18 @@
1
+ // Menu item customization. For top menu, see menu.js
2
+
3
+ const host = ui.divText('Click for context menu');
4
+ DG.Menu.popup()
5
+ .item('Explore', () => grok.shell.info('Foo'), null, {
6
+ description: 'Explore Foo',
7
+ shortcut: 'Ctrl+E'})
8
+ .group('Single choice')
9
+ .items(['Apple', 'Banana', 'Peach'], (s) => grok.shell.info(s),
10
+ {radioGroup: 'Fruits', isChecked: (s) => s === 'Banana'})
11
+ .endGroup()
12
+ .group('Multi choice')
13
+ .items(['Apple', 'Banana', 'Peach'], (s) => grok.shell.info(s), {isChecked: (s) => s === 'Banana'})
14
+ .endGroup()
15
+ .separator()
16
+ .item('Touch', () => grok.shell.info('Foo'), null, {isEnabled: () => 'Can\'t touch this!'})
17
+ .bind(host)
18
+ .show();
@@ -1,21 +1,21 @@
1
1
  // dynamically create properties and edit objects in the property grid
2
2
 
3
- let person = {name: 'John', sex: 'M', weight: 67.2, age: 32, checked: true }
3
+ const person = {name: 'John', sex: 'M', weight: 67.2, age: 32, checked: true};
4
4
 
5
5
  // generate properties
6
- let name = DG.Property.string('name', x => x.name, (x, v) => x.name = v, '');
7
- let sex = DG.Property.string('sex', x => x.sex, (x, v) => x.sex = v, '');
6
+ const name = DG.Property.string('name', (x) => x.name, (x, v) => x.name = v, '');
7
+ const sex = DG.Property.string('sex', (x) => x.sex, (x, v) => x.sex = v, '');
8
8
 
9
9
  // shorter notation for JS properties
10
- let width = DG.Property.jsFloat('weight');
11
- let age = DG.Property.jsInt('age');
12
- let checked = DG.Property.jsBool('checked');
10
+ const weight = DG.Property.jsFloat('weight');
11
+ const age = DG.Property.jsInt('age');
12
+ const checked = DG.Property.jsBool('checked');
13
13
 
14
14
  // change properties if you wish
15
15
  sex.choices = ['M', 'F'];
16
16
 
17
- let propGrid = new DG.PropertyGrid();
18
- propGrid.update(person, [name, sex, width, age, checked]);
17
+ const propGrid = new DG.PropertyGrid();
18
+ propGrid.update(person, [name, sex, weight, age, checked]);
19
19
 
20
20
  //ui.dialog().add(propGrid).show({width: 400, height: 250});
21
21
 
@@ -23,5 +23,5 @@ ui.dialog()
23
23
  .add(ui.h1('Property grid'))
24
24
  .add(propGrid)
25
25
  .add(ui.h1('Form'))
26
- .add(ui.input.form(person, [name, sex, width, age, checked]))
27
- .show({width: 350, height: 500});
26
+ .add(ui.input.form(person, [name, sex, weight, age, checked]))
27
+ .show({width: 350, height: 500});
@@ -9,12 +9,12 @@ let block = ui.splitV([
9
9
  ui.textInput('text',' multi line /n text input'),
10
10
  ]),
11
11
  DG.Viewer.grid(t).root
12
- ]),
12
+ ], {}, true),
13
13
  ui.splitH([
14
14
  DG.Viewer.scatterPlot(t).root,
15
15
  DG.Viewer.histogram(t).root
16
- ])
17
- ]);
16
+ ], {}, true)
17
+ ], {}, true);
18
18
 
19
19
  let view = grok.shell.newView('Splitters');
20
20
  view.box = true;
@@ -0,0 +1,20 @@
1
+ //Datagrok has pre-build CSS helper classes to manipulate most common parameters such as:
2
+ //margins, paddings, text size, text weight, etc.
3
+ //To call them, use ui.css.
4
+
5
+ let div1 = ui.div('Child 1');
6
+
7
+ div1.classList.add(
8
+ ui.css.padding.large, // Padding
9
+ ui.css.border.all, // Border
10
+ ui.css.background.white, // Background color
11
+ ui.css.margin.medium, // Margin
12
+ ui.css.textSize.medium, // Text size
13
+ ui.css.textWeight.bold, // Text weight
14
+ ui.css.shadow.small // Shadow
15
+ );
16
+
17
+ ui.div([
18
+ 'Parent',
19
+ div1
20
+ ], ui.css.background.light); //add light grey background color
@@ -5,12 +5,12 @@ could be either dragged out and positioned manually, or set up automatically.
5
5
 
6
6
  ## Top-level window docking
7
7
 
8
- Use `grok.shell.dockManager` to dock, undock, or reposition windows.
9
- See also `View.dockNode`
8
+ Use `grok.shell.dockManager` to dock, undock, or reposition windows.
9
+ See also `View.dockNode`
10
10
 
11
11
  ## Nested docking
12
12
 
13
13
  Some of the views contain a nested docking manager, which allows to manage
14
14
  windows within that particular view (they cannot be undocked and docked on
15
- a top level, or within a different view). See `dockManager` property of the
15
+ a top level, or within a different view). See `dockManager` property of the
16
16
  View class.
@@ -1,5 +1,5 @@
1
1
  // Custom object handlers
2
- // Clicking on the item shows its properties in the property panel
2
+ // Clicking on the item shows its properties in the context panel
3
3
  // Right-clicking allows to use context actions
4
4
 
5
5
  class Fruit {
@@ -0,0 +1,47 @@
1
+ const df = grok.data.demo.demog();
2
+ grok.shell.addTable(df);
3
+
4
+ const properties = [
5
+ { "name": "int", "inputType": "Int", "showPlusMinus": true },
6
+ { "name": "float", "inputType": "Float", min: 0, max: 10, "showSlider": true},
7
+ { "name": "bigInt", "inputType": "BigInt"},
8
+ { "name": "qnum", "inputType": "QNum"},
9
+ { "name": "slider", "inputType": "Slider", "min": 0, "max": 10},
10
+ { "name": "bool", "inputType": "Bool"},
11
+ { "name": "textArea", "inputType": "TextArea"},
12
+ { "name": "text", "inputType": "Text"},
13
+ { "name": "date", "inputType": "Date"},
14
+ //{ "name": "map", "inputType": "Map"},
15
+ { "name": "list", "inputType": "List"},
16
+ { "name": "color", "inputType": "Color"},
17
+ { "name": "table", "inputType": "Table"},
18
+ { "name": "column", "inputType": "Column"},
19
+ { "name": "radio", "inputType": "Radio", choices: ["Apple", "Banana"]},
20
+ { "name": "choice", "inputType": "Choice", choices: ["Apple", "Banana"]},
21
+ { "name": "multiChoice", "inputType": "MultiChoice", choices: ["Apple", "Banana"]},
22
+ ];
23
+
24
+ let props = properties.map((p) => DG.Property.fromOptions(p))
25
+ let object = {
26
+ int: 12,
27
+ bigInt: "12345678901234567890",
28
+ float: 4.5,
29
+ qnum: DG.Qnum.less(5),
30
+ slider: 10,
31
+ bool: true,
32
+ textArea: "Bins rise and they fall,\nDistribution's gentle dance,\nHistogram unveils",
33
+ text: 'Only text',
34
+ //date: '2023/10/30', //dayjs(1977, 10, 2),
35
+ map: { key1: 'value1', key2: 'value2'},
36
+ color: '#e66465',
37
+ list: ['1', '2', '4'],
38
+ table: df,
39
+ column: df.columns.byName('race'),
40
+ choice: 'Apple',
41
+ radio: 'Apple',
42
+ };
43
+
44
+ ui.divV([
45
+ ui.input.form(object, props),
46
+ ui.button('Show', () => grok.shell.info(JSON.stringify(object)))
47
+ ])
@@ -9,17 +9,30 @@ const properties = [
9
9
  {
10
10
  "name": "structure",
11
11
  "type": "string",
12
- "semType": "Molecule"
12
+ //"semType": "Molecule"
13
13
  },
14
14
  {
15
15
  "name": "weight",
16
16
  "type": DG.TYPE.FLOAT,
17
- "valueValidators": [(w) => w > 10]
17
+ "valueValidators": [(w) => w > 10 ? null : 'Too small']
18
18
  },
19
19
  {
20
20
  "name": "started",
21
21
  "type": DG.TYPE.DATE_TIME,
22
22
  },
23
+ {
24
+ "name": "stage",
25
+ "type": "int",
26
+ "showPlusMinus": true
27
+ },
28
+ {
29
+ "name": "slider",
30
+ "type": DG.TYPE.FLOAT,
31
+ "showSlider": true,
32
+ "min": 2.2,
33
+ "max": 5.5,
34
+ "nullable": false,
35
+ },
23
36
  {
24
37
  "name": "rating",
25
38
  "type": "int",
@@ -33,6 +46,8 @@ let props = properties.map((p) => DG.Property.fromOptions(p))
33
46
  let object = {
34
47
  reactorType: 'Production',
35
48
  structure: 'CC(=O)OC1=CC=CC=C1C(=O)O',
49
+ stage: 5,
50
+ slider: 3.3,
36
51
  rating: 7,
37
52
  department: 'IT'
38
53
  };
@@ -0,0 +1,10 @@
1
+ // creating a form, and accessing its individual inputs
2
+
3
+ DG.Func.findAll({name: 'Pkpd'}).then((fs) => {
4
+ let fc = fs[0].prepare({dosage: 77});
5
+ DG.InputForm.forFuncCall(fc).then((inputForm) => {
6
+ inputForm.getInput('Clearance').addPostfix('foo');
7
+ inputForm.onInputChanged.subscribe((_) => grok.shell.info('changed'));
8
+ grok.shell.o = inputForm.root;
9
+ });
10
+ });
@@ -0,0 +1,35 @@
1
+ // Different form types
2
+
3
+ let v = grok.shell.newView('demo: form types');
4
+
5
+ //Basic form
6
+ //To set labels aligned to left add class .ui-form-left
7
+ let form = ui.form([
8
+ ui.h1('Basic form'),
9
+ ui.stringInput('First name', 'Arthur'),
10
+ ui.stringInput('Last name', 'Dent'),
11
+ ui.intInput('Age', 30)
12
+ ]);
13
+
14
+ //Add class .ui-form-wide to make the form wide
15
+ let wideForm = ui.form([
16
+ ui.h1('Wide form'),
17
+ ui.stringInput('First name', 'Arthur'),
18
+ ui.stringInput('Last name', 'Dent'),
19
+ ui.intInput('Age', 30)
20
+ ], 'ui-form-wide');
21
+
22
+ //Condensed form. You can also use .ui-form-condensed
23
+ let narrowForm = ui.narrowForm([
24
+ ui.h1('Condensed form'),
25
+ ui.stringInput('First name', 'Arthur'),
26
+ ui.stringInput('Last name', 'Dent'),
27
+ ui.intInput('Age', 30)
28
+ ]);
29
+ v.append(ui.panel([narrowForm]));
30
+
31
+ v.append(ui.divV([
32
+ form,
33
+ wideForm,
34
+ narrowForm,
35
+ ]))
@@ -0,0 +1,14 @@
1
+ const props = [
2
+ //DG.Property.js("fragment", "string", {semType: "Molecule"}),
3
+ DG.Property.js("chemist", "string"),
4
+ DG.Property.js("stage", "string", {choices: ['Screening', 'Optimization']}),
5
+ DG.Property.js("color", "string", {inputType: "Color"})
6
+ ];
7
+
8
+ let molColors = [
9
+ { chemist: 'Jon Snow', stage: 'Screening', fragment: 'CC(=O)OC1=CC=CC=C1C(=O)O', color: '#ff0000' },
10
+ { chemist: 'John Wick', stage: 'Optimization', fragment: 'OC1=CC', color: '#00ff00' }
11
+ ];
12
+
13
+ const grid = ui.input.grid(molColors, props);
14
+ grid.root
@@ -0,0 +1,24 @@
1
+ // Different input types
2
+
3
+ let v = grok.shell.newView('demo: inputs');
4
+
5
+ let search = ui.searchInput('Search', '');
6
+ let name = ui.stringInput('Name', 'Arthur Dent');
7
+ let age = ui.intInput('Age', 30);
8
+ let date = ui.dateInput('Birthday', dayjs('1970-5-10'));
9
+ let alien = ui.boolInput('Alien', false);
10
+ let friends = ui.multiChoiceInput('Friends', ['Ford', 'Fenchurch'], ['Ford', 'Fenchurch', 'Zaphod', 'Slartibartfast']);
11
+ let bestFriend = ui.radioInput('Best friend', 'Ford', ['Ford', 'Fenchurch']);
12
+ let active = ui.switchInput('Active', true);
13
+ let color = ui.colorInput('Favorite color', '#ff0000');
14
+ let country = ui.typeAhead('Country', {source: {local: ['USA', 'Ukraine', 'Antigua', 'United Kingdom', 'United Arab Emirates']}});
15
+ let data = ui.tableInput('Data', null);
16
+ let tags = ui.tagsInput('Skills', ['HTML', 'CSS', 'JS'], true);
17
+ let memo = ui.textInput('Memo', '');
18
+
19
+ name.addValidator(s => s.length < 15 ? 'Too short' : null);
20
+
21
+ let form = ui.form([search, data, name, age, date, alien, friends,bestFriend, active, color, country, tags, memo]);
22
+
23
+ form.append(ui.buttonsInput([ui.bigButton('Submit', ()=>{grok.shell.info('Submit')})]));
24
+ v.append(form);
@@ -3,6 +3,5 @@ grok.shell.addTableView(grok.data.demo.randomWalk());
3
3
 
4
4
  let tables = grok.shell.tables;
5
5
  let input = ui.tableInput('Table', tables[0], tables, (t) => grok.shell.info(t.name));
6
- grok.shell.newView('tableInput', [input.root]);
7
6
 
8
- grok.shell.addTableView(grok.data.demo.biosensor());
7
+ grok.shell.newView('tableInput', [input.root]);
@@ -0,0 +1,12 @@
1
+ const tagsInput = ui.tagsInput('Tags', ['Apps', 'Demo', 'Curves'], false);
2
+
3
+ tagsInput.addTag('New');
4
+ tagsInput.removeTag('Demo');
5
+
6
+ tagsInput.onTagAdded.subscribe((value) => grok.shell.info(`${value} tag was added.`));
7
+ tagsInput.onTagRemoved.subscribe((value) => grok.shell.info(`${value} tag was removed.`));
8
+
9
+ const tagsInput2 = ui.tagsInput('Tags', ['Apps2', 'Demo2', 'Curves2'], true);
10
+ tagsInput2.setTags(['Apps', 'Demo', 'Viewers', 'Tree']);
11
+
12
+ grok.shell.newView('TagsInput', [ui.form([tagsInput, tagsInput2])]);
@@ -0,0 +1,19 @@
1
+ const typeAhead = ui.typeAhead('Countries', {
2
+ source: {
3
+ local: ['USA', 'Ukraine', 'Antigua', 'United Kingdom', 'United Arab Emirates']
4
+ },
5
+ minLength: 2,
6
+ limit: 3,
7
+ hint: true,
8
+ autoSelect: true,
9
+ highlight: true,
10
+ diacritics: true,
11
+ onSubmit: (event, value) => grok.shell.info(value.label),
12
+ debounceRemote: 100
13
+ });
14
+
15
+ typeAhead.onInput(() => grok.shell.info('input event'));
16
+ typeAhead.onChanged(() => grok.shell.info('change event'));
17
+
18
+
19
+ grok.shell.newView('TypeAhead', [typeAhead.root]);
@@ -0,0 +1,25 @@
1
+ const df = grok.data.demo.demog();
2
+ const view = grok.shell.addTableView(df);
3
+ let scatterPlot = view.scatterPlot();
4
+ let histogram = view.histogram();
5
+
6
+ // Place a hint on a visual component in your application.
7
+ // Remove it by clicking on the root element event or by time-out.
8
+ const icon1 = $('div.d4-ribbon-item').has('i.svg-remove-selected-rows')[0];
9
+
10
+ let indicator1 = ui.hints.addHintIndicator(icon1, false, 4000);
11
+ let indicator2 = ui.hints.addHintIndicator(scatterPlot.root, true);
12
+
13
+ // Place a hint popup with a custom HTMLElement.
14
+ let msg = ui.divV([
15
+ ui.h1('Title'),
16
+ ui.divV([
17
+ ui.divText('Click on Scatter plot to close hint indicator'),
18
+ ui.link('Remove hint-indicator and hint-popup',()=>{
19
+ indicator2.click();
20
+ popup.remove();
21
+ }, '','')
22
+ ])
23
+ ]);
24
+
25
+ let popup = ui.hints.addHint(scatterPlot.root, msg, 'left');
@@ -0,0 +1,15 @@
1
+ const df = grok.data.demo.demog();
2
+ const view = grok.shell.addTableView(df);
3
+
4
+ // You can describe a series of visual components in the wizard. Each wizard page is associated
5
+ // with the [showNextTo] element. Provide either [text] or [root] parameter to populate the page, the
6
+ // other parameters are optional. The wizard header is shown only if [title] or [helpUrl] are provided.
7
+ // The user can use the arrow buttons to navigate the set of instructions. The wizard can be closed
8
+ // from the dialog header (the "x" icon), via the "Cancel" button, or via the [Wizard.close()] method.
9
+ const sp = view.scatterPlot();
10
+ const hist = view.histogram();
11
+
12
+ const wizard = ui.hints.addTextHint({title: 'Viewers', pages: [
13
+ {caption: 'First Hint', text: 'Welcome! This is the 1st hint about a scatter plot.', showNextTo: sp.root},
14
+ {caption: 'Second Hint', root: ui.divText('This is the 2nd hint about a histogram.'), showNextTo: hist.root},
15
+ ]});
@@ -0,0 +1,9 @@
1
+ // user-editable form
2
+
3
+ let t = grok.data.demo.demog();
4
+ let form = DG.Form.forDataFrame(t, {columns: ['sex', 'race', 'age']});
5
+ form.editable = true;
6
+ form.designMode = true;
7
+ form.row = new DG.Row(t, 4);
8
+
9
+ ui.dialog().add(form).show();
@@ -19,4 +19,4 @@ let sp = DG.Viewer.scatterPlot(grok.data.demo.randomWalk(20, 2), {
19
19
  });
20
20
  grok.shell.newView('View', [sp]);
21
21
 
22
- sp.onAfterDrawScene.subscribe(_ => renderLines(sp));
22
+ sp.onAfterDrawScene.subscribe((_) => renderLines(sp));
@@ -1,8 +1,8 @@
1
- let view = grok.shell.addTableView(grok.data.demo.geo(10000));
2
- let leaflet = view.addViewer('Leaflet');
3
- leaflet.setOptions({
1
+ const view = grok.shell.addTableView(grok.data.demo.geo(1000));
2
+ const map = view.addViewer('Map');
3
+ map.setOptions({
4
4
  latitudeColumnName: 'lat',
5
- longitudeColumnName: 'lng'
5
+ longitudeColumnName: 'lng',
6
6
  });
7
7
 
8
- grok.shell.info(leaflet.props.getProperties().map((p) => p.name).join(', '));
8
+ grok.shell.info(map.props.getProperties().map((p) => p.name).join(', '));
@@ -1,4 +1,9 @@
1
1
  let tv = grok.shell.addTableView(grok.data.demo.demog());
2
- tv.filters({filters: [
3
- {type: 'Widgets:radioButtonFilter', columnName: 'race'},
4
- ]});
2
+
3
+ // We need to load the external package before we use the
4
+ // synchronous "tv.filters" method that uses the filter
5
+ grok.functions.call('Widgets:radioButtonFilter').then((_) => {
6
+ tv.filters({filters: [
7
+ {type: 'Widgets:radioButtonFilter', columnName: 'race'},
8
+ ]});
9
+ });
@@ -0,0 +1,3 @@
1
+ const df = await grok.data.files.openTable("Demo:Files/energy_uk.csv");
2
+ let view = grok.shell.addTableView(df);
3
+ view.addViewer('chord');