ASP.NET MVC TreeMap Overview
The TreeMap displays hierarchical data in a traditional tree structure. TreeMaps also support different rendering types such us Squarified, Vertical, and Horizontal (slice and dice algorithm).
The Telerik UI TreeMap HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI TreeMap widget.
To see the component in action, check the examples:
Initializing the TreeMap
The following example demonstrates how to define a TreeMap by using the TreeMap TagHelper and the TreeMap HtmlHelper.
Razor
@(Html.Kendo().TreeMap()
.Name("treeMap")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("Population_Read", "TreeMap")
)
.Model(m => m.Children("Items"))
)
.ValueField("Value")
.TextField("Name")
)
Binding to Remote Data
You can also bind the DataSource
to remote data. The following example demonstrates how to bind the Kendo UI TreeMap TagHelper to a remote service.
Razor
@(Html.Kendo().TreeMap()
.Name("treeMap")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("_PopulationUSA", "TreeMap")
)
.Model(m => m.Children("Items"))
)
.ValueField("Value")
.TextField("Name")
.HtmlAttributes(new { style = "height:600px; font-size: 12px;" })
)
Setting Custom Color Ranges
You can customize the TreeMap through the Colors
configuration option by adding the desired color ranges:
Razor
@(Html.Kendo().TreeMap()
.Name("treeMap")
.DataSource(dataSource => dataSource
.Read(read => read
.Action("Population_Read", "TreeMap")
)
.Model(m => m.Children("Items"))
)
.Colors(color =>
{
color.AddRange("#0072c6", "#cbe2f3");
color.AddRange("#5db2ff", "#deeffe");
color.AddRange("#ff8f32", "#cbe7d0");
color.AddRange("#82ba00", "#e5f0cb");
color.AddRange("#ff8f32", "#fee8d5");
color.AddRange("#9e0a61", "#eccedf");
color.AddRange("#ac193d", "#eed0d7");
})
.ValueField("Value")
.TextField("Name")
)