|
187 | 187 | var csv = '', |
188 | 188 | rows = this.getDataRows(), |
189 | 189 | options = (this.options.exporting || {}).csv || {}, |
| 190 | + dataFormatter = options.dataFormatter || function (val) { |
| 191 | + return Highcharts.numberFormat(val, -1, useLocalDecimalPoint ? (1.1).toLocaleString()[1] : '.', ''); |
| 192 | + }, |
190 | 193 | itemDelimiter = options.itemDelimiter || ',', // use ';' for direct import to Excel |
191 | 194 | lineDelimiter = options.lineDelimiter || '\n'; // '\n' isn't working with the js csv data extraction |
192 | 195 |
|
193 | 196 | // Transform the rows to CSV |
194 | 197 | each(rows, function (row, i) { |
195 | 198 | var val = '', |
196 | | - j = row.length, |
197 | | - n = useLocalDecimalPoint ? (1.1).toLocaleString()[1] : '.'; |
| 199 | + j = row.length; |
198 | 200 | while (j--) { |
199 | 201 | val = row[j]; |
200 | 202 | if (typeof val === "string") { |
201 | 203 | val = '"' + val + '"'; |
202 | 204 | } |
203 | 205 | if (typeof val === 'number') { |
204 | | - if (n === ',') { |
205 | | - val = val.toString().replace(".", ","); |
206 | | - } |
| 206 | + val = dataFormatter(val); |
207 | 207 | } |
208 | 208 | row[j] = val; |
209 | 209 | } |
|
223 | 223 | */ |
224 | 224 | Highcharts.Chart.prototype.getTable = function (useLocalDecimalPoint) { |
225 | 225 | var html = '<table><thead>', |
226 | | - rows = this.getDataRows(); |
| 226 | + rows = this.getDataRows(), |
| 227 | + options = (this.options.exporting || {}).csv || {}, |
| 228 | + dataFormatter = options.dataFormatter || function (val) { |
| 229 | + return Highcharts.numberFormat(val, -1, useLocalDecimalPoint ? (1.1).toLocaleString()[1] : '.', ''); |
| 230 | + }; |
227 | 231 |
|
228 | 232 | // Transform the rows to HTML |
229 | 233 | each(rows, function (row, i) { |
230 | 234 | var tag = i ? 'td' : 'th', |
231 | 235 | val, |
232 | | - j, |
233 | | - n = useLocalDecimalPoint ? (1.1).toLocaleString()[1] : '.'; |
| 236 | + j; |
234 | 237 |
|
235 | 238 | html += '<tr>'; |
236 | 239 | for (j = 0; j < row.length; j = j + 1) { |
237 | 240 | val = row[j]; |
238 | 241 | // Add the cell |
239 | 242 | if (typeof val === 'number') { |
240 | | - val = val.toString(); |
241 | | - if (n === ',') { |
242 | | - val = val.replace('.', n); |
243 | | - } |
| 243 | + val = dataFormatter(val); |
244 | 244 | html += '<' + tag + ' class="number">' + val + '</' + tag + '>'; |
245 | 245 |
|
246 | 246 | } else { |
|
0 commit comments