From 0bfadbde3c8f83a557dde1340ab2faee10359223 Mon Sep 17 00:00:00 2001 From: lang Date: Thu, 17 Sep 2015 16:39:26 +0800 Subject: [PATCH] Data type --- src/data/List.js | 13 ++++++++++--- test/polarLine.html | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/data/List.js b/src/data/List.js index 836d76314..3208f4149 100644 --- a/src/data/List.js +++ b/src/data/List.js @@ -182,7 +182,7 @@ define(function (require) { } // Bar chart, line chart which uses category axis // only gives the 'y' value. 'x' value is the indices of cateogry - if (typeof (value) === 'number') { + if (!isNaN(value)) { // Use a tempValue to normalize the value to be a (x, y) value tempValue[0] = idx; tempValue[1] = value; @@ -193,11 +193,18 @@ define(function (require) { // Store the data by dimensions for (var k = 0; k < dimensions.length; k++) { var dim = dimensions[k]; + var dimInfo = this._dimensionInfos[k]; var dimStorage = storage[dim]; var dimValue = value[k]; // PENDING NULL is empty or zero - if (dimValue == null || dimValue === '-') { - dimValue = NaN; + switch (dimInfo.type) { + case 'float': + case 'number': + dimValue = +dimValue; + break; + case 'int': + dimValue = dimValue | 0; + break; } dimStorage[idx] = dimValue; } diff --git a/test/polarLine.html b/test/polarLine.html index c224b0752..51db93584 100644 --- a/test/polarLine.html +++ b/test/polarLine.html @@ -33,9 +33,9 @@ for (var i = 0; i < 10; i++) { xAxisData.push('类目' + i); - data1.push(Math.random() * 2); - data2.push(Math.random()); - data3.push(Math.random()); + data1.push((Math.random() * 2).toFixed(3)); + data2.push(Math.random().toFixed(3)); + data3.push(Math.random().toFixed(3)); } chart.setOption({ -- GitLab