How can I get the datatable's last row to not display on Highcharts?
How can I get the datatable's last row to not display on Highcharts?
Noodles12
Posts: 113Questions: 41Answers: 2
I am using the following Highcharts to extract data from a datatable. Highcharts functions okay, but there is a case where I don't want to show the last row from the table because it is the "Total" . Is there a way I can not display last row? This is the code.
This question has an accepted answers - jump to answer
Answers
Probably the easiest thing to do is use an if statement. When you say last row I'm guessing you mean the row with
Total
in the first column. Use an if statement to see ifTotal
is in the row and if it is then don't build that row into the chart. This way if someone sorts the table differently you still skip the correct row.Kevin
Thankyou. This table will not have sort. I am going to disable it. I read in the highcharts documentation that you can add startrow, endrow option. I am not sure where to add it? Thanks.
Those options are not for Datatables. In
initComplete
you are building an array,allSeriesData
, of objects using standard Javascript methods. If you want to skip the Total row in this area of code then you will need to do something like the above.The array
allSeriesData
is then applied to the chart using the Highcharts series option. You will need to refer to this documentation to learn if there are ways for Highcharts to control which rows are displayed from the supplied series.Kevin
Thankyou.