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?

Noodles12Noodles12 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.

http://live.datatables.net/nuyopuxe/5/edit

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954
    edited December 2022

    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 if Total 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

  • Noodles12Noodles12 Posts: 113Questions: 41Answers: 2

    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.

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954
    edited December 2022 Answer ✓

    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

  • Noodles12Noodles12 Posts: 113Questions: 41Answers: 2

    Thankyou.

Sign In or Register to comment.