Edit this page

Render External Content in Shapes

The Diagram is rendered through the Drawing API.

The shape visual templates allow you to override the rendering entirely as demonstrated in the Basic Usage demo. In addition to the manual drawing of the shapes, you can use the HTML Drawing feature to convert existing document content into static drawings.

      .container {
        /* Move rendering container off-screen */
        position: absolute;
        left: -4000px;

        /* Set dimensions */
        width: 100px;
        height: 100px;

      .shape {
        width: 100px;
        border: 2px solid red;
        text-align: center;
        padding-bottom: 10px;

      .title {
        font-size: 20px;
        margin: 5px 0 20px 0;

    <script id="template" type="text/x-kendo-template">
      <div class="shape">
        <div class='title'>#= title #</div>
        Foo Bar

    <div id="diagram"></div>
      // Import the Drawing API namespaces
      var geom = kendo.geometry;
      var draw = kendo.drawing;

      // Compile the shape template
      var contentTemplate = kendo.template($("#template").html());

      function visualTemplate(options) {
        // Render template and bind it to the current data item
        var dataItem = options.dataItem;
        var renderElement = $("<div />").appendTo("body");

        // Create a new group that will hold the rendered content
        var output = new kendo.drawing.Group();
        .then(function(group) {

          /* Clean-up */

        var visual = new kendo.dataviz.diagram.Group();

        return visual;

      var data = [{
        title: "Foo",
        items: [{
          title: "Bar"

        dataSource: {
          data: data,
          schema: {
            model: {
              children: "items"
          type: "tree",
          subtype: "right"
        shapeDefaults: {
          visual: visualTemplate

See Also

For more runnable examples on the Kendo UI Diagram, browse its How To documentation folder.

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article