You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,12 @@ Visualize a NetJSON NetworkGraph with pan/zoom, labels and tooltips.
25
25
26
26
Plot nodes by geographic coordinates on a Leaflet basemap; pan/zoom with markers.
27
27
28
+
### Geographic map with nodes moving in real-time
29
+
30
+
[](https://openwisp.github.io/netjsongraph.js/examples/netjsonmap-moving-node.html)
31
+
32
+
This example demonstrates how to update a node’s coordinates to simulate a moving vehicle.
The netjsongraph.js library provides **two build variants** to optimize bundle size for different use cases.
153
+
154
+
By default, `yarn build` executes the full bundle.
155
+
156
+
### 1. Full Bundle (Recommended for standalone usage)
157
+
158
+
Build the complete library with all dependencies included:
159
+
160
+
```bash
161
+
yarn build:full
162
+
```
163
+
164
+
Analyze the build with [Webpack Bundle Analyzer](https://github.com/webpack/webpack-bundle-analyzer):
165
+
166
+
```bash
167
+
yarn build:full:stats
168
+
```
169
+
170
+
**Output**:
171
+
172
+
-`dist/netjsongraph.min.js` - Complete library with ECharts and Leaflet
173
+
- Compressed versions (`.gz` and `.br`) for optimized delivery
174
+
- Deletes/overwrites previous builds
175
+
176
+
**Use when**: You want a standalone library with all dependencies bundled.
177
+
178
+
### 2. ECharts-Only Bundle (Optimized for projects with existing Leaflet)
179
+
180
+
Build the library without Leaflet, expecting it to be provided externally:
181
+
182
+
```bash
183
+
yarn build:echarts-only
184
+
```
185
+
186
+
Analyze the build with [Webpack Bundle Analyzer](https://github.com/webpack/webpack-bundle-analyzer):
187
+
188
+
```bash
189
+
yarn build:echarts-only:stats
190
+
```
191
+
192
+
**Output**:
193
+
194
+
-`dist/netjsongraph.echarts.min.js` - Library with ECharts only
195
+
- Compressed versions (`.gz` and `.br`)
196
+
- Deletes/overwrites previous builds
197
+
198
+
**Use when**: Your project already includes Leaflet (e.g., via django-leaflet in OpenWISP projects). This reduces bundle size by ~144 KiB.
199
+
200
+
**Requirements**: Leaflet must be loaded before NetJSONGraph (available as global `L` object).
201
+
202
+
**Note**: The echarts-only build dynamically loads Leaflet from CDN for map examples.
203
+
For production use, ensure Leaflet is available locally or from a trusted CDN.
204
+
144
205
### Run Tests
145
206
146
207
The test suite includes browser tests, so **ensure that ChromeDriver is installed** before running them.
@@ -924,6 +985,22 @@ yarn start
924
985
</html>
925
986
```
926
987
988
+
### Geographic map nodes moving in realtime
989
+
990
+
You can move a node programmatically on the map at runtime using the `moveNodeInRealTime` helper in utils.
991
+
992
+
This is useful to animate devices, show mobile nodes, or reflect position updates coming from a realtime source (sockets, polling, etc.).
993
+
994
+
You can see this feature in action in the following example: [Geographic map nodes moving in realtime](https://openwisp.github.io/netjsongraph.js/examples/netjsonmap-moving-node.html).
995
+
996
+
```JS
997
+
// .util.moveNodeInRealTime(nodeId, location)
998
+
moveNodeInRealTime(id, location)
999
+
```
1000
+
1001
+
-`id` - the node id (string) to move.
1002
+
-`location` - `{lat: number, lng: number}`
1003
+
927
1004
### Upgrading from 0.1.x versions to 0.2.x
928
1005
929
1006
We advise all users of netjsongraph.js who are using the 0.1.x version to
0 commit comments