Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions js/render-chartjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
for (i = 0; i < data.length; i++) {
row = [];
for (j = 0; j < series.length; j++) {
if (series[j].type === 'date' || series[j].type === 'datetime') {
if (series[j].type === 'date' || series[j].type === 'datetime') {
date = new Date(data[i][j]);
data[i][j] = null;
if (Object.prototype.toString.call(date) === "[object Date]") {
Expand Down Expand Up @@ -349,19 +349,22 @@
// format the axes labels.
if(typeof settings[axis + '_format'] !== 'undefined' && settings[axis + '_format'] !== ''){
var format = settings[axis + '_format'];
switch(axis){
case 'xAxes':
settings.scales.x.ticks.callback = function(value, index, values){
return format_datum(value, format);
};
break;
case 'yAxes':
settings.scales.y.ticks.callback = function(value, index, values){
return format_datum(value, format);
};
break;
}
delete settings[axis + '_format'];
var isDateFormat = moment( moment().format( format ),format, true ).isValid();
if ( ! isDateFormat ) {
switch(axis){
case 'xAxes':
settings.scales.x.ticks.callback = function(value, index, values){
return format_datum(value, format);
};
break;
case 'yAxes':
settings.scales.y.ticks.callback = function(value, index, values){
return format_datum(value, format);
};
break;
}
delete settings[axis + '_format'];
}
}
delete settings[axis];
}
Expand Down Expand Up @@ -445,6 +448,11 @@
function format_data(datum, j, settings, series){
j = j - 1;
var format = typeof settings.series !== 'undefined' && typeof settings.series[j] !== 'undefined' ? settings.series[j].format : '';
if ( '' === format && typeof settings.yAxes_format !== 'undefined' ) {
format = settings.yAxes_format;
} else if ( '' === format && typeof settings.xAxes_format !== 'undefined' ) {
format = settings.xAxes_format;
}
return format_datum(datum, format, series[j + 1].type);
}

Expand Down