New to Kendo UI for jQuery? Download free 30-day trial

Set the TreeMap Header Items Color

Environment

Product Progress® Kendo UI® Chart for jQuery
Operating System Windows 10 64bit
Visual Studio Version Visual Studio 2017
Preferred Language JavaScript

Description

How can I set the Kendo UI TreeMap tiles color from the items?

Solution

Obtain the node elements in the dataBound event handler and apply the style through the css() jQuery method.

  • When you use a Sass-based theme, apply an additional .k-treemap .k-treemap-title { background-color: inherit; } style.
  • R1 2023 is the last official release of Kendo jQuery, which supports and ships Less themes with the product.

The following example demonstrates how to set the Kendo UI TreeMap tiles color from the items.


    <style>
      .k-treemap .k-treemap-title {
        background-color: inherit;
      }
    </style>

    <div id="treemap">
    </div>

    <script>
      $("#treemap").kendoTreeMap({
        dataSource: {
          data: [{
            name: "Root",
            color: "red",
            items: [{
              name: "Group A",
              value: 1,
              color: "green",
              items: [{ name: "foo", value: 1, color: "blue" }, { name: "bar", value: 2, color: "orange"}]
            }]
          }]
        },
        valueField: "value",
        textField: "name",
        colorField: "color",
        dataBound: function (e) {
          if (e.node) {
            var element = this.findByUid(e.node.uid);
            element.css("background-color", e.node.color);
          }
        }
      });
    </script>

See Also

In this article