This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Javascript code for meteo icon on visu
#1
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
Reply
#2
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`    
  }
})
Reply


Forum Jump: