|
53 | 53 | } |
54 | 54 | graphContainer = graphContainer[0]; |
55 | 55 | } else { |
56 | | - $table.before('<div ></div>'); |
| 56 | + $table.before('<div></div>'); |
57 | 57 | graphContainer = $table.prev(); |
58 | 58 | graphContainer = graphContainer[0]; |
59 | 59 | } |
|
81 | 81 | var skippedColumns = 0; |
82 | 82 | var graphIsStacked = false; |
83 | 83 | ths.each(function(indexTh, th) { |
84 | | - var columnScale = $(th).data('graph-value-scale'); |
| 84 | + var $th = $(th); |
| 85 | + var columnScale = $th.data('graph-value-scale'); |
85 | 86 |
|
86 | | - var serieGraphType = $(th).data('graph-type'); |
| 87 | + var serieGraphType = $th.data('graph-type'); |
87 | 88 | if($.inArray(serieGraphType, allowedGraphTypes) == -1) { |
88 | 89 | serieGraphType = globalGraphType; |
89 | 90 | } |
90 | 91 |
|
91 | | - var serieStackGroup = $(th).data('graph-stack-group'); |
| 92 | + var serieStackGroup = $th.data('graph-stack-group'); |
92 | 93 | if(serieStackGroup) { |
93 | 94 | graphIsStacked = true; |
94 | 95 | } |
95 | 96 |
|
96 | | - if (typeof $(th).data('graph-yaxis') != 'undefined' && $(th).data('graph-yaxis') == '1') { |
| 97 | + var yaxis = $th.data('graph-yaxis'); |
| 98 | + |
| 99 | + if (typeof yaxis != 'undefined' && yaxis == '1') { |
97 | 100 | nbYaxis = 2; |
98 | 101 | } |
99 | 102 |
|
100 | | - var isColumnSkipped = $(th).data('graph-skip') == 1; |
| 103 | + var isColumnSkipped = $th.data('graph-skip') == 1; |
101 | 104 | if (isColumnSkipped) |
102 | 105 | { |
103 | 106 | skippedColumns = skippedColumns + 1; |
104 | 107 | } |
105 | 108 |
|
106 | 109 | var thGraphConfig = { |
107 | | - libelle: $(th).text(), |
| 110 | + libelle: $th.text(), |
108 | 111 | skip: isColumnSkipped, |
109 | 112 | 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' |
| 113 | + color: $th.data('graph-color'), |
| 114 | + visible: !$th.data('graph-hidden'), |
| 115 | + yAxis: typeof yaxis != 'undefined' ? yaxis : 0, |
| 116 | + dashStyle: $th.data('graph-dash-style') || 'solid' |
114 | 117 | }; |
115 | 118 |
|
116 | | - if (typeof $(th).data('graph-vline-x') == 'undefined') { |
| 119 | + var vlinex = $th.data('graph-vline-x'); |
| 120 | + if (typeof vlinex == 'undefined') { |
117 | 121 | thGraphConfig.scale = typeof columnScale != 'undefined' ? parseFloat(columnScale) : 1; |
118 | 122 | thGraphConfig.graphType = serieGraphType; |
119 | 123 | thGraphConfig.stack = serieStackGroup; |
120 | | - thGraphConfig.unit = $(th).data('graph-unit'); |
| 124 | + thGraphConfig.unit = $th.data('graph-unit'); |
121 | 125 | columns[indexTh] = thGraphConfig; |
122 | 126 | } else { |
123 | | - thGraphConfig.x = $(th).data('graph-vline-x'); |
124 | | - thGraphConfig.height = $(th).data('graph-vline-height'); |
125 | | - thGraphConfig.name = $(th).data('graph-vline-name'); |
| 127 | + thGraphConfig.x = vlinex; |
| 128 | + thGraphConfig.height = $th.data('graph-vline-height'); |
| 129 | + thGraphConfig.name = $th.data('graph-vline-name'); |
126 | 130 | vlines[indexTh] = thGraphConfig; |
127 | 131 | } |
128 | 132 | }); |
|
145 | 149 | dataLabels: { |
146 | 150 | x: isGraphInverted ? 15 : 0, |
147 | 151 | enabled: $table.data('graph-datalabels-enabled') == 1, |
148 | | - align: typeof $table.data('graph-datalabels-align') != 'undefined' ? $table.data('graph-datalabels-align') : 'center' |
| 152 | + align: $table.data('graph-datalabels-align') || 'center' |
149 | 153 | } |
150 | 154 | }); |
151 | 155 | } |
|
184 | 188 | if (column.skip) { |
185 | 189 | return; |
186 | 190 | } |
| 191 | + var $td = $(td); |
187 | 192 | if (indexTd==0) { |
188 | | - cellValue = $(td).text(); |
| 193 | + cellValue = $td.text(); |
189 | 194 | xValues.push(cellValue); |
190 | 195 | } else { |
191 | | - var rawCellValue = $(td).text(); |
| 196 | + var rawCellValue = $td.text(); |
192 | 197 | var serie = series[column.indexTd]; |
193 | 198 |
|
194 | 199 | if (rawCellValue.length==0) { |
|
197 | 202 | var cleanedCellValue = rawCellValue.replace(/ /g, '').replace(/,/, '.'); |
198 | 203 | cellValue = Math.round(parseFloat(cleanedCellValue) * column.scale * 100) / 100; |
199 | 204 |
|
200 | | - var dataGraphX = $(td).data('graph-x'); |
| 205 | + var dataGraphX = $td.data('graph-x'); |
201 | 206 |
|
202 | 207 | if (isGraphDatetime) { |
203 | 208 | dataGraphX = $('td', $(row)).first().text(); |
|
206 | 211 | dataGraphX = date.getTime() - date.getTimezoneOffset()*60*1000; |
207 | 212 | } |
208 | 213 |
|
| 214 | + var tdGraphName = $td.data('graph-name'); |
209 | 215 | var serieDataItem = { |
210 | | - name: typeof $(td).data('graph-name') != 'undefined' ? $(td).data('graph-name') : rawCellValue, |
| 216 | + name: typeof tdGraphName != 'undefined' ? tdGraphName : rawCellValue, |
211 | 217 | y: cellValue, |
212 | 218 | x: dataGraphX //undefined if no x defined in table |
213 | 219 | }; |
|
221 | 227 | } |
222 | 228 |
|
223 | 229 | if (column.graphType === 'pie') { |
224 | | - if ($(td).data('graph-item-highlight')) { |
| 230 | + if ($td.data('graph-item-highlight')) { |
225 | 231 | serieDataItem.sliced = 1; |
226 | 232 | } |
227 | 233 | } |
228 | 234 |
|
229 | | - if (typeof $(td).data('graph-item-color') != 'undefined') { |
230 | | - serieDataItem.color = $(td).data('graph-item-color'); |
| 235 | + var tdGraphItemColor = $td.data('graph-item-color'); |
| 236 | + if (typeof tdGraphItemColor != 'undefined') { |
| 237 | + serieDataItem.color = tdGraphItemColor; |
231 | 238 | } |
232 | 239 |
|
233 | 240 | serie.data.push(serieDataItem); |
|
280 | 287 | var colors = []; |
281 | 288 |
|
282 | 289 | var themeColors = typeof Highcharts.theme != 'undefined' && typeof Highcharts.theme.colors != 'undefined' ? Highcharts.theme.colors : []; |
| 290 | + var lineShadow = $table.data('graph-line-shadow'); |
| 291 | + var lineWidth = $table.data('graph-line-width') || 2; |
283 | 292 |
|
284 | 293 | for(var i=0; i<9; i++) { |
285 | 294 | var dataname = 'graph-color-' + (i+1); |
|
306 | 315 | }, |
307 | 316 | legend: { |
308 | 317 | enabled: $table.data('graph-legend-disabled') != '1', |
309 | | - layout: typeof $table.data('graph-legend-layout') != 'undefined' ? $table.data('graph-legend-layout') : 'horizontal', |
| 318 | + layout: $table.data('graph-legend-layout') || 'horizontal', |
310 | 319 | symbolWidth: $table.data('graph-legend-width') || 30, |
311 | 320 | x: $table.data('graph-legend-x') || 15, |
312 | 321 | y: $table.data('graph-legend-y') || 0 |
|
340 | 349 | title: { |
341 | 350 | text: $table.data('graph-xaxis-title-text') || null |
342 | 351 | }, |
343 | | - gridLineWidth: typeof $table.data('graph-xaxis-gridLine-width') != 'undefined' ? $table.data('graph-xaxis-gridLine-width') : 0, |
| 352 | + gridLineWidth: $table.data('graph-xaxis-gridLine-width') || 0, |
344 | 353 | gridLineDashStyle: $table.data('graph-xaxis-gridLine-style') || 'ShortDot' |
345 | 354 | }, |
346 | 355 | yAxis: yAxisConfig, |
|
361 | 370 | dataLabels: { |
362 | 371 | enabled: true |
363 | 372 | }, |
364 | | - lineWidth: $table.data('graph-line-width') || 2 |
| 373 | + lineWidth: lineWidth |
365 | 374 | }, |
366 | 375 | area: { |
367 | | - lineWidth: $table.data('graph-line-width') || 2, |
368 | | - shadow: typeof $table.data('graph-line-shadow') != 'undefined' ? $table.data('graph-line-shadow') : true, |
369 | | - fillOpacity: typeof $table.data('graph-area-fillOpacity') != 'undefined' ? $table.data('graph-area-fillOpacity') : 0.75 |
| 376 | + lineWidth: lineWidth, |
| 377 | + shadow: typeof lineShadow != 'undefined' ? lineShadow : true, |
| 378 | + fillOpacity: $table.data('graph-area-fillOpacity') || 0.75 |
370 | 379 | }, |
371 | 380 | pie: { |
372 | 381 | allowPointSelect: true, |
|
380 | 389 | animation: false, |
381 | 390 | stickyTracking : false, |
382 | 391 | stacking: graphIsStacked ? stackingType : null, |
383 | | - groupPadding: typeof $table.data('graph-group-padding') != 'undefined' ? $table.data('graph-group-padding') : 0 |
| 392 | + groupPadding: $table.data('graph-group-padding') || 0 |
384 | 393 | } |
385 | 394 | }, |
386 | 395 | series: series, |
|
0 commit comments