Browse Source

Fix bug for raw timeseries input again - #311

pull/329/head
Masayuki Tanaka 11 years ago
parent
commit
d7b7b0645c
  1. 18
      c3.js
  2. 2
      c3.min.js

18
c3.js

@ -1465,17 +1465,7 @@
function generateTargetX(rawX, id, index) { function generateTargetX(rawX, id, index) {
var x; var x;
if (isTimeSeries) { if (isTimeSeries) {
if (rawX) { x = rawX ? parseDate(rawX) : parseDate(getXValue(id, index));
if (typeof rawX === 'number') {
x = new Date(rawX);
} else if (rawX instanceof Date) {
x = rawX;
} else {
x = parseDate(rawX);
}
} else {
x = parseDate(getXValue(id, index));
}
} }
else if (isCustomX() && !isCategorized) { else if (isCustomX() && !isCategorized) {
x = isValue(rawX) ? +rawX : getXValue(id, index); x = isValue(rawX) ? +rawX : getXValue(id, index);
@ -2293,11 +2283,15 @@
function parseDate(date) { function parseDate(date) {
var parsedDate; var parsedDate;
if (date instanceof Date) {
parsedDate = date;
} else {
try { try {
parsedDate = date instanceof Date ? new Date(date) : d3.time.format(__data_x_format).parse(date); parsedDate = typeof date === 'number' ? new Date(date) : d3.time.format(__data_x_format).parse(date);
} catch (e) { } catch (e) {
window.console.error("Failed to parse x '" + date + "' to Date with format " + __data_x_format); window.console.error("Failed to parse x '" + date + "' to Date with format " + __data_x_format);
} }
}
return parsedDate; return parsedDate;
} }

2
c3.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save