LogicMachine Forum
Javascript code for meteo icon on visu - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: OLD visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Javascript code for meteo icon on visu (/showthread.php?tid=6130)



Javascript code for meteo icon on visu - gdimaria - 29.09.2025

hi, I used the following JS to display a forecast icon on old scada-vis:

Code:
// wheater icon change $(function(){   if (typeof grp != 'undefined') {     grp.listen('34/1/1', function(object, state) {       var ICO = grp.getvalue('34/1/1'); ;       $('.icona').find('img').attr('src', 'http://openweathermap.org/img/w/'+ICO+'.png')     }, true);   } });

Is it possible to get the same on Visu?

Peppe


RE: Javascript code for meteo icon on visu - admin - 29.09.2025

It will be possible in the next version.

Create a text input widget, set display mode to Icon and enable read-only mode.
Add to Custom JS, change 123 to the relevant widget ID (ID is shown in the modal window title when editing a widget).
Code:
const widgetId = 123 Visu.on('widget-show', widgetId, ({ widget }) => {   widget.getIcon = function() {     const value = this.values.default     return `https://openweathermap.org/img/wn/${value}@2x.png`       } })