Пример #1
0
        private void InitChart()
        {
            button1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;            //!!VBPassThru
            // --Setup Chart1--------------------------
            c1Chart1.BackColor = Color.White;

            // Setup the header
            C1.Win.C1Chart.Title header = c1Chart1.Header;
            header.Text                     = "Stock Chart ";
            header.Style.Font               = new Font("Century", 16, FontStyle.Bold);
            header.Style.ForeColor          = Color.DodgerBlue;
            header.Style.BackColor          = Color.LightCyan;
            header.Style.Border.BorderStyle = C1.Win.C1Chart.BorderStyleEnum.Solid;
            header.Style.Border.Color       = Color.Gold;
            header.Style.Border.Thickness   = 3;

            // Hide the footer
            c1Chart1.Footer.Visible = false;

            // Setup the Axis X
            C1.Win.C1Chart.Axis ax = c1Chart1.ChartArea.AxisX;
            ax.Thickness         = 1;
            ax.AnnoFormat        = C1.Win.C1Chart.FormatEnum.DateManual;
            ax.AnnoFormatString  = "d";
            ax.GridMajor.Color   = Color.DarkGray;
            ax.GridMajor.Pattern = C1.Win.C1Chart.LinePatternEnum.Dash;
            ax.GridMajor.Visible = true;
            ax.Compass           = C1.Win.C1Chart.CompassEnum.North;

            // Setup the Axis Y
            C1.Win.C1Chart.Axis ay = c1Chart1.ChartArea.AxisY;
            ay.Thickness         = 1;
            ay.Min               = 1600;
            ay.Max               = 1960;
            ay.AnnoFormat        = C1.Win.C1Chart.FormatEnum.NumericManual;
            ay.AnnoFormatString  = "F";
            ay.GridMajor.Color   = Color.DarkGray;
            ay.GridMajor.Pattern = C1.Win.C1Chart.LinePatternEnum.Solid;
            ay.GridMajor.Visible = true;
            ay.Text              = "Price ($)";

            // Setup the Axis Y2
            C1.Win.C1Chart.Axis ay2 = c1Chart1.ChartArea.AxisY2;
            ay2.Thickness = 1;
            ay2.Min       = 0;
            ay2.Max       = 30000000;
            ay2.Text      = "Volume";
            ay2.Visible   = true;

            c1Chart1.ChartArea.PlotArea.Boxed = true;

            // Setup the group 0
            c1Chart1.ChartGroups[0].ChartType = C1.Win.C1Chart.Chart2DTypeEnum.Candle;

            c1Chart1.ChartGroups[0].ChartData.SeriesList.RemoveAll();
            series0 = c1Chart1.ChartGroups[0].ChartData.SeriesList.AddNewSeries();
            series0.LineStyle.Color = Color.Blue;

            // Setup the group 1
            c1Chart1.ChartGroups[1].ChartType = C1.Win.C1Chart.Chart2DTypeEnum.Bar;

            c1Chart1.ChartGroups[1].ChartData.SeriesList.RemoveAll();
            series1 = c1Chart1.ChartGroups[1].ChartData.SeriesList.AddNewSeries();
            series1.LineStyle.Color = Color.FromArgb(40, Color.Blue);
        }
        /// <summary>
        /// Initialize the Chart
        /// </summary>
        private void InitChart()
        {
            c1Chart1.BackColor = Color.DarkGray;
            c1Chart1.ChartArea.Margins.Left   = 0;
            c1Chart1.ChartArea.Margins.Top    = 0;
            c1Chart1.ChartArea.Margins.Right  = 0;
            c1Chart1.ChartArea.Margins.Bottom = 0;

            c1Chart1.ChartArea.Style.BackColor          = Color.SkyBlue;
            c1Chart1.ChartArea.Style.BackColor2         = Color.PaleGreen;
            c1Chart1.ChartArea.Style.GradientStyle      = C1.Win.C1Chart.GradientStyleEnum.Vertical;
            c1Chart1.ChartArea.Style.Border.BorderStyle = C1.Win.C1Chart.BorderStyleEnum.Fillet;
            c1Chart1.ChartArea.Style.Border.Thickness   = 6;


            // Setup the Header
            c1Chart1.Header.Compass                  = C1.Win.C1Chart.CompassEnum.North;
            c1Chart1.Header.Style.Font               = new Font("Courier New", 12, FontStyle.Bold);
            c1Chart1.Header.Style.ForeColor          = Color.Lime;
            c1Chart1.Header.Style.Border.BorderStyle = C1.Win.C1Chart.BorderStyleEnum.RaisedBevel;
            c1Chart1.Header.Style.Border.Thickness   = 2;
            c1Chart1.Header.Visible                  = true;
            SetStatusLabel();


            // Setup the Footer
            c1Chart1.Footer.Compass                  = C1.Win.C1Chart.CompassEnum.North;
            c1Chart1.Footer.Style.Font               = new Font("Courier New", 12, FontStyle.Bold);
            c1Chart1.Footer.Style.ForeColor          = Color.Blue;
            c1Chart1.Footer.Style.Border.BorderStyle = C1.Win.C1Chart.BorderStyleEnum.RaisedBevel;
            c1Chart1.Footer.Style.Border.Thickness   = 2;
            c1Chart1.Footer.Text    = "Play";
            c1Chart1.Footer.Visible = true;

            SetHeaderAndFooterPos();

            // Setup the Axis X
            C1.Win.C1Chart.Axis xa = c1Chart1.ChartArea.AxisX;
            xa.AutoMax    = false;
            xa.AutoMin    = false;
            xa.AutoMajor  = false;
            xa.AutoMinor  = false;
            xa.Min        = 0;
            xa.Max        = 100;
            xa.TickMajor  = C1.Win.C1Chart.TickMarksEnum.None;
            xa.TickMinor  = C1.Win.C1Chart.TickMarksEnum.None;
            xa.TickLabels = C1.Win.C1Chart.TickLabelsEnum.None;
            xa.Thickness  = 1;
            xa.Visible    = true;

            // Setup the Axis Y
            C1.Win.C1Chart.Axis ya = c1Chart1.ChartArea.AxisY;
            ya.AutoMax    = false;
            ya.AutoMin    = false;
            ya.AutoMajor  = false;
            ya.AutoMinor  = false;
            ya.Min        = 0;
            ya.Max        = 100;
            ya.TickMajor  = C1.Win.C1Chart.TickMarksEnum.None;
            ya.TickMinor  = C1.Win.C1Chart.TickMarksEnum.None;
            ya.TickLabels = C1.Win.C1Chart.TickLabelsEnum.None;
            ya.Thickness  = 1;

            // Setup the Axis Y2
            C1.Win.C1Chart.Axis y2a = c1Chart1.ChartArea.AxisY2;
            y2a.AutoMax    = false;
            y2a.AutoMin    = false;
            y2a.AutoMajor  = false;
            y2a.AutoMinor  = false;
            y2a.Min        = 0;
            y2a.Max        = 100;
            y2a.TickMajor  = C1.Win.C1Chart.TickMarksEnum.None;
            y2a.TickMinor  = C1.Win.C1Chart.TickMarksEnum.None;
            y2a.TickLabels = C1.Win.C1Chart.TickLabelsEnum.None;
            y2a.Visible    = false;

            c1Chart1.ChartArea.PlotArea.Boxed = true;

            // Set the Group 0 to Bubble Chart
            C1.Win.C1Chart.ChartGroup group0 = c1Chart1.ChartGroups.Group0;
            group0.ChartType          = C1.Win.C1Chart.Chart2DTypeEnum.Bubble;
            group0.Bubble.MaximumSize = 30;
            group0.Bubble.MinimumSize = 3;

            group0.ChartData.SeriesList.RemoveAll();

            C1.Win.C1Chart.ChartDataSeries series = null;
            // Setup five dummy candies for size foundation, two of them are used for backgound, the sun
            for (int i = 0; i < 3; i++)
            {
                series = group0.ChartData.SeriesList.AddNewSeries();
                series.SymbolStyle.Shape = C1.Win.C1Chart.SymbolShapeEnum.Dot;
                series.SymbolStyle.Color = Color.Red;

                series.X.Length  = 1;
                series.Y.Length  = 1;
                series.Y1.Length = 1;
                series.X[0]      = 0;
                series.Y[0]      = -100;
                series.Y1[0]     = i;
            }

            series = group0.ChartData.SeriesList.AddNewSeries();
            series.SymbolStyle.Shape = C1.Win.C1Chart.SymbolShapeEnum.Star;
            series.SymbolStyle.Color = Color.Gold;

            series.X.Length  = 1;
            series.Y.Length  = 1;
            series.Y1.Length = 1;
            series.X[0]      = 10;
            series.Y[0]      = 95;
            series.Y1[0]     = 5;

            series = group0.ChartData.SeriesList.AddNewSeries();
            series.SymbolStyle.Shape = C1.Win.C1Chart.SymbolShapeEnum.Dot;
            series.SymbolStyle.Color = Color.Yellow;

            series.X.Length  = 1;
            series.Y.Length  = 1;
            series.Y1.Length = 1;
            series.X[0]      = 10;
            series.Y[0]      = 95;
            series.Y1[0]     = 4;

            // Label style
            c1Chart1.ChartLabels.DefaultLabelStyle.ForeColor = SystemColors.InfoText;
            c1Chart1.ChartLabels.DefaultLabelStyle.BackColor = Color.FromArgb(90, SystemColors.Info);
            c1Chart1.ChartLabels.DefaultLabelStyle.Font      = new Font("Arial", 10, FontStyle.Bold);

            // Set the Group 1 to Area Chart, the montain background
            C1.Win.C1Chart.ChartGroup group1 = c1Chart1.ChartGroups.Group1;
            group1.ChartType = C1.Win.C1Chart.Chart2DTypeEnum.Area;
            group1.ChartData.SeriesList.RemoveAll();
            series = group1.ChartData.SeriesList.AddNewSeries();
            series.X.CopyDataIn(new int[] { 0, 15, 30, 50, 80, 100 });
            series.Y.CopyDataIn(new int[] { 40, 70, 50, 90, 40, 70 });
            series.LineStyle.Color = Color.DarkGoldenrod;
            series.FitType         = C1.Win.C1Chart.FitTypeEnum.Spline;

            series = group1.ChartData.SeriesList.AddNewSeries();
            series.X.CopyDataIn(new int[] { 0, 30, 60, 80, 100 });
            series.Y.CopyDataIn(new int[] { 30, 65, 50, 70, 50 });
            series.LineStyle.Color = Color.ForestGreen;
            series.FitType         = C1.Win.C1Chart.FitTypeEnum.Spline;

            series = group1.ChartData.SeriesList.AddNewSeries();
            series.X.CopyDataIn(new int[] { 0, 20, 40, 60, 80, 100 });
            series.Y.CopyDataIn(new int[] { 15, 25, 15, 25, 15, 15 });
            series.LineStyle.Color = Color.DarkMagenta;
            series.FitType         = C1.Win.C1Chart.FitTypeEnum.Spline;
        }