chore: tweak docs (#557)

This commit is contained in:
Tobias Åström
2021-01-13 14:50:36 +01:00
committed by GitHub
parent 2871ab01ff
commit b250362020
2 changed files with 12 additions and 7 deletions

View File

@@ -26,6 +26,8 @@ The quickest way to get started is to use the `nebula.js` CLI:
$ npx @nebula.js/cli create hello --picasso none
```
The `--picasso none` option tells the command to not create a picasso visualization template, other options are `minimal` and `barchart`.
The command will scaffold a project into the `hello` folder with the following structure:
- `/src`
@@ -100,7 +102,7 @@ Add a dimension by clicking on **Add dimension** and selecting a value in the me
In order to render the data you first need to access it through the `useLayout` hook:
```js
import { useElement, useLayout } from '@nebula.js/stardust';
import { useLayout, useElement, useEffect } from '@nebula.js/stardust';
// ...
component() {
@@ -202,7 +204,7 @@ useEffect(() => {
const idx = +tr.getAttribute('data-row');
tr.style.backgroundColor = selectedRows.includes(idx) ? '#eee' : '';
});
}, [element, selectedRows]);
}, [element, selectedRows, layout]);
```
Finally, apply the selected values through the `selections` API:

View File

@@ -12,7 +12,7 @@ Selections can be applied with methods exposed on the model returned from the `u
Since a generic object can hold multiple hypercubes, you always need to specify which hypercube you want to select in by providing the JSON path of it as the first argument:
```js
import { useModel } from '@nebula.js/stardust';
import { useModel, useEffect } from '@nebula.js/stardust';
// ...
component() {
const model = useModel();
@@ -43,7 +43,8 @@ In the following example, the user first selects one value in the bar chart, at
![Modal selections](./assets/selections-modal.gif)
To implement this type of pattern you need to `useSelections` in combination with `useModel` and follow a few simple steps:
To implement this type of pattern you need to `useSelections` instead of
`useModel` and follow a few simple steps:
1. Enter the modal state by calling `beginSelections`.
1. Select values.
@@ -51,11 +52,10 @@ To implement this type of pattern you need to `useSelections` in combination wit
1. Keep track of when the modal state has been exited in order to reset the visual feedback.
```js
import { useModel, useSelections, useElement } from '@nebula.js/stardust';
import { useSelections, useElement } from '@nebula.js/stardust';
// ...
component() {
const element = useElement();
const model = useModel();
const selections = useSelections();
useEffect(() => {
@@ -67,7 +67,10 @@ component() {
selections.beginSelections(['/qHyperCubeDef']);
}
// 2. select the clicked row
model.selectHyperCubeCells('/qHyperCubeDef', [clickedOnRow], []);
selections.select({
method: "selectHyperCubeCells",
params: ['/qHyperCubeDef', [clickedOnRow], [column]]
});
}
element.addEventListener('click', clicked);