javascriptjustgage

Symbol to show before value JustGage.js


I want to show the '£' symbol before every number on JustGage.js

There's an symbol option already but this only added it to the middle number and at the end.

enter image description here


Solution

  • Between line 711 - 737 I added in '£' + before all of these values and it works like a charm

    // set value to display
            if (obj.config.textRenderer) {
              obj.originalValue = obj.config.textRenderer('£' + obj.originalValue);
          } else if (obj.config.humanFriendly) {
              obj.originalValue = humanFriendlyNumber('£' + obj.originalValue, obj.config.humanFriendlyDecimal) + obj.config.symbol;
          } else if (obj.config.formatNumber) {
              obj.originalValue = formatNumber('£' + obj.originalValue) + obj.config.symbol;
          } else {
              obj.originalValue = ('£' + obj.originalValue * 1).toFixed(obj.config.decimals) + obj.config.symbol;
          }
    
          if (obj.config.counter === true) {
              //on each animation frame
              eve.on("raphael.anim.frame." + (obj.level.id), function() {
                  var currentValue = obj.level.attr("pki");
                  if (obj.config.textRenderer) {
                      obj.txtValue.attr("text", '£' + obj.config.textRenderer(Math.floor(currentValue[0])));
                  } else if (obj.config.humanFriendly) {
                      obj.txtValue.attr("text", '£' + humanFriendlyNumber(Math.floor(currentValue[0]), obj.config.humanFriendlyDecimal) + obj.config.symbol);
                  } else if (obj.config.formatNumber) {
                      obj.txtValue.attr("text", '£' + formatNumber(Math.floor(currentValue[0])) + obj.config.symbol);
                  } else {
                      obj.txtValue.attr("text", '£' + (currentValue[0] * 1).toFixed(obj.config.decimals) + obj.config.symbol);
                  }
                  setDy(obj.txtValue, obj.params.valueFontSize, obj.params.valueY);
                  currentValue = null;
              });