Solved

How do I create a asp.net chart with side by side

Posted on 2011-03-21
4
272 Views
Last Modified: 2012-05-11
I have a graph that needs to be done side by side. an example would be you have two sets of dates. one date set is jan 1, 2011 - jan 7, 2011 and the second set is march 12, 2011 - march 19, 2011. what I need to know is how to have a side by side comparison from both of these date sets vertically. so the first date set would be on the left and the second date set would be on the right. my data looks like this...

date         |   hour   |   mw
1/1/2011       1        500
1/1/2011       2        500
1/1/2011       3        500
1/1/2011       4        500
1/1/2011       5        500
1/2/2011       1        500
1/2/2011       2        500
1/2/2011       3        500
1/2/2011       4        500
1/2/2011       5        500
1/3/2011       1        500
1/3/2011       2        500
1/3/2011       3        500
1/3/2011       4        500
1/3/2011       5        500

3/12/2011     1        500
3/12/2011     2        500
3/12/2011     3        500
3/12/2011     4        500
3/12/2011     5        500
3/13/2011     1        500
3/13/2011     2        500
3/13/2011     3        500
3/13/2011     4        500
3/13/2011     5        500
3/14/2011     1        500
3/14/2011     2        500
3/14/2011     3        500
3/14/2011     4        500
3/14/2011     5        500
0
Comment
Question by:bschave2
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
nbove earned 500 total points
ID: 35185292
Bind each set of data to a gridview with a style of "display:inline"
0
 

Author Comment

by:bschave2
ID: 35191287
i need this to be a chart with points. I cannot use a gridview.
0
 
LVL 7

Assisted Solution

by:nbove
nbove earned 500 total points
ID: 35191634
The method of rendering the tables is rather irrelevant.  The end result will be two table elements.  If you simply add a "style=display:inline" to those tables, they will display side by side.
0
 

Author Comment

by:bschave2
ID: 35284222
nevermind. I used a union on the data and created strip lines to solve this problem. Here is the code.
on page load i put:

CurrentChart.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = false;
                CurrentChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Interval = 24;
                CurrentChart.ChartAreas["ChartArea1"].AxisX.MajorGrid.Interval = 24;
                CurrentChart.ChartAreas["ChartArea1"].AxisX.MajorTickMark.Interval = 24;
                CurrentChart.ChartAreas["ChartArea1"].AxisX.Interval = 24;
                CurrentChart.ChartAreas["ChartArea1"].AxisX.StripLines.Add(new StripLine());
                CurrentChart.ChartAreas["ChartArea1"].AxisX.StripLines[0].StripWidth = 168;
                CurrentChart.ChartAreas["ChartArea1"].AxisX.StripLines[0].BackColor = System.Drawing.ColorTranslator.FromHtml("#eeeeee");
                CurrentChart.ChartAreas["ChartArea1"].AxisX.StripLines[0].IntervalOffset = 168;
                CurrentChart.ChartAreas["ChartArea1"].AxisX.StripLines.Add(new StripLine());
                CurrentChart.ChartAreas["ChartArea1"].AxisX.StripLines[1].StripWidth = 168;
                CurrentChart.ChartAreas["ChartArea1"].AxisX.StripLines[1].BackColor = System.Drawing.ColorTranslator.FromHtml("#99ccff");
                CurrentChart.ChartAreas["ChartArea1"].AxisX.StripLines[1].IntervalOffset = 0;

                
                Build_daily_Graphs();

private void Build_daily_Graphs()
        {
            try
            {
                CurrentChart.DataSource = Get_WPP_Period(ReportType);

                CurrentChart.Series["WPPSeries"].XValueMember = "study_date";
                CurrentChart.Series["WPPSeries"].YValueMembers = "mw";

                CurrentChart.Series["MinSeries"].XValueMember = "study_date";
                CurrentChart.Series["MinSeries"].YValueMembers = "minmw";
                CurrentChart.Series["MinSeries"].Color = Color.Red;

                CurrentChart.Series["MaxSeries"].XValueMember = "study_date";
                CurrentChart.Series["MaxSeries"].YValueMembers = "maxmw";
                CurrentChart.Series["MaxSeries"].Color = Color.Red;
                
                CurrentChart.DataBind();

               
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

        }

Open in new window

0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now