Advice on improving calculation speed of data for HighCharts
Advice on improving calculation speed of data for HighCharts

Hi All,
I have highcharts working with my datatable and it looks great, the only issue I'm having is the calculation of the data for the chart is taking 10+ seconds on 6500+ records, so every time a user does a search or sorts a column it takes that long.
Below is the offending section of my function. What I'd like to know is, is there a faster\better way of achieving this? (Atm server-side is not an option).
For clarity, column 2 of the datatable is the month and year (i.e. 'June 21' or 'December 20') and column 6 is the sales value of that row. So, my function is summing up the total sales for each month+year and putting it into an array for highcharts to use.
var monthTO = {};
var indexes = TurnoverRepoTable.rows({ search: 'applied' }).indexes().toArray();
for (var i = 0; i < indexes.length; i++) {
var cMonth = TurnoverRepoTable.cell(indexes[i], 2).data();
var value = TurnoverRepoTable.cell(indexes[i], 6).data();
if (monthTO[cMonth] === undefined) {
monthTO[cMonth] = Number(value);
} else {
monthTO[cMonth] = monthTO[cMonth] + Number(value);
}
}
Thanks, Chris
This question has an accepted answers - jump to answer
Answers
One idea is to gather the data from columns 2 and 6 at the same time I generate the 'indexes' array, something like:
Although, I'm not sure if that is possible or how I would go about doing this
I have found the solution, I'm now referencing the data directly rather than by indexes, latest code below:
Glad you got it working, thanks for reporting back,
Colin