Charts HtmlHelper Overview

The Telerik UI Chart HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI Chart widget.

The Chart uses modern browser technologies to render high-quality data visualizations. All graphics are rendered on the client by using Scalable Vector Graphics (SVG) with a fallback to Canvas. The Charts support a set of series types such as Bar, Line, Area, Bullet, Pie, Scatter, Bubble, Polar, and other.

Basic Configuration

This runnable demo demonstrates how to define a Bar Chart by using the Chart HtmlHelper.

Functionality and Features

Events

You can subscribe to all Chart events. For a complete example on basic Chart events, refer to the demo on using the events of the Chart.

Handling by Handler Name

The following example demonstrates how to subscribe to events by a handler name.

    <%: Html.Kendo().Chart(Model)
            .Name("internetUsersChart")
            .Events(e => e
                .DataBound("internetUsersChart_dataBound")
                .SeriesClick("internetUsersChart_seriesClick")
            )
    %>

    <script>
        function internetUsersChart_dataBound() {
            // Handle the dataBound event.
        }

        function internetUsersChart_seriesClick() {
            // Handle the series click event.
        }
    </script>
    @(Html.Kendo().Chart(Model)
        .Name("internetUsersChart")
        .Events(e => e
            .DataBound("internetUsersChart_dataBound")
            .SeriesClick("internetUsersChart_seriesClick")
        )
    )

    <script>
        function internetUsersChart_dataBound() {
            // Handle the dataBound event.
        }

        function internetUsersChart_seriesClick() {
            // Handle the seriesClick event.
        }
    </script>

Handling by Template Delegate

The following example demonstrates how to subscribe to events by a template delegate.

    @(Html.Kendo().Chart(Model)
        .Name("internetUsersChart")
        .Events(e => e
            .DataBound(@<text>
                    function() {
                        // Handle the dataBound event inline.
                    }
            </text>)
            .SeriesClick(@<text>
                    function() {
                        // Handle the seriesClick event inline.
                    }
            </text>)
        )
    )

Referencing Existing Instances

To reference an existing Chart instance, use the jQuery.data() configuration option. Once a reference is established, use the Chart client-side API to control its behavior.

// Place the following after the Chart for ASP.NET MVC declaration.
<script>
    $(function() {
        // The Name() of the Chart is used to get its client-side instance.
        var chart = $("#internetUsersChart").data("kendoChart");
    });
</script>

See Also

In this article
Not finding the help you need? Improve this article