exportImage

Exports the Sankey as an image. The result can be saved using kendo.saveAs.

The export operation is asynchronous and returns a promise. The promise will be resolved with a PNG image encoded as a Data URI.

Example - Exporting the Sankey to an image

<div id="sankey" style="width: 500px; height: 200px;"></div>
<script>
    $("#sankey").kendoSankey({
        data: {
            nodes: [
                { id: 1, label: { text: "Node 1" } },
                { id: 2, label: { text: "Node 2" } },
                { id: 3, label: { text: "Node 3" } }
            ],
            links: [
                { sourceId: 1, targetId: 3, value: 2 },
                { sourceId: 2, targetId: 3, value: 1 }
            ]
        }
    });

    var sankey = $("#sankey").getKendoSankey();
    sankey.exportImage().done(function(data) {
        kendo.saveAs({
            dataURI: data,
            fileName: "sankey.png"
        });
    });
</script>

Parameters

options Object (optional)Parameters for the exported image.
options.width StringThe width of the exported image. Defaults to the Sankey width.
options.height StringThe height of the exported image. Defaults to the Sankey height.
options.cors String (default: "anonymous")Specifies how cross-origin images

should be requested.

Requesting images without CORS will "taint" the canvas. It will still be visible on the page, but all script access to it is disabled to prevent information disclosure.

By default they're requested anonymously. Available options are:

  • "anonymous" - do not send user credentials as part of the request
  • "use-credentials" - send credentials as part of the request
  • false - fetch images without CORS, possibly tainting the canvas

See crossorigin attribute for more details.

ReturnsPromise A promise that will be resolved with a PNG image encoded as a Data URI.

In this article