Skip to content

Commit d3eefbf

Browse files
committed
Optimization : some <table> attributes were fetched inside <td> iteration
1 parent 0ca0413 commit d3eefbf

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

jquery.highchartTable.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,16 @@
166166
}
167167
});
168168

169-
var xValues = [];
170-
var rows = $('tbody:first tr', table);
169+
var xValues = [];
170+
var callablePoint = getCallable(table, 'graph-point-callback');
171+
var isGraphDatetime = $table.data('graph-xaxis-type') == 'datetime';
172+
173+
var rows = $('tbody:first tr', table);
171174
rows.each(function(indexRow, row) {
172175
if (!!$(row).data('graph-skip')) {
173176
return;
174177
}
175-
178+
176179
var tds = $('td', row);
177180
tds.each(function(indexTd, td) {
178181
var cellValue;
@@ -196,34 +199,33 @@
196199

197200
var dataGraphX = $(td).data('graph-x');
198201

199-
if ($table.data('graph-xaxis-type') == 'datetime') {
202+
if (isGraphDatetime) {
200203
dataGraphX = $('td', $(row)).first().text();
201204
var dateInfos = dataGraphX.split('-');
202205
var date = parseDate(dateInfos);
203206
dataGraphX = date.getTime() - date.getTimezoneOffset()*60*1000;
204207
}
205-
208+
206209
var serieDataItem = {
207210
name: typeof $(td).data('graph-name') != 'undefined' ? $(td).data('graph-name') : rawCellValue,
208211
y: cellValue,
209212
x: dataGraphX //undefined if no x defined in table
210213
};
211-
212-
var callablePoint = getCallable(table, 'graph-point-callback');
214+
213215
if (callablePoint) {
214216
serieDataItem.events = {
215217
click: function () {
216218
return callablePoint(this);
217219
}
218220
};
219221
}
220-
222+
221223
if (column.graphType === 'pie') {
222224
if ($(td).data('graph-item-highlight')) {
223225
serieDataItem.sliced = 1;
224226
}
225227
}
226-
228+
227229
if (typeof $(td).data('graph-item-color') != 'undefined') {
228230
serieDataItem.color = $(td).data('graph-item-color');
229231
}

0 commit comments

Comments
 (0)