Get real time news update from your favorite websites.
Don't miss any news about your favorite topic.
Personalize your app.
Check out NTyles.
Don't miss any news about your favorite topic.
Personalize your app.
Get it on....
Enable 3D in asp.net chart control in Visual C#.
For the beginners who are trying to make something out of data to visualize on, because of the some project you guys have taken or you are really a geek this post will really help you to add something to your knowledge about chart control and its features in ASP.Net and how we can control these features using Visual C#.
In my previous post I show you how to create a chart in Asp.net in MS Visual Studio 2010. In this post I will show how to give you chart a 3D look and how to change the chart types:
- Pie
- Doughnut
- Stacked
- Spline
How to enable 3D in chart.
In the source view of Design.aspx from the earlier post add following code snippet:
<asp:Table ID="Table1" runat="server" Height="55px" Width="141px">
<asp:TableRow runat="server">
<asp:TableCell runat="server">
Features
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">3D</asp:TableCell>
<asp:TableCell runat="server">
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"
OnCheckedChanged="RadioButton1_CheckedChanged" GroupName = "chartFeature" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
Pie Chart
</asp:TableCell>
<asp:TableCell runat="server">
<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True"
OnCheckedChanged="RadioButton2_CheckedChanged" GroupName = "chartFeature" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
Features
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">3D</asp:TableCell>
<asp:TableCell runat="server">
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"
OnCheckedChanged="RadioButton1_CheckedChanged" GroupName = "chartFeature" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
Pie Chart
</asp:TableCell>
<asp:TableCell runat="server">
<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True"
OnCheckedChanged="RadioButton2_CheckedChanged" GroupName = "chartFeature" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
How to change the chart types.
Open your Default.aspx.cs and add copy paste the code(if you want to):
//Default.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.DataVisualization.Charting; namespace SortingDemo { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //to do after page loads } protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; } protected void RadioButton2_CheckedChanged(object sender, EventArgs e) { Chart1.Series["Series1"].ChartType = SeriesChartType.Pie; } } }If everything is right then you will see following outputs:
1. New added design view with Enable 3D radio button and chart type. |
2. After Enabling 3D |
3. After changing chart type. |
4. Applying 3D to changed Chart type. |
Try these stuffs, you will really feel good when everything is ok. You will rock when you find that the MS Chart Control is really easy to control and modify according to your need.
For other chart types you can do as follows:
1. For bar chart :
Chart1.Series["Series1"].ChartType = SeriesChartType.Bar;
2. For Spline chart :
Chart1.Series["Series1"].ChartType = SeriesChartType.Spline;
So far I guess you masta' have gotten the idea.
Don't hesitate to hit me with any of your queries. Above all you all know I am "Problem Solver".
Happy Charting!!
No comments:
Post a Comment