Skip to content

Commit 8216bed

Browse files
authored
Update index.md
Add widgets section and update widget creation instructions
1 parent 3aa5d5b commit 8216bed

1 file changed

Lines changed: 43 additions & 14 deletions

File tree

‎index.md‎

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ UDAV is designed to enable different disciplines to display their automatic pre-
88
- Visual editor
99
- Different export options
1010

11+
## Widgets
12+
13+
UDAV currently contains the following widgets:
14+
15+
- Text (static)
16+
- Image (static)
17+
- Video (static)
18+
- Inline Frame (static)
19+
- Table
20+
- Bar Chart
21+
- Pie Chart
22+
- Line Chart
23+
- Highlight Text
24+
- Simple Map
25+
- Network Graph
26+
1127
### Demo
1228

1329
You can find a demo [here](udav/demo) where you can play around a little.
@@ -135,7 +151,7 @@ The only exception is the data API, which uses a custom ChartHandler to support
135151

136152
# Webpage
137153

138-
The frontend uses [Freemarker](https://freemarker.apache.org/) to render the html templates, [d3.js](https://d3js.org/) for some of the visualization components, [gridstack.js](https://gridstackjs.com/) for the draggable grid in the editor and [Bootstrap](https://getbootstrap.com/) for icons and styling.
154+
The frontend uses [Freemarker](https://freemarker.apache.org/) to render the html templates, [d3.js](https://d3js.org/) for some of the visualization components, [gridstack.js](https://gridstackjs.com/) for the draggable grid in the editor, [Floating UI](https://floating-ui.com/) for some UI components and [Bootstrap](https://getbootstrap.com/) for icons and styling.
139155

140156
## Structure
141157

@@ -154,6 +170,7 @@ Global CSS variables are defined in `variables.css`. The widgets are registered
154170
│ │ ├─ 📁 pages
155171
│ │ ├─ 📁 shared
156172
│ │ └─ 📄 variables.css
173+
│ ├─ 📁 data
157174
│ ├─ 📁 img
158175
│ ├─ 📁 js
159176
│ │ ├─ 📁 api
@@ -176,16 +193,17 @@ Global CSS variables are defined in `variables.css`. The widgets are registered
176193
│ │ │ ├─ 📁 charts
177194
│ │ │ ├─ 📁 static
178195
│ │ │ ├─ 📄 D3Visualization.js
196+
│ │ │ ├─ 📄 WidgetInterface.js
179197
│ │ │ └─ 📄 widgets.js
180198
│ ├─ 📁 packages
181199
│ └─ 📄 favicon.ico
182200
└─ 📁 templates
201+
├─ 📁 error
183202
├─ 📁 pages
184203
│ ├─ 📁 editor
185204
│ │ ├─ 📄 editor.ftl
186205
│ │ ├─ 📄 editorGrid.ftl
187206
│ │ └─ 📄 editorSidebar.ftl
188-
│ ├─ 📁 error
189207
│ ├─ 📁 index
190208
│ └─ 📁 view
191209
└─ 📁 shared
@@ -217,17 +235,16 @@ To add a new chart widget, follow these steps:
217235
- label: The label displayed to the user.
218236
- options (optional): Additional configuration for the input.
219237

220-
4. To support the controls sidepanel and export functionality of the chart's toolbar, create a ControlsHandler and an ExportHandler in the constructor.
221-
222-
5. Provide a `data` property, an `init` and a `render` method.
223-
- The data property is used to cache the latest data which allows re-rendering the chart without fetching the data again.
238+
4. Extend the `WidgetInterface` class and implement a `init` and a `render` method.
224239
- The init method will be called once after creation of the widget and should contain the first data fetch and rendering as well as the configuration of the controls.
225240
- The render method will be called every time the chart data changes, for example after a filter is applied.
241+
242+
5. If your new widget uses d3.js to create an svg, you can extend the `D3Visualization` class instead. This class already provides helpful functions for svg initialization and resizing, tooltips or axis creation.
226243

227244
6. You can use this template as a starting point:
228245

229246
```js
230-
export default class NewChart {
247+
export default class NewChart extends WidgetInterface {
231248
static defaultConfig = {
232249
type: "NewChart",
233250
title: "New Chart",
@@ -249,24 +266,30 @@ To add a new chart widget, follow these steps:
249266
},
250267
};
251268

252-
constructor(root, getData, options) {
253-
this.controls = new ControlsHandler(this);
254-
this.exports = new ExportHandler(this);
269+
constructor(root, config) {
270+
super(root, config);
271+
}
255272

256-
this.data;
273+
clear() {
274+
// Clear and set-up chart inside chart area
257275
}
258276

259277
init() {
260-
const data = this.getData();
261-
this.render(data);
278+
const { data, meta } = await this.fetch();
279+
this.render(data[0]);
280+
281+
// Initialize export options
282+
this.exports.init(meta.total > 1);
283+
this.filter = {
284+
// Initialize filter
285+
};
262286

263287
// Add controls ...
264288
}
265289

266290
render(data) {
267291
this.clear();
268292

269-
// Append svg to root
270293
// Render chart data ...
271294

272295
this.data = data;
@@ -340,6 +363,12 @@ To add a new generator, follow these steps:
340363
};
341364
```
342365

366+
### Formular configuration
367+
368+
The widget controls and option modals in the editor are defined through a JSON structure. This structure is used by the `ControlsHandler` for widgets, as well as by the `formConfig` parameter of widgets, source and generator configurations. It defines the form input fields, including their types, labels, and available options.
369+
370+
Available input types are implemented in inputFactories.js, which acts as a central registry for creating the form inputs. If additional input types are needed, they can be easily extended by adding new implementations to inputFactories.js.
371+
343372
## Screenshots
344373

345374
| ![menu](/img/menu.png) |

0 commit comments

Comments
 (0)