| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. All rights reserved. | 2 * Copyright 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style | 4 * Use of this source code is governed by a BSD-style |
| 5 * license that can be found in the LICENSE file or at | 5 * license that can be found in the LICENSE file or at |
| 6 * https://developers.google.com/open-source/licenses/bsd | 6 * https://developers.google.com/open-source/licenses/bsd |
| 7 */ | 7 */ |
| 8 part of charted.locale.format; | 8 part of charted.locale.format; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } else if (type == 'e' || type == 'f') { | 134 } else if (type == 'e' || type == 'f') { |
| 135 precision = math.max(0, math.min(20, precision)); | 135 precision = math.max(0, math.min(20, precision)); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 NumberFormatFunction formatFunction = _getFormatFunction(type); | 139 NumberFormatFunction formatFunction = _getFormatFunction(type); |
| 140 | 140 |
| 141 var zcomma = (zfill != null) && comma; | 141 var zcomma = (zfill != null) && comma; |
| 142 | 142 |
| 143 return (value) { | 143 return (value) { |
| 144 if (value == null) return '-'; |
| 144 var fullSuffix = suffix; | 145 var fullSuffix = suffix; |
| 145 | 146 |
| 146 // Return the empty string for floats formatted as ints. | 147 // Return the empty string for floats formatted as ints. |
| 147 if (integer && (value % 1) > 0) return ''; | 148 if (integer && (value % 1) > 0) return ''; |
| 148 | 149 |
| 149 // Convert negative to positive, and record the sign prefix. | 150 // Convert negative to positive, and record the sign prefix. |
| 150 var negative; | 151 var negative; |
| 151 if (value < 0 || value == 0 && 1 / value < 0) { | 152 if (value < 0 || value == 0 && 1 / value < 0) { |
| 152 value = -value; | 153 value = -value; |
| 153 negative = '-'; | 154 negative = '-'; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 case 'e': | 240 case 'e': |
| 240 return (num x, [int p = 0]) => x.toStringAsExponential(p); | 241 return (num x, [int p = 0]) => x.toStringAsExponential(p); |
| 241 case 'f': | 242 case 'f': |
| 242 return (num x, [int p = 0]) => x.toStringAsFixed(p); | 243 return (num x, [int p = 0]) => x.toStringAsFixed(p); |
| 243 case 'r': | 244 case 'r': |
| 244 default: | 245 default: |
| 245 return (num x, [int p = 0]) => x.toString(); | 246 return (num x, [int p = 0]) => x.toString(); |
| 246 } | 247 } |
| 247 } | 248 } |
| 248 } | 249 } |
| OLD | NEW |