Search code examples
javascriptdygraphs

(Dygraphs JS) How can I clear (remove) graphics rendered using underlayCallback?


This should be simple but I have been unable to find a way to do this in the Dygraphs documentation.

If I have generated some custom graphics using underlayCallback, then how can I later clear these graphics?

For example, in the highlighted region demo (http://dygraphs.com/gallery/#g/highlighted-region), how could I implement a button that removes the yellow highlighted region?


Solution

  • use something like this

    http://jsfiddle.net/cephei/husevsfm/

    the important thing is the property DygraphObject.updateOptions(object), with this you can set option underlayCallback to null and you will get the base result

    $("#mybutton1").click(function () {
        g.updateOptions({
            underlayCallback: null
        });
    });