Commits

Anonymous committed 841b662

Changed %d functionality to now round value to nearest integer. %i still parsed integer value (rounds down).

  • Participants
  • Parent commits 9330d9b

Comments (0)

Files changed (1)

File src/jqplot.sprintf.js

             case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
             case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace).toUpperCase();
             case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad, htmlSpace);
-            case 'i':
+            case 'i': {
+              var number = parseInt(+value, 10);
+              if (isNaN(number)) {
+                return '';
+              }
+              var prefix = number < 0 ? '-' : positivePrefix;
+              value = prefix + pad(String(Math.abs(number)), precision, '0', false);
+              return justify(value, prefix, leftJustify, minWidth, zeroPad, htmlSpace);
+                  }
             case 'd': {
-              var number = parseInt(+value, 10);
+              var number = Math.round(+value);
               if (isNaN(number)) {
                 return '';
               }