var schema = require('signalk-schema');

function BaseWidget(id, options, streamBundle, instrumentPanel) {
  this.instrumentPanel = instrumentPanel;
}

BaseWidget.prototype.setActive = function(value) {
  this.options.active = value;
  this.instrumentPanel.onWidgetChange(this);
}

BaseWidget.prototype.getLabelForPath = function(path) {
  var i18nElement = schema.i18n.en[path];
  return i18nElement ?
    i18nElement.shortName || i18nElement.longName || "??" :
    path
}

BaseWidget.prototype.getUnitForPath = function(path) {
  var i18nElement = schema.i18n.en[path];
  return i18nElement ? i18nElement.unit : undefined;
}

module.exports = BaseWidget;

@@ -621,16 +621,311 @@
 ned;%0A%7D%0A%0A
+BaseWidget.prototype.displayValue = function(value) %7B%0A  if(typeof value === 'number') %7B%0A    var v = Math.abs(value);%0A    if(v %3E= 50) %7B%0A      return value.toFixed(0);%0A    %7D else if(v %3E= 10) %7B%0A      return value.toFixed(1);%0A    %7D else %7B%0A      return value.toFixed(2);%0A    %7D%0A  %7D%0A  return value;%0A%7D%0A%0A
 module.e

Add shared function for range sensitive rounding