tel8618217223380 / dwpe

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

Data contains comma(,) is not parsed. #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I made table value like this:
<td>100,000</td>
,but the value is not parsed.

I modified visualize.jQuery.js:

----------------------------------------------------------
        var self = $(this);

        function elimComma(str) {
            return new String(str).replace(/,/g, '');
        }

        //function to scrape data from html table
        function scrapeTable(){
            var colors = o.colors;
            var textColors = o.textColors;
            var tableData = {
                dataGroups: function(){
                    var dataGroups = [];
                    if(o.parseDirection == 'x'){
                        self.find('tr:gt(0)').filter(o.rowFilter).each(function(i){
                            dataGroups[i] = {};
                            dataGroups[i].points = [];
                            dataGroups[i].color = colors[i];
                            if(textColors[i]){ dataGroups[i].textColor = textColors[i]; }
                            $(this).find('td').filter(o.colFilter).each(function(){
                                dataGroups[i].points.push( parseFloat(elimComma($(this).text())) );
                            });
                        });
                    }
                    else {
                        var cols = self.find('tr:eq(1) td').filter(o.colFilter).size();
                        for(var i=0; i<cols; i++){
                            dataGroups[i] = {};
                            dataGroups[i].points = [];
                            dataGroups[i].color = colors[i];
                            if(textColors[i]){ dataGroups[i].textColor = textColors[i]; }
                            self.find('tr:gt(0)').filter(o.rowFilter).each(function(){
                                dataGroups[i].points.push( elimComma($(this).find('td').filter(o.colFilter).eq(i).text())*1 );
                            });
                        };
                    }
                    return dataGroups;
                },

Original issue reported on code.google.com by Seiichi....@gmail.com on 5 Sep 2011 at 2:37

GoogleCodeExporter commented 9 years ago
Would be nice if commas could be added back in after parsing, to display more 
readable numbers.

Original comment by webk...@live.ca on 10 Feb 2012 at 6:57

GoogleCodeExporter commented 9 years ago
        function addCommas(str) {
            return str.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
        }

                $.each(yLabels, function(i){  
                    var thisLi = $('<li><span>'+addCommas(this)+'</span></li>')
                        .prepend('<span class="line"  />')
                        .css('bottom',liBottom*i)
                        .prependTo(ylabelsUL);
                        var label = thisLi.find('span:not(.line)');
                        var topOffset = label.height()/-2;
                        if(i == 0){ topOffset = -label.height(); }
                        else if(i== yLabels.length-1){ topOffset = 0; }
                        label
                            .css('margin-top', topOffset)
                            .addClass('label');
                });

Original comment by webk...@live.ca on 10 Feb 2012 at 7:07