Beispiel #1
0
        // Add Chart Labels with beginning and ending dates for each data point
        // in the Gantt chart.  Labels are placed inside on the western edge.
        private void AddGanttTaskLabels(C1Chart chart, ChartDataSeriesCollection cdsc)
        {
            ChartLabels cl = chart.ChartLabels;

            cl.DefaultLabelStyle.BackColor           = Color.Transparent;
            cl.DefaultLabelStyle.GradientStyle       = GradientStyleEnum.None;
            cl.DefaultLabelStyle.ForeColor           = Color.Azure;
            cl.DefaultLabelStyle.HorizontalAlignment = AlignHorzEnum.Far;

            C1.Win.C1Chart.LabelsCollection clc = cl.LabelsCollection;
            clc.Clear();

            int slen = cdsc.Count;

            for (int s = 0; s < cdsc.Count; s++)
            {
                ChartDataSeries cds = cdsc[s];
                for (int p = 0; p < cds.Length; p++)
                {
                    C1.Win.C1Chart.Label lab   = clc.AddNewLabel();
                    DateTime             start = (DateTime)cds.Y[p];
                    DateTime             end   = (DateTime)cds.Y1[p];
                    lab.Text         = start.ToString("ddMMM") + "-" + end.ToString("ddMMM");
                    lab.AttachMethod = AttachMethodEnum.DataIndex;
                    lab.AttachMethodData.GroupIndex  = 0;
                    lab.AttachMethodData.SeriesIndex = s;
                    lab.AttachMethodData.PointIndex  = p;
                    lab.Compass = LabelCompassEnum.West;
                    lab.Offset  = 0;
                    lab.Visible = true;
                }
            }
        }
Beispiel #2
0
        private void StepChart_Load(object sender, System.EventArgs e)
        {
            // position the controls
            hScrollBar1.Location = new Point(c1Chart1.Left, 0);
            vScrollBar1.Location = new Point(c1Chart1.Left - vScrollBar1.Width, hScrollBar1.Height);
            c1Chart1.Location    = new Point(hScrollBar1.Left, vScrollBar1.Top);

            // set 3D effects scrollbars visibility
            bool is3d = chkShow3D.Checked;

            vScrollBar1.Visible = is3d;
            hScrollBar1.Visible = is3d;

            // set up the charts
            ChartGroup cg = c1Chart1.ChartGroups.Group0;

            cg.Use3D = is3d;

            // ChartType is a Step chart.
            cg.ChartType = Chart2DTypeEnum.Step;

            ChartData cd = cg.ChartData;
            ChartDataSeriesCollection cdsc = cd.SeriesList;

            cdsc.Clear();                       // remove existing data.

            // create some data using this application GetData() routine
            PointF[] pfa = GetData();

            // add the data to the chart
            ChartDataSeries cds = cdsc.AddNewSeries();

            cds.PointData.CopyDataIn(pfa);
            cds.LineStyle.Thickness = 3;
            cds.TooltipText         = "Step0";
            cds.TooltipTextLegend   = "Step0 Legend";
            cds.SymbolStyle.Size    = 15;

            // add a second series using the application AdjustYValues
            // routine.  This data is similar to show behavior when
            // excluding the data holes found in the first data.
            cds = cdsc.AddNewSeries();
            cds.PointData.CopyDataIn(AdjustYValues(pfa, 1f, 2f));
            cds.LineStyle.Thickness = 3;
            cds.SymbolStyle.Size    = 15;
            cds.TooltipText         = "Step1";
            cds.TooltipTextLegend   = "Step1 Legend";
            cds.Display             = SeriesDisplayEnum.ExcludeHoles;

            // set up the 3D view object and scrollbars.  When
            // the 3D view is shown, the scrollbars can adjust
            // the angles.
            const int initialAngles = 30;
            View3D    v3d           = c1Chart1.ChartArea.PlotArea.View3D;

            v3d.Depth     = initialAngles;
            v3d.Elevation = initialAngles;
            v3d.Rotation  = initialAngles;

            hScrollBar1.Maximum = 45;
            hScrollBar1.Minimum = -45;
            hScrollBar1.Value   = -initialAngles;

            vScrollBar1.Maximum = 45;
            vScrollBar1.Minimum = -45;
            vScrollBar1.Value   = initialAngles;

            updnDepth.Value   = initialAngles;
            labDepth.Visible  = is3d;
            updnDepth.Visible = is3d;

            // in chart labels to label the scroll bars.
            C1.Win.C1Chart.LabelsCollection labs = c1Chart1.ChartLabels.LabelsCollection;
            C1.Win.C1Chart.Label            lab  = labs.AddNewLabel();
            lab.AttachMethod              = AttachMethodEnum.Coordinate;
            lab.AttachMethodData.X        = 1;
            lab.AttachMethodData.Y        = 1;
            lab.Compass                   = LabelCompassEnum.SouthEast;
            lab.SizeDefault               = new Size(c1Chart1.Size.Width, 12);
            lab.Style.HorizontalAlignment = AlignHorzEnum.Center;
            lab.Name    = "hbar";
            lab.Text    = "3D Rotation";
            lab.Visible = is3d;

            lab = labs.AddNewLabel();
            lab.AttachMethod              = AttachMethodEnum.Coordinate;
            lab.AttachMethodData.X        = 1;
            lab.AttachMethodData.Y        = 1;
            lab.Compass                   = LabelCompassEnum.SouthEast;
            lab.SizeDefault               = new Size(12, c1Chart1.Size.Height);
            lab.Style.Rotation            = RotationEnum.Rotate270;
            lab.Style.HorizontalAlignment = AlignHorzEnum.Center;
            lab.Name    = "vbar";
            lab.Text    = "3D Elevation";
            lab.Visible = is3d;

            // set up the Chart header
            Title header = c1Chart1.Header;

            header.Style.Font = new Font("Arial Black", 16);
            header.Style.Border.BorderStyle = BorderStyleEnum.Solid;
            if (is3d)
            {
                header.Text = "3D Step Chart";
            }
            else
            {
                header.Text = "2D Step Chart";
            }

            // clear the position CoordInfo label
            labCoordInfo.Text    = "";
            labCoordInfo.Visible = false;

            // force a resize to allow everything reposition.
            StepChart_Resize(null, null);
        }