Background
To represent data on a chart in an application, it is very important to summarize the huge amount of data. Sometimes I wonder when many developers and project managers decided to use third-party chart control for their project but it's not required. The Microsoft .Net Framework is quite a capable and powerful tool to design and create any type of chart control with high quality design. In my career life I have created many custom controls to avoid third-party controls. Because of this I have saved a huge amount of cost that required buying third-party controls for projects. Similarly we can avoid a huge cost by using ASP.Net controls properly instead of third-party controls. So by considering the preceding requirements and to introduce the ASP.Net Chart Control I decided to write this article.Let us learn about the one ASP.Net chart type Renko and Area chart that provides the powerful UI and design quality. So let us start to learn about these chart type controls step-by-step.
Renko Type Chart
Renko chart is the type of ASP.Net Chart Control that displays a user-interactive graphical information of the data. All the charts are in the System.Web.UI.DataVisualization.Charting namespace.
- X Axis: the horizontal line of the chart termed as X axis
- Y Axis: the vertical line of the chart termed as Y axis
- AlternetText: Sets the alternate text when the image is not available.
- Annotation: Stores the chart annotations.
- AntiAliasing: Sets a value that determines whether anti-aliasing is used when text and graphics are drawn.
- BackGradientStyle: Sets the orientation for the background gradient for the chart control. Also determines whether a gradient is used, it has following styles, the default is None.

- Backcolor: Sets the background color for the chart, the default color is White
- BackImage: Sets the background image for the chart control.
- BackHatchStyle: Sets the hatching style for the chart control, the default is None. It has the following styles that is used along with the chart as in the following:

- Height: Sets the height for chart control
- Width: Sets the width for the chart control.
- Palette: Sets the style with a color for the chart control, the default style is Chocolate. The following are the styles available to use:

- PaletteCustomColors: Sets the custom color for the chart control, it has the following Color Editor, you can make any custom style for your chart.

- Series: Sets the series collection for the Chary Control
- Legends: Sets the series of legends to the chart
Now let us see an example of the preceding explanation by creating a simple web application as in the following.


Now create the project with:
- "Start" - "All Programs" - "Microsoft Visual Studio 2010".
- "File" - "New Project" - "C#" - "Empty Project" (to avoid adding a master page).
- Provide the Project name such as RenkoChart or another as you wish and specify the location.
- Then right-click on Solution Explorer and select "Add New Item" then select Default.aspx page.
- Drag and Drop Chart control from ToolBox onto the Default.aspx page.
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
- <%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
- Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>Article by Vithal Wadje</title>
- </head>
- <body bgcolor="blue">
- <form id="form1" runat="server">
- <h4 style="color: White;">
- Article for C#Corner
- </h4>
- <br />
- <asp:Chart ID="Chart1" runat="server" TextAntiAliasingQuality="Normal">
- <Series>
- <asp:Series Name="Series1">
- </asp:Series>
- </Series>
- <ChartAreas>
- <asp:ChartArea Name="ChartArea1">
- </asp:ChartArea>
- </ChartAreas>
- </asp:Chart>
- </form>
- </body>
- </html>
- private void Bindchart()
- {
- connection();
- query = "select *from orderdet";//not recommended this i have written just for example,write stored procedure for security
- com = new SqlCommand(query, con);
- SqlDataAdapter da = new SqlDataAdapter(query, con);
- DataSet ds = new DataSet();
- da.Fill(ds);
- con.Close();
- DataTable ChartData=ds.Tables[0];
- //storing total rows count to loop on each Record
- string[] XPointMember = new string[ChartData.Rows.Count];
- int[] YPointMember = new int[ChartData.Rows.Count];
- for (int count = 0; count < ChartData.Rows.Count;count++ )
- {
- //storing Values for X axis
- XPointMember[count] = ChartData.Rows[count]["Month"].ToString();
- //storing values for Y Axis
- YPointMember[count] = Convert.ToInt32(ChartData.Rows[count]["Orders"]);
- }
- //binding chart control
- Chart1.Series[0].Points.DataBindXY(XPointMember, YPointMember);
- //setting Chart type
- Chart1.Series[0].ChartType = SeriesChartType.Renko;
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- Bindchart();
- }
- }
- using System;
- 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.Configuration;
- using System.Data;
- using System.Web.UI.DataVisualization.Charting;
- public partial class _Default : System.Web.UI.Page
- {
- private SqlConnection con;
- private SqlCommand com;
- private string constr, query;
- private void connection()
- {
- constr = ConfigurationManager.ConnectionStrings["getconn"].ToString();
- con = new SqlConnection(constr);
- con.Open();
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- Bindchart();
- }
- }
- private void Bindchart()
- {
- connection();
- query = "select *from orderdet";//not recommended this i have written just for example,write stored procedure for security
- com = new SqlCommand(query, con);
- SqlDataAdapter da = new SqlDataAdapter(query, con);
- DataSet ds = new DataSet();
- da.Fill(ds);
- con.Close();
- DataTable ChartData=ds.Tables[0];
- //storing total rows count to loop on each Record
- string[] XPointMember = new string[ChartData.Rows.Count];
- int[] YPointMember = new int[ChartData.Rows.Count];
- for (int count = 0; count < ChartData.Rows.Count;count++ )
- {
- //storing Values for X axis
- XPointMember[count] = ChartData.Rows[count]["Month"].ToString();
- //storing values for Y Axis
- YPointMember[count] = Convert.ToInt32(ChartData.Rows[count]["Orders"]);
- }
- //binding chart control
- Chart1.Series[0].Points.DataBindXY(XPointMember, YPointMember);
- //setting Chart type
- Chart1.Series[0].ChartType = SeriesChartType.Renko;
- }
- }







Notes
- Download the Zip file from the attachment for the full source code of the application.
- Change the connection string in the web.config file to specify your server location.

Vithal WadjePosted Jan 1, 2016, 1:51 PM
Yes Leopold , Thanks
Leopold MinikusPosted Jan 1, 2016, 10:10 AM
Interesting ... thanks. Just wondering how i can iterate through the bricks? I would like to check for example if two "same direction" bricks in the same direction are existent.
Vithal WadjePosted Dec 31, 2014, 9:48 AM
Thanks Abhishek Arora sir
Abhishek AroraPosted Dec 31, 2014, 7:35 AM
Vithal Wadje sir good to see your article selected as article of the day on the Microsoft ASP.NET community.
Vithal WadjePosted Dec 31, 2014, 2:11 AM
Thanks Sandeep Singh Shekhawat sir
Vithal WadjePosted Dec 31, 2014, 2:10 AM
Thanks Dinesh Beniwal sir for your great support and motivation ,only because of your support we get courage to write articles
Sandeep Singh ShekhawatPosted Dec 31, 2014, 1:44 AM
Congratulations Vithal. Its selected aas Articles of the Day on Microsoft ASP.NET community.
Dinesh BeniwalPosted Dec 31, 2014, 1:24 AM
Congratulations Vithal Wadje Articles of the Day on ASP.NET
Vithal WadjePosted Dec 16, 2014, 12:59 AM
Thanks Michal Habalcik sir
Michal HabalcikPosted Dec 16, 2014, 12:57 AM
never heard about Renko before, thanks for introducing it ...
Vithal WadjePosted Dec 15, 2014, 11:48 PM
thanks Manish Kumar Choudhary sir
Manish Kumar ChoudharyPosted Dec 15, 2014, 11:33 PM
nice one..