|
65 | 65 | for (i = 0; i < data.length; i++) {
|
66 | 66 | row = [];
|
67 | 67 | for (j = 0; j < series.length; j++) {
|
68 |
| - if (series[j].type === 'date' || series[j].type === 'datetime') { |
| 68 | + if (series[j].type === 'date' || series[j].type === 'datetime') { |
69 | 69 | date = new Date(data[i][j]);
|
70 | 70 | data[i][j] = null;
|
71 | 71 | if (Object.prototype.toString.call(date) === "[object Date]") {
|
|
349 | 349 | // format the axes labels.
|
350 | 350 | if(typeof settings[axis + '_format'] !== 'undefined' && settings[axis + '_format'] !== ''){
|
351 | 351 | var format = settings[axis + '_format'];
|
352 |
| - switch(axis){ |
353 |
| - case 'xAxes': |
354 |
| - settings.scales.x.ticks.callback = function(value, index, values){ |
355 |
| - return format_datum(value, format); |
356 |
| - }; |
357 |
| - break; |
358 |
| - case 'yAxes': |
359 |
| - settings.scales.y.ticks.callback = function(value, index, values){ |
360 |
| - return format_datum(value, format); |
361 |
| - }; |
362 |
| - break; |
363 |
| - } |
364 |
| - delete settings[axis + '_format']; |
| 352 | + var isDateFormat = moment( moment().format( format ),format, true ).isValid(); |
| 353 | + if ( ! isDateFormat ) { |
| 354 | + switch(axis){ |
| 355 | + case 'xAxes': |
| 356 | + settings.scales.x.ticks.callback = function(value, index, values){ |
| 357 | + return format_datum(value, format); |
| 358 | + }; |
| 359 | + break; |
| 360 | + case 'yAxes': |
| 361 | + settings.scales.y.ticks.callback = function(value, index, values){ |
| 362 | + return format_datum(value, format); |
| 363 | + }; |
| 364 | + break; |
| 365 | + } |
| 366 | + delete settings[axis + '_format']; |
| 367 | + } |
365 | 368 | }
|
366 | 369 | delete settings[axis];
|
367 | 370 | }
|
|
445 | 448 | function format_data(datum, j, settings, series){
|
446 | 449 | j = j - 1;
|
447 | 450 | var format = typeof settings.series !== 'undefined' && typeof settings.series[j] !== 'undefined' ? settings.series[j].format : '';
|
| 451 | + if ( '' === format && typeof settings.yAxes_format !== 'undefined' ) { |
| 452 | + format = settings.yAxes_format; |
| 453 | + } else if ( '' === format && typeof settings.xAxes_format !== 'undefined' ) { |
| 454 | + format = settings.xAxes_format; |
| 455 | + } |
448 | 456 | return format_datum(datum, format, series[j + 1].type);
|
449 | 457 | }
|
450 | 458 |
|
|
0 commit comments