|
78 | 78 | var ths = $('thead th', table); |
79 | 79 | var columns = []; |
80 | 80 | var vlines = []; |
| 81 | + var skippedColumns = 0; |
81 | 82 | var graphIsStacked = false; |
82 | 83 | ths.each(function(indexTh, th) { |
83 | 84 | var columnScale = $(th).data('graph-value-scale'); |
|
96 | 97 | nbYaxis = 2; |
97 | 98 | } |
98 | 99 |
|
| 100 | + var isColumnSkipped = $(th).data('graph-skip') == 1; |
| 101 | + if (isColumnSkipped) |
| 102 | + { |
| 103 | + skippedColumns = skippedColumns + 1 |
| 104 | + } |
| 105 | + |
| 106 | + var object = { |
| 107 | + libelle: $(th).text(), |
| 108 | + skip: isColumnSkipped, |
| 109 | + indexTd: indexTh - skippedColumns - 1, |
| 110 | + color: $(th).data('graph-color'), |
| 111 | + visible: !$(th).data('graph-hidden'), |
| 112 | + yAxis: typeof $(th).data('graph-yaxis') != 'undefined' ? $(th).data('graph-yaxis') : 0, |
| 113 | + dashStyle: $(th).data('graph-dash-style') || 'solid' |
| 114 | + }; |
| 115 | + |
99 | 116 | if (typeof $(th).data('graph-vline-x') == 'undefined') { |
100 | | - columns[indexTh] = { |
101 | | - libelle: $(th).text(), |
102 | | - scale: typeof columnScale != 'undefined' ? parseFloat(columnScale) : 1, |
103 | | - graphType: serieGraphType, |
104 | | - stack: serieStackGroup, |
105 | | - color: $(th).data('graph-color'), |
106 | | - visible: !$(th).data('graph-hidden'), |
107 | | - unit: $(th).data('graph-unit'), |
108 | | - yAxis: typeof $(th).data('graph-yaxis') != 'undefined' ? $(th).data('graph-yaxis') : 0, |
109 | | - dashStyle: $(th).data('graph-dash-style') || 'solid' |
110 | | - }; |
| 117 | + object.scale = typeof columnScale != 'undefined' ? parseFloat(columnScale) : 1; |
| 118 | + object.graphType = serieGraphType; |
| 119 | + object.stack = serieStackGroup; |
| 120 | + object.unit = $(th).data('graph-unit'); |
| 121 | + columns[indexTh] = object; |
111 | 122 | } else { |
112 | | - vlines[indexTh] = { |
113 | | - libelle: $(th).text(), |
114 | | - x: $(th).data('graph-vline-x'), |
115 | | - height: $(th).data('graph-vline-height'), |
116 | | - color: $(th).data('graph-color'), |
117 | | - visible: !$(th).data('graph-hidden'), |
118 | | - name: $(th).data('graph-vline-name'), |
119 | | - yAxis: typeof $(th).data('graph-yaxis') != 'undefined' ? $(th).data('graph-yaxis') : 0, |
120 | | - dashStyle: $(th).data('graph-dash-style') || 'solid' |
121 | | - }; |
| 123 | + object.x = $(th).data('graph-vline-x'); |
| 124 | + object.height = $(th).data('graph-vline-height'); |
| 125 | + object.name = $(th).data('graph-vline-name'); |
| 126 | + vlines[indexTh] = object; |
122 | 127 | } |
123 | 128 | }); |
124 | 129 |
|
125 | 130 | var series = []; |
126 | 131 | $(columns).each(function(indexColumn, column) { |
127 | | - if(indexColumn!=0) { |
| 132 | + if(indexColumn!=0 && !column.skip) { |
128 | 133 | series.push({ |
129 | 134 | name: column.libelle + (column.unit ? ' (' + column.unit + ')' : ''), |
130 | 135 | data: [], |
|
147 | 152 | }); |
148 | 153 |
|
149 | 154 | $(vlines).each(function(indexColumn, vline) { |
150 | | - if (typeof vline != 'undefined') { |
| 155 | + if (typeof vline != 'undefined' && !vline.skip) { |
151 | 156 | series.push({ |
152 | 157 | name: vline.libelle, |
153 | 158 | data: [{x: vline.x, y:0, name: vline.name}, {x:vline.x, y:vline.height, name: vline.name}], |
|
171 | 176 | var tds = $('td', row); |
172 | 177 | tds.each(function(indexTd, td) { |
173 | 178 | var cellValue; |
| 179 | + var column = columns[indexTd]; |
| 180 | + |
| 181 | + if (column.skip) { |
| 182 | + return; |
| 183 | + } |
174 | 184 | if (indexTd==0) { |
175 | 185 | cellValue = $(td).text(); |
176 | 186 | xValues.push(cellValue); |
177 | 187 | } else { |
178 | 188 | var rawCellValue = $(td).text(); |
| 189 | + var serie = series[column.indexTd]; |
| 190 | + |
179 | 191 | if (rawCellValue.length==0) { |
180 | | - series[indexTd-1].data.push(null); |
| 192 | + serie.data.push(null); |
181 | 193 | } else { |
182 | 194 | var cleanedCellValue = rawCellValue.replace(/ /g, '').replace(/,/, '.'); |
183 | | - cellValue = Math.round(parseFloat(cleanedCellValue) * columns[indexTd].scale * 100) / 100; |
| 195 | + cellValue = Math.round(parseFloat(cleanedCellValue) * column.scale * 100) / 100; |
184 | 196 |
|
185 | 197 | var dataGraphX = $(td).data('graph-x'); |
186 | 198 |
|
|
206 | 218 | }; |
207 | 219 | } |
208 | 220 |
|
209 | | - if (columns[indexTd].graphType === 'pie') { |
| 221 | + if (column.graphType === 'pie') { |
210 | 222 | if ($(td).data('graph-item-highlight')) { |
211 | 223 | serieDataItem.sliced = 1; |
212 | 224 | } |
|
216 | 228 | serieDataItem.color = $(td).data('graph-item-color'); |
217 | 229 | } |
218 | 230 |
|
219 | | - series[indexTd-1].data.push(serieDataItem); |
| 231 | + serie.data.push(serieDataItem); |
220 | 232 | } |
221 | 233 | } |
222 | 234 | }); |
|
0 commit comments