modify chart c#

I have good solutions from Robert Schutt at:

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

In my posts,I have used two different chart samples. Now I am having a bit trouble consolidating the solutions.

Question How can I consolidate solution 1 through 6 with the code below it?

Thank you.
            // 1 don't show grid*********************************************************
            chartImage.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
           chartImage.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
           chartImage.ChartAreas[0].BorderWidth = 1;

           // 2 remove y labels?********************************************************
            chartImage.ChartAreas[0].AxisY.LabelStyle.Enabled = false;

            // 3 show value*************************************************************
            chartImage.Series[0].IsValueShownAsLabel = true;
            chartImage.Series[0].LabelForeColor = System.Drawing.Color.Blue;

            // 4 rotate x labels**********************************************************
           chartImage.ChartAreas[0].AxisX.LabelStyle.Angle = 90;

           //5.remove tick marks and add border*************************************
           chartImage.ChartAreas[0].AxisY.MajorTickMark.Enabled = false;

           //6. add border************************************************************
           chartImage.ChartAreas[0].BorderDashStyle = ChartDashStyle.Solid;
           chartImage.ChartAreas[0].BorderColor = System.Drawing.Color.DeepPink;

The above solutions (1-6) to be included with:
       double[] yValues = { 15, 60, 12, 13 };   //for column chart
        double[] yValues2 = { 30, 32, 30, 0 };   //for line
        string[] xValues = { "September", "October", "November", "December" };

        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 = 5; // 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);

        chart.Series["Default"].Points.DataBindXY(xValues, yValues);
        chart.Series["Default2"].Points.DataBindXY(xValues, yValues2);
        chart.Series["Default"].Color = System.Drawing.Color.Blue; // change default if you want to
        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;

        chart.ChartAreas.Add(chartArea);

        chart.Width = new Unit(300, UnitType.Pixel);
        chart.Height = new Unit(200, UnitType.Pixel);
        string filename = "C:\\image\\Chart.png";
        chart.SaveImage(filename, ChartImageFormat.Png);

Open in new window

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:
Well the main thing would be that you can only set properties on the series and chartAreas after they have been created. In this case it's probably nicer to use the variables you create for that instead of the indexed properties of the Chart object. Question is if both series need to have a label shown which might overlap (see the comment in the code below). All in all it should be something like this:
            double[] yValues = { 15, 60, 12, 13 };   //for column chart
            double[] yValues2 = { 30, 32, 30, 0 };   //for line
            string[] xValues = { "September", "October", "November", "December" };

            Chart chart = new Chart();

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

            // 3 show value*************************************************************
            series.IsValueShownAsLabel = true;
            series.LabelForeColor = System.Drawing.Color.Blue;

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

            // also show value label for series2?
            //series2.IsValueShownAsLabel = true;
            //series2.LabelForeColor = System.Drawing.Color.Purple;

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

            chart.Series["Default"].Points.DataBindXY(xValues, yValues);
            chart.Series["Default2"].Points.DataBindXY(xValues, yValues2);
            chart.Series["Default"].Color = System.Drawing.Color.Blue; // change default if you want to
            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;

            // 1 don't show grid*********************************************************
            chartArea.AxisX.MajorGrid.Enabled = false;
            chartArea.AxisY.MajorGrid.Enabled = false;
            chartArea.BorderWidth = 1;

            // 2 remove y labels?********************************************************
            chartArea.AxisY.LabelStyle.Enabled = false;

            // 4 rotate x labels**********************************************************
            chartArea.AxisX.LabelStyle.Angle = 90;

            //5.remove tick marks and add border*************************************
            chartArea.AxisY.MajorTickMark.Enabled = false;

            //6. add border************************************************************
            chartArea.BorderDashStyle = ChartDashStyle.Solid;
            chartArea.BorderColor = System.Drawing.Color.DeepPink;

            chart.ChartAreas.Add(chartArea);

            chart.Width = new Unit(300, UnitType.Pixel);
            chart.Height = new Unit(200, UnitType.Pixel);
            string filename = "C:\\image\\Chart.png";
            chart.SaveImage(filename, ChartImageFormat.Png);

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.

There is yet another question turning these charts to dynamic data source. If interested please see:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_28490316.html


Regards,

Mike
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.