Search code examples
c#jsonthejit

How to reset thejit treemap control after the first display?


I use thejit treemap to display first 50 most frequently used words from a .txt file. My code is deployed here.

After the first text upload I receive JSON result and bind it to thejit control. All good so far. However, if I do another upload of a file without manually refreshing the page I get the result where boxes from the first result overlap with boxes from the second upload.

See the picture below.

overlapping of JSON

Question: how do I reset this control to display only new JSON and discard any previous data?


Solution

  • Empty the div containing the visualisation before loading in the new data.

    On the first line of your InitTreeMap function (before the var tm = new $jit.TM.Squarified({ line), add this:

    $('#infovis').empty();