data processing bug parsing floats.

I have three series of data for a bar chart of 24 values * 3 series.

some have values like 4.3 545.44 and some just a 0, not a 0.00

There is a parse float error Dom Exception 9 on line 6780

    if(type == "light"){
        if(axis == "x")
            gradient = ctx.createLinearGradient(x1,y1,x2,y1);
        else
            gradient = ctx.createLinearGradient(x1,y1,x1,y2);

Where y2 is NaN.
The parent caller did a parse Float on “0”

Work around is to add 0.000001 to all numbers.

But the library should check for this and treat a “0”, “null” “-” “0.0” or “” as the same, not just
bail out and ignore all series data points after this one.

Browser was Chrome 10.0.654 , XP.

I have located the actual bug.

line 4744

var value = parseFloat(this._settings.value(data[i]));

the problem is in the value() function.

it does a obj.v0||’’ due to

function anonymous(obj,common) {
return “”+(obj.v0||’’)+"";
}

Now if the value is 0, it replaces it with a ‘’

If its 0.1 it obviously is left alone.

I fixed it by changing line 2469 to:
str=str.replace(/#([a-z0-9_[]]+)#/gi,""+(obj.$1)+"");

Though the other way its for the line post 4744 to check for NaN, and set it to 0.

So although the samples have values for each bar, and look pretty, the rare unusual case of one value having zero, was not tested.

Hello,

we have not reproduced the problem with 0.8 beta. Could you provide the chart initialization code that allows to reproduce the issue.

Ok, I worked out how to re-create it using the touchui samples with a tiny change.

charts/03_types.html

I changed some values to zero (0), not in a string, but just 0.

    /*Bar Chart*/
    var barData = [
        { sales:"4.2",sales1:"3.4",sales2:"1.2", year:"2000" },
        { sales:"3.8",sales1:0,sales2:0, year:"2001" },
        { sales:"3.4",sales1:"4.7",sales2:"1.9", year:"2002" }
    ];

If the values are not strings but just 0, it fails.

My values are sourced from an external URL json data thats not in this format, so it is transformed.

ie. (closer to jqplot format btw)

data = { “lines”: [ [[“2009-02-15 00:00”,2.78], [“2009-02-15 01:00”,2.78], [“2009-02-15 02:00”,2.80], [“2009-02-15 03:00”,2.80], [“2009-02-15 04:00”,2.80], [“2009-02-15 05:00”,2.78], [“2009-02-15 06:00”,2.81], [“2009-02-15 07:00”,2.79], [“2009-02-15 08:00”,2.77], [“2009-02-15 09:00”,2.77], [“2009-02-15 10:00”,100.80], [“2009-02-15 11:00”,118.22], [“2009-02-15 12:00”,69.79], [“2009-02-15 13:00”,59.92], [“2009-02-15 14:00”,59.82], [“2009-02-15 15:00”,59.76], [“2009-02-15 16:00”,24.17], [“2009-02-15 17:00”,2.75], [“2009-02-15 18:00”,2.76], [“2009-02-15 19:00”,2.74], [“2009-02-15 20:00”,2.76], [“2009-02-15 21:00”,2.78], [“2009-02-15 22:00”,2.78], [“2009-02-15 23:00”,1.39]], [[“2009-02-15 00:00”,0.00], [“2009-02-15 01:00”,0.00], [“2009-02-15 02:00”,0.00], [“2009-02-15 03:00”,0.00], [“2009-02-15 04:00”,0.00], [“2009-02-15 05:00”,0.00], [“2009-02-15 06:00”,0.00], [“2009-02-15 07:00”,0.00], [“2009-02-15 08:00”,0.00], [“2009-02-15 09:00”,0.00], [“2009-02-15 10:00”,0.00], [“2009-02-15 11:00”,0.00], [“2009-02-15 12:00”,0.00], [“2009-02-15 13:00”,0.00], [“2009-02-15 14:00”,0.00], [“2009-02-15 15:00”,0.00], [“2009-02-15 16:00”,0.00], [“2009-02-15 17:00”,0.00], [“2009-02-15 18:00”,0.00], [“2009-02-15 19:00”,0.00], [“2009-02-15 20:00”,0.00], [“2009-02-15 21:00”,0.00], [“2009-02-15 22:00”,0.00], [“2009-02-15 23:00”,0.00]], [[“2009-02-15 00:00”,2.78], [“2009-02-15 01:00”,2.78], [“2009-02-15 02:00”,2.80], [“2009-02-15 03:00”,2.80], [“2009-02-15 04:00”,2.80], [“2009-02-15 05:00”,2.78], [“2009-02-15 06:00”,2.81], [“2009-02-15 07:00”,2.79], [“2009-02-15 08:00”,2.77], [“2009-02-15 09:00”,2.77], [“2009-02-15 10:00”,100.80], [“2009-02-15 11:00”,118.22], [“2009-02-15 12:00”,69.79], [“2009-02-15 13:00”,59.92], [“2009-02-15 14:00”,59.82], [“2009-02-15 15:00”,59.76], [“2009-02-15 16:00”,24.17], [“2009-02-15 17:00”,2.75], [“2009-02-15 18:00”,2.76], [“2009-02-15 19:00”,2.74], [“2009-02-15 20:00”,2.76], [“2009-02-15 21:00”,2.78], [“2009-02-15 22:00”,2.78], [“2009-02-15 23:00”,1.39]] ] };

Then converted as follows;

  for( i=0;i<data.lines[0].length;i++)
  {
	var xv = data.lines[0][i][0];
	var value = { X: xv };
	value.v0 = data.lines[0][i][1];
	value.v1 = data.lines[1][i][1];
	value.v2 = data.lines[2][i][1];
	chart.data.push( value );
  }

I can now see that all numbers must be really strings to make it work.

But even so, the touch.js should not do a value || ‘’ , as value can be a zero (0), instead of a string “0”.

Cheers

Hi,

we have reproduce dthe problem. The fix will be added into the next version.

Thank you for the information.