TanTayBui / flot

Automatically exported from code.google.com/p/flot
MIT License
0 stars 0 forks source link

IE7, IE8 - JS errors #715

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have hit some IE specific errors... that can be fixed easily...

first, line 308
** if (d[i].data != null) { **

when d[i].data is null, IE7 will halt with JS error.
This can be fixed via try-catch block

function parseData(d) {
            var res = [];
            for (var i = 0; i < d.length; ++i) {
                var s = $.extend(true, {}, options.series);
                try {
                    if (d[i].data != null) {
                        s.data = d[i].data; // move the data instead of deep-copy
                        delete d[i].data;

                        $.extend(true, s, d[i]);

                        d[i].data = s.data;
                    }
                    else
                        s.data = d[i];

                } catch (ex) { s.data = d[i]; }

                res.push(s);
            }

            return res;
        }

next, around line 525 (after modification)

// first pass: clean and copy data
            for (i = 0; i < series.length; ++i) {
                s = series[i];
                var data = s.data, format = s.datapoints.format;

I have to add this one line just after this block:

if (!data) data = '';

(when data is null, the JS will halt few lines after this statement on:
** for (j = k = 0; j < data.length; ++j, k += ps) { **  as data.length is not 
valid in IE7 for data with null value.

Original issue reported on code.google.com by ladislav...@gmail.com on 9 Jul 2012 at 12:02