.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Create Devexpress Bar chart - Webchartcontrol - Xtracharts

Posted By:Deepika Haridas       Posted Date: October 27, 2010    Points: 15    Category: Visual Studio    URL: http://www.dotnetspark.com  

This code shows how its easy to use a Bar chart in your Web applications through Devexpress Webchartcontrol

This code shows how its easy to use a Bar chart in your Web applications.

To start with first of all download and install Devexpress controls from www.devexpress.com

Here I am going to make a bar chart with the use of WebchartControl (Xtracharts)

Note : I have used version 9.2.3 and also tried it with 9.3.3

Code .cs Page

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using DevExpress.XtraCharts;
using System.Drawing;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

private void BindChart()
SqlConnection conn = new SqlConnection("Connection string here");
SqlCommand cmd;
cmd = new SqlCommand("select * from Transactions"); // my sample query
cmd.Connection = conn;
DataSet dsClaimCat = new DataSet();

SqlDataAdapter dapt = new SqlDataAdapter(cmd);
WebChartControl1.DataSource = dsClaimCat.Tables[0];
//Values for X-axis
WebChartControl1.SeriesDataMember = dsClaimCat.Tables[0].Columns["percentage"].ToString();
//Values for Y-axis
WebChartControl1.SeriesTemplate.ArgumentDataMember = dsClaimCat.Tables[0].Columns["paymentDays"].ToString();
WebChartControl1.SeriesTemplate.ValueDataMembers.AddRange(new string[] { dsClaimCat.Tables[0].Columns["percentage"].ToString() });
string paletteName = "MyPalette";
PaletteEntry entry1 = new PaletteEntry(Color.Green, Color.LightGreen);
Palette palette = new Palette(paletteName, new PaletteEntry[] { entry1 });
WebChartControl1.PaletteRepository.Add(paletteName, palette);
WebChartControl1.PaletteName = paletteName;
SideBySideBarSeriesView v = new SideBySideBarSeriesView();
v.BarWidth = 0.4;

WebChartControl1.SeriesTemplate.View = v;


Design Page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="DevExpress.XtraCharts.v9.2.Web, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.XtraCharts.Web" TagPrefix="dxchartsui" %>
<%@ Register Assembly="DevExpress.XtraCharts.v9.2, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.XtraCharts.Web" TagPrefix="cci" %>
<%@ Register Assembly="DevExpress.XtraCharts.v9.2, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.XtraCharts" TagPrefix="cc1" %>

PaletteName="The Trees">


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend