HtmlChart - XmlDataSource

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

This example shows how a RadHtmlChart can be bound to a XmlDataSource. The major properties are:

  • DataSourceID in the main tag sets the declarative data source for the entire chart. The DataSource property can be used for a programmatic data source if you create the connection in the code-behind.
  • 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
  • BooksPricingData.xml
<%@ 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" />
    <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/HtmlChart/Examples/DataBinding/BindToXml/BooksPricingData.xml"></asp:XmlDataSource>
    <div class="demo-container size-wide">
        <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="800px" Height="500px"
                    <telerik:BarSeries Name="Paperback Price" DataFieldY="PaperbackPrice">
                        <TooltipsAppearance Color="White" DataFormatString="${0}"></TooltipsAppearance>
                        <LabelsAppearance Visible="false">
                    <telerik:BarSeries Name="E-book Price" DataFieldY="EbookPrice">
                        <TooltipsAppearance Color="White" DataFormatString="${0}"></TooltipsAppearance>
                        <LabelsAppearance Visible="false">
                <XAxis DataLabelsField="Title">
                    <LabelsAppearance DataFormatString="${0}">
                <Appearance Position="Bottom">
            <ChartTitle Text="Books Pricing">

Find Assistance

Help Us Improve

Was this example helpful?