@datagrok/api-samples 1.0.8 → 1.0.12
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/CHANGELOG.md +9 -0
- package/dist/package-test.js +2 -2
- package/files/viewer-events/bar-chart/on-category-clicked.js +1 -0
- package/files/viewer-events/grid/on-cell-clicked.js +1 -0
- package/files/viewer-events/pc-plot/on-line-clicked.js +1 -0
- package/files/viewer-events/pie-chart/on-segment-clicked.js +1 -0
- package/files/viewer-events/scatter-plot/on-point-clicked.js +1 -0
- package/files/viewer-events/scatter-plot/on-rendered.js +1 -0
- package/layouts/demog-table-layout.json +329 -181
- package/package.json +17 -15
- package/scripts/dapi/files.js +40 -0
- package/scripts/dapi/projects-open.js +1 -1
- package/scripts/dapi/sticky-meta-1-tags.js +54 -0
- package/scripts/dapi/sticky-meta-2-semtype.js +33 -0
- package/scripts/data-access/db-master-details-manual.js +3 -2
- package/scripts/data-access/external/stock-prices.js +1 -1
- package/scripts/data-access/open-table-by-id.js +11 -3
- package/scripts/data-access/output-layouts.js +3 -1
- package/scripts/data-frame/advanced/data-frames-in-columns.js +4 -1
- package/scripts/data-frame/advanced/virtual-columns.js +1 -1
- package/scripts/data-frame/aggregation/unpivot.js +1 -1
- package/scripts/data-frame/column-access.js +1 -3
- package/scripts/data-frame/compare-tables.js +3 -2
- package/scripts/data-frame/construction/create-from-csv-format.js +3 -3
- package/scripts/data-frame/construction/create-from-typed-arrays.js +7 -2
- package/scripts/data-frame/construction/export-to-csv-advanced.js +14 -4
- package/scripts/data-frame/construction/export-to-csv-molblock.js +3 -0
- package/scripts/data-frame/construction/export-to-csv.js +1 -1
- package/scripts/data-frame/events/calculated-columns/creation.js +1 -1
- package/scripts/data-frame/events/calculated-columns/deletion.js +1 -1
- package/scripts/data-frame/events/calculated-columns/update.js +1 -1
- package/scripts/data-frame/join-link/link-tables-dynamic.js +3 -5
- package/scripts/data-frame/metadata/dataframe-meta.js +1 -1
- package/scripts/data-frame/modification/add-columns.js +1 -1
- package/scripts/data-frame/modification/append.js +1 -1
- package/scripts/data-frame/modification/calculated-columns/edit-formula.js +2 -2
- package/scripts/data-frame/modification/double-precision.js +26 -0
- package/scripts/data-frame/modification/manipulate.js +3 -3
- package/scripts/domains/chem/sketcher.js +2 -2
- package/scripts/events/form-creation.js +2 -2
- package/scripts/events/global-events.js +1 -1
- package/scripts/events/layout-events.js +5 -6
- package/scripts/events/viewer-data-events.js +11 -0
- package/scripts/functions/func-call.js +5 -0
- package/scripts/grid/advanced/cell-renderer.js +1 -1
- package/scripts/grid/advanced/format-formula.js +7 -0
- package/scripts/grid/advanced/link-click.js +3 -3
- package/scripts/grid/advanced/markup-link.js +6 -0
- package/scripts/grid/advanced/paint-counts.js +4 -1
- package/scripts/grid/{color-coding-conditional.js → color-coding/color-coding-conditional.js} +17 -10
- package/scripts/grid/color-coding/color-coding.js +5 -9
- package/scripts/grid/color-coding/get-cell-color.js +3 -5
- package/scripts/grid/column-cell-styles.js +10 -0
- package/scripts/grid/column-controlled-values.js +2 -2
- package/scripts/grid/data-format.js +4 -4
- package/scripts/grid/hit-test.js +1 -1
- package/scripts/grid/html-cells/html-table-cells.js +1 -1
- package/scripts/misc/audit/test-tracking.js +1 -1
- package/scripts/misc/user-settings-storage.js +48 -0
- package/scripts/scripting/files-for-scripting.js +24 -0
- package/scripts/scripting/grok-scripting.js +1 -1
- package/scripts/shell/last-error.js +1 -1
- package/scripts/shell/ui-parts.js +9 -9
- package/scripts/shell/windows/browse/customize-tree.js +3 -0
- package/scripts/ui/apps/bioreactor.js +5 -5
- package/scripts/ui/components/accordion.js +3 -3
- package/scripts/ui/components/tree-view-adv.js +4 -2
- package/scripts/ui/containers/splitters.js +13 -13
- package/scripts/ui/dialogs/wizard.js +8 -8
- package/scripts/ui/docking/docking.js +4 -1
- package/scripts/ui/handlers/markup-handlers.js +61 -0
- package/scripts/ui/inputs/advanced/all-input-types.js +37 -24
- package/scripts/ui/inputs/advanced/input-api.js +39 -0
- package/scripts/ui/inputs/advanced/input-events.js +10 -10
- package/scripts/ui/inputs/advanced/input-form.js +8 -8
- package/scripts/ui/inputs/choice-input.js +5 -5
- package/scripts/ui/inputs/column-combo-box.js +3 -3
- package/scripts/ui/inputs/column-inputs.js +3 -3
- package/scripts/ui/inputs/forms.js +10 -10
- package/scripts/ui/inputs/helm-input-ui.js +7 -0
- package/scripts/ui/inputs/inputs-events.js +8 -8
- package/scripts/ui/inputs/inputs-extended.js +2 -2
- package/scripts/ui/inputs/inputs.js +17 -15
- package/scripts/ui/inputs/molecule-input.js +1 -1
- package/scripts/ui/inputs/table-input.js +1 -1
- package/scripts/ui/inputs/tags-input.js +2 -2
- package/scripts/ui/inputs/typeahead-input.js +16 -17
- package/scripts/ui/inputs/validation/input-validators.js +11 -0
- package/scripts/ui/inputs/validation/script-param-validation.js +6 -0
- package/scripts/ui/inputs/validation/visible-enabled.js +9 -0
- package/scripts/ui/interactivity/drag-and-drop.js +3 -3
- package/scripts/ui/tooltips/tooltips.js +6 -2
- package/scripts/ui/viewers/advanced/attached-properties.js +5 -5
- package/scripts/ui/viewers/advanced/default-axis-type.js +1 -1
- package/scripts/ui/viewers/advanced/init-function.js +21 -0
- package/scripts/ui/viewers/advanced/init-script.js +15 -0
- package/scripts/ui/viewers/filters/add-single-filter.js +5 -5
- package/scripts/ui/viewers/filters/custom-filters.js +3 -3
- package/scripts/ui/viewers/filters/filter-group.js +6 -1
- package/scripts/ui/viewers/filters/multi-value-filter.js +1 -1
- package/scripts/ui/viewers/js viewers/chord-viewer.js +1 -1
- package/scripts/ui/viewers/js viewers/sankey-viewer.js +1 -1
- package/scripts/ui/viewers/js viewers/word-cloud.js +1 -1
- package/scripts/ui/viewers/scatter-plot-events.js +6 -1
- package/scripts/ui/viewers/trellis-plot-with-summary-viewer.js +3 -1
- package/scripts/ui/viewers/types/markup-advanced.js +1 -1
- package/scripts/ui/viewers/types/trellis-plot.js +13 -1
- package/scripts/ui/viewers/types/word-cloud.js +1 -1
- package/scripts/ui/views/default-views.js +3 -3
- package/scripts/ui/views/layouts.js +16 -17
- package/scripts/ui/views/multi-view.js +1 -1
- package/src/global.d.ts +13 -0
- package/src/package-test.ts +106 -16
- package/webpack.config.js +4 -1
- package/files.js +0 -39
- package/scripts/misc/user-data-storage.js +0 -49
- /package/scripts/scripting/{scripting.js → package-scripting.js} +0 -0
- /package/{scripts/ui/handlers → to fix}/dynamic-loading.js +0 -0
|
@@ -2,14 +2,14 @@ let v = grok.shell.newView('demo: inputs-events');
|
|
|
2
2
|
|
|
3
3
|
const msg = (v) => grok.shell.info(v);
|
|
4
4
|
|
|
5
|
-
let name = ui.
|
|
6
|
-
let age = ui.
|
|
7
|
-
let sex = ui.
|
|
8
|
-
let date = ui.
|
|
9
|
-
let alien = ui.
|
|
10
|
-
let friends = ui.
|
|
11
|
-
['Ford', 'Fenchurch'],
|
|
12
|
-
let active = ui.
|
|
5
|
+
let name = ui.input.string('Name', {value: 'Arthur Dent', onValueChanged: (v) => msg(v)});
|
|
6
|
+
let age = ui.input.int('Age', {value: 30, onValueChanged: (v) => msg(v)});
|
|
7
|
+
let sex = ui.input.choice('Sex', {items: ['Male', 'Female'], value: 'Male', onValueChanged: (v) => msg(v)});
|
|
8
|
+
let date = ui.input.date('Birthday', {value: dayjs('1970-5-10'), onValueChanged: (v) => msg(v)});
|
|
9
|
+
let alien = ui.input.bool('Alien', {value: false, onValueChanged: (v) => msg(v)});
|
|
10
|
+
let friends = ui.input.multiChoice('Friends', {items: ['Ford', 'Fenchurch', 'Zaphod', 'Slartibartfast'],
|
|
11
|
+
value: ['Ford', 'Fenchurch'], onValueChanged: (v) => msg(v)});
|
|
12
|
+
let active = ui.input.toggle('Active', {value: true, onValueChanged: (v) => msg(v)});
|
|
13
13
|
|
|
14
14
|
let inputs = [name, age, sex, date, alien, friends, active];
|
|
15
15
|
let container = ui.div();
|
|
@@ -24,8 +24,8 @@ for (let n = 0; n < inputs.length; n++) {
|
|
|
24
24
|
let label = ui.divText('');
|
|
25
25
|
label.style.margin = '10px';
|
|
26
26
|
content.appendChild(label);
|
|
27
|
-
input.onChanged(
|
|
28
|
-
label.innerText = `${input.caption}: ${
|
|
27
|
+
input.onChanged.subscribe((value) => {
|
|
28
|
+
label.innerText = `${input.caption}: ${value}`;
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
let v = grok.shell.newView('demo: inputs');
|
|
4
4
|
|
|
5
|
-
let search = ui.
|
|
6
|
-
let name = ui.
|
|
7
|
-
let age = ui.
|
|
8
|
-
let date = ui.
|
|
9
|
-
let alien = ui.
|
|
10
|
-
let friends = ui.
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
let
|
|
14
|
-
let
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
let
|
|
5
|
+
let search = ui.input.search('Search');
|
|
6
|
+
let name = ui.input.string('Name', {value: 'Arthur Dent'});
|
|
7
|
+
let age = ui.input.int('Age', {value: 30});
|
|
8
|
+
let date = ui.input.date('Birthday', {value: dayjs('1970-5-10')});
|
|
9
|
+
let alien = ui.input.bool('Alien', {value: false});
|
|
10
|
+
let friends = ui.input.multiChoice('Friends', {items: ['Ford', 'Fenchurch', 'Zaphod', 'Slartibartfast'],
|
|
11
|
+
value: ['Ford', 'Fenchurch']});
|
|
12
|
+
let bestFriend = ui.input.radio('Best friend', {items: ['Ford', 'Fenchurch'], value: 'Ford'});
|
|
13
|
+
let active = ui.input.toggle('Active', {value: true});
|
|
14
|
+
let color = ui.input.color('Favorite color', {value: '#ff0000'});
|
|
15
|
+
let country = ui.typeAhead('Country', {source: {
|
|
16
|
+
local: ['USA', 'Ukraine', 'Antigua', 'United Kingdom', 'United Arab Emirates']}});
|
|
17
|
+
let data = ui.input.table('Data');
|
|
18
|
+
let tags = ui.input.tags('Skills', {tags: ['HTML', 'CSS', 'JS'], showButton: true});
|
|
19
|
+
let memo = ui.input.textArea('Memo');
|
|
18
20
|
|
|
19
21
|
name.addValidator(s => s.length < 15 ? 'Too short' : null);
|
|
20
22
|
|
|
21
|
-
let form = ui.form([search, data, name, age, date, alien, friends,bestFriend, active, color, country, tags, memo]);
|
|
23
|
+
let form = ui.form([search, data, name, age, date, alien, friends, bestFriend, active, color, country, tags, memo]);
|
|
22
24
|
|
|
23
|
-
form.append(ui.buttonsInput([ui.bigButton('Submit', ()=>{grok.shell.info('Submit')})]));
|
|
25
|
+
form.append(ui.buttonsInput([ui.bigButton('Submit', ()=>{grok.shell.info('Submit');})]));
|
|
24
26
|
v.append(form);
|
|
@@ -2,6 +2,6 @@ grok.shell.addTableView(grok.data.demo.demog());
|
|
|
2
2
|
grok.shell.addTableView(grok.data.demo.randomWalk());
|
|
3
3
|
|
|
4
4
|
let tables = grok.shell.tables;
|
|
5
|
-
let input = ui.
|
|
5
|
+
let input = ui.input.table('Table', {value: tables[0], items: tables, onValueChanged: (t) => grok.shell.info(t.name)});
|
|
6
6
|
|
|
7
7
|
grok.shell.newView('tableInput', [input.root]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const tagsInput = ui.
|
|
1
|
+
const tagsInput = ui.input.tags('Tags', {tags: ['Apps', 'Demo', 'Curves'], showButton: false});
|
|
2
2
|
|
|
3
3
|
tagsInput.addTag('New');
|
|
4
4
|
tagsInput.removeTag('Demo');
|
|
@@ -6,7 +6,7 @@ tagsInput.removeTag('Demo');
|
|
|
6
6
|
tagsInput.onTagAdded.subscribe((value) => grok.shell.info(`${value} tag was added.`));
|
|
7
7
|
tagsInput.onTagRemoved.subscribe((value) => grok.shell.info(`${value} tag was removed.`));
|
|
8
8
|
|
|
9
|
-
const tagsInput2 = ui.
|
|
9
|
+
const tagsInput2 = ui.input.tags('Tags', {tags: ['Apps2', 'Demo2', 'Curves2'], showButton: true});
|
|
10
10
|
tagsInput2.setTags(['Apps', 'Demo', 'Viewers', 'Tree']);
|
|
11
11
|
|
|
12
12
|
grok.shell.newView('TagsInput', [ui.form([tagsInput, tagsInput2])]);
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
const typeAhead = ui.typeAhead('Countries', {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
grok.shell.newView('TypeAhead', [typeAhead.root]);
|
|
15
|
+
typeAhead.onInput.subscribe(() => grok.shell.info('input event'));
|
|
16
|
+
typeAhead.onChanged.subscribe(() => grok.shell.info('change event'));
|
|
17
|
+
|
|
18
|
+
grok.shell.newView('TypeAhead', [typeAhead.root]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const intInput = ui.input.int('int', {value: 6, min: 2, max: 12, step: 1});
|
|
2
|
+
intInput.addValidator((v) => +v % 2 === 0 ? null : 'Value should be even');
|
|
3
|
+
const floatInput = ui.input.float('float', {value: 6.5758, min: 0, max: 10, step: 0.5});
|
|
4
|
+
floatInput.addValidator((v) => +v > 4.75 ? 'Value should be less than 4.75' : null);
|
|
5
|
+
const textInput = ui.input.string('string', {value: 'text'});
|
|
6
|
+
textInput.addValidator((v) => v.length > 5 ? null : 'Text should be longer than 5 characters');
|
|
7
|
+
|
|
8
|
+
ui.dialog({title: 'Inputs'})
|
|
9
|
+
.add(intInput).add(floatInput).add(textInput)
|
|
10
|
+
.onOK(() => grok.shell.info(`Int: ${intInput.value}, Float: ${floatInput.value}, Text: ${textInput.value}`))
|
|
11
|
+
.show();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//name: parameter expressions
|
|
2
|
+
//language: javascript
|
|
3
|
+
//input: string type = 'ICE' { choices: ['Electric', 'ICE'] }
|
|
4
|
+
//input: int cylinders = 4 { visible: type == 'ICE' }
|
|
5
|
+
//input: double tankVolume = 40 { visible: type == 'ICE'; units: liters }
|
|
6
|
+
//input: bool tankExtension = false { visible: type == 'ICE'; enabled: tankVolume > 50 }
|
|
7
|
+
//input: double batteryCapacity = 80 { visible: type == 'Electric'; units: kWh }
|
|
8
|
+
|
|
9
|
+
grok.shell.info(type);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Demonstrates how to create and manipulate drag-n-dropped objects.
|
|
2
2
|
|
|
3
|
-
let control = ui.
|
|
3
|
+
let control = ui.input.search('', {value: 'Drag column header or image here...'});
|
|
4
4
|
|
|
5
5
|
// Allow dragging and dropping objects into the search field:
|
|
6
6
|
ui.makeDroppable(control.input, {
|
|
7
|
-
acceptDrop: (
|
|
8
|
-
doDrop: (o, _) => {
|
|
7
|
+
acceptDrop: (_) => true, // Allow to drag anything into the field
|
|
8
|
+
doDrop: (o, _) => { // Let's check what fell into the input field
|
|
9
9
|
if (o instanceof DG.Column)
|
|
10
10
|
control.value = o.name.toUpperCase() + ' was dropped';
|
|
11
11
|
else if (o instanceof HTMLDivElement)
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
let v = grok.shell.newView('Tooltips demo');
|
|
2
2
|
|
|
3
3
|
v.root.appendChild(ui.divV([
|
|
4
|
-
ui.tooltip.bind(ui.span(['Static']), '
|
|
4
|
+
ui.tooltip.bind(ui.span(['Static']), 'Simple string'),
|
|
5
5
|
ui.tooltip.bind(ui.span(['Dynamic string']), () => `Function that returns a string. Time: ${new Date()}`),
|
|
6
|
+
ui.tooltip.bind(ui.span(['ddd']), ui.button('Click me', () => grok.shell.info('Clicked'))),
|
|
6
7
|
ui.tooltip.bind(ui.span(['Element']), ui.span([ui.iconFA('search'), 'DOM Element'])),
|
|
7
|
-
ui.tooltip.bind(ui.span(['
|
|
8
|
+
ui.tooltip.bind(ui.span(['Markup']), () => ui.markdown('Learn more [here](https://wikipedia.org)')),
|
|
8
9
|
]));
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
//ui.tooltip.bind(ui.span(['Element']), () => ui.button('Click me', () => grok.shell.info('Clicked'))),
|
|
@@ -13,8 +13,8 @@ grok.events.onViewerAdded.subscribe((data) => {
|
|
|
13
13
|
// this property is now editable
|
|
14
14
|
let view = grok.shell.addTableView(grok.data.demo.demog());
|
|
15
15
|
let plot = view.scatterPlot();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
plot.onAfterDrawScene.subscribe((_) => {
|
|
17
|
+
if (showStats) {
|
|
18
|
+
grok.shell.info(`showStats enabled`);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Custom viewer initialization function.
|
|
2
|
+
// Нou can attach bevahior to functions that could be saved in the layout, etc.
|
|
3
|
+
// For JS-based initialization, see init-script.js
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// This function is dynamically registered for the sake of simplicity.
|
|
7
|
+
// Normally, you would use a package function
|
|
8
|
+
grok.functions.register({
|
|
9
|
+
signature: 'void initScatterSquare(viewer v)',
|
|
10
|
+
run: (v) => {
|
|
11
|
+
v.onAfterDrawScene.subscribe((_) => {
|
|
12
|
+
v.canvas.getContext('2d')
|
|
13
|
+
.setFillStyle('red')
|
|
14
|
+
.fillRect(100, 100, 50, 50);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
grok.shell
|
|
20
|
+
.addTableView(grok.data.demo.demog())
|
|
21
|
+
.scatterPlot({ initializationFunction: 'initScatterSquare' });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Custom initialization script
|
|
2
|
+
// Use it to provide custom behavior for viewers that would survive saving/loading in a layout or project
|
|
3
|
+
// "v" parameter refers to the viewer. The following function gets executed:
|
|
4
|
+
// (v) => { <script> }
|
|
5
|
+
// For function-based initialization, see init-function.js
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
let view = grok.shell.addTableView(grok.data.demo.demog());
|
|
9
|
+
|
|
10
|
+
let plot = view.scatterPlot({
|
|
11
|
+
onInitializedScript:
|
|
12
|
+
"v.onAfterDrawScene.subscribe((_) => { " +
|
|
13
|
+
" v.canvas.getContext('2d').setFillStyle('red').fillRect(100, 100, 50, 50); " +
|
|
14
|
+
"});"
|
|
15
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// adding the specified filter to the already existing filter group
|
|
2
2
|
|
|
3
|
-
let tv = grok.shell.addTableView(grok.data.demo.
|
|
3
|
+
let tv = grok.shell.addTableView(grok.data.demo.demog(100));
|
|
4
4
|
let options = {
|
|
5
|
-
type:
|
|
6
|
-
column:
|
|
7
|
-
|
|
5
|
+
type: DG.FILTER_TYPE.CATEGORICAL,
|
|
6
|
+
column: 'site',
|
|
7
|
+
selected: ['New York', 'Orlando']
|
|
8
8
|
};
|
|
9
|
-
tv.getFiltersGroup({createDefaultFilters: false}).
|
|
9
|
+
tv.getFiltersGroup({createDefaultFilters: false}).updateOrAdd(options);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
let tv = grok.shell.addTableView(grok.data.demo.
|
|
1
|
+
let tv = grok.shell.addTableView(grok.data.demo.molecules());
|
|
2
2
|
|
|
3
3
|
// We need to load the external package before we use the
|
|
4
4
|
// synchronous "tv.filters" method that uses the filter
|
|
5
|
-
grok.functions.call('
|
|
5
|
+
grok.functions.call('Chem:substructureFilter').then((_) => {
|
|
6
6
|
tv.filters({filters: [
|
|
7
|
-
{type: '
|
|
7
|
+
{type: 'Chem:substructureFilter', columnName: 'smiles'},
|
|
8
8
|
]});
|
|
9
9
|
});
|
|
@@ -2,6 +2,11 @@ let tv = grok.shell.addTableView(grok.data.demo.demog());
|
|
|
2
2
|
tv.filters({filters: [
|
|
3
3
|
{type: DG.FILTER_TYPE.HISTOGRAM, column: 'height', min: 120, max: 150},
|
|
4
4
|
{type: DG.FILTER_TYPE.FREE_TEXT},
|
|
5
|
-
{type: DG.FILTER_TYPE.MULTI_VALUE, column: 'sex', selected: 'F'},
|
|
5
|
+
{type: DG.FILTER_TYPE.MULTI_VALUE, column: 'sex', selected: ['F']},
|
|
6
6
|
{type: DG.FILTER_TYPE.CATEGORICAL, column: 'disease'},
|
|
7
|
+
]});
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
tv.filters({filters: [
|
|
11
|
+
{'min': 120, 'max': 150},
|
|
7
12
|
]});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// https://datagrok.ai/help/visualize/viewers/scatter-plot
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
let eventId = 'd4-scatterplot-point-click';
|
|
3
5
|
let view = grok.shell.addTableView(grok.data.demo.demog());
|
|
4
6
|
|
|
5
7
|
let plot = view.scatterPlot({
|
|
@@ -9,4 +11,7 @@ let plot = view.scatterPlot({
|
|
|
9
11
|
color: 'race',
|
|
10
12
|
});
|
|
11
13
|
|
|
12
|
-
plot.
|
|
14
|
+
plot.onPointClicked.subscribe((e) => grok.shell.info(`${e.args.rowId} click`));
|
|
15
|
+
plot.onPointDoubleClicked.subscribe((e) => grok.shell.info(`${e.args.rowId} double click`));
|
|
16
|
+
plot.onZoomed.subscribe((e) => grok.shell.info(`zoomed`));
|
|
17
|
+
|
|
@@ -9,6 +9,8 @@ tv.addViewer(DG.VIEWER.TRELLIS_PLOT, {
|
|
|
9
9
|
visualizationType: 'bars',
|
|
10
10
|
colorColumnName: 'age',
|
|
11
11
|
colorAggrType: 'stdev',
|
|
12
|
-
invertColorScheme: true
|
|
12
|
+
invertColorScheme: true,
|
|
13
|
+
colorSchemes: [DG.Color.categoricalPalette, [DG.Color.darkGray, DG.Color.blue, DG.Color.green, DG.Color.darkGreen,
|
|
14
|
+
DG.Color.yellow, DG.Color.olive, DG.Color.orange]],
|
|
13
15
|
}
|
|
14
16
|
});
|
|
@@ -27,7 +27,7 @@ let filter = DG.Viewer.filters(table, {
|
|
|
27
27
|
columnNames: ['race']
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
let markup = `<div style="padding:
|
|
30
|
+
let markup = `<div style="padding:0 20px">
|
|
31
31
|
<h2>HTML Markup</h2>
|
|
32
32
|
Markup Viewer lets you combine HTML markup with the properties that are dynamically evaluated against
|
|
33
33
|
the current dataset. This is useful for creating custom dashboards, or telling stories with data. Here are some
|
|
@@ -2,4 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
let view = grok.shell.addTableView(grok.data.demo.demog());
|
|
4
4
|
|
|
5
|
-
view.
|
|
5
|
+
view.addViewer(DG.VIEWER.TRELLIS_PLOT, {
|
|
6
|
+
"viewerType": "Histogram",
|
|
7
|
+
"xColumnNames": [
|
|
8
|
+
"site"
|
|
9
|
+
],
|
|
10
|
+
"yColumnNames": [
|
|
11
|
+
"race"
|
|
12
|
+
],
|
|
13
|
+
"innerViewerLook": {
|
|
14
|
+
"#type": "HistogramLook",
|
|
15
|
+
"valueColumnName": "age"
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//tags: View
|
|
2
|
-
let host = ui.divV(null, {style: {
|
|
2
|
+
let host = ui.divV(null, {style: {width: '500px', height: '500px'}});
|
|
3
3
|
|
|
4
|
-
let selector = ui.
|
|
4
|
+
let selector = ui.input.choice('View', {items: DG.View.ALL_VIEW_TYPES, value: DG.View.APPS, onValueChanged: (x) => {
|
|
5
5
|
$(host).empty();
|
|
6
6
|
host.appendChild(DG.View.createByType(x).root);
|
|
7
|
-
});
|
|
7
|
+
}});
|
|
8
8
|
|
|
9
9
|
ui.dialog().add(ui.divV([selector, host])).show();
|
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
// Layouts save, apply and serialization into user
|
|
1
|
+
// Layouts save, apply and serialization into user settings storage
|
|
2
2
|
|
|
3
3
|
const STORAGE_NAME = 'layouts-demo';
|
|
4
4
|
|
|
5
5
|
let view = grok.shell.addTableView(grok.data.testData('demog', 1000));
|
|
6
6
|
view.name = 'layouts demo';
|
|
7
7
|
|
|
8
|
-
let nameInput = ui.
|
|
8
|
+
let nameInput = ui.input.string('', {value: 'Default'});
|
|
9
9
|
nameInput.captionLabel.style.width = '0';
|
|
10
10
|
|
|
11
11
|
let save = ui.button('Save', () => {
|
|
12
|
-
grok.
|
|
12
|
+
grok.userSettings.add(STORAGE_NAME, nameInput.value, view.saveLayout().toJson());
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
let load = ui.iconFA('bars', () => {
|
|
16
|
-
grok.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
menu.show();
|
|
16
|
+
let layouts = grok.userSettings.get(STORAGE_NAME);
|
|
17
|
+
if (layouts !== null && Object.keys(layouts).length === 0)
|
|
18
|
+
grok.shell.info('Storage is empty. Save some layouts to the storage');
|
|
19
|
+
else {
|
|
20
|
+
let menu = DG.Menu.popup();
|
|
21
|
+
for (let layout of Object.keys(layouts)) {
|
|
22
|
+
menu.item(layout, () => {
|
|
23
|
+
view.loadLayout(DG.ViewLayout.fromJson(layouts[layout]));
|
|
24
|
+
nameInput.stringValue = layout;
|
|
25
|
+
});
|
|
28
26
|
}
|
|
29
|
-
|
|
27
|
+
menu.show();
|
|
28
|
+
}
|
|
30
29
|
}, 'Select layout from storage');
|
|
31
30
|
|
|
32
31
|
let clear = ui.iconFA('trash-alt', () => {
|
|
33
|
-
grok.
|
|
32
|
+
grok.userSettings.delete(STORAGE_NAME, null);
|
|
34
33
|
}, 'Clear storage');
|
|
35
34
|
|
|
36
35
|
let acc = view.toolboxPage.accordion;
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as grokNamespace from 'datagrok-api/grok';
|
|
2
|
+
import * as uiNamespace from 'datagrok-api/ui';
|
|
3
|
+
import * as DGNamespace from 'datagrok-api/dg';
|
|
4
|
+
import * as rxjsNamespace from 'rxjs';
|
|
5
|
+
import $Namespace from 'cash-dom';
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
const grok: typeof grokNamespace;
|
|
9
|
+
const ui: typeof uiNamespace;
|
|
10
|
+
const DG: typeof DGNamespace;
|
|
11
|
+
const rjxs: typeof rxjsNamespace;
|
|
12
|
+
const $: typeof $Namespace;
|
|
13
|
+
}
|