Telerik skin

HtmlChart - ClientDataSource

Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

This example shows how a RadHtmlChart control can be bound to RadClienDataSource. The RadClientDataSource instance retreieves the data stored in a json file and orderes the data items by the year property in asc order. The significant chart properties are:

  • ClientDataSourceID in the main tag sets the declarative client data source for the entire chart.
  • DataFieldY for the series to point it to the desired column of the data source.
  • DataLabelsField for the x-axis labels to populate the items for the axis (it can also be applied to the y-axis).
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • spain-electricity.json
<%@ Page Language="C#" AutoEventWireup="true"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-wide">
        <telerik:RadClientDataSource ID="ClientDataSource1" runat="server">
                <telerik:ClientDataSourceSortExpression FieldName="year" SortOrder="Asc" />
                <WebServiceDataSourceSettings ServiceType="GeoJSON">
                    <Select Url="spain-electricity.json" DataType="JSON" ContentType="application/json" />

        <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="100%" ClientDataSourceID="ClientDataSource1">
            <ChartTitle Text="Spain electricity production (GWh)"></ChartTitle>
                <Appearance Position="Top"></Appearance>
                    <telerik:LineSeries DataFieldY="nuclear" Name="Nuclear">
                        <LabelsAppearance Visible="false"></LabelsAppearance>
                    <telerik:LineSeries DataFieldY="hydro" Name="Hydro">
                        <LabelsAppearance Visible="false"></LabelsAppearance>
                    <telerik:LineSeries DataFieldY="wind" Name="Wind">
                        <LabelsAppearance Visible="false"></LabelsAppearance>
                <XAxis DataLabelsField="year">
                    <LabelsAppearance RotationAngle="-90"></LabelsAppearance>
                <YAxis Step="10000"></YAxis>
                <CommonTooltipsAppearance Shared="true" Visible="true"></CommonTooltipsAppearance>

Find Assistance

Help Us Improve

Was this example helpful?