Commit 0f35c49850d85b85c448617b45fe12bdfe7396e7

Authored by Andrea Petta
1 parent e94f9513

number with % fix

datalets/highcharts-datalet/highcharts-datalet.html
... ... @@ -88,24 +88,26 @@ Example :
88 88 /**
89 89 * Normalizes a number in agreement with javascript's conventions. Delete all NaN characters. Exception: number representing lat & long remain unchanged.
90 90 */
91   -// jNumConverter: function(num) {
92   -// //lat-long
93   -// if(num.charAt(num.length-7) == "." && (num.match(/[\.,]/g) || []).length == 1)
94   -// return num;
95   -//
96   -// var jNum = "";
97   -// for (var i = 0; i < num.length; i++) {
98   -// if(num[i].match(/[\.,]/g))
99   -// if (i == num.length - 3)
100   -// jNum += ".";
101   -// else
102   -// ;
103   -// else if (!isNaN(num[i]))
104   -// jNum += num[i];
105   -// }
106   -//
107   -// return jNum;
108   -// },
  91 + jNumConverter: function(num) {
  92 + //lat-long
  93 + if(num.charAt(num.length-7) == "." && (num.match(/[\.,]/g) || []).length == 1)
  94 + return num;
  95 +
  96 + num = num.replace(/[^0-9\.]/, '');
  97 +
  98 + var jNum = "";
  99 + for (var i = 0; i < num.length; i++) {
  100 + if(num[i].match(/[\.,]/g))
  101 + if (i == num.length - 3)
  102 + jNum += ".";
  103 + else
  104 + ;
  105 + else if (!isNaN(num[i]))
  106 + jNum += num[i];
  107 + }
  108 +
  109 + return jNum;
  110 + },
109 111 /**
110 112 * Populate the categories and the series array.
111 113 *
... ... @@ -121,17 +123,16 @@ Example :
121 123  
122 124 for (var i = 1; i < this.data.length; i++)
123 125 {
124   -
125   -// this.data[i].data.every(function (element, index, array) {
126   -// try {
127   -// var e = HighchartsBehavior.jNumConverter(element);
128   -// (isNaN(element)) ? array[index] = parseFloat(HighchartsBehavior.jNumConverter(element)) :
129   -// array[index] = parseFloat(element);
130   -// }catch(e){
131   -// //console.log("Parsing data error. Highchart-datalet.selectData");
132   -// }
133   -// return true;
134   -// });
  126 + this.data[i].data.every(function (element, index, array) {
  127 + try {
  128 + var e = HighchartsBehavior.jNumConverter(element);
  129 + (isNaN(element)) ? array[index] = parseFloat(HighchartsBehavior.jNumConverter(element)) :
  130 + array[index] = parseFloat(element);
  131 + }catch(e){
  132 + //console.log("Parsing data error. Highchart-datalet.selectData");
  133 + }
  134 + return true;
  135 + });
135 136  
136 137 this.properties.series.value.push(this.data[i]);
137 138 }
... ...