Product Bundles
DevCraft
All Telerik .NET and Kendo UI JavaScript components and AI Tools in one package.
Kendo UI
Bundle of AI Tools plus four JavaScript UI libraries built natively for jQuery, Angular, React and Vue.
Telerik
Build great .NET business apps
.Net Web
Cross-Platform
Desktop
Reporting and Documents
Testing & Mocking
Debugging
Build JavaScript UI
Javascript
AI for Developers & IT
Ensure AI program success
AI Coding
Additional Tools
Enhance the developer and designer experience
UI/UX Tools
Free Tools
CMS
Support and Learning
Productivity and Design Tools
New to Telerik UI for ASP.NET AJAX? Download free 30-day trial
This example demonstrates how to use the client-side data-binding feature of the ASP.NET AJAX Chart control. This RadHtmlChart example demonstrates how to use the client-side data-binding feature of Telerik's ASP.NET Chart. A PieSeries is used for illustration purposes.
There are three buttons present on this demo:
Here is how you can work with the client-side data source of the RadHtmlChart:
Note: The field names in the JSON objects must match the chart's data-binding properties - DataFieldY, NameField, ColorField and ExplodeField for a PieSeries. In order for the new data source to take effect, the chart must be refreshed through its repaint method.
Note: At least the DataFieldY property must be set (either in the markup or in the code behind), in order for the chart to reference the respective values from the data source. In this example all PieSeries data-binding properties are used - DataFieldY, NameField, ColorField and ExplodeField.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.HtmlChart.ClientSideDataBinding.DefaultCS" %> <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %> <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> <!DOCTYPE html> <html xmlns='http://www.w3.org/1999/xhtml'> <head runat="server"> <title>Telerik ASP.NET Example</title> <script src="scripts.js" type="text/javascript"></script> </head> <body> <form id="form1" runat="server"> <telerik:RadScriptManager runat="server" ID="RadScriptManager1" /> <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" /> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="ButtonResetData"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadHtmlChart1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadXmlHttpPanel runat="server" ID="XmlHttpPanelWCF" WcfRequestMethod="GET" OnClientResponseEnding="setDataFromService " WcfServicePath="HtmlChartWcfService.svc" WcfServiceMethod="getJsonData"> </telerik:RadXmlHttpPanel> <div class="demo-container size-wide"> <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server"> <ClientEvents OnLoad="onChartLoad" /> <ChartTitle Text="Countries Exporting Crude Oil the United States (in Thousands of Barrels)"> </ChartTitle> <PlotArea> <Series> <telerik:PieSeries DataFieldY="Barrels" ColorField="Color" ExplodeField="IsExploded" NameField="Country"> <LabelsAppearance DataFormatString="{0:N0} bbl"></LabelsAppearance> <TooltipsAppearance Color="White" /> </telerik:PieSeries> </Series> </PlotArea> </telerik:RadHtmlChart> </div> <qsf:ConfiguratorPanel runat="server" ID="ConfiguratorPanel1"> <Views> <qsf:View> <qsf:ConfiguratorColumn ID="ConfiguratorColumn1" runat="server" Size="Auto"> <qsf:Button ID="ButtonGetDataFromService" runat="server" Text="Bind to WCF Service" AutoPostBack="false" OnClientClicked="getDataFromService" Size="Wide"> </qsf:Button> <qsf:Button ID="ButtonGetRandomData" runat="server" Text="Bind to Random Data" AutoPostBack="false" OnClientClicked="setRandomDataSource" Size="Wide"> </qsf:Button> <qsf:Button ID="ButtonResetData" runat="server" Text="Reset Data" OnClientClicked="clearConsole" Size="Wide"> </qsf:Button> </qsf:ConfiguratorColumn> </qsf:View> </Views> </qsf:ConfiguratorPanel> <qsf:EventLogConsole ID="EventLogConsole1" runat="server" AllowClear="true"></qsf:EventLogConsole> <script type="text/javascript"> var xmlHttpPanel = null; Sys.Application.add_load(function () { xmlHttpPanel = $find("<%=XmlHttpPanelWCF.ClientID %>"); }); </script> </form> </body> </html>