C# chart help...

The following chart needs 3 minor modifications I cannot handle:

1. Change font-size for the data-points.
2. Force to show all of the x-axis labels (it is skipping some).
3. Add a chart title.

Please see the attached image.

Thank you for your comments in advance.
 protected void createMonthlyChartImages(string YYYY, int RegionID, string Region, int Metric_ID, int MedCtrID, string MedCenter, string chartImageName)
    {
        var filePathName = "~\\image\\" + chartImageName + ".png";
        if (!File.Exists(Server.MapPath(filePathName)))
        {
            Session["Metric_ID"] = Metric_ID;
            Session["YYYY"] = YYYY;
            Session["MedCtr_ID"] = MedCtrID;

            SqlDataSource mySqlDataSource = new SqlDataSource();
            mySqlDataSource.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["myConn"].ConnectionString;
            mySqlDataSource.SelectCommand = "spMonthlyChart";
            mySqlDataSource.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
            mySqlDataSource.SelectParameters.Add(new SessionParameter("Metric_ID", DbType.Int32, "Metric_ID"));
            mySqlDataSource.SelectParameters.Add(new SessionParameter("YYYY", DbType.String, "YYYY"));
            mySqlDataSource.SelectParameters.Add(new SessionParameter("MedCtr_ID", DbType.Int32, "MedCtr_ID"));

            Chart chart = new Chart();

            Series series = new Series("Default");
            series.ChartType = SeriesChartType.Column;
            chart.Series.Add(series);

            Series series2 = new Series("Default2");
            series2.ChartType = SeriesChartType.Line;
            series2.Color = System.Drawing.Color.Red;
            series2.BorderWidth = 1; // this is actually the line width...
            chart.Series.Add(series2);

            ChartArea chartArea = new ChartArea();
            Axis yAxis = new Axis(chartArea, AxisName.Y);
            Axis xAxis = new Axis(chartArea, AxisName.X);

            series.XValueMember = "ColName"; // X
            series.YValueMembers = "ColValue"; // Y1
            series2.XValueMember = "ColName"; // X
            series2.YValueMembers = "Target"; // Y2
            chart.DataSource = mySqlDataSource;
            chart.DataBind();

            chart.Series["Default"].Color = System.Drawing.Color.Green;
            chart.Series["Default"].Points[0].Color = System.Drawing.Color.Red;
            chart.Series["Default"].Points[chart.Series["Default"].Points.Count - 1].Color = System.Drawing.Color.Orange;
            series.IsValueShownAsLabel = true; // 3 show value
            series.LabelForeColor = System.Drawing.Color.Black;
            chartArea.AxisX.MajorGrid.Enabled = false; // 1 don't show grid
            chartArea.AxisY.MajorGrid.Enabled = false;// 1 don't show grid
            chartArea.AxisY.LabelStyle.Enabled = false; // 2 remove y labels
            chartArea.AxisX.LabelStyle.Angle = 90; // 4 rotate x labels
            chartArea.AxisY.MajorTickMark.Enabled = false; //5.remove tick marks and add border
            chartArea.BorderDashStyle = ChartDashStyle.Solid; //6. add border
            chartArea.BorderWidth = 3;
            chartArea.BorderColor = System.Drawing.Color.Black; //6. add border

            chart.Series["Default"].Color = System.Drawing.Color.Green;// Blue;
            chart.Series["Default"].BackGradientStyle = GradientStyle.TopBottom;
            chart.Series["Default"].BackSecondaryColor = System.Drawing.Color.DarkGreen;// DarkBlue;
            chart.Series["Default"].Points[0].Color = System.Drawing.Color.Red;
            chart.Series["Default"].Points[0].BackGradientStyle = GradientStyle.TopBottom;
            chart.Series["Default"].Points[0].BackSecondaryColor = System.Drawing.Color.DarkRed;
            chart.Series["Default"].Points[chart.Series["Default"].Points.Count - 1].Color = System.Drawing.Color.Orange;
            chart.Series["Default"].Points[chart.Series["Default"].Points.Count - 1].BackGradientStyle = GradientStyle.TopBottom;
            chart.Series["Default"].Points[chart.Series["Default"].Points.Count - 1].BackSecondaryColor = System.Drawing.Color.Yellow;

            chartArea.BackGradientStyle = GradientStyle.HorizontalCenter;
            chartArea.BackColor = System.Drawing.Color.SlateGray;
            chartArea.BackSecondaryColor = System.Drawing.Color.White;
           // chartArea.Position.X = 0;
          //  chartArea.Position.Y = 0;

            chart.Width = new Unit(1200, UnitType.Pixel);
            chart.Height = new Unit(600, UnitType.Pixel);
            chart.ChartAreas.Add(chartArea);
            string filename = "C:\\image\\" + chartImageName + ".png";
            chart.SaveImage(filename, ChartImageFormat.Png);
     }
    }

Open in new window

ChartModification.png
LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robert SchuttSoftware EngineerCommented:
Try this (somewhere around line 70):
                series.Font = new Font("Verdana", 16f);
                chartArea.AxisX.Interval = 1;
                chart.Titles.Add(string.Format("Chart {0} - {1}", YYYY, MedCtrID));
                chart.Titles[0].Alignment = ContentAlignment.TopLeft;
                chart.Titles[0].Font = new Font("Verdana", 20f);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Thank you Robert.

I guess the following line was a bounces:

chartArea.AxisX.Interval = 1;

or you have answered my next question.

Thanks,

Mike
0
Robert SchuttSoftware EngineerCommented:
ha ha, no that was the "2. force show all labels" part ;-)
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Mike EghtebasDatabase and Application DeveloperAuthor Commented:
I am totally lost. This is my first project and I love it as you suffer through my not knowing much (LOL) and teaching me.

Is there a site where you one can learn c# chart by trying thing? Similar to http://www.w3schools.com/

Pretty soon, I will get hang of it though. I wonder it you could possibly add some comment to:

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_28491538.html

Regards,

Mike
0
Robert SchuttSoftware EngineerCommented:
A website to learn C# by trying, no I haven't come across that. I mostly just use IntelliSense en "Add Watch" in Visual Studio to learn about the structure of objects. The MSDN site is usually very good when it comes to the documentation of classes, methods and properties. But in this case I have struggled with finding good examples showing the relations between the various parts of the chart like labels and axes. It's mainly been trial and error...
0
Robert SchuttSoftware EngineerCommented:
I just remembered at some point it gave good insight just into what is possible with the Chart object by downloading the samples from Microsoft: http://code.msdn.microsoft.com/Samples-Environments-for-b01e9c61/view/SamplePack#content

Your new question I'm afraid I have no answer, hopefully somebody with more experience regarding skins/styles will step in. All I see is setting a normal border, not that nice one.
0
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Thank you.

Mie
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.