Fix string values.

This commit is contained in:
Olly Smith 2012-06-08 21:37:27 +01:00
parent aa67b1a305
commit 79575dce97
3 changed files with 15 additions and 3 deletions

View File

@ -87,7 +87,10 @@ class Morris.Line
for ykey in @options.ykeys
series_data = []
for d in @options.data
series_data.push(if typeof d[ykey] == 'number' then d[ykey] else null)
series_data.push switch typeof d[ykey]
when 'number' then d[ykey]
when 'string' then parseFloat(d[ykey])
else null
@series.push(series_data)
# translate x labels into nominal dates

View File

@ -97,7 +97,16 @@
_ref1 = this.options.data;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
d = _ref1[_j];
series_data.push(typeof d[ykey] === 'number' ? d[ykey] : null);
series_data.push((function() {
switch (typeof d[ykey]) {
case 'number':
return d[ykey];
case 'string':
return parseFloat(d[ykey]);
default:
return null;
}
})());
}
this.series.push(series_data);
}

2
morris.min.js vendored

File diff suppressed because one or more lines are too long