Beispiel #1
0
        }//Method

        public void CreateYAxis(System.Web.UI.DataVisualization.Charting.Chart chart, System.Web.UI.DataVisualization.Charting.ChartArea area, Series series, float axisOffset, float labelsSize)
        {
            area.Position          = new ElementPosition(axisOffset, 20, 100 - axisOffset, 80);
            area.InnerPlotPosition = new ElementPosition(labelsSize, 0, 100 - axisOffset - labelsSize, 80);

            // Create new chart area for original series

            System.Web.UI.DataVisualization.Charting.ChartArea areaSeries = chart.ChartAreas.Add("ChartArea_" + series.Name);
            areaSeries.BackColor   = Color.Transparent;
            areaSeries.BorderColor = Color.Transparent;
            areaSeries.Position.FromRectangleF(area.Position.ToRectangleF());
            areaSeries.InnerPlotPosition.FromRectangleF(area.InnerPlotPosition.ToRectangleF());
            areaSeries.AxisX.MajorGrid.Enabled     = false;
            areaSeries.AxisX.MajorTickMark.Enabled = false;
            areaSeries.AxisX.LabelStyle.Enabled    = false;
            areaSeries.AxisY.MajorGrid.Enabled     = false;
            areaSeries.AxisY.MajorTickMark.Enabled = false;
            areaSeries.AxisY.LabelStyle.Enabled    = false;
            areaSeries.AxisY.IsStartedFromZero     = area.AxisY.IsStartedFromZero;

            series.ChartArea = areaSeries.Name;

            // Create new chart area for axis
            System.Web.UI.DataVisualization.Charting.ChartArea areaAxis = chart.ChartAreas.Add("AxisY_" + series.ChartArea);
            areaAxis.BackColor   = Color.Transparent;
            areaAxis.BorderColor = Color.Transparent;
            areaAxis.Position.FromRectangleF(chart.ChartAreas[series.ChartArea].Position.ToRectangleF());
            areaAxis.InnerPlotPosition.FromRectangleF(chart.ChartAreas[series.ChartArea].InnerPlotPosition.ToRectangleF());

            // Create a copy of specified series
            Series seriesCopy = chart.Series.Add(series.Name + "_Copy");

            seriesCopy.ChartType = series.ChartType;
            foreach (DataPoint point in series.Points)
            {
                seriesCopy.Points.AddXY(point.XValue, point.YValues[0]);
            }

            // Hide copied series
            seriesCopy.IsVisibleInLegend = false;
            seriesCopy.Color             = Color.Transparent;
            seriesCopy.BorderColor       = Color.Transparent;
            seriesCopy.ChartArea         = areaAxis.Name;

            // IsDisable grid lines & tickmarks
            areaAxis.AxisX.LineWidth             = 0;
            areaAxis.AxisX.MajorGrid.Enabled     = false;
            areaAxis.AxisX.MajorTickMark.Enabled = false;
            areaAxis.AxisX.LabelStyle.Enabled    = false;
            areaAxis.AxisY.MajorGrid.Enabled     = false;
            areaAxis.AxisY.IsStartedFromZero     = area.AxisY.IsStartedFromZero;
            areaAxis.AxisY.LineColor             = series.Color;
            areaAxis.AxisY.LabelStyle.ForeColor  = series.Color;
            // Adjust area position


            areaAxis.Position.X          -= axisOffset;
            areaAxis.InnerPlotPosition.X += labelsSize;
        } //Method
Beispiel #2
0
        public FileResult ChartSample()
        {
            var chart = new System.Web.UI.DataVisualization.Charting.Chart();

            chart.BackColor = System.Drawing.Color.Transparent;
            chart.BackColor = System.Drawing.Color.FromArgb(0, 0, 0);

            chart.Width  = System.Web.UI.WebControls.Unit.Pixel(250);
            chart.Height = System.Web.UI.WebControls.Unit.Pixel(2500);

            var series = new System.Web.UI.DataVisualization.Charting.Series();

            series.ChartArea = "ca1";



            series.ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;
            //series.Font = new Font("Verdana", 8.25f, FontStyle.Regular);

            System.Random myRandom = new System.Random();

            for (int i = 0; i < 100; i++)
            {
                var dp = new System.Web.UI.DataVisualization.Charting.DataPoint();
                dp.AxisLabel = String.Format("{0}-{1}", i, Guid.NewGuid().ToString().Substring(0, 4));
                dp.YValues   = new double[] { myRandom.Next(5, 100) };
                series.Points.Add(dp);
            } // Next i


            chart.Series.Add(series);

            var area = new System.Web.UI.DataVisualization.Charting.ChartArea("ca1");

            area.Area3DStyle.Enable3D = false;
            area.AxisX.Interval       = 1;
            //area.BackColor = Color.Transparent;
            //var labelStyle = new LabelStyle();
            //labelStyle.Enabled = true;
            //labelStyle.Font = new Font("Arial", 3f);
            area.AxisX.LabelStyle.Font = new System.Drawing.Font("Verdana", 8.25f, System.Drawing.FontStyle.Underline);//Why does it recognize the style but not the font!!!???

            area.BackColor = System.Drawing.Color.Red;
            //area.BackColor = System.Drawing.Color.White;

            chart.ChartAreas.Add(area);

            /*
             * using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
             * {
             *  chart.SaveImage(ms, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png);
             *  ms.Seek(0, System.IO.SeekOrigin.Begin);
             *
             *  return File(ms.ToArray(), "image/png", "mychart.png");
             * } // End Using ms
             */
            return(Chart2Image(chart));
        } // End Action ChartSample
Beispiel #3
0
        // Notes on ApplyXXX methods:
        // Chart elements should be configured before they are added to the chart, otherwise there
        // will be some rendering problems.
        // We must catch all exceptions when configuring chart elements and dispose of them manually
        // if they have not been added to the chart yet, otherwise FxCop will complain.

        private void ApplyChartArea(DV.Chart chart)
        {
            DV.ChartArea chartArea = new DV.ChartArea("Default");
            try {
                ApplyAxis(chartArea.AxisX, _xAxis);
                ApplyAxis(chartArea.AxisY, _yAxis);
                chart.ChartAreas.Add(chartArea);
            }
            catch {
                // This is to appease FxCop
                chartArea.Dispose();
                throw;
            }
        }
Beispiel #4
0
        private void SetChartData_(XChart xChart)
        {
            Title title = msChart.Titles.Add("aaaa");

            title.Text = "测试图表";

            msChart.Series.Clear();

            Legend lg = msChart.Legends.FindByName("Default");

            if (lg == null)
            {
                lg = new Legend("Default");
                msChart.Legends.Add(lg);
            }

            try
            {
                lg.Docking = Docking.Top;
            }
            catch { }

            try
            {
                lg.Alignment = StringAlignment.Center;
            }
            catch { }

            lg.LegendStyle = LegendStyle.Column;

            lg.LegendStyle = LegendStyle.Row;



            //lg.Alignment = StringAlignment.Near;
            //lg.Position.X = 0;
            //lg.Position.Y = 0;
            lg.Title     = "xxxxx";
            lg.BackColor = Color.Transparent;

            if (msChart.Titles.Count < 1)
            {
                msChart.Titles.Add("Chart");
            }

            msChart.Width  = 300;
            msChart.Height = 300;

            System.Web.UI.DataVisualization.Charting.ChartArea area = msChart.ChartAreas.Add("Default");

            //            System.Web.UI.DataVisualization.Charting.ChartArea area = chart.ChartAreas[0];



            area.Area3DStyle.Enable3D = true;
            //  area.AxisY.IsLogarithmic = true;
            //  area.AxisX.IsLogarithmic = true;

            //            area.AxisX.Interval = 0;
            area.AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
            area.AxisX.IsMarginVisible  = false;
            area.BackColor = Color.Pink;
            // area.AxisX.

            //            area.AxisX.Interval = 1;
            Series a = msChart.Series.Add("a");

            a.Legend    = "Default";
            a.ChartArea = "Default";
            a.Points.AddXY(1, 23);

            a.Points.AddXY(2, 84);
            a.Points.AddXY(3, 45);
            a.Points.AddXY(4, 245);
            a.Points.AddXY(5, 34);
            a.Points.AddXY(6, 34);
            a.Points.AddXY(7, 33);
            //            a.PostBackValue = "#AXISLABEL";
            a.PostBackValue = "xxxxxxx";
            a.ToolTip       = "#LEGENDTEXT \n" +
                              "X轴:#VALX\n" +
                              "Y轴:#VAL";
        }
Beispiel #5
0
        }//Method

        private void ShowReverseSeries(DataSource table, System.Web.UI.DataVisualization.Charting.ChartArea area)
        {
            //   area.AxisX.LabelStyle.Enabled = false;
            area.AxisX.LabelStyle.Interval = 0;
            area.AxisX.IntervalAutoMode    = IntervalAutoMode.FixedCount;

            string[]    xValues = null;
            ChartSchema schema  = xChart.Schema;

            if (table != null && !String.IsNullOrEmpty(schema.XField))
            {
                xValues = table.GetFieldData(schema.XField);
            }
            if (xValues == null)
            {
                return;
            }
            if (schema.SeriesList.Count < 1)
            {
                return;
            }
            SeriesSchema se0 = schema.SeriesList[0];

            area.AxisY.IsStartedFromZero = se0.IsFromY0;

            Dictionary <string, string[]> YDatas = new Dictionary <string, string[]>();

            foreach (SeriesSchema se in schema.SeriesList)
            {
                string[] values = new string[0];
                try
                {
                    values = table.GetFieldData(se.Id);
                }
                catch { }
                YDatas.Add(se.Id, values);
            }


            for (int i = 0; i < xValues.Length; i++)
            {
                string name = xValues[i];
                if (area.AxisX.IntervalType != DateTimeIntervalType.Auto &&
                    area.AxisX.IntervalType != DateTimeIntervalType.NotSet &&
                    area.AxisX.IntervalType != DateTimeIntervalType.Number)
                {
                    try { name = DateTime.Parse(name).ToString(area.AxisX.LabelStyle.Format); }
                    catch { }
                }
                if (string.IsNullOrEmpty(name) || name.Equals("null"))
                {
                    name = xValues[i];
                }
                Series series = msChart.Series.Add(name);
                series.Legend = "Default";

                series.ChartType   = (SeriesChartType)se0.ChartType;
                series.Color       = ToColor(se0.Color);
                series.MarkerStyle = (System.Web.UI.DataVisualization.Charting.MarkerStyle)se0.MarkerStyle;
                //  series.AxisLabel=
                //series.ChartArea = se.Area;
                series.BorderWidth = se0.LineWidth;
                series.Points.Clear();
                foreach (string k in YDatas.Keys)
                {
                    double v = 0;
                    string x = table.FieldCaptions[k];
                    if (x == null || x == "")
                    {
                        x = k;
                    }

                    try { v = double.Parse(YDatas[k][i]); }
                    catch { }

                    int j = series.Points.AddY(v);
                    series.Points[j].AxisLabel = x;
                }
            }
        }//Method
Beispiel #6
0
        private void SetChartData(XChart xChart)
        {
            ChartSchema schema = xChart.Schema;

            DataSource table = null;

            if (!String.IsNullOrEmpty(schema.DataSource))
            {
                table = new DataSource(schema.DataSource);
                //    table.RefreshData();
                //    table.PageSize = 100;
            }

            //    Dictionary<string, ListData<string>> keyValues = table.FieldValues;
            //    Dictionary<string, string> captions = table.FieldCaptions;

            //    msChart.ChartAreas.Clear();
            //   msChart.ChartAreas[0].
            //  msChart.ChartAreas[0].Area3DStyle=ChartArea3DStyle.
            msChart.Series.Clear();

            Legend lg = msChart.Legends.FindByName("Default");

            if (lg == null)
            {
                lg = new Legend("Default");
                msChart.Legends.Add(lg);
            }

            try
            {
                lg.Docking = (Docking)int.Parse(schema.LegenPos);
            }
            catch { }

            try
            {
                lg.Alignment = (StringAlignment)int.Parse(schema.LegenAlign);
            }
            catch { }

            lg.LegendStyle = LegendStyle.Column;
            if (schema.LegenH)
            {
                lg.LegendStyle = LegendStyle.Row;
            }



            //lg.Alignment = StringAlignment.Near;
            //lg.Position.X = 0;
            //lg.Position.Y = 0;


            if (msChart.Titles.Count < 1)
            {
                msChart.Titles.Add("Chart");
            }
            Title title = msChart.Titles[0];

            title.Text = schema.Title;
            try
            {
                title.Alignment = (ContentAlignment)int.Parse(schema.TitlePos);
            }
            catch
            {
                title.Alignment = ContentAlignment.TopCenter;
            }

            //            if (schema.Width > 200)
            msChart.Width = schema.Width;
            //   if (schema.Width > 710)
            //       msChart.Width = 710;

            if (schema.Height > 100)
            {
                msChart.Height = schema.Height;
            }


            //            System.Web.UI.DataVisualization.Charting.ChartArea area = msChart.ChartAreas[0];
            msChart.ChartAreas.Clear();
            System.Web.UI.DataVisualization.Charting.ChartArea area = msChart.ChartAreas.Add("Default");

            if (!string.IsNullOrEmpty(schema.BackColor))
            {
                msChart.BackColor = ToColor(schema.BackColor);
            }

            if (!string.IsNullOrEmpty(xChart.AreaBackColor))
            {
                area.BackColor = ToColor(xChart.AreaBackColor);
            }


            area.Area3DStyle.Enable3D = schema.Is3D;
            //  area.AxisY.IsLogarithmic = true;
            //  area.AxisX.IsLogarithmic = true;

            //            area.AxisX.Interval = 0;
            area.AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
            area.AxisX.IsMarginVisible  = false;
            // area.AxisX.

            area.AxisX.Interval = schema.XInterval;

            try
            {
                area.AxisX.IntervalType = (DateTimeIntervalType)int.Parse(schema.XIntervalUnit);
            }
            catch
            {
                area.AxisX.IntervalType = DateTimeIntervalType.Auto;
            }

            area.AxisX.IsLabelAutoFit    = true;
            area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont | LabelAutoFitStyles.IncreaseFont |
                                           LabelAutoFitStyles.LabelsAngleStep90 | LabelAutoFitStyles.LabelsAngleStep45 |
                                           LabelAutoFitStyles.LabelsAngleStep30;

            area.AxisX.LabelStyle.Enabled = true;
            area.AxisX.LabelStyle.Format  = schema.XLableFormat;

            //  lg.



            //            area.AxisX.IntervalAutoMode = IntervalAutoMode.FixedCount;

            //            area.AxisX.IntervalOffsetType =DateTimeIntervalType.Minutes;

            if (schema.AreaList[0].MinY == float.NaN || schema.AreaList[0].MaxY == float.NaN || schema.AreaList[0].MaxY == 0 || schema.AreaList[0].MinY == 0)
            {
                area.AxisY.Minimum = Double.NaN;
                area.AxisY.Maximum = Double.NaN;
            }
            else
            {
                // area.AxisY.IsLogarithmic = true;
                area.AxisY.Minimum = schema.AreaList[0].MinY;
                area.AxisY.Maximum = schema.AreaList[0].MaxY;
            }


            string[] xValues = null;
            if (table != null && !String.IsNullOrEmpty(schema.XField))
            {
                xValues = table.GetFieldData(schema.XField);
            }


            area.AxisX.MajorGrid.Enabled   = schema.ShowGridHLine;
            area.AxisX.MajorGrid.LineColor = ToColor(schema.GridHLineColor);
            area.AxisX.MajorGrid.LineWidth = schema.GridHLineWidth;

            area.AxisY.MajorGrid.Enabled   = schema.ShowGridVLine;
            area.AxisY.MajorGrid.LineColor = ToColor(schema.GridVLineColor);
            area.AxisY.MajorGrid.LineWidth = schema.GridVLineWidth;

            int mutYOffset = MutiYOffSetUnit;

            if (xChart.XYReverse)
            {
                ShowReverseSeries(table, area);
            }
            else
            {
                foreach (SeriesSchema se in schema.SeriesList)
                {
                    Series series = msChart.Series.Add(se.Id);
                    series.ChartType   = (SeriesChartType)se.ChartType;
                    series.Color       = ToColor(se.Color);
                    series.MarkerStyle = (System.Web.UI.DataVisualization.Charting.MarkerStyle)se.MarkerStyle;
                    //  series.AxisLabel=
                    series.ChartArea             = area.Name;
                    series.BorderWidth           = se.LineWidth;
                    series.Legend                = "Default";
                    series.YAxisType             = AxisType.Primary;
                    area.AxisY.IsStartedFromZero = se.IsFromY0;
                    // series.
                    if (se.UsingY2)
                    {
                        series.YAxisType                 = AxisType.Secondary;
                        area.AxisY2.LineColor            = series.Color;
                        area.AxisY2.LabelStyle.ForeColor = series.Color;
                        area.AxisY2.IsStartedFromZero    = se.IsFromY0;
                    }
                    if (table != null)
                    {
                        try
                        {
                            series.LegendText = table.FieldCaptions[se.Id];
                        }
                        catch
                        {
                            series.LegendText = se.Id;
                        }


                        string[] values     = new string[0];
                        string[] valuesUp   = new string[0];
                        string[] valuesDown = new string[0];

                        int count = 0;
                        try { values = table.GetFieldData(se.Id); }
                        catch { }
                        if (values != null)
                        {
                            count = values.Length;
                        }

                        try { valuesUp = table.GetFieldData(se.UpSeries); }
                        catch { }
                        if (valuesUp != null && valuesUp.Length > count)
                        {
                            count = valuesUp.Length;
                        }

                        try { valuesDown = table.GetFieldData(se.DownSeries); }
                        catch { }
                        if (valuesDown != null && valuesDown.Length > count)
                        {
                            count = valuesDown.Length;
                        }



                        for (int i = 0; i < count; i++)
                        {
                            double v = 0;
                            try
                            {
                                v = double.Parse(values[i]);
                            }
                            catch { }

                            double vUp = 0;
                            try
                            {
                                vUp = double.Parse(valuesUp[i]);
                            }
                            catch { }

                            double vDown = 0;
                            try
                            {
                                vDown = double.Parse(valuesDown[i]);
                            }
                            catch { }

                            object x = i;
                            try { x = xValues[i]; }
                            catch { }

                            if (area.AxisX.IntervalType != DateTimeIntervalType.Auto &&
                                area.AxisX.IntervalType != DateTimeIntervalType.NotSet &&
                                area.AxisX.IntervalType != DateTimeIntervalType.Number)
                            {
                                try { x = DateTime.Parse(xValues[i]); }
                                catch { }
                            }
                            else
                            {
                                try { x = Double.Parse(xValues[i]); }
                                catch { }
                            }



                            switch (series.ChartType)
                            {
                            case SeriesChartType.SplineRange:
                            case SeriesChartType.Range:
                            case SeriesChartType.RangeColumn:
                            case SeriesChartType.RangeBar:
                                //  series.Points.AddY(vUp, vDown);
                                series.Points.AddXY(x, vUp, vDown);
                                break;

                            default:
                                series.Points.AddXY(x, v);
                                break;
                            }

                            //     if (xValues != null)
                            //         series.Points[i].AxisLabel = xValues[i];
                        }

                        //       Legend lg = new Legend(se.Id);
                        // lg.s
                        //       msChart.Legends.Add(lg);
                        //     lg.Title = table.FieldCaptions[se.Id];
                        //msChart.Legends[se.Id].Title = table.FieldCaptions[se.Id];
                    }
                    if (se.CreateAxisY && !se.UsingY2)
                    {
                        this.CreateYAxis(msChart, area, series, mutYOffset, MutiYOffSetUnit);
                        mutYOffset += MutiYOffSetUnit;
                    }

                    series.PostBackValue = "#AXISLABEL";
                    series.ToolTip       = "#LEGENDTEXT \n" +
                                           "X轴:#VALX\n" +
                                           "Y轴:#VAL";
                }
            }
            //msChart.Style=

            //    foreach (BI.Schema.ChartArea areaSch in schema.AreaList)
            //    {
            //        System.Web.UI.DataVisualization.Charting.ChartArea chartArea = msChart.ChartAreas.Add(areaSch.Id);
            //    }
        }//Method
Beispiel #7
0
        // http://stackoverflow.com/questions/6047961/c-sharp-chart-rotate-labels
        public FileResult RadarSample()
        {
            int pixelWidth  = 1000;
            int pixelHeight = 1000;

            // Populate series data
            //string[] xValues = { "France", "Canada", "Germany", "USA", "Italy", "Spain", "Russia", "Sweden", "Japan" };

            string[] xValues = { "Offene\nAussenpolitik", "Liberale\nWirtschaftspolitik", "Restriktive\nFinanzpolitik", "Law & Order", "Restriktive\nMigrationspolitik", "Ausgebauter\nUmweltschutz", "Ausgebauter\nSozialstaat", "Liberale\nGesellschaft" };
            double[] yValues = { 80, 90, 45, 75, 37.5, 40, 28, 54 };


            //double[] yValues = { 65.62, 75.54, 60.45, 34.73, 85.42, 55.9, 63.6, 55.1, 77.2 };
            //double[] yValues2 = { 76.45, 23.78, 86.45, 30.76, 23.79, 35.67, 89.56, 67.45, 38.98 };


            var Chart1 = new System.Web.UI.DataVisualization.Charting.Chart();


            var area = new System.Web.UI.DataVisualization.Charting.ChartArea("ca1");

            area.Area3DStyle.Enable3D = false;
            //area.AxisX.Interval = 1;


            Chart1.BackColor = System.Drawing.Color.HotPink;
            Chart1.BackColor = System.Drawing.Color.White;

            area.BackColor = System.Drawing.Color.Red;
            area.BackColor = System.Drawing.Color.Transparent;

            //area.AxisY.Interval = 5;

            area.AxisY.MajorTickMark.Enabled = false;
            area.AxisY.MajorGrid.LineColor   = Color.Gray;
            area.AxisY.MajorGrid.Interval    = 25;

            area.AxisY.MinorTickMark.Enabled = false;
            area.AxisY.MinorGrid.Interval    = 5;
            area.AxisY.MinorGrid.LineColor   = Color.Yellow;

            Chart1.ChartAreas.Add(area);


            var series1 = new System.Web.UI.DataVisualization.Charting.Series();
            var series2 = new System.Web.UI.DataVisualization.Charting.Series();

            series1.Name = "Series1";
            series2.Name = "Series2";

            //series1.Color = System.Drawing.Color.Yellow;
            series1.Color = System.Drawing.Color.FromArgb(100, 84, 130, 255);
            series1.SmartLabelStyle.Enabled = true;
            //series1.LabelAngle = 90;

            //Legend legend = new Legend();

            ////legend.Name = "mylegend";
            //legend.Title = "Hello world";
            //legend.BackColor = Color.Transparent;
            //legend.BackColor = Color.Tomato;

            //Chart1.Legends.Add(legend);


            // series1.Legend = "mylegend";
            series1.LegendText = "A";
            series2.LegendText = "B";

            // series1.Label = "kickme";
            // series2.Label = "bar";

            //series1.ChartArea = "ca1";

            series1.ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Radar;
            series2.ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Radar;

            series1.ChartArea = "ca1";
            series2.ChartArea = "ca1";


            Chart1.Series.Add(series1);
            //Chart1.Series.Add(series2);


            Chart1.Series["Series1"].Points.DataBindXY(xValues, yValues);
            //Chart1.Series["Series2"].Points.DataBindXY(xValues, yValues2);

            Chart1.Series["Series1"].SmartLabelStyle.Enabled = false;
            // Chart1.ChartAreas[0].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep30;
            // Chart1.ChartAreas[0].AxisX.LabelStyle.Angle = 30;

            Chart1.ChartAreas[0].Axes[0].CustomLabels.Add((double)0, (double)0, "hello");
            Chart1.ChartAreas[0].Axes[0].CustomLabels.Add((double)1, (double)0, "bar");



            for (int i = 0; i < Chart1.ChartAreas[0].Axes[0].CustomLabels.Count; ++i)
            {
                Chart1.ChartAreas[0].Axes[0].CustomLabels[0].Axis.TextOrientation = TextOrientation.Rotated90;
            }

            for (int i = 0; i < Chart1.Series["Series1"].Points.Count; ++i)
            {
                Chart1.Series["Series1"].Points[i].LabelAngle     = -30;
                Chart1.Series["Series1"].Points[i].LabelBackColor = System.Drawing.Color.Turquoise;
                //Chart1.Series["Series1"].Points[i].AxisLabel = "This works";
                Chart1.Series["Series1"].IsValueShownAsLabel = true;
            }


            /*
             *  foreach (DataPoint dp2 in Chart1.Series["Series1"].Points)
             *  {
             *      Console.WriteLine(dp2);
             *      //series1.SmartLabelStyle.Enabled = true;
             *
             *      dp2.LabelAngle = 30;
             *  }
             *
             * DataPoint dp = new DataPoint(0, 0);
             * dp.AxisLabel = "hollavballoo";
             * dp.LabelAngle = 30;
             */

            //series1.Points.Add(dp);



            string[] astrRadarStyleList       = new string[] { "Area", "Line", "Marker" }; // Fill, Line, or point
            string[] astrAreaDrawingStyleList = new string[] { "Circle", "Polygon" };      // Shape
            string[] astrLabelStyleList       = new string[] { "Circular", "Radial", "Horizontal" };



            string strRadarStyle       = astrRadarStyleList[0];
            string strAreaDrawingStyle = astrAreaDrawingStyleList[0];
            string strLabelStyle       = astrLabelStyleList[0];


            Chart1.Width  = System.Web.UI.WebControls.Unit.Pixel(pixelWidth);
            Chart1.Height = System.Web.UI.WebControls.Unit.Pixel(pixelHeight);


            // Set radar chart style
            Chart1.Series["Series1"]["RadarDrawingStyle"] = strRadarStyle; // RadarStyleList.SelectedItem.Text;
            //Chart1.Series["Series2"]["RadarDrawingStyle"] = strRadarStyle; // RadarStyleList.SelectedItem.Text;



            if (strRadarStyle == "Area")
            {
                Chart1.Series["Series1"].BorderColor = Color.FromArgb(100, 100, 100);
                Chart1.Series["Series1"].BorderWidth = 1;
                // Chart1.Series["Series2"].BorderColor = Color.FromArgb(100, 100, 100);
                // Chart1.Series["Series2"].BorderWidth = 1;
            }
            else if (strRadarStyle == "Line")
            {
                Chart1.Series["Series1"].BorderColor = Color.Empty;
                Chart1.Series["Series1"].BorderWidth = 2;
                // Chart1.Series["Series2"].BorderColor = Color.Empty;
                // Chart1.Series["Series2"].BorderWidth = 2;
            }
            else if (strRadarStyle == "Marker")
            {
                Chart1.Series["Series1"].BorderColor = Color.Empty;
                // Chart1.Series["Series2"].BorderColor = Color.Empty;
            }

            // Set circular area drawing style
            Chart1.Series["Series1"]["AreaDrawingStyle"] = strAreaDrawingStyle; // AreaDrawingStyleList.SelectedItem.Text;
            //Chart1.Series["Series2"]["AreaDrawingStyle"] = strAreaDrawingStyle; // AreaDrawingStyleList.SelectedItem.Text;



            // Set labels style
            //Chart1.Series["Series1"]["CircularLabelsStyle"] = strLabelStyle; // LabelStyleList.SelectedItem.Text;
            //Chart1.Series["Series2"]["CircularLabelsStyle"] = strLabelStyle; //LabelStyleList.SelectedItem.Text;

            return(Chart2Image(Chart1));
        }
Beispiel #8
0
        public async Task<MemoryStream>  LoadQSORateChart(ChartCtlDataSettingsDto ChartCtlDataSettingsDto, IRepositoryAsync<Log> LogRepository, string username)
        {
            MemoryStream MemoryStream = null; 
            bool bOK = true;

            IList<ContestInfoDTO> ContestInfosDTOList = new List<ContestInfoDTO>();
            LoadContestInfoDTO(ChartCtlDataSettingsDto, ContestInfosDTOList,  LogRepository, username);

            //set ContestInfoDTO
            ContestInfoDTO ContestInfoDTO1 = ContestInfosDTOList.Where(c => c.CallGroup == common.Enum.CallGroupEnum.CALL1).FirstOrDefault();
            ContestInfoDTO ContestInfoDTO2 = ContestInfosDTOList.Where(c => c.CallGroup == common.Enum.CallGroupEnum.CALL2).FirstOrDefault();
            ContestInfoDTO ContestInfoDTO3= ContestInfosDTOList.Where(c => c.CallGroup == common.Enum.CallGroupEnum.CALL3).FirstOrDefault();

            ChartQuery ChartQuery = new Charting.ChartQuery();
            ChartAreaInfoParams ChartAreaParams = new ChartAreaInfoParams();
            //CHART
            QSORateChart = new System.Web.UI.DataVisualization.Charting.Chart()
            {
                ID = "QSORateChart",
                Height = new System.Web.UI.WebControls.Unit("400px"),
                //ImageStorageMode = System.Web.UI.DataVisualization.Charting.ImageStorageMode.UseImageLocation,
                RenderType = RenderType.BinaryStreaming,

                BackColor = Color.FromArgb(0xFF, 0xC9, 0xEC, 0xFE),
                Width = new System.Web.UI.WebControls.Unit("984px"),
                AntiAliasing = System.Web.UI.DataVisualization.Charting.AntiAliasingStyles.All,
                TextAntiAliasingQuality = System.Web.UI.DataVisualization.Charting.TextAntiAliasingQuality.High
            };
            QSORateChart.CustomizeLegend += QSORateChart_CustomizeLegend;
            //QSORateChart.Customize += QSORateChart_Customize;
            //TITLES
            Title TitleChartName = new System.Web.UI.DataVisualization.Charting.Title()
            {
                Name = "ChartName",
                TextStyle = System.Web.UI.DataVisualization.Charting.TextStyle.Emboss,
                ForeColor = Color.FromArgb(0xFF, 0, 99, 99),
                Font =  new System.Drawing.Font(new System.Drawing.FontFamily("Microsoft Sans Serif"), 22)
            };
            Title TitleTkey3 = new System.Web.UI.DataVisualization.Charting.Title()
            {
                Name = "Tkey3",
                TextStyle = System.Web.UI.DataVisualization.Charting.TextStyle.Emboss,
                ForeColor = Color.FromArgb(0xFF, 0, 99, 99),
                Font = new System.Drawing.Font(new System.Drawing.FontFamily("Courier New"), 10),
                Alignment = ContentAlignment.BottomLeft,
                Docking = System.Web.UI.DataVisualization.Charting.Docking.Bottom,
                DockingOffset = 2
            };
            Title TitleTkey2 = new System.Web.UI.DataVisualization.Charting.Title()
            {
                Name = "Tkey2",
                TextStyle = System.Web.UI.DataVisualization.Charting.TextStyle.Emboss,
                ForeColor = Color.FromArgb(0xFF, 0, 99, 99),
                Font = new System.Drawing.Font(new System.Drawing.FontFamily("Courier New"), 10),
                Alignment = ContentAlignment.BottomLeft,
                Docking = System.Web.UI.DataVisualization.Charting.Docking.Bottom,
                DockingOffset = 4
            };
            Title TitleTkey1 = new System.Web.UI.DataVisualization.Charting.Title()
            {
                Name = "Tkey1",
                TextStyle = System.Web.UI.DataVisualization.Charting.TextStyle.Emboss,
                ForeColor = Color.FromArgb(0xFF, 0, 99, 99),
                Font = new System.Drawing.Font(new System.Drawing.FontFamily("Courier New"), 10),
                Alignment = ContentAlignment.BottomLeft,
                Docking = System.Web.UI.DataVisualization.Charting.Docking.Bottom,
                DockingOffset = 6
            };
            Title TitleCorp = new System.Web.UI.DataVisualization.Charting.Title()
            {
                Name = "Corp",
                TextStyle = System.Web.UI.DataVisualization.Charting.TextStyle.Default,
                ForeColor = Color.Blue,
                Font = new System.Drawing.Font(new System.Drawing.FontFamily("Trebuchet MS"), 8.25f),
                Alignment = ContentAlignment.BottomRight,
                Url = "http://www.psws.com",
                Text="© PSWS.com",
                Docking = System.Web.UI.DataVisualization.Charting.Docking.Bottom,
                DockingOffset = 18
            };
            Title TitleVersion = new System.Web.UI.DataVisualization.Charting.Title()
            {
                Name = "Vers",
                TextStyle = System.Web.UI.DataVisualization.Charting.TextStyle.Default,
                ForeColor = Color.Black,
                Font = new System.Drawing.Font(new System.Drawing.FontFamily("Trebuchet MS"), 8.25f),
                Alignment = ContentAlignment.BottomRight,
                Docking = System.Web.UI.DataVisualization.Charting.Docking.Bottom,
                DockingOffset = 20
            };

            QSORateChart.Titles.Add(TitleChartName);
            QSORateChart.Titles.Add(TitleTkey3);
            QSORateChart.Titles.Add(TitleTkey2);
            QSORateChart.Titles.Add(TitleTkey1);
            QSORateChart.Titles.Add(TitleCorp);
            QSORateChart.Titles.Add(TitleVersion);

            //LEGENDS
            Legend LegendLegend1 = new System.Web.UI.DataVisualization.Charting.Legend()
            {
                Name = "Legend1",
                TitleSeparator = System.Web.UI.DataVisualization.Charting.LegendSeparatorStyle.DoubleLine,
                BorderColor = Color.Black,
                BorderWidth = 1,
                LegendStyle = System.Web.UI.DataVisualization.Charting.LegendStyle.Row,
                IsEquallySpacedItems = true,
                IsTextAutoFit = false,
                TitleAlignment = StringAlignment.Center,
                BackGradientStyle = System.Web.UI.DataVisualization.Charting.GradientStyle.HorizontalCenter,
                BackColor = Color.FromArgb(0xFF, 0xEE, 0xEE, 0xEE),
                BackSecondaryColor = Color.White,
                Alignment = StringAlignment.Center,
                Docking = System.Web.UI.DataVisualization.Charting.Docking.Bottom,
                ItemColumnSeparator = System.Web.UI.DataVisualization.Charting.LegendSeparatorStyle.GradientLine,
                ItemColumnSpacing = 30,
                
            };
            QSORateChart.Legends.Add(LegendLegend1);

            //CHARTAREAS
            ChartArea ChartAreaChartArea1 = new System.Web.UI.DataVisualization.Charting.ChartArea()
            {
                Name = "ChartArea1",
                BackColor = Color.FromArgb(0xFF, 0x99, 0xCC, 0xFF),
                Area3DStyle = new System.Web.UI.DataVisualization.Charting.ChartArea3DStyle()
                {
                    Enable3D = false
                },
                BackGradientStyle = System.Web.UI.DataVisualization.Charting.GradientStyle.TopBottom,
                AxisX = new System.Web.UI.DataVisualization.Charting.Axis()
                {
                    LineWidth = 2,
                    MaximumAutoSize = 100,
                    Title = "Day-Time",
                    IsMarginVisible = true,
                    IntervalOffsetType = System.Web.UI.DataVisualization.Charting.DateTimeIntervalType.Auto,
                    IsStartedFromZero = false
                },
                AxisY = new System.Web.UI.DataVisualization.Charting.Axis()
                {
                    LineWidth = 0
                }

            };

            QSORateChart.ChartAreas.Add(ChartAreaChartArea1);

            // get from combobox
            ChartAreaParams.ChartPointInterval = Convert.ToInt32(ChartCtlDataSettingsDto.ControlSettingsDto.ControlYaxisSettingsDto.YaxisInterval);
            //ChartInfo
            int AlphaBlend;
            string YaxisViewtype = ChartCtlDataSettingsDto.ControlSettingsDto.ControlYaxisSettingsDto.YaxisViewType;
            if (YaxisViewtype.Contains("3D"))
            {
                //strip 3d
                string str = YaxisViewtype.Replace("3D", "");
                ChartAreaParams.charttype = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), str.Trim());
                QSORateChart.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
                QSORateChart.ChartAreas["ChartArea1"].Area3DStyle.PointDepth = 75;
                QSORateChart.ChartAreas["ChartArea1"].Area3DStyle.PointGapDepth = 75;
                //QSORateChart.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 20;
                //QSORateChart.ChartAreas["ChartArea1"].Area3DStyle.Rotation = 20;
                //QSORateChart.ChartAreas["ChartArea1"].ShadowColor = Color.Transparent;
                //QSORateChart.ChartAreas["ChartArea1"].Area3DStyle.LightStyle= LightStyle.Realistic;
                AlphaBlend = 220;
            }
            else
            {
                ChartAreaParams.charttype = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), YaxisViewtype);
                AlphaBlend = 0xff;
            }
            ChartAreaParams.ChartXaxisInterval = 1;
            ChartAreaParams.ChartXaxisIntervalType = DateTimeIntervalType.Hours;
            //tickmarks and grids.
            ChartAreaParams.MajorVerticalInterval = 24;
            ChartAreaParams.MinorVerticalInterval = 1;
            ChartAreaParams.AxisXMaxFudgeSeconds = 1;

            //check if all years the same
            MixedYears = SetMixedYears(ChartCtlDataSettingsDto.DataCallInfoDto, ContestInfoDTO1, ContestInfoDTO2, ContestInfoDTO3);
            // get from combo box
            ChartAreaParams.MixedYears = MixedYears;


            //ChartTickmarkInfo XMajorTickMarkObj = new ChartTickmarkInfo(ChartXaxisIntervalType, 24, 5, Color.Red, 2);
            ChartAreaDto ChartAreaDto = new ChartAreaDto(ChartAreaParams);

            TickMarkInfoParams TMinfo = new TickMarkInfoParams();
            GridInfoParams CgInfo = new GridInfoParams();
            //Major Vertical 
            TMinfo.IntervalType = ChartAreaDto.ChartXaxisIntervalType;
            TMinfo.Interval = ChartAreaDto.MajorHorizontalInterval;
            TMinfo.Size = 5;
            TMinfo.LineColor = Color.Red;
            TMinfo.LineWidth = 1;
            TMinfo.Style = TickMarkStyle.OutsideArea;

            ChartAreaDto.CreateChartTickmark(QSORateChart.ChartAreas["ChartArea1"].AxisX.MajorTickMark, ChartAreaDto.VerticalType.Major, TMinfo);

            CgInfo.IntervalType = ChartAreaDto.ChartXaxisIntervalType;// need  to set for lines to appear
            CgInfo.Interval = ChartAreaDto.MajorHorizontalInterval;
            CgInfo.LineColor = Color.Red;
            CgInfo.LineDashStyle = ChartDashStyle.Dot;
            CgInfo.LineWidth = 1;
            ChartAreaDto.CreateChartGrid(QSORateChart.ChartAreas["ChartArea1"].AxisX.MajorGrid, ChartAreaDto.VerticalType.Major, CgInfo);

            //Minor Vertical 
            TMinfo.IntervalType = ChartAreaDto.ChartXaxisIntervalType;
            TMinfo.Interval = ChartAreaDto.MinorHorizontalInterval;
            TMinfo.Size = 2;
            TMinfo.LineColor = Color.Black;
            TMinfo.LineWidth = 1;
            TMinfo.Style = TickMarkStyle.OutsideArea;

            ChartAreaDto.CreateChartTickmark(QSORateChart.ChartAreas["ChartArea1"].AxisX.MinorTickMark, ChartAreaDto.VerticalType.Minor, TMinfo);

            CgInfo.IntervalType = ChartAreaDto.ChartXaxisIntervalType;// need  to set for lines to appear
            CgInfo.Interval = ChartAreaDto.MinorHorizontalInterval;
            CgInfo.LineColor = Color.FromArgb(37, 0, 0, 0);
            CgInfo.LineDashStyle = ChartDashStyle.Solid;
            CgInfo.LineWidth = 1;
            ChartAreaDto.CreateChartGrid(QSORateChart.ChartAreas["ChartArea1"].AxisX.MinorGrid, ChartAreaDto.VerticalType.Minor, CgInfo);

            string QSOQuery = string.Empty;
            ContestViewParmsDTO ContestViewParmsDTO = null; //dummy
            //Series
            ICollection<SeriesObj> SerCollection = new System.Collections.ObjectModel.Collection<SeriesObj>();


            string YaxisFunction = ChartCtlDataSettingsDto.ControlSettingsDto.ControlYaxisSettingsDto.YaxisFunction;
            QSOLogFilter QSOFilter;
            QSOFilter = ChartQuery.GetQSOFilter(ChartCtlDataSettingsDto.ControlSettingsDto.ControlFiltersSettingsDto,
                                                ChartCtlDataSettingsDto.DataCallInfoDto);


            if (!string.IsNullOrEmpty(ChartCtlDataSettingsDto.DataCallInfoDto[0].SelectedCall) && !ChartCtlDataSettingsDto.DataCallInfoDto[0].Disabled)
            {
                QsoRadioStationFilter QsoRadioStationFilter = ChartQuery.GetQsoRadioStationFilter(ChartCtlDataSettingsDto.DataCallInfoDto[0]);
                ChartQuery.GetQuery(LogRepository, QSORateChart.ID, QSOFilter, QsoRadioStationFilter, ChartCtlDataSettingsDto.DataCallInfoDto[0], ChartCtlDataSettingsDto.ControlSettingsDto,
                    ContestInfoDTO1, ChartAreaDto, YaxisFunction, out ContestViewParmsDTO, username);
                SeriesObj Series1Obj = new SeriesObj(ContestInfoDTO1, Color.FromArgb(AlphaBlend, Color.Blue), ChartQuery.GetDataTableSQL);
                bOK = Series1Obj.Create(LogRepository, ChartAreaDto, QSORateChart.ID, ContestViewParmsDTO, username);
                if (bOK)
                {
                    QSORateChart.Series.Add(Series1Obj);
                    SerCollection.Add(Series1Obj);
                }
            }

            if (!string.IsNullOrEmpty(ChartCtlDataSettingsDto.DataCallInfoDto[1].SelectedCall) && !ChartCtlDataSettingsDto.DataCallInfoDto[1].Disabled)
            {
                QsoRadioStationFilter QsoRadioStationFilter = ChartQuery.GetQsoRadioStationFilter(ChartCtlDataSettingsDto.DataCallInfoDto[1]);
                ChartQuery.GetQuery(LogRepository, QSORateChart.ID, QSOFilter, QsoRadioStationFilter, ChartCtlDataSettingsDto.DataCallInfoDto[1], ChartCtlDataSettingsDto.ControlSettingsDto,
                    ContestInfoDTO2, ChartAreaDto, YaxisFunction, out ContestViewParmsDTO, username);
                SeriesObj Series2Obj = new SeriesObj(ContestInfoDTO2, Color.FromArgb(AlphaBlend, Color.OrangeRed), ChartQuery.GetDataTableSQL);
                bOK = Series2Obj.Create(LogRepository, ChartAreaDto, QSORateChart.ID, ContestViewParmsDTO, username);
                if (bOK)
                {
                    QSORateChart.Series.Add(Series2Obj);
                    //string st = QSORateChart.Series[Series2Obj.Name].ChartArea;
                    //QSORateChart.Series[Series2Obj.Name].ChartArea = Chart1.ChartAreas["ChartArea1"].Name;
                    SerCollection.Add(Series2Obj);
                }
            }

            if (!string.IsNullOrEmpty(ChartCtlDataSettingsDto.DataCallInfoDto[2].SelectedCall) && !ChartCtlDataSettingsDto.DataCallInfoDto[2].Disabled)
            {
                QsoRadioStationFilter QsoRadioStationFilter = ChartQuery.GetQsoRadioStationFilter(ChartCtlDataSettingsDto.DataCallInfoDto[2]);
                ChartQuery.GetQuery(LogRepository, QSORateChart.ID, QSOFilter, QsoRadioStationFilter, ChartCtlDataSettingsDto.DataCallInfoDto[2], ChartCtlDataSettingsDto.ControlSettingsDto,
                    ContestInfoDTO3, ChartAreaDto, YaxisFunction, out ContestViewParmsDTO, username);
                SeriesObj Series3Obj = new SeriesObj(ContestInfoDTO3, Color.FromArgb(AlphaBlend, Color.SeaGreen), ChartQuery.GetDataTableSQL);
                bOK = Series3Obj.Create(LogRepository, ChartAreaDto, QSORateChart.ID, ContestViewParmsDTO, username);
                if (bOK)
                {
                    QSORateChart.Series.Add(Series3Obj);
                    SerCollection.Add(Series3Obj);
                }
            }


            //set 2nd titles
            string key = "";
            foreach (SeriesObj obj in SerCollection)
            {
                switch (obj.ContestInfoDTO.CallGroup)
                {
                    case Logqso.mvc.common.Enum.CallGroupEnum.CALL1:
                        key = "Tkey1";
                        break;
                    case Logqso.mvc.common.Enum.CallGroupEnum.CALL2:
                        key = "Tkey2";
                        break;
                    case Logqso.mvc.common.Enum.CallGroupEnum.CALL3:
                        key = "Tkey3";
                        break;
                    default:
                        break;
                }
                if (obj.ContestInfoDTO.Call != string.Empty)
                {
                    string OPr = string.Empty;
                    switch (obj.ContestInfoDTO.CatOperatorEnum)
	                {
		                case Logqso.mvc.common.Enum.CatOperatorEnum.ALL:
                            //should never occur
                            break;
                        case Logqso.mvc.common.Enum.CatOperatorEnum.SINGLE_OP:
                            if (obj.ContestInfoDTO.CatBandEnum == common.Enum.CatBandEnum.ALL)
	                        {
                                OPr = "SOAB";
	                        }else{
                                OPr = "SOSB";
                            }
                            break;
                        case Logqso.mvc.common.Enum.CatOperatorEnum.MULTI_OP:
                            if (obj.ContestInfoDTO.CatNoOfTxEnum == common.Enum.CatNoOfTxEnum.ONE)
	                        {
                                OPr = "MS";
	                        }
                            else if (obj.ContestInfoDTO.CatNoOfTxEnum == common.Enum.CatNoOfTxEnum.TWO)
                            {
                                OPr = "M2";
                            }
                            else{
                                OPr = "MM";
                            }
                            break;
                        case Logqso.mvc.common.Enum.CatOperatorEnum.CHECKLOG:
                           OPr = "CHECKLOG";
                           break;
                        default:
                            break;
	                }
                    if (OPr == "SOSB")
                    {
                        switch (obj.ContestInfoDTO.CatBandEnum)
                        {
                            case Logqso.mvc.common.Enum.CatBandEnum.ALL:
                                 //doews not occur
                                 break;
                            case Logqso.mvc.common.Enum.CatBandEnum._160M:
                                 OPr += " 160M";
                                 break;
                            case Logqso.mvc.common.Enum.CatBandEnum._80M:
                                OPr += "  80M";
                                break;
                            case Logqso.mvc.common.Enum.CatBandEnum._40M:
                                OPr += "  40M";
                                break;
                            case Logqso.mvc.common.Enum.CatBandEnum._20M:
                                OPr += "  20M";
                                break;
                            case Logqso.mvc.common.Enum.CatBandEnum._15M:
                                OPr += "  15M";
                                break;
                            case Logqso.mvc.common.Enum.CatBandEnum._10M:
                                OPr += "  10M";
                                break;
                            default:
                                break;
                        }
                        switch (obj.ContestInfoDTO.CatPowerEnum)
                        {
                            case Logqso.mvc.common.Enum.CatPowerEnum.ALL:
                                //does not occur
                                break;
                            case Logqso.mvc.common.Enum.CatPowerEnum.HIGH:
                                OPr += " HIGH";
                                break;
                            case Logqso.mvc.common.Enum.CatPowerEnum.LOW:
                                OPr += "  LOW";
                                break;
                            case Logqso.mvc.common.Enum.CatPowerEnum.QRP:
                                OPr += "  QRP";
                                break;
                            default:
                                break;
                        }
                        if (obj.ContestInfoDTO.CatAssistedEnum == common.Enum.CatAssistedEnum.ASSISTED)
                        {
                            OPr += " Assisted";
                        }
                        else
                        {
                            OPr += " Non-Assisted";
                        }
                    }
                    QSORateChart.Titles[key].Text += string.Format("{0} {1} {2}",
                        obj.ContestInfoDTO.Call.PadRight(10), obj.ContestInfoDTO.ContestName,
                        OPr);
                    //QSORateChart.Titles[key].ForeColor = Color.FromArgb(0xff, 0, 99, 99);

                }

            }

            //Select Log that exists
            ContestInfoDTO ContestInfoDTON = null;
            if (ContestInfoDTO1 != null)
            {
                ContestInfoDTON = ContestInfoDTO1;
            }
            else if (ContestInfoDTO2 != null)
            {
                ContestInfoDTON = ContestInfoDTO2;
            }
            else if (ContestInfoDTO3 != null)
            {
                ContestInfoDTON = ContestInfoDTO2;
            }

            //TITLES
            if (ChartAreaDto.MixedYears)
            {
                QSORateChart.Titles["ChartName"].Text = ContestViewParmsDTO.sTitle;
            }
            else
            {
                if (ContestInfoDTON != null)
                {
                    QSORateChart.Titles["ChartName"].Text = string.Format("{0}  {1}", ContestInfoDTON.ContestID, ContestViewParmsDTO.sTitle);
                }
            }
            string ver = ConfigurationManager.AppSettings["AppVersion"].ToString();
            QSORateChart.Titles["Vers"].Text = string.Format("Version:  {0}", ver);

            //AXISX
            Font fontAxis = new Font("Times New Roman", 14, FontStyle.Bold);
            AxisInfoParams Ai = new AxisInfoParams();
            Ai.TitleFont = fontAxis;
            Ai.Title = "Time";
            Ai.LineWidth = 1;
            Ai.LabelStyleFormat = "{0:HH:mm}";
            Ai.LabelStyleAngle = -90;
            //Date can be different but times are the same 48 hours
            if (ChartAreaDto.MixedYears)
            {
                if (ContestInfoDTON != null)
                {
                    int days = ContestInfoDTON.endTime.AddMinutes(1).Subtract(ContestInfoDTON.startTime).Days;
                    Ai.Minimum = DateTime.Parse("1/1/1990 " + ContestInfoDTON.startTime.TimeOfDay).ToOADate();
                    Ai.Maximum = DateTime.Parse("1/" + string.Format("{0}", 1 + days) + "/1990 " +
                        ContestInfoDTON.endTime.AddSeconds(ChartAreaDto.AxisXMaxFudgeSeconds).TimeOfDay).ToOADate();
                }
            }
            else
            {
                if (ContestInfoDTO1 != null && !ContestInfoDTO1.Disabled)
                {
                    Ai.Minimum = ContestInfoDTO1.startTime.ToOADate();
                    Ai.Maximum = ContestInfoDTO1.endTime.AddSeconds(ChartAreaDto.AxisXMaxFudgeSeconds).ToOADate();
                }
                else if (ContestInfoDTO2 != null && !ContestInfoDTO2.Disabled)
                {
                    Ai.Minimum = ContestInfoDTO2.startTime.ToOADate();
                    Ai.Maximum = ContestInfoDTO2.endTime.AddSeconds(ChartAreaDto.AxisXMaxFudgeSeconds).ToOADate();
                }
                else if ( ContestInfoDTO3 != null && !ContestInfoDTO3.Disabled)
                {
                    Ai.Minimum = ContestInfoDTO3.startTime.ToOADate();
                    Ai.Maximum = ContestInfoDTO3.endTime.AddSeconds(ChartAreaDto.AxisXMaxFudgeSeconds).ToOADate();
                }
            }
            Ai.IntervalType = ChartAreaDto.ChartXaxisIntervalType;
            Ai.Interval = ChartAreaDto.MinorHorizontalInterval;
            ChartAreaDto.InitChartAxis(QSORateChart.ChartAreas["ChartArea1"].AxisX, Ai);

            // set second row of labels
            QSORateChart.ChartAreas["ChartArea1"].AxisX.CustomLabels.Add(24, ChartAreaDto.ChartXaxisIntervalType, "Day {0:dd}", 2, LabelMarkStyle.LineSideMark);
            //QSORateChart.ChartAreas["ChartArea1"].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.DecreaseFont | LabelAutoFitStyles.StaggeredLabels | LabelAutoFitStyles.LabelsAngleStep90;
            //QSORateChart.Series[Series1Obj.Name].AxisLabel = "#VALX{dd}\n#VALX{MMM}\n#VALX{yyy}";
            //QSORateChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.IsEndLabelVisible = true;
            //QSORateChart.ChartAreas["ChartArea1"].InnerPlotPosition = new ElementPosition(0, 0, 90, 100);
            //QSORateChart.ChartAreas["ChartArea1"].AxisX.IntervalOffset = 15;
            //QSORateChart.ChartAreas["ChartArea1"].AxisX.IntervalOffsetType = DateTimeIntervalType.Minutes;
            //TabContainerCall.Controls.Add(
            ////SCALEVIEW
            int startHour = Convert.ToInt32(ChartCtlDataSettingsDto.ControlSettingsDto.ControlXaxisSettingsDto.XaxisStarttime.Substring(0, 2));
            int Size = Convert.ToInt32(ChartCtlDataSettingsDto.ControlSettingsDto.ControlXaxisSettingsDto.XaxisDuration);

            if (Size != 48)
            {
                int Day = 1;
                if (ChartCtlDataSettingsDto.ControlSettingsDto.ControlXaxisSettingsDto.XaxisStarttime.Contains("Day2"))
                {
                    Day = 2;
                }
                QSORateChart.ChartAreas["ChartArea1"].AxisX.IsStartedFromZero = true;
                DateTime pos;

                if (ChartAreaDto.MixedYears)
                {
                    pos = new DateTime(1990, 1, Day, startHour, 00, 00);
                }
                else
                {
                    if (ContestInfoDTON != null)
                    {
                        if (Day == 2)
                        {
                            pos = ContestInfoDTON.startTime.AddDays(1).AddHours(startHour);
                        }
                        else
                        {
                            pos = ContestInfoDTON.startTime.AddHours(startHour);
                        }
                    }else
	                {
                        pos = new DateTime(1990, 1, Day, startHour, 00, 00);
	                }
                }
                QSORateChart.ChartAreas["ChartArea1"].AxisX.ScaleView.Position = pos.ToOADate();
                QSORateChart.ChartAreas["ChartArea1"].AxisX.ScaleView.Size = Size;// count of ScaleView.SizeType
                QSORateChart.ChartAreas["ChartArea1"].AxisX.ScaleView.SizeType = ChartAreaParams.ChartXaxisIntervalType;
            }


            //AXISY
            //QSORateChart.ImageLocation
            QSORateChart.ChartAreas["ChartArea1"].AxisY.TitleFont = fontAxis;
            QSORateChart.ChartAreas["ChartArea1"].AxisY.Title = ContestViewParmsDTO.sYAxis;
            QSORateChart.ChartAreas["ChartArea1"].AxisY.LabelStyle.Format = "{0:n0}";
            if (ChartCtlDataSettingsDto.ControlSettingsDto.ControlYaxisSettingsDto.YaxisFunction.Contains("Sum"))
            {
                QSORateChart.ChartAreas["ChartArea1"].AxisY.Enabled = AxisEnabled.False;
            }
            QSORateChart.ChartAreas["ChartArea1"].AxisY2.Enabled = AxisEnabled.True;
            QSORateChart.ChartAreas["ChartArea1"].AxisY2.LineWidth = 0;
            QSORateChart.ChartAreas["ChartArea1"].AxisY2.LabelStyle.Format = "{0:n0}";
            QSORateChart.ChartAreas["ChartArea1"].Position = new ElementPosition(0, 10, 100, 80);
            QSORateChart.Titles["ChartName"].Position = new ElementPosition(2, 0, 50, 10);
            QSORateChart.Legends["Legend1"].Position = new ElementPosition(50, 1, 50, 9);

            // LEGENDS
            QSORateChart.Legends["Legend1"].ForeColor = Color.DarkOliveGreen;
            Font fontLegend = new Font("Times New Roman", 11, FontStyle.Bold, GraphicsUnit.Point);
            QSORateChart.Legends["Legend1"].Font = fontLegend;
            QSORateChart.Legends["Legend1"].Position.Height = 7;

            // draw!
            //QSORateChart.Invalidate();
            //string path = Server.MapPath("~/ChartImages/chart.png");
            try
            {
                //String filePath = HostingEnvironment.MapPath("~/Image/charttest.png");
                //QSORateChart.SaveImage(filePath, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png);
                //FileStream fileStream = new FileStream(filePath, FileMode.Open);
                //Image image = System.Drawing.Image.FromStream(fileStream);
                //MemoryStream memoryStream = new MemoryStream();
                //image.Save(memoryStream, ImageFormat.Png);

                MemoryStream = new MemoryStream();
                QSORateChart.SaveImage(MemoryStream, ChartImageFormat.Png);
            }
            catch (Exception ex)
            {
                
                throw;
            }

            return MemoryStream;

        }
        public static string GetTheme()
        {
            ChartArea ca    = new System.Web.UI.DataVisualization.Charting.ChartArea("Default");
            var       chart = new System.Web.UI.DataVisualization.Charting.Chart();

            chart.BackColor           = Color.Azure;
            chart.BackGradientStyle   = GradientStyle.TopBottom;
            chart.BackSecondaryColor  = Color.White;
            chart.BorderColor         = Color.FromArgb(26, 59, 105);
            chart.BorderlineDashStyle = ChartDashStyle.Solid;
            chart.BorderWidth         = 2;
            chart.Palette             = ChartColorPalette.None;
            chart.PaletteCustomColors = new Color[] { Color.Lime, Color.Red,
                                                      Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Purple,
                                                      Color.Black };
            chart.ChartAreas.Add(new ChartArea("Default")
            {
                BackColor          = Color.FromArgb(64, 165, 191, 228),
                BackGradientStyle  = GradientStyle.TopBottom,
                BackSecondaryColor = Color.White,
                BorderColor        = Color.FromArgb(64, 64, 64, 64),
                BorderDashStyle    = ChartDashStyle.Solid,
                ShadowColor        = Color.Transparent,
                Area3DStyle        = new ChartArea3DStyle()
                {
                    LightStyle       = LightStyle.Simplistic,
                    Enable3D         = true,
                    Inclination      = 5,
                    IsClustered      = true,
                    IsRightAngleAxes = true,
                    Perspective      = 5,
                    Rotation         = 0,
                    WallWidth        = 0
                }
            });
            chart.Legends.Add(new Legend("All")
            {
                BackColor = Color.Transparent,
                Font      = new Font("Trebuchet MS", 8.25f, FontStyle.Bold,
                                     GraphicsUnit.Point),
                IsTextAutoFit = false
            }
                              );
            chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;

            var cs = chart.Serializer;

            cs.IsTemplateMode = true;
            //cs.Content = SerializationContents.Appearance;
            cs.Format = SerializationFormat.Xml;
            var sb = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.OmitXmlDeclaration = true;
            using (XmlWriter xw = XmlWriter.Create(sb, settings))
            {
                cs.Save(xw);
            }
            string theme = sb.ToString();

            return(theme);
        }