Redrawing Chart after first load

Redrawing Chart after first load

east1999east1999 Posts: 31Questions: 11Answers: 0

Hi. I'm trying to link Highcharts to Datatable, but I can't redraw the chart whenever I attempt a search.

Here is the fiddle: https://jsfiddle.net/8qrojfoz/7/

I think it has to do with using initComplete and filling the chart from the JSON and not the rendered data, right? However, whenever I move this function out of initComplete, the returned arrays always come empty.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    Here is an updated fiddle:
    https://jsfiddle.net/qkff4a4a/

    I made 4 or 5 changes and commented them, I think :smile: . Here are the highlights:

    • Moved the getdata() function outside of initComplete
    • initComplete now calls setTableEvents() and getdata()
      initComplete passes $('#mytable').DataTable() for the table variable to setTableEvents()
    • getdata() also uses $('#mytable').DataTable() in place of table and uses selector-modifier to filter the rows based on the search
      var data = $('#mytable').DataTable().rows({search: 'applied'}).data();

    Now it seems to behave as desired. At least it updates the chart appropriately.

    Kevin

  • east1999east1999 Posts: 31Questions: 11Answers: 0

    Have you really updated the fiddle? I'm still seeing mine :'(

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    edited February 2018 Answer ✓

    Sorry, forgot to "update" (I'm used to the auto save of live.datatables.net :smile:

    https://jsfiddle.net/qkff4a4a/2/

    Kevin

  • east1999east1999 Posts: 31Questions: 11Answers: 0

    I'm flabbergasted, my friend. This works like a charm and seems to be very efficient. Thank you so, so much!

This discussion has been closed.