예제 #1
0
        private void ChartSettiong_positiondata_realtime()
        {
            position_realtime_series = new DevExpress.XtraCharts.Series("위치", ViewType.Line);

            //   position_series[0].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;  //시리즈에 라벨 표시
            //   position_series[1].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;


            //ChartControl에 Series 추가
            chartControl_path.Series.Add(position_realtime_series);

            chartControl_path.CrosshairEnabled = DefaultBoolean.False;
            XYDiagram diagram = (XYDiagram)chartControl_path.Diagram;

            diagram.AxisY.WholeRange.MaxValue         = 10;    // y축 최대값
            diagram.AxisY.WholeRange.MinValue         = -1;    // y축 최소값
            diagram.AxisY.WholeRange.Auto             = false; // y축 범위 자동변경 설정
            diagram.AxisX.WholeRange.SideMarginsValue = 0;

            ConstantLine zeroLine = new ConstantLine();

            zeroLine.Color        = Color.Green;
            zeroLine.AxisValue    = 0;
            zeroLine.ShowInLegend = false;
            diagram.AxisY.ConstantLines.Add(zeroLine);  // y값 0인 x축 생성
        }
예제 #2
0
        private void chartControl1_MouseDown(object sender, MouseEventArgs e)
        {
            mouseDown = true;
            ChartHitInfo hitinfo = chartControl1.CalcHitInfo(e.X, e.Y);

            curruentConstantLine = hitinfo.ConstantLine;
        }
        void stockChart_MouseDown(object sender, MouseEventArgs e)
        {
            if (!isSelection)
            {
                draggingIndicator = CreateDraggingIndicator();
                if (draggingIndicator == null)
                {
                    return;
                }

                DiagramCoordinates coords = Diagram.PointToDiagram(e.Location);
                draggingIndicator.Point1.Argument   = coords.DateTimeArgument;
                draggingIndicator.Point1.ValueLevel = ValueLevel.Close;
                draggingIndicator.Point2.Argument   = coords.DateTimeArgument;
                draggingIndicator.Point2.ValueLevel = ValueLevel.Close;

                PriceSeriesView.Indicators.Add(draggingIndicator);

                trendlineBorder                     = new ConstantLine();
                trendlineBorder.AxisValue           = coords.DateTimeArgument;
                trendlineBorder.LineStyle.DashStyle = DashStyle.Dash;
                trendlineBorder.LineStyle.Thickness = 1;
                trendlineBorder.ShowInLegend        = false;
                Diagram.AxisX.ConstantLines.Add(trendlineBorder);
                stockChart.Capture = true;

                isDrawing          = true;
                stockChart.Capture = true;
            }
        }
예제 #4
0
        private void ChartSettiong_angluardata_result()
        {
            //  position_series[0] = new DevExpress.XtraCharts.Series("위치", ViewType.Line);
            angluar_result_series = new DevExpress.XtraCharts.Series("앵글", ViewType.Line);

            //   position_series[0].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;  //시리즈에 라벨 표시
            //   position_series[1].LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;


            //ChartControl에 Series 추가
            chartControl2.Series.Add(angluar_result_series);
            // chartControl1.Series.Add(position_series[1]);

            chartControl2.CrosshairEnabled = DefaultBoolean.False;
            XYDiagram diagram = (XYDiagram)chartControl2.Diagram;

            diagram.AxisY.WholeRange.MaxValue         = 3.14;  // y축 최대값
            diagram.AxisY.WholeRange.MinValue         = -3.14; // y축 최소값
            diagram.AxisY.WholeRange.Auto             = false; // y축 범위 자동변경 설정
            diagram.AxisX.WholeRange.SideMarginsValue = 0;

            ConstantLine zeroLine = new ConstantLine();

            zeroLine.Color        = Color.LightYellow;
            zeroLine.AxisValue    = 0;
            zeroLine.ShowInLegend = false;
            diagram.AxisY.ConstantLines.Add(zeroLine);  // y값 0인 x축 생성
        }
예제 #5
0
        /// <summary>
        /// 创建基准线ConstantLine
        /// </summary>
        /// <param name="chart">ChartControl</param>
        /// <param name="ctAxisValue">基准线数值</param>
        /// <param name="ctLegendText">基准线图例文字</param>
        /// <param name="ctTitle">基准线文字</param>
        /// <param name="ctTitleColor">基准线字体颜色</param>
        /// <param name="ctLineColor">基准线颜色</param>
        /// <param name="ctLineStyle">基准线样式</param>
        public static void CreateConstantLine(this ChartControl chart, int ctAxisValue, string ctLegendText, string ctTitle, Color ctTitleColor, Color ctLineColor, DashStyle ctLineStyle)
        {
            if (chart.Diagram is XYDiagram)
            {
                XYDiagram _diagram = (XYDiagram)chart.Diagram;
                if (_diagram != null)
                {
                    ConstantLine _ctLine = new ConstantLine();

                    _ctLine.AxisValue    = ctAxisValue;
                    _ctLine.Visible      = true;
                    _ctLine.ShowInLegend = true;
                    _ctLine.LegendText   = ctLegendText;
                    _ctLine.ShowBehind   = false;

                    _ctLine.Title.Visible            = true;
                    _ctLine.Title.Text               = ctTitle;
                    _ctLine.Title.TextColor          = ctTitleColor;
                    _ctLine.Title.EnableAntialiasing = DefaultBoolean.False;
                    _ctLine.Title.Font               = new Font("Tahoma", 14, FontStyle.Bold);
                    _ctLine.Title.ShowBelowLine      = true;
                    _ctLine.Title.Alignment          = ConstantLineTitleAlignment.Far;

                    _ctLine.Color = ctLineColor;
                    _ctLine.LineStyle.DashStyle = ctLineStyle;
                    _ctLine.LineStyle.Thickness = 2;

                    _diagram.AxisY.ConstantLines.Add(_ctLine);
                }
            }
        }
예제 #6
0
        public ConstantAssignLine(CodeLine codeLine, ConstantLine constantLine) : base(codeLine.Code, codeLine,
                                                                                       codeLine.Strings)
        {
            base.Comment = codeLine.Comment;
            base.Raw     = codeLine.Raw;

            ConstantLine = constantLine;
        }
 void stockChart_MouseUp(object sender, MouseEventArgs e)
 {
     if (!isSelection)
     {
         draggingIndicator = null;
         Diagram.AxisX.ConstantLines.Remove(trendlineBorder);
         trendlineBorder    = null;
         isDrawing          = false;
         stockChart.Capture = false;
     }
 }
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create an empty chart.
            ChartControl chartControl1 = new ChartControl();

            // Create a bar series and add points to it.
            Series series1 = new Series("Series 1", ViewType.Spline);

            series1.Points.Add(new SeriesPoint("A", new double[] { 10 }));
            series1.Points.Add(new SeriesPoint("B", new double[] { 2 }));
            series1.Points.Add(new SeriesPoint("C", new double[] { 17 }));
            series1.Points.Add(new SeriesPoint("D", new double[] { 4 }));
            series1.Points.Add(new SeriesPoint("E", new double[] { 17 }));
            series1.Points.Add(new SeriesPoint("F", new double[] { 10 }));
            series1.Points.Add(new SeriesPoint("G", new double[] { 15 }));

            // Add the series to the chart.
            chartControl1.Series.Add(series1);

            // Cast the chart's diagram to the XYDiagram type, to access its axes.
            XYDiagram diagram = chartControl1.Diagram as XYDiagram;

            // Create a constant line.
            ConstantLine constantLine1 = new ConstantLine("Constant Line 1");

            diagram.AxisY.ConstantLines.Add(constantLine1);

            // Define its axis value.
            constantLine1.AxisValue = 7;

            // Customize the behavior of the constant line.
            constantLine1.Visible      = true;
            constantLine1.ShowInLegend = true;
            constantLine1.LegendText   = "Some Threshold";
            constantLine1.ShowBehind   = false;

            // Customize the constant line's title.
            constantLine1.Title.Visible            = true;
            constantLine1.Title.Text               = "Constant Line Title";
            constantLine1.Title.TextColor          = Color.Red;
            constantLine1.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.False;
            constantLine1.Title.Font               = new Font(this.Font.FontFamily.Name, 14, FontStyle.Bold);
            constantLine1.Title.ShowBelowLine      = true;
            constantLine1.Title.Alignment          = ConstantLineTitleAlignment.Far;

            // Customize the appearance of the constant line.
            constantLine1.Color = Color.Red;
            constantLine1.LineStyle.DashStyle = DashStyle.Dash;
            constantLine1.LineStyle.Thickness = 2;

            // Add the chart to the form.
            chartControl1.Dock = DockStyle.Fill;
            this.Controls.Add(chartControl1);
        }
예제 #9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.chart   = this.chartControl1;
            this.diagram = this.chart.Diagram as XYDiagram;
            this.line    = this.diagram.AxisX.ConstantLines.GetConstantLineByName("ConstantLine1");

            // Add a title to the chart.
            ChartTitle chartTitle1 = new ChartTitle();

            chartTitle1.Text = "Drag the constant line...";
            this.chart.Titles.Add(chartTitle1);
        }
예제 #10
0
 void CreateOscilloscopeGrid() {
     SolidColorBrush majorConstantLineBrush = new SolidColorBrush(Color.FromArgb(0x80, 0x4B,0xC7, 0xB9));
     SolidColorBrush minorConstantLineBrush = new SolidColorBrush(Color.FromArgb(0x29, 0x4B, 0xC7, 0xB9));
     for (double i = 0.25; i < 4; i += 0.25) {
         ConstantLine constantLineX = new ConstantLine();
         ConstantLine constantLineY = new ConstantLine();
         constantLineX.Value = constantLineY.Value = i;
         constantLineX.Brush = constantLineY.Brush = (i / 0.25) % 2 == 0 ? majorConstantLineBrush : minorConstantLineBrush;
         gridAxisX.ConstantLinesBehind.Add(constantLineX);
         gridAxisY.ConstantLinesBehind.Add(constantLineY);
     }
 }
        public static void CustomExport(CustomExportWebEventArgs e)
        {
            Dictionary <string, XRControl> controls = e.GetPrintableControls();

            foreach (var control in controls)
            {
                string             componentName = control.Key;
                XRChart            chartControl  = control.Value as XRChart;
                ChartDashboardItem chartItem     = e.GetDashboardItem(componentName) as ChartDashboardItem;
                if (chartControl != null && chartItem != null)
                {
                    string constantLinesJSON = chartItem.CustomProperties["ConstantLineSettings"];
                    if (constantLinesJSON != null)
                    {
                        XYDiagram diagram = chartControl.Diagram as XYDiagram;
                        if (diagram != null)
                        {
                            List <CustomConstantLine> customConstantLines = JsonConvert.DeserializeObject <List <CustomConstantLine> >(constantLinesJSON);
                            customConstantLines.ForEach(customConstantLine =>
                            {
                                ConstantLine line        = new ConstantLine();
                                line.Visible             = true;
                                line.ShowInLegend        = false;
                                line.Color               = ColorTranslator.FromHtml(customConstantLine.color);
                                line.Title.Text          = customConstantLine.labelText;
                                line.LineStyle.DashStyle = DashStyle.Dash;
                                line.LineStyle.Thickness = 2;
                                if (customConstantLine.isBound)
                                {
                                    MultiDimensionalData data = e.GetItemData(componentName);
                                    MeasureDescriptor measure = data.GetMeasures().FirstOrDefault(m => m.ID == customConstantLine.measureId);
                                    if (measure != null)
                                    {
                                        line.AxisValue = data.GetValue(measure).Value;
                                    }
                                }
                                else
                                {
                                    line.AxisValue = customConstantLine.value;
                                }


                                if (diagram.SecondaryAxesY.Count > 0)
                                {
                                    diagram.SecondaryAxesY[0].ConstantLines.Add(line);
                                }
                            });
                        }
                    }
                }
            }
        }
예제 #12
0
        private void InitRangeIndicators()
        {
            lineStart = new ConstantLine(string.Empty, minRange);
            lineStart.LineStyle.DashStyle = DashStyle.Dash;
            lineStart.LineStyle.Thickness = 4;
            lineStart.ShowInLegend        = false;

            lineEnd = new ConstantLine(string.Empty, maxRange);
            lineEnd.LineStyle.DashStyle = DashStyle.Dash;
            lineEnd.LineStyle.Thickness = 4;
            lineEnd.ShowInLegend        = false;
            Diagram.AxisX.ConstantLines.AddRange(new ConstantLine[] { lineStart, lineEnd });
        }
예제 #13
0
        private void Clr_GCStop(GCEndTraceData data)
        {
            DateTime now        = DateTime.Now;
            int      currentPID = Process.GetCurrentProcess().Id;

            if (data.ProcessID == currentPID)
            {
                var line = new ConstantLine(data.Depth.ToString(), now);
                line.Color        = Color.LightGray;
                line.ShowInLegend = false;
                gcseries.Add(line);
            }
        }
예제 #14
0
        public Monitoring()
        {
            InitializeComponent();

            this.seriesArray[0] = new Series("섭씨온도('C)", ViewType.Line);
            this.seriesArray[1] = new Series("화씨온도('F)", ViewType.Line);
            this.seriesArray[2] = new Series("습도(%)", ViewType.Line);

            this.chartCtrl1.Series.Add(this.seriesArray[1]);
            this.chartCtrl1.Series.Add(this.seriesArray[0]);
            this.chartCtrl1.Series.Add(this.seriesArray[2]);

            this.chartCtrl1.CrosshairEnabled = DefaultBoolean.False;
            XYDiagram diagram = (XYDiagram)this.chartCtrl1.Diagram;


            diagram.AxisY.WholeRange.Auto     = false;
            diagram.AxisY.WholeRange.MinValue = 0;
            diagram.AxisY.WholeRange.MaxValue = 100;
            //diagram.AxisX.WholeRange.SideMarginsValue = 0;
            diagram.AxisX.WholeRange.EndSideMargin = 0.4;


            ConstantLine constantLine = new ConstantLine();

            constantLine.Color        = Color.LightYellow;
            constantLine.AxisValue    = 0;
            constantLine.ShowInLegend = false;

            diagram.AxisY.ConstantLines.Add(constantLine);
            diagram.EnableAxisXScrolling = false;
            diagram.EnableAxisXZooming   = false;

            LineSeriesView seriesView0 = (LineSeriesView)seriesArray[0].View;
            LineSeriesView seriesView1 = (LineSeriesView)seriesArray[1].View;
            LineSeriesView seriesView2 = (LineSeriesView)seriesArray[2].View;

            seriesView0.LastPoint.LabelDisplayMode  = SidePointDisplayMode.SeriesPoint;
            seriesView0.LastPoint.Label.TextPattern = "{V:f2}";
            seriesView1.LastPoint.LabelDisplayMode  = SidePointDisplayMode.SeriesPoint;
            seriesView1.LastPoint.Label.TextPattern = "{V:f2}";
            seriesView2.LastPoint.LabelDisplayMode  = SidePointDisplayMode.SeriesPoint;
            seriesView2.LastPoint.Label.TextPattern = "{V:f2}";



            #region 이벤트를 설정한다.
            Load += Monitoring_Load;
            #endregion
        }
        void SetUpLine(Axis chartAxis, Color color, Color textColor, double value)
        {
            ConstantLine line = new ConstantLine()
            {
                AxisValue = value
            };

            line.ShowInLegend        = false;
            line.Color               = color;
            line.LineStyle.Thickness = 2;
            line.LineStyle.DashStyle = DashStyle.Dash;
            line.Title.Text          = "Value: " + value.ToString();
            line.Title.TextColor     = textColor;
            chartAxis.ConstantLines.Add(line);
        }
예제 #16
0
        void chart_BoundDataChanged(object sender, RoutedEventArgs e)
        {
            ConstantLines.Clear();//清理上次显示的线条


            XYDiagram2D diagram = (XYDiagram2D)cc_CaseStatistics.Diagram;

            if (diagram.Series[0].Points.Count == 0)
            {
                return;
            }
            double minPrice     = Double.MaxValue;
            double maxPrice     = 0;
            double averagePrice = 0;

            foreach (SeriesPoint point in diagram.Series[0].Points)
            {
                double price = point.Value;
                if (price < minPrice)
                {
                    minPrice = price;
                }
                if (price > maxPrice)
                {
                    maxPrice = price;
                }
                averagePrice += price;
            }
            averagePrice /= diagram.Series[0].Points.Count;
            ConstantLine minConstantLine = new ConstantLine(minPrice, "最少");

            minConstantLine.Brush            = new SolidColorBrush(Colors.Green);
            minConstantLine.Title.Foreground = new SolidColorBrush(Colors.Green);
            ConstantLine maxConstantLine = new ConstantLine(maxPrice, "最多");

            maxConstantLine.Brush            = new SolidColorBrush(Colors.Red);
            maxConstantLine.Title.Foreground = new SolidColorBrush(Colors.Red);
            ConstantLine averageConstantLine = new ConstantLine(averagePrice, "平均");

            averageConstantLine.Brush            = new SolidColorBrush(Color.FromArgb(0xFF, 0x9A, 0xCD, 0x32));
            averageConstantLine.Title.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x9A, 0xCD, 0x32));
            ConstantLines.AddRange(new ConstantLine[] { minConstantLine, maxConstantLine, averageConstantLine });
            foreach (ConstantLine constantLine in ConstantLines)
            {
                constantLine.Title.Alignment = ConstantLineTitleAlignment.Far;
            }
        }
예제 #17
0
        public void AddHorizontalConstantLine(double value, Color color)
        {
            var yAxis = ContainerChart.ViewXY.YAxes[0];
            var xAxis = ContainerChart.ViewXY.XAxes[0];

            var constantLine = new ConstantLine(ContainerChart.ViewXY, xAxis, yAxis)
            {
                Title            = { Visible = false },
                AssignXAxisIndex = 0,
                LineStyle        = { Color = Color.FromArgb(200, color.R, color.G, color.B) },
                Behind           = true,
            };

            constantLine.LineStyle.Width  = 1;
            constantLine.MouseInteraction = false;
            constantLine.Value            = value;
            ContainerChart.ViewXY.ConstantLines.Add(constantLine);
        }
예제 #18
0
        void initGantt(List<TaskTree> tasktree,DateTime[] projectDate)
        {
            BandedGridView view = advBandedGridView1 as BandedGridView;
            view.BeginUpdate(); //开始视图的编辑,防止触发其他事件
            view.BeginDataUpdate(); //开始数据的编辑
            view.Bands.Clear();
            DateTime start = new DateTime(2013, 12, 10);
            DateTime end = new DateTime(2014, 5, 2);
            GridBand gridBand = view.Bands.AddBand(start.ToString("yy-MM-dd"));
            gridBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            int days = (end - start).Days;
            string Day = "日一二三四五六";
            CustomAxisLabel[] customaxislabels = new CustomAxisLabel[days + 1];
            customaxislabels[0] = new CustomAxisLabel(start.ToString("yy-MM-dd"), start);
            for (int i = 0; i <= days + 1; i++)
            {
                try
                {
                    CustomAxisLabel cal = new CustomAxisLabel();
                    cal.AxisValue = start;
                    cal.Name = start.ToString("yy-MM-dd");
                    customaxislabels[i + 1] = cal;
                    if (start.DayOfWeek == DayOfWeek.Monday)
                    {
                        gridBand = view.Bands.AddBand(start.ToString("yyyy-MM-dd"));
                        gridBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    }
                    GridBand childen = gridBand.Children.AddBand(Day[(int)start.DayOfWeek] + "");
                    childen.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    childen.Width = 24;
                    start = start.AddDays(1);
                }
                catch { }
            }
            gcGanttDate.Width = days * 24 + 2;
            view.EndDataUpdate();//结束数据的编辑
            view.EndUpdate();   //结束视图的编辑

            //设置甘特图属性
            ccProjectGantt.Width = gcGanttDate.Width;
            //chartControl1.Height = 4 * 24;
            ganttDiagram1.AxisX.Visible = false;
            ganttDiagram1.AxisY.CustomLabels.AddRange(customaxislabels);
            ConstantLine progress = new ConstantLine("当前进度", DateTime.Now);
            progress.Color = Color.Red;
            ganttDiagram1.AxisY.ConstantLines.Add(progress);
            ganttDiagram1.AxisY.Range.MinValueInternal = 0;
            ganttDiagram1.AxisY.Range.MaxValueInternal = days * 24;
            ganttDiagram1.AxisY.Visible = false;

            series1.Points.Add(new SeriesPoint("项目进度", new DateTime[] { new DateTime(2013, 12, 12, 0, 0, 0), new DateTime(2014, 4, 30) }));
            SeriesPoint sp = new SeriesPoint();
            series2.Points.Add(new SeriesPoint("产品进度", new DateTime[] { new DateTime(2013, 12, 12), new DateTime(2014, 1, 12) }));
            series2.Points.Add(new SeriesPoint("Task 2", new DateTime[] { new DateTime(2014, 1, 13), new DateTime(2014, 2, 28) }));
            series2.Points.Add(new SeriesPoint("Task 3", new DateTime[] { new DateTime(2014, 3, 1), new DateTime(2014, 3, 30) }));
            series2.Points.Add(new SeriesPoint("Task 4", new DateTime[] { new DateTime(2014, 4, 1), new DateTime(2014, 4, 30) }));
            series2.Points[2].Relations.Add(series2.Points[1]);
            series3.Points.Add(new SeriesPoint("产品进度", new DateTime[] { new DateTime(2013, 12, 12), new DateTime(2014, 1, 12) }));
            series3.Points.Add(new SeriesPoint("Task 2", new DateTime[] { new DateTime(2014, 1, 13), new DateTime(2014, 2, 28) }));
            series3.Points.Add(new SeriesPoint("Task 3", new DateTime[] { new DateTime(2014, 3, 1), new DateTime(2014, 3, 4) }));
            series4.Points.Add(new SeriesPoint("Task 3", new DateTime[] { new DateTime(2014, 3, 4), DateTime.Now }));
        }
예제 #19
0
        public void CreateHVChart()
        {
            XYDiagram pDiagram = chartMain.Diagram as XYDiagram;

            if (pDiagram != null)
            {
                for (int i = pDiagram.AxisX.ConstantLines.Count - 1; i >= 0; i--)
                {
                    if (((SuperTag)pDiagram.AxisX.ConstantLines[i].Tag)?.AxisXConstantLine == "HV")
                    {
                        pDiagram.AxisX.ConstantLines.RemoveAt(i);
                    }
                }
                for (int i = pDiagram.AxisY.ConstantLines.Count - 1; i >= 0; i--)
                {
                    if (((SuperTag)pDiagram.AxisY.ConstantLines[i].Tag)?.AxisYConstantLine == "HV")
                    {
                        pDiagram.AxisY.ConstantLines.RemoveAt(i);
                    }
                }

                if (m_IsShowHV)
                {
                    for (int ii = 0; ii < CETCManagerApp.Instance.m_pETETCStage.m_nHAxisNum; ii++)
                    {
                        Axis pAxisX = pDiagram.AxisX;
                        if (pAxisX != null)
                        {
                            var          pAxisConstantLines = pAxisX.ConstantLines;
                            ConstantLine pAxisConstantLine  = new ConstantLine();

                            string strAxis = string.Format("{0:n1}", CETCManagerApp.Instance.m_pETETCStage.m_fHAxis[ii]);
                            pAxisConstantLine.AxisValue = strAxis;
                            strAxis = string.Format("X{0}:[{1:n1}]", ii + 1, CETCManagerApp.Instance.m_pETETCStage.m_fHAxis[ii]);

                            pAxisConstantLine.ShowInLegend    = false;
                            pAxisConstantLine.Title.Text      = strAxis;
                            pAxisConstantLine.Title.Alignment = ConstantLineTitleAlignment.Near;

                            pAxisConstantLine.Color = Color.FromArgb(255, 0, 0);
                            pAxisConstantLine.Tag   = new SuperTag()
                            {
                                AxisXConstantLine = "HV"
                            };
                            pAxisConstantLines.Add(pAxisConstantLine);
                        }
                    }

                    for (int ii = 0; ii < CETCManagerApp.Instance.m_pETETCStage.m_nVAxisNum; ii++)
                    {
                        Axis pAxisY = pDiagram.AxisY;
                        if (pAxisY != null)
                        {
                            var          pAxisCustomLabels = pAxisY.ConstantLines;
                            ConstantLine pAxisCustomLabel  = new ConstantLine();

                            string strAxis = string.Format("{0:n1}", CETCManagerApp.Instance.m_pETETCStage.m_fVAxis[ii]);
                            pAxisCustomLabel.AxisValue = strAxis;
                            strAxis = string.Format("Y{0}:[{1:n1}]", ii + 1, CETCManagerApp.Instance.m_pETETCStage.m_fVAxis[ii]);

                            pAxisCustomLabel.ShowInLegend    = false;
                            pAxisCustomLabel.Title.Text      = strAxis;
                            pAxisCustomLabel.Title.Alignment = ConstantLineTitleAlignment.Far;
                            pAxisCustomLabel.Color           = Color.FromArgb(0, 0, 0);
                            pAxisCustomLabel.Tag             = new SuperTag()
                            {
                                AxisYConstantLine = "HV"
                            };
                            pAxisCustomLabels.Add(pAxisCustomLabel);
                        }
                    }
                }
            }
        }
예제 #20
0
        private void CheckInitializeTimeAxis()
        {
            int      totalMinutes = Visual.MeasureUnitMultiplier;
            DateTime first        = DateTime.MinValue;
            DateTime last         = DateTime.MaxValue;

            ((XYDiagram)Chart.Diagram).AxisX.DateTimeScaleOptions.MeasureUnit = (DateTimeMeasureUnit)Enum.Parse(typeof(DateTimeMeasureUnit), Visual.MeasureUnit.ToString());
            if (Visual.Items != null && Visual.Items.Count > 1)
            {
                object       data1    = Visual.Items[1];
                object       data0    = Visual.Items[0];
                object       dataLast = Visual.Items.Last();
                PropertyInfo pi       = data1.GetType().GetProperty("Time", BindingFlags.Public | BindingFlags.Instance);
                if (pi != null)
                {
                    DateTime time1 = (DateTime)pi.GetValue(data1);
                    DateTime time0 = (DateTime)pi.GetValue(data0);
                    first        = time1;
                    last         = (DateTime)pi.GetValue(dataLast);
                    totalMinutes = (int)((time1 - time0).TotalMinutes);
                }
            }

            StrategyDataItemInfo di = Visual.DataItemInfos.FirstOrDefault(i => i.Type == DataType.DateTime && i.FieldName == "Time");

            if (di != null)
            {
                if (di.UseCustomTimeUnit)
                {
                    ((XYDiagram)Chart.Diagram).AxisX.DateTimeScaleOptions.MeasureUnit           = (DateTimeMeasureUnit)Enum.Parse(typeof(DateTimeMeasureUnit), di.TimeUnit.ToString());
                    ((XYDiagram)Chart.Diagram).AxisX.DateTimeScaleOptions.MeasureUnitMultiplier = di.TimeUnitMeasureMultiplier;
                }
            }

            ((XYDiagram)Chart.Diagram).AxisX.DateTimeScaleOptions.MeasureUnitMultiplier   = totalMinutes;
            ((XYDiagram)Chart.Diagram).AxisX.Label.ResolveOverlappingOptions.AllowRotate  = false;
            ((XYDiagram)Chart.Diagram).AxisX.Label.ResolveOverlappingOptions.AllowStagger = false;

            ((XYDiagram)Chart.Diagram).AxisX.LabelVisibilityMode = AxisLabelVisibilityMode.AutoGeneratedAndCustom;
            if (first != DateTime.MinValue)
            {
                DateTime current = first.Date;
                while (current <= last)
                {
                    ConstantLine constantLine = new ConstantLine(current.ToShortDateString(), current)
                    {
                        Color = Color.FromArgb(0x40, Color.LightGray), ShowInLegend = false
                    };
                    constantLine.Title.Visible = false;
                    ((XYDiagram)Chart.Diagram).AxisX.ConstantLines.Add(constantLine);
                    ((XYDiagram)Chart.Diagram).AxisX.CustomLabels.Add(new CustomAxisLabel(current.ToShortDateString(), current));
                    current = current.AddDays(1);
                }
            }

            StrategyDataItemInfo time = Visual.DataItemInfos.FirstOrDefault(i => i.Name == "Time");
            string datePattern        = "{A:dd.MM hh:mm:ss}";

            if (time != null && !string.IsNullOrEmpty(time.LabelPattern))
            {
                datePattern = "{A:" + time.LabelPattern + "}";
            }

            if (Chart.Series[0].ArgumentScaleType == ScaleType.Numerical)
            {
                ((XYDiagram)Chart.Diagram).AxisX.Label.TextPattern = "{A}";
            }
            else
            {
                ((XYDiagram)Chart.Diagram).AxisX.Label.TextPattern = datePattern;
            }
        }
        /// <summary>
        /// Generates Past 12 Months charts
        /// </summary>
        private void GenerateChartsPastMonths()
        {
            Balance bal = new Balance();
            GeneralInfo info = new GeneralInfo();
            info.LoadAll();
            DataTable dtList = new DataTable();
            DataTable dtAmc = new DataTable();
            DataTable dtMOS = new DataTable();
            DataTable dtIss = new DataTable();
            DataTable dtRec = new DataTable();
            DataTable dtBB = new DataTable();

            //foreach(string s in co)
            //{
            dtList.Columns.Add("Month");
            dtList.Columns.Add("Value");
            dtList.Columns[1].DataType = typeof(Int64);

            dtMOS.Columns.Add("Month");
            dtMOS.Columns.Add("Value");
            dtMOS.Columns[1].DataType = typeof(Int32);

            dtAmc.Columns.Add("Month");
            dtAmc.Columns.Add("Value");
            dtAmc.Columns[1].DataType = typeof(Int64);

            dtIss.Columns.Add("Month");
            dtIss.Columns.Add("Value");
            dtIss.Columns[1].DataType = typeof(Int64);

            dtRec.Columns.Add("Month");
            dtRec.Columns.Add("Value");
            dtRec.Columns[1].DataType = typeof(Int64);

            dtBB.Columns.Add("Month");
            dtBB.Columns.Add("Value");
            dtBB.Columns[1].DataType = typeof(Int64);

            //dtDate.Value = DateTime.Now;
            //dtDate.CustomFormat = "MM/dd/yyyy";
            //DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text);
            DateTime dtPast = _dtCurrent.AddMonths(-11);
            //CALENDAR:
            string[] wer = { "Mes", "Tek", "Hed", "Tah", "Tir", "Yek", "Meg", "Miz", "Gen", "Sen", "Ham", "Neh" };
            string[] co = new string[12];
            int[] mon = new int[12];
            int[] yr = new int[12];
            int intialM = dtPast.Month;
            int j = 0;
            while (dtPast <= _dtCurrent && j < 12)
            {
                //mon[j] = intialM;
                //co[j] = wer[intialM-1];
                //yr[j] = (intialM < 11)?dtPast.Year: dtPast.Year +1;
                //dtPast = dtPast.AddMonths(1);
                //intialM = dtPast.Month;
                mon[j] = dtPast.Month;
                co[j] = wer[intialM - 1];
                yr[j] = dtPast.Year;
                dtPast = dtPast.AddMonths(1);
                intialM = dtPast.Month;
                j++;
            }
            //{ 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            long[] cons = new long[12];
            long[] amc = new long[12];
            DataTable dtBal = new DataTable();
            IssueDoc issd = new IssueDoc();
            Items recd = new Items();

            YearEnd yEnd = new YearEnd();
            Int64 bb = yEnd.GetBBalance(_year, _storeId, _itemId, 10);
            object[] objBB = { "Ham", bb };
            dtBB.Rows.Add(objBB);

            for (int i = 0; i < mon.Length; i++)
            {
                Int64 con = bal.GetSOH(_itemId, _storeId, mon[i], yr[i]);
                object[] str = { co[i], con };
                amc[i] = bal.CalculateAMC(_itemId, _storeId, mon[i], yr[i]);
                object[] objAmc = { co[i], amc[i] };
                decimal mos = (amc[i] > 0) ? (Convert.ToDecimal(con) / Convert.ToDecimal(amc[i])) : 0;
                mos = Decimal.Round(mos, 1);

                object[] objMos = { co[i], mos };
                Int64 issval = issd.GetIssuedQuantityByMonth(_itemId, _storeId, mon[i], yr[i]);
                object[] objIss = { co[i], issval };

                Int64 recVal = recd.GetQuantityReceiveByItemPerMonth(mon[i], _itemId, _storeId, yr[i]);
                object[] objrec = { co[i], recVal };

                dtList.Rows.Add(str);
                dtAmc.Rows.Add(objAmc);
                dtMOS.Rows.Add(objMos);
                dtIss.Rows.Add(objIss);
                dtRec.Rows.Add(objrec);
                //}
            }
            // string[] str = { ((cons[0] != 0) ? cons[0].ToString("") : "0"), ((cons[1] != 0) ? cons[1].ToString() : "0"), ((cons[2] != 0) ? cons[2].ToString() : "0"), ((cons[3] != 0) ? cons[3].ToString() : "0"), ((cons[4] != 0) ? cons[4].ToString() : "0"), ((cons[5] != 0) ? cons[5].ToString() : "0"), ((cons[6] != 0) ? cons[6].ToString() : "0"), ((cons[7] != 0) ? cons[7].ToString() : "0"), ((cons[8] != 0) ? cons[8].ToString() : "0"), ((cons[9] != 0) ? cons[9].ToString() : "0"), ((cons[10] != 0) ? cons[10].ToString() : "0"), ((cons[11] != 0) ? cons[11].ToString() : "0")};
            chartAmc.Series.Clear();
            chartComp.Series.Clear();
            chartBar.Series.Clear();
            chartMOS.Series.Clear();
            consuTrend.Series.Clear();

            Series ser = new Series("Stock On Hand", ViewType.Line);
            ser.DataSource = dtList;
            ser.ArgumentScaleType = ScaleType.Qualitative;
            ser.ArgumentDataMember = "Month";
            ser.ValueScaleType = ScaleType.Numerical;
            ser.ValueDataMembers.AddRange(new string[] { "Value" });
            chartBar.Series.Add(ser);

            Series serB = new Series("Begining Balance", ViewType.Bar);
            serB.DataSource = dtBB;
            serB.ArgumentScaleType = ScaleType.Qualitative;
            serB.ArgumentDataMember = "Month";
            serB.ValueScaleType = ScaleType.Numerical;
            serB.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            serB.PointOptions.ValueNumericOptions.Precision = 0;
            serB.ValueDataMembers.AddRange(new string[] { "Value" });
            chartComp.Series.Add(serB);

            Series serRec = new Series("Received Qty", ViewType.Bar);
            serRec.DataSource = dtRec;
            serRec.ArgumentScaleType = ScaleType.Qualitative;
            serRec.ArgumentDataMember = "Month";
            serRec.ValueScaleType = ScaleType.Numerical;
            serRec.ValueDataMembers.AddRange(new string[] { "Value" });
            chartComp.Series.Add(serRec);

            Series serAmc = new Series("Average Monthly Consumption", ViewType.Line);
            serAmc.DataSource = dtAmc;
            serAmc.ArgumentScaleType = ScaleType.Qualitative;
            serAmc.ArgumentDataMember = "Month";
            serAmc.ValueScaleType = ScaleType.Numerical;
            serAmc.ValueDataMembers.AddRange(new string[] { "Value" });
            chartAmc.Series.Add(serAmc);

            Series serIss = new Series("Issue Qty", ViewType.Bar);
            serIss.DataSource = dtIss;
            serIss.ArgumentScaleType = ScaleType.Qualitative;
            serIss.ArgumentDataMember = "Month";
            serIss.ValueScaleType = ScaleType.Numerical;
            serIss.ValueDataMembers.AddRange(new string[] { "Value" });
            chartComp.Series.Add(serIss);

            Series serSOH = new Series("SOH", ViewType.Bar);
            serSOH.DataSource = dtList;
            serSOH.ArgumentScaleType = ScaleType.Qualitative;
            serSOH.ArgumentDataMember = "Month";
            serSOH.ValueScaleType = ScaleType.Numerical;
            serSOH.ValueDataMembers.AddRange(new string[] { "Value" });
            chartComp.Series.Add(serSOH);

            Series sercons = new Series("Consumption Trend", ViewType.Line);
            sercons.DataSource = dtIss;
            sercons.ArgumentScaleType = ScaleType.Qualitative;
            sercons.ArgumentDataMember = "Month";
            sercons.ValueScaleType = ScaleType.Numerical;
            sercons.ValueDataMembers.AddRange(new string[] { "Value" });
            consuTrend.Series.Add(sercons);

            Series serMos = new Series("Month Of Stock", ViewType.Line);
            serMos.DataSource = dtMOS;
            serMos.ArgumentScaleType = ScaleType.Qualitative;
            serMos.ArgumentDataMember = "Month";
            serMos.ValueScaleType = ScaleType.Numerical;
            serMos.ValueDataMembers.AddRange(new string[] { "Value" });

            chartMOS.Series.Add(serMos);
            ((XYDiagram)chartMOS.Diagram).AxisY.Range.MaxValue = 12;

            Int64 amcCurent = bal.CalculateAMC(_itemId, _storeId, _dtCurrent.Month, _year);
            //Int64 soh = bal.GetSOH(itemId,storeId,dtCurrent.Month,year);
            //if (bal.RowCount > 0)
            //{
            Int64 min = info.Min * amcCurent;
            Int64 max = info.Max * amcCurent;
            ConstantLine target = new ConstantLine();
            target.AxisValue = min;
            //which min and max to show month
            ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Clear();
            target.Visible = true;
            target.Title.Text = "Current Min value is " + target.AxisValue.ToString() + " " + lblBUnit.Text;
            target.Color = Color.Red;
            target.LineStyle.Thickness = 2;
            // ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Add(target);

            ConstantLine targetMax = new ConstantLine();
            targetMax.AxisValue = max;
            //which min and max to show month
            targetMax.Visible = true;
            targetMax.Title.Text = "Current Max value is " + targetMax.AxisValue.ToString() + " " + lblBUnit.Text;
            targetMax.Color = Color.Blue;
            targetMax.LineStyle.Thickness = 2;
            //((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Add(targetMax);
            //}
        }
예제 #22
0
        // 回流炉
        public void CreateReflowerChart()
        {
            XYDiagram pDiagram = chartMain.Diagram as XYDiagram;

            //ASSERT(pDiagram);
            if (pDiagram != null)
            {
                for (int i = m_pChartSeries.Count - 1; i >= 0; i--)
                {
                    if (((SuperTag)m_pChartSeries[i].Tag)?.SeriesMark == "Reflower")
                    {
                        m_pChartSeries.RemoveAt(i);
                    }
                }

                /*for (int i = m_pChartSeries.Count - 1; i >= 0; i--)
                 * {
                 *  if (m_pChartSeries[i].Tag?.ToString() == "Reflower")
                 *  {
                 *      m_pChartSeries.RemoveAt(i);
                 *  }
                 * }*/

                for (int i = pDiagram.AxisX.ConstantLines.Count - 1; i >= 0; i--)
                {
                    if (((SuperTag)pDiagram.AxisX.ConstantLines[i].Tag)?.AxisXConstantLine == "Reflower")
                    {
                        pDiagram.AxisX.ConstantLines.RemoveAt(i);
                    }
                }

                for (int i = pDiagram.AxisY.ConstantLines.Count - 1; i >= 0; i--)
                {
                    if (((SuperTag)pDiagram.AxisY.ConstantLines[i].Tag)?.AxisYConstantLine == "Reflower")
                    {
                        pDiagram.AxisY.ConstantLines.RemoveAt(i);
                    }
                }

                if (m_IsShowReflowerZone)
                {
                    double dReflowerlenth         = CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_fInitTempl;
                    var    pReflowerAreaData_Hot  = CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_CAreaData["Hot"];
                    var    pReflowerAreaData_Cool = CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_CAreaData["Cool"];

                    for (int ii = 0; ii < CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_nSampleHeaterAreaCount; ii++)
                    {
                        Series      pSeries     = new Series("", ViewType.Line);
                        CETReflower pETReflower = CETCManagerApp.Instance.m_pETETCStage.m_ETReflower;

                        pSeries.CrosshairEnabled  = DefaultBoolean.False;
                        pSeries.View.Color        = Color.FromArgb(0, 255, 0);
                        pSeries.ArgumentScaleType = ScaleType.Numerical;
                        pSeries.ValueScaleType    = ScaleType.Numerical;
                        pSeries.ShowInLegend      = false;
                        pSeries.Tag = new SuperTag()
                        {
                            SeriesMark = "Reflower"
                        };

                        ((LineSeriesView)pSeries.View).LineStyle.Thickness = 2;

                        // 竖线
                        // 获得时间
                        double dZonePosX  = (dReflowerlenth / pETReflower.m_fSpeed) * 60.0;
                        double dTempWidth = (pReflowerAreaData_Hot[ii].m_fAreaLength / pETReflower.m_fSpeed) * 60.0;

                        SeriesPoint pSeriesPoint = new SeriesPoint(dZonePosX, pReflowerAreaData_Hot[ii].m_fAreaTemplTop);


                        pSeries.Points.Add(pSeriesPoint);
                        pSeriesPoint = new SeriesPoint(dZonePosX + dTempWidth, pReflowerAreaData_Hot[ii].m_fAreaTemplTop);
                        pSeries.Points.Add(pSeriesPoint);

                        // 横线
                        AxisX pAxisX = pDiagram.AxisX;
                        if (pAxisX != null)
                        {
                            var          pAxisCustomLabels = pAxisX.ConstantLines;
                            ConstantLine pAxisCustomLabel  = new ConstantLine();

                            // 获得时间
                            pAxisCustomLabel.AxisValue = dZonePosX.ToString("n1");

                            if (ii != CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_nSampleHeaterAreaCount)
                            {
                                string strTingTemp = string.Format(" [{0:n1}°C]", pReflowerAreaData_Hot[ii].m_fAreaTemplTop);

                                pAxisCustomLabel.Title.Text      = pReflowerAreaData_Hot[ii].m_strAreaTitle + strTingTemp;
                                pAxisCustomLabel.Title.Alignment = ConstantLineTitleAlignment.Far;
                            }

                            pAxisCustomLabel.Color               = Color.FromArgb(0, 128, 0);
                            pAxisCustomLabel.Title.TextColor     = Color.FromArgb(0, 128, 0);
                            pAxisCustomLabel.LineStyle.DashStyle = DashStyle.Dash;
                            pAxisCustomLabel.LineStyle.Thickness = 2;
                            pAxisCustomLabel.ShowInLegend        = false;
                            pAxisCustomLabel.Tag = new SuperTag()
                            {
                                AxisXConstantLine = "Reflower"
                            };
                            pAxisCustomLabels.Add(pAxisCustomLabel);

                            pSeries.Name = pAxisCustomLabel.AxisValue.ToString();
                        }

                        if (ii != CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_nSampleHeaterAreaCount - 1)
                        {
                            dReflowerlenth += pReflowerAreaData_Hot[ii].m_fAreaLength;
                            m_pChartSeries.Add(pSeries);
                        }
                        else
                        {
                            if (CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_nSampleCoolAreaCount > 0)
                            {
                                //dReflowerlenth += pReflowerAreaData_Hot[ii].m_fAreaLength;
                                dReflowerlenth += pReflowerAreaData_Cool[0].m_fAreaLength;
                                m_pChartSeries.Add(pSeries);
                            }
                        }
                    }


                    //      //
                    for (int ii = 0; ii < CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_nSampleCoolAreaCount; ii++)
                    {
                        Series      pSeries     = new Series("", ViewType.Line);
                        CETReflower pETReflower = CETCManagerApp.Instance.m_pETETCStage.m_ETReflower;

                        pSeries.View.Color        = Color.FromArgb(0, 255, 0);
                        pSeries.CrosshairEnabled  = DefaultBoolean.False;
                        pSeries.ArgumentScaleType = ScaleType.Numerical;
                        pSeries.ValueScaleType    = ScaleType.Numerical;
                        pSeries.ShowInLegend      = false;
                        pSeries.Tag = new SuperTag()
                        {
                            SeriesMark = "Reflower"
                        };
                        ((LineSeriesView)pSeries.View).LineStyle.Thickness = 2;

                        // 竖线
                        // 获得时间
                        double dZonePosX = (dReflowerlenth / pETReflower.m_fSpeed) * 60.0;//Frm_Main.GetMainForm().m_pETETCStage.m_nSampleRate*60;
                        //double dTempWith = (pETReflower.m_fAreaLength[ii + 12] / pETReflower.m_fSpeed) * 60.0;//Frm_Main.GetMainForm().m_pETETCStage.m_nSampleRate*60;
                        double dTempWith = (pReflowerAreaData_Cool[ii].m_fAreaLength / pETReflower.m_fSpeed) * 60.0;

                        //
                        //SeriesPoint pSeriesPoint = new SeriesPoint(dZonePosX, pETReflower.m_fAreaTemplTop[ii + 12]);
                        SeriesPoint pSeriesPoint = new SeriesPoint(dZonePosX, pReflowerAreaData_Cool[ii].m_fAreaTemplTop);
                        pSeries.Points.Add(pSeriesPoint);
                        //pSeriesPoint = new SeriesPoint(dZonePosX + dTempWith, pETReflower.m_fAreaTemplTop[ii + 12]);
                        pSeriesPoint = new SeriesPoint(dZonePosX + dTempWith, pReflowerAreaData_Cool[ii].m_fAreaTemplTop);
                        pSeries.Points.Add(pSeriesPoint);


                        //
                        // 横线
                        Axis pAxisX = pDiagram.AxisX;
                        if (pAxisX != null)
                        {
                            var          pAxisCustomLabels = pAxisX.ConstantLines;
                            ConstantLine pAxisCustomLabel  = new ConstantLine();

                            // 获得时间
                            pAxisCustomLabel.AxisValue = dZonePosX.ToString("n1");

                            if (ii != CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_nSampleCoolAreaCount)
                            {
                                //string strTingTemp = string.Format(" [{0:n1}°C]", pETReflower.m_fAreaTemplTop[ii + 12]);
                                string strTingTemp = string.Format(" [{0:n1}°C]", pReflowerAreaData_Cool[ii].m_fAreaTemplTop);
                                //pAxisCustomLabel.Title.Text = pETReflower.m_strAreaTitle[ii + 12] + strTingTemp;
                                pAxisCustomLabel.Title.Text      = pReflowerAreaData_Cool[ii].m_strAreaTitle + strTingTemp;
                                pAxisCustomLabel.Title.Alignment = ConstantLineTitleAlignment.Far;
                            }

                            pAxisCustomLabel.Color               = Color.FromArgb(0, 128, 0);
                            pAxisCustomLabel.Title.TextColor     = Color.FromArgb(0, 128, 0);
                            pAxisCustomLabel.LineStyle.DashStyle = DashStyle.Dash;
                            pAxisCustomLabel.LineStyle.Thickness = 2;
                            pAxisCustomLabel.ShowInLegend        = false;
                            pAxisCustomLabel.Tag = new SuperTag()
                            {
                                AxisXConstantLine = "Reflower"
                            };
                            pAxisCustomLabels.Add(pAxisCustomLabel);

                            pSeries.Name = pAxisCustomLabel.AxisValue.ToString();
                        }
                        if (ii != CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_nSampleCoolAreaCount - 1)
                        {
                            //dReflowerlenth += pETReflower.m_fAreaLength[ii + 12];
                            dReflowerlenth += pReflowerAreaData_Cool[ii].m_fAreaLength;
                            m_pChartSeries.Add(pSeries);
                        }
                    }
                    //

                    /*Series pSeries2 = new Series("", ViewType.Line);
                     * CETReflower pETReflower2 = Frm_Main.GetMainForm().m_pETETCStage.m_ETReflower;
                     *
                     * pSeries2.View.Color = Color.FromArgb(0, 255, 0);
                     *
                     * pSeries2.ArgumentScaleType = ScaleType.Numerical;
                     * //pSeries2.ArgumentDataMember = "時間";
                     * pSeries2.ValueScaleType = ScaleType.Numerical;
                     * pSeries2.ShowInLegend = false;
                     * ((LineSeriesView)pSeries2.View).LineStyle.Thickness = 2;
                     *
                     * // 竖线
                     * //
                     * // 横线
                     * Axis pAxisX2 = pDiagram.AxisX;
                     * if (pAxisX2 != null)
                     * {
                     *  // 获得时间
                     *  var pAxisCustomLabels = pAxisX2.ConstantLines;
                     *  ConstantLine pAxisCustomLabel = new ConstantLine();
                     *  string strAxis = ((pETReflower2.m_fInitTempl / pETReflower2.m_fSpeed) * 60.0).ToString();
                     *  pAxisCustomLabel.AxisValue = string.Format("n1", strAxis);
                     *  pAxisCustomLabel.Color = Color.FromArgb(255, 0, 0);
                     *  pAxisCustomLabel.Title.TextColor = Color.FromArgb(255, 0, 0);
                     *  pAxisCustomLabel.LineStyle.DashStyle = DashStyle.Solid;
                     *  pAxisCustomLabel.LineStyle.Thickness = 2;
                     *  pAxisCustomLabel.ShowInLegend = false;
                     *  pAxisCustomLabels.Add(pAxisCustomLabel);
                     *  pSeries2.Name = pAxisCustomLabel.AxisValue.ToString();
                     * }
                     *
                     * pCollection.Add(pSeries2);*/
                }
            }
        }
예제 #23
0
        public void SetGraph(string DeviceName, System.DateTime starttime, System.DateTime endtime)
        {
            try
            {
                DBPerformanceWebChartControl.Series.Clear();
                DataTable dt = VSWebBL.DashboardBL.DatabaseHealthBL.Ins.SetGraph(DeviceName, starttime, endtime);

                Series series = null;
                series                    = new Series("DominoServer", ViewType.Line);
                series.Visible            = true;
                series.ArgumentDataMember = dt.Columns["Date"].ToString();

                ValueDataMemberCollection seriesValueDataMembers = (ValueDataMemberCollection)series.ValueDataMembers;
                seriesValueDataMembers.AddRange(dt.Columns["StatValue"].ToString());
                DBPerformanceWebChartControl.Series.Add(series);

                // Constant Line

                // Cast the chart's diagram to the XYDiagram type, to access its axes.
                XYDiagram diagram = (XYDiagram)DBPerformanceWebChartControl.Diagram;

                // Create a constant line.
                ConstantLine constantLine1 = new ConstantLine("Constant Line 1");
                diagram.AxisY.ConstantLines.Add(constantLine1);

                // Define its axis value.
                constantLine1.AxisValue = 25000;

                // Customize the behavior of the constant line.
                // constantLine1.Visible = true;
                //constantLine1.ShowInLegend = true;
                // constantLine1.LegendText = "Some Threshold";
                constantLine1.ShowBehind = true;

                // Customize the constant line's title.
                constantLine1.Title.Visible   = true;
                constantLine1.Title.Text      = "Threshold:25000";
                constantLine1.Title.TextColor = Color.Red;
                // constantLine1.Title.Antialiasing = false;
                //constantLine1.Title.Font = new Font("Tahoma", 14, FontStyle.Bold);
                constantLine1.Title.ShowBelowLine = true;
                constantLine1.Title.Alignment     = ConstantLineTitleAlignment.Far;

                // Customize the appearance of the constant line.
                constantLine1.Color = Color.Red;
                constantLine1.LineStyle.DashStyle = DashStyle.Solid;
                constantLine1.LineStyle.Thickness = 4;



                ((XYDiagram)DBPerformanceWebChartControl.Diagram).PaneLayoutDirection = PaneLayoutDirection.Horizontal;

                XYDiagram seriesXY = (XYDiagram)DBPerformanceWebChartControl.Diagram;
                seriesXY.AxisY.Title.Text    = "ResponseTme";
                seriesXY.AxisY.Title.Visible = true;

                DBPerformanceWebChartControl.Legend.Visible = false;

                // ((SplineSeriesView)series.View).LineTensionPercent = 100;
                ((LineSeriesView)series.View).LineMarkerOptions.Size  = 4;
                ((LineSeriesView)series.View).LineMarkerOptions.Color = Color.White;

                AxisBase axis = ((XYDiagram)DBPerformanceWebChartControl.Diagram).AxisX;
                //4/18/2014 NS commented out for VSPLUS-312
                //axis.DateTimeGridAlignment = DateTimeMeasurementUnit.Day;
                axis.GridSpacingAuto                = false;
                axis.MinorCount                     = 15;
                axis.GridSpacing                    = 0.5;
                axis.Range.SideMarginsEnabled       = false;
                axis.GridLines.Visible              = true;
                axis.DateTimeOptions.Format         = DateTimeFormat.Custom;
                axis.DateTimeOptions.FormatString   = "dd/MM HH:mm";
                ((LineSeriesView)series.View).Color = Color.Blue;

                AxisBase axisy = ((XYDiagram)DBPerformanceWebChartControl.Diagram).AxisY;
                axisy.Range.AlwaysShowZeroLevel = false;
                axisy.Range.SideMarginsEnabled  = true;

                DBPerformanceWebChartControl.DataSource = dt;
                DBPerformanceWebChartControl.DataBind();
            }
            catch (Exception ex)
            {
                Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                throw ex;
            }
        }
예제 #24
0
        public void SetGraphs(LightningChartUltimate throughputGraph, LightningChartUltimate tfGraph,
                              LightningChartUltimate timeGraph, LightningChartUltimate freqGraph)
        {
            int    i, j;
            double fstart = _dataFileNode.fstart;
            double df     = _dataFileNode.fs / _dataFileNode.Nfft / 2;

            float[] maxfreq = _dbClientService.getMaxFrf(_dataFileNode.Id);
            flen = maxfreq.Length;

            _throughputGraph = throughputGraph;
            _tfGraph         = tfGraph;
            _timeGraph       = timeGraph;
            _freqGraph       = freqGraph;

            {
                _throughputGraph.BeginUpdate();
                _throughputGraph.Title.Visible = false;
                _throughputGraph.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.TopRight;
                _throughputGraph.ViewXY.LegendBoxes[0].Layout   = LegendBoxLayout.Vertical;
                AxisX axisX = _throughputGraph.ViewXY.XAxes[0];
                axisX.Title.Text = "时间(s)";
                AxisY axisY0 = _throughputGraph.ViewXY.YAxes[0];
                axisY0.Title.Text = "声压(Pa)";
                AxisY axisY1 = new AxisY(_throughputGraph.ViewXY);
                axisY1.Title.Text = "总声压级(dBA)";
                _throughputGraph.ViewXY.YAxes.Add(axisY1);

                _maxrmsSeries                      = new SampleDataSeries(_throughputGraph.ViewXY, axisX, axisY1);
                _maxrmsSeries.Title.Text           = "最大总声压级";
                _maxrmsSeries.LineStyle.Color      = Colors.Red;
                _maxrmsSeries.SampleFormat         = SampleFormat.SingleFloat;
                _maxrmsSeries.FirstSampleTimeStamp = _dataFileNode.Nfft / _dataFileNode.fs / 2;
                _maxrmsSeries.SamplingFrequency    = _dataFileNode.fs / _dataFileNode.FrameDN;
                _throughputGraph.ViewXY.SampleDataSeries.Add(_maxrmsSeries);

                _rmsSeries                      = new SampleDataSeries(_throughputGraph.ViewXY, axisX, axisY1);
                _rmsSeries.Title.Text           = "总声压级";
                _rmsSeries.LineStyle.Color      = Colors.Blue;
                _rmsSeries.SampleFormat         = SampleFormat.SingleFloat;
                _rmsSeries.FirstSampleTimeStamp = _maxrmsSeries.FirstSampleTimeStamp;
                _rmsSeries.SamplingFrequency    = _maxrmsSeries.SamplingFrequency;
                _throughputGraph.ViewXY.SampleDataSeries.Add(_rmsSeries);

                _throughputgraph_verticalCursor                   = new LineSeriesCursor(_throughputGraph.ViewXY, axisX);
                _throughputgraph_verticalCursor.Style             = CursorStyle.VerticalNoTracking;
                _throughputgraph_verticalCursor.LineStyle.Color   = Colors.White;
                _throughputgraph_verticalCursor.LineStyle.Pattern = LinePattern.Dot;
                _throughputgraph_verticalCursor.LineStyle.Width   = 3;
                _throughputgraph_verticalCursor.ValueAtXAxis      = 10;
                _throughputgraph_verticalCursor.MouseHighlight    = MouseOverHighlight.None;
                _throughputGraph.ViewXY.LineSeriesCursors.Add(_throughputgraph_verticalCursor);

                _throughputSeries                      = new SampleDataSeries(_throughputGraph.ViewXY, axisX, axisY0);
                _throughputSeries.Title.Text           = "时域";
                _throughputSeries.LineStyle.Color      = Colors.Orange;
                _throughputSeries.SampleFormat         = SampleFormat.SingleFloat;
                _throughputSeries.FirstSampleTimeStamp = 0;
                _throughputSeries.SamplingFrequency    = _dataFileNode.fs;
                _throughputGraph.ViewXY.SampleDataSeries.Add(_throughputSeries);

                float[] _maxrmsData = new float[_dataFileNode.NFrame];
                _rmsData[0].CopyTo(_maxrmsData, 0);
                for (i = 1; i < _dataFileNode.NFrame; i++)
                {
                    for (j = 0; j < _dataFileNode.ChannelNum; j++)
                    {
                        if (_rmsData[j][i] > _maxrmsData[i])
                        {
                            _maxrmsData[i] = _rmsData[j][i];
                        }
                    }
                }
                _maxrmsSeries.SamplesSingle = _maxrmsData;

                _throughputGraph.EndUpdate();
            }

            {
                _tfGraph.BeginUpdate();
                _tfGraph.Title.Visible = false;
                //_tfGraph.ViewXY.LegendBoxes[0].Visible = false;
                _tfGraph.ViewXY.LegendBoxes[0].Position       = LegendBoxPositionXY.TopRight;
                _tfGraph.ViewXY.LegendBoxes[0].ShowCheckboxes = false;
                AxisX axisX = _tfGraph.ViewXY.XAxes[0];
                axisX.Title.Text = "时间(s)";
                AxisY axisY = _tfGraph.ViewXY.YAxes[0];
                axisY.Title.Text = "频率(Hz)";

                _tfSeries = new IntensityGridSeries(_throughputGraph.ViewXY, axisX, axisY);
                _tfSeries.PixelRendering    = true;
                _tfSeries.ContourLineType   = ContourLineTypeXY.None;
                _tfSeries.ValueRangePalette = CreatePalette(_tfSeries, 20, 100);
                _tfSeries.SetRangesXY(_dataFileNode.Nfft / _dataFileNode.fs / 2,
                                      _dataFileNode.Nfft / _dataFileNode.fs / 2 + (_dataFileNode.NFrame - 1) * _dataFileNode.FrameDN / _dataFileNode.fs,
                                      fstart, fstart + (flen - 1) * df);
                _tfSeries.MouseInteraction      = false;
                _tfSeries.LegendBoxUnits        = null;
                _tfSeries.LegendBoxValuesFormat = "0";
                //_tfSeries.Title.Visible = false;
                _tfSeries.Title.Text = "声压级(dBA)";
                _tfGraph.ViewXY.IntensityGridSeries.Add(_tfSeries);

                _tfgraph_verticalCursor                   = new LineSeriesCursor(_tfGraph.ViewXY, axisX);
                _tfgraph_verticalCursor.Style             = CursorStyle.VerticalNoTracking;
                _tfgraph_verticalCursor.LineStyle.Color   = Colors.White;
                _tfgraph_verticalCursor.LineStyle.Pattern = LinePattern.Dot;
                _tfgraph_verticalCursor.LineStyle.Width   = 3;
                _tfgraph_verticalCursor.ValueAtXAxis      = _throughputgraph_verticalCursor.ValueAtXAxis;
                _tfgraph_verticalCursor.MouseHighlight    = MouseOverHighlight.None;
                _tfGraph.ViewXY.LineSeriesCursors.Add(_tfgraph_verticalCursor);

                _tfgraph_horizontalCursor = new ConstantLine(_tfGraph.ViewXY, axisX, axisY);
                _tfgraph_horizontalCursor.LineStyle.Color   = Colors.White;
                _tfgraph_horizontalCursor.LineStyle.Width   = 3;
                _tfgraph_horizontalCursor.LineStyle.Pattern = LinePattern.Dot;
                _tfgraph_horizontalCursor.Value             = 2000;
                _tfgraph_horizontalCursor.ShowInLegendBox   = false;
                _tfgraph_horizontalCursor.MouseHighlight    = MouseOverHighlight.None;
                _tfGraph.ViewXY.ConstantLines.Add(_tfgraph_horizontalCursor);

                spectrumCalculator = new SpectrumCalculator();
                double[] _aweight = Weight.GetWeightData(FreqWeightType.AWeight, fstart, df, flen);
                _aweightdb = new double[_aweight.Length];

                for (i = 0; i < flen; i++)
                {
                    _aweightdb[i] = 20 * Math.Log10(_aweight[i] * Math.Sqrt(2) / _dataFileNode.Nfft) + 93.9794;//93.9794为2e-5Pa参考
                }
                fstarti = (int)(fstart / df);

                ////Configure legend
                _tfGraph.ViewXY.LegendBoxes[0].IntensityScales.ScaleSizeDim1 = 400;
                _tfGraph.ViewXY.LegendBoxes[0].Layout = LegendBoxLayout.Horizontal;
                //_tfGraph.ViewXY.LegendBoxes[0].Offset = new PointIntXY(-15, -70);
                _tfGraph.ViewXY.LegendBoxes[0].ResetLocation();

                _tfGraph.EndUpdate();
            }

            {
                _timeGraph.BeginUpdate();
                _timeGraph.Title.Visible = false;
                _timeGraph.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.TopRight;
                _timeGraph.ViewXY.LegendBoxes[0].Visible  = false;
                AxisX axisX = _timeGraph.ViewXY.XAxes[0];
                axisX.Title.Text = "时间(s)";
                AxisY axisY = _timeGraph.ViewXY.YAxes[0];
                axisY.Title.Text = "声压(Pa)";

                _timegraph_verticalCursor                   = new LineSeriesCursor(_timeGraph.ViewXY, axisX);
                _timegraph_verticalCursor.Style             = CursorStyle.VerticalNoTracking;
                _timegraph_verticalCursor.LineStyle.Color   = Colors.White;
                _timegraph_verticalCursor.LineStyle.Pattern = LinePattern.Dot;
                _timegraph_verticalCursor.LineStyle.Width   = 3;
                _timegraph_verticalCursor.ValueAtXAxis      = _dataFileNode.Nfft / _dataFileNode.fs / 2;
                _timegraph_verticalCursor.MouseHighlight    = MouseOverHighlight.None;
                _timeGraph.ViewXY.LineSeriesCursors.Add(_timegraph_verticalCursor);

                _timeSeries                      = new SampleDataSeries(_timeGraph.ViewXY, axisX, axisY);
                _timeSeries.Title.Text           = "时域";
                _timeSeries.LineStyle.Color      = Colors.Orange;
                _timeSeries.SampleFormat         = SampleFormat.SingleFloat;
                _timeSeries.FirstSampleTimeStamp = 0;
                _timeSeries.SamplingFrequency    = _dataFileNode.fs;
                _timeGraph.ViewXY.SampleDataSeries.Add(_timeSeries);

                _timeGraph.ViewXY.ZoomToFit();

                _timeGraph.EndUpdate();
            }

            {
                _freqGraph.BeginUpdate();
                _freqGraph.Title.Visible = false;
                _freqGraph.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.TopRight;
                _freqGraph.ViewXY.LegendBoxes[0].Layout   = LegendBoxLayout.Vertical;
                AxisX axisX = _freqGraph.ViewXY.XAxes[0];
                axisX.Title.Text = "频率(Hz)";
                AxisY axisY = _freqGraph.ViewXY.YAxes[0];
                axisY.Title.Text = "声压级(dBA)";

                _freqgraph_verticalCursor                   = new LineSeriesCursor(_freqGraph.ViewXY, axisX);
                _freqgraph_verticalCursor.Style             = CursorStyle.VerticalNoTracking;
                _freqgraph_verticalCursor.LineStyle.Color   = Colors.White;
                _freqgraph_verticalCursor.LineStyle.Pattern = LinePattern.Dot;
                _freqgraph_verticalCursor.LineStyle.Width   = 3;
                _freqgraph_verticalCursor.ValueAtXAxis      = _tfgraph_horizontalCursor.Value;
                _freqgraph_verticalCursor.MouseHighlight    = MouseOverHighlight.None;
                _freqGraph.ViewXY.LineSeriesCursors.Add(_freqgraph_verticalCursor);

                _maxfreqSeries                      = new SampleDataSeries(_freqGraph.ViewXY, axisX, axisY);
                _maxfreqSeries.Title.Text           = "最大值";
                _maxfreqSeries.LineStyle.Color      = Colors.Red;
                _maxfreqSeries.SampleFormat         = SampleFormat.SingleFloat;
                _maxfreqSeries.FirstSampleTimeStamp = fstart;
                _maxfreqSeries.SamplingFrequency    = 1 / df;
                _freqGraph.ViewXY.SampleDataSeries.Add(_maxfreqSeries);
                _maxfreqSeries.SamplesSingle = maxfreq;

                _freqSeries                      = new SampleDataSeries(_freqGraph.ViewXY, axisX, axisY);
                _freqSeries.Title.Text           = "频谱";
                _freqSeries.LineStyle.Color      = Colors.Orange;
                _freqSeries.SampleFormat         = SampleFormat.DoubleFloat;
                _freqSeries.FirstSampleTimeStamp = fstart;
                _freqSeries.SamplingFrequency    = 1 / df;
                _freqGraph.ViewXY.SampleDataSeries.Add(_freqSeries);

                _freqGraph.ViewXY.ZoomToFit();

                _freqGraph.EndUpdate();
            }

            _ShowTimer.Interval = _dataFileNode.FrameDN / _dataFileNode.fs * 1000 / 2;
            _ShowTimer.Elapsed += _ShowTimer_Elapsed;

            _tfgraph_verticalCursor.PositionChanged += verticalCursor_PositionChanged;
            _tfgraph_horizontalCursor.ValueChanged  += horizontalCursor_ValueChanged;

            UpdateChannel();
        }
예제 #25
0
        private void ChartInit()
        {
            //#region Title

            //ChartTitle chartTitle = new ChartTitle();
            ////标题内容
            //chartTitle.Text = "";
            ////字体颜色
            //chartTitle.TextColor = Color.White;
            ////字体类型字号
            //chartTitle.Font = new Font("新宋体", 11, FontStyle.Bold);
            ////标题对齐方式
            //chartTitle.Dock = ChartTitleDockStyle.Top;
            //chartTitle.Alignment = StringAlignment.Near;

            //chartControl1.Titles.Clear();
            //chartControl1.Titles.Add(chartTitle);
            //#endregion

            _clZero              = new ConstantLine(string.Empty, 0);
            _clZero.Color        = Color.Black;
            _clZero.ShowInLegend = false;
            _clZero.ShowBehind   = true;

            #region Series

            _seAccumulateProfit = new Series("累计收益额(万元)", ViewType.Line);
            _seAccumulateProfit.ArgumentScaleType        = ScaleType.Qualitative;
            _seAccumulateProfit.CrosshairHighlightPoints = DevExpress.Utils.DefaultBoolean.False;
            _seAccumulateProfit.LabelsVisibility         = DevExpress.Utils.DefaultBoolean.False;
            LineSeriesView myView1 = (LineSeriesView)_seAccumulateProfit.View;
            myView1.Color = Color.DeepSkyBlue;

            _seDayProfit = new Series("日收益额(万元)", ViewType.Line);
            _seDayProfit.ArgumentScaleType        = ScaleType.Qualitative;
            _seDayProfit.CrosshairHighlightPoints = DevExpress.Utils.DefaultBoolean.False;
            _seDayProfit.LabelsVisibility         = DevExpress.Utils.DefaultBoolean.True;
            LineSeriesView myView2 = (LineSeriesView)_seDayProfit.View;
            myView2.Color = Color.OrangeRed;

            this.chartControl1.Series.Add(_seAccumulateProfit);
            this.chartControl1.Series.Add(_seDayProfit);

            #endregion Series

            #region XYDiagram

            XYDiagram myDiagram = chartControl1.Diagram as XYDiagram;

            #endregion XYDiagram

            #region AxisX

            AxisX myAxisX = myDiagram.AxisX;

            myAxisX.Label.Font                 = new Font("Tahoma ", 8, FontStyle.Bold);
            myAxisX.Label.Staggered            = false;
            myAxisX.Label.Angle                = -45;
            myAxisX.Label.EnableAntialiasing   = DevExpress.Utils.DefaultBoolean.True;
            myAxisX.Tickmarks.MinorVisible     = false;
            myAxisX.WholeRange.Auto            = true;
            myAxisX.WholeRange.AutoSideMargins = true;

            #endregion AxisX

            #region AxisY

            AxisY myAxisY = myDiagram.AxisY;
            myAxisY.Label.Font        = new Font("Tahoma ", 8, FontStyle.Bold);
            myAxisY.Label.TextPattern = "{ V:F2}";
            //myAxisY.GridLines.Color = Color.FromArgb(165, 42, 42);
            //myAxisY.GridLines.LineStyle.Thickness = 1;
            //myAxisY.GridLines.LineStyle.DashStyle = DevExpress.XtraCharts.DashStyle.Dot;
            myAxisY.Tickmarks.MinorVisible = false;
            myAxisY.WholeRange.Auto        = true;

            myAxisY.ConstantLines.Add(_clZero);

            #endregion AxisY
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create an empty chart.
            ChartControl chartControl1 = new ChartControl();

            // Create a series and add points to it.
            Series series1 = new Series("Series 1", ViewType.Bar);

            series1.Points.Add(new SeriesPoint("A", new double[] { 4 }));
            series1.Points.Add(new SeriesPoint("B", new double[] { 2 }));
            series1.Points.Add(new SeriesPoint("C", new double[] { 17 }));
            series1.Points.Add(new SeriesPoint("D", new double[] { 4 }));
            series1.Points.Add(new SeriesPoint("E", new double[] { 17 }));
            series1.Points.Add(new SeriesPoint("F", new double[] { 12 }));
            series1.Points.Add(new SeriesPoint("G", new double[] { 15 }));

            // Add the series to the chart.
            chartControl1.Series.Add(series1);

            // Create a constant line (optional).
            ConstantLine constantLine1 = new ConstantLine("Constant Line 1");

            ((XYDiagram)chartControl1.Diagram).AxisY.ConstantLines.Add(constantLine1);
            constantLine1.AxisValue = 4.5;

            // Create a strip (optional).
            Strip strip1 = new Strip("Strip 1");

            ((XYDiagram)chartControl1.Diagram).AxisY.Strips.Add(strip1);
            strip1.MaxLimit.AxisValue = 15;
            strip1.MinLimit.AxisValue = 7.5;

            // Customize the strip's and constant line's legend appearance.
            strip1.ShowInLegend        = true;
            constantLine1.ShowInLegend = true;
            constantLine1.LegendText   = "Some Threshold";

            // Display the chart control's legend.
            chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;

            // Define its horizontal and vertical alignment.
            chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside;
            chartControl1.Legend.AlignmentVertical   = LegendAlignmentVertical.Top;

            // Define the layout of items within the legend.
            chartControl1.Legend.Direction          = LegendDirection.LeftToRight;
            chartControl1.Legend.EquallySpacedItems = true;
            chartControl1.Legend.HorizontalIndent   = 4;
            chartControl1.Legend.VerticalIndent     = 4;
            chartControl1.Legend.TextOffset         = 4;

            // Define the limits for the legend to occupy the chart's space.
            chartControl1.Legend.MaxHorizontalPercentage = 50;
            chartControl1.Legend.MaxVerticalPercentage   = 50;

            // Define the legend markers' options.
            chartControl1.Legend.MarkerVisible = true;
            chartControl1.Legend.MarkerSize    = new Size(20, 20);

            // Customize the legend appearance.
            chartControl1.Legend.BackColor          = Color.LightBlue;
            chartControl1.Legend.FillStyle.FillMode = FillMode.Empty;

            chartControl1.Legend.Border.Color      = Color.DarkBlue;
            chartControl1.Legend.Border.Thickness  = 2;
            chartControl1.Legend.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;

            chartControl1.Legend.Shadow.Visible = true;
            chartControl1.Legend.Shadow.Color   = Color.LightGray;
            chartControl1.Legend.Shadow.Size    = 2;

            // Customize the legend text properties.
            chartControl1.Legend.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.False;
            chartControl1.Legend.Font      = new Font(this.Font.FontFamily.Name, 9, FontStyle.Bold);
            chartControl1.Legend.TextColor = Color.DarkBlue;

            // Add the chart to the form.
            chartControl1.Dock = DockStyle.Fill;
            this.Controls.Add(chartControl1);
        }
예제 #27
0
 private void drawConstantline()
 {
     #region 在图标中画分割线,并将分割线的值显示在textedit中
     XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
     diagram.AxisX.ConstantLines.Clear();
     textAndLine = new TextAndLine[valueCount];
     for (int i = 0; i < valueCount; i++)
     {
         TextEdit textedit = new TextEdit();
         textedit.Dock   = DockStyle.Top;
         textedit.Margin = new System.Windows.Forms.Padding(10, 10, 10, 10);
         double       value = (maxValue - minValue) * (i + 1) / valueCount + minValue;
         ConstantLine line  = new ConstantLine(string.Format("{0:############0.#######}", value), value);
         textedit.Text  = line.Name;
         line.Color     = Color.Pink;
         textAndLine[i] = new TextAndLine()
         {
             textEdit = textedit, constantLine = line
         };
         diagram.AxisX.ConstantLines.Add(line);
     }
     #endregion
     #region 设置textedit中值改变时constantline自动改变
     for (int i = 0; i < valueCount; i++)
     {
         panelControl9.Controls.Add(textAndLine[valueCount - i - 1].textEdit);
         textAndLine[valueCount - i - 1].textEdit.TextChanged += (sender1, e1) =>
         {
             try
             {
                 if (Convert.ToDouble((sender1 as TextEdit).Text) >= minValue)
                 {
                     textAndLine[valueCount - 1 - panelControl9.Controls.IndexOf(sender1 as Control)].constantLine.AxisValue =
                         Convert.ToDouble((sender1 as TextEdit).Text);
                     textAndLine[valueCount - 1 - panelControl9.Controls.IndexOf(sender1 as Control)].constantLine.Name =
                         (sender1 as TextEdit).Text;
                 }
             }
             catch
             {
             }
         };
         textAndLine[valueCount - i - 1].textEdit.LostFocus += (sender1, e1) =>
         {
             try
             {
                 if (Convert.ToDouble((sender1 as TextEdit).Text) < minValue)
                 {
                     XtraMessageBox.Show("输入值不再范围内");
                     (sender1 as TextEdit).Text =
                         textAndLine[valueCount - 1 - panelControl9.Controls.IndexOf(sender1 as Control)].constantLine.Name;
                 }
             }
             catch
             {
                 XtraMessageBox.Show("请输入数字谢谢,本来能限制的,不想改了");
                 (sender1 as TextEdit).Text =
                     textAndLine[valueCount - 1 - panelControl9.Controls.IndexOf(sender1 as Control)].constantLine.Name;
             }
         };
         textAndLine[valueCount - i - 1].textEdit.KeyDown += (sender1, e1) =>
         {
             if (e1.KeyCode == Keys.Enter)
             {
                 try
                 {
                     if (Convert.ToDouble((sender1 as TextEdit).Text) < minValue)
                     {
                         XtraMessageBox.Show("输入值不再范围内");
                         (sender1 as TextEdit).Text =
                             textAndLine[valueCount - 1 - panelControl9.Controls.IndexOf(sender1 as Control)].constantLine.Name;
                     }
                 }
                 catch
                 {
                     XtraMessageBox.Show("请输入数字谢谢,本来能限制的,不想改了");
                     (sender1 as TextEdit).Text =
                         textAndLine[valueCount - 1 - panelControl9.Controls.IndexOf(sender1 as Control)].constantLine.Name;
                 }
             }
         };
     }
     #endregion
 }
예제 #28
0
        /// <summary>
        /// 画SD图形
        /// </summary>
        /// <param name="results"></param>
        private void Dline(QCRelationProjectInfo results)
        {
            try
            {
                if (results != null)
                {
                    if (AccumulationTimeSeries == null)
                    {
                        AccumulationTimeSeries = new Series("QCSD", ViewType.Line);
                        AccumulationTimeSeries.ArgumentScaleType = ScaleType.Qualitative;
                        AccumulationTimeSeries.LabelsVisibility  = DevExpress.Utils.DefaultBoolean.True;//是否显示
                        chartControl1.Series.Add(AccumulationTimeSeries);
                    }
                    else
                    {
                        chartControl1.Series.Clear();
                        AccumulationTimeSeries = null;
                        AccumulationTimeSeries = new Series("QCSD", ViewType.Line);
                        AccumulationTimeSeries.ArgumentScaleType = ScaleType.Qualitative;
                        AccumulationTimeSeries.LabelsVisibility  = DevExpress.Utils.DefaultBoolean.True;//是否显示
                        chartControl1.Series.Add(AccumulationTimeSeries);
                    }
                    this._TemporaryQCProjectInfo = results;
                    XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
                    if (diagram != null)
                    {
                        diagram.AxisY.ConstantLines.Clear();
                        chartControl1.Titles.Clear();
                        ChartTitle SD1title = new ChartTitle();
                        SD1title.Text      = "● Mean/±1SD — 正常!" + "     ● ±2SD警告!" + "     ● ±3SD错误!";
                        SD1title.TextColor = Color.OrangeRed;
                        SD1title.Font      = new System.Drawing.Font("Tahoma", (float)10);
                        chartControl1.Titles.Add(SD1title);

                        double       StandardDeviation1 = Math.Round((double)(results.TargetMean + results.TargetSD), 1, MidpointRounding.AwayFromZero);
                        ConstantLine constantLine1      = new ConstantLine("1SD", StandardDeviation1);
                        diagram.AxisY.ConstantLines.Add(constantLine1);
                        constantLine1.Color               = Color.Blue; //直线颜色
                        constantLine1.Title.TextColor     = Color.Blue; //直线文本字体颜色
                        constantLine1.LineStyle.Thickness = 2;
                        double       StandardDeviation2 = Math.Round((double)(results.TargetMean + results.TargetSD * 2), 1, MidpointRounding.AwayFromZero);
                        ConstantLine constantLine4      = new ConstantLine("2SD", StandardDeviation2);
                        diagram.AxisY.ConstantLines.Add(constantLine4);
                        constantLine4.Color               = Color.Orange; //直线颜色
                        constantLine4.Title.TextColor     = Color.Orange; //直线文本字体颜色
                        constantLine4.LineStyle.Thickness = 2;
                        double       StandardDeviation3 = Math.Round((double)(results.TargetMean + results.TargetSD * 3), 1, MidpointRounding.AwayFromZero);
                        ConstantLine constantLine5      = new ConstantLine("3SD", StandardDeviation3);
                        diagram.AxisY.ConstantLines.Add(constantLine5);
                        constantLine5.Color               = Color.Red; //直线颜色
                        constantLine5.Title.TextColor     = Color.Red; //直线文本字体颜色
                        constantLine5.LineStyle.Thickness = 2;
                        double       Mean          = Math.Round(results.TargetMean, 1, MidpointRounding.AwayFromZero);
                        ConstantLine constantLine2 = new ConstantLine("MEAN", Mean);
                        diagram.AxisY.ConstantLines.Add(constantLine2);
                        constantLine2.Color               = Color.Green;
                        constantLine2.Title.TextColor     = Color.Green;
                        constantLine2.LineStyle.Thickness = 2;
                        double       Negative1SD   = Math.Round((double)(results.TargetMean - results.TargetSD), 1, MidpointRounding.AwayFromZero);
                        ConstantLine constantLine3 = new ConstantLine("-1SD", Negative1SD);
                        diagram.AxisY.ConstantLines.Add(constantLine3);
                        constantLine3.Color               = Color.Blue;
                        constantLine3.Title.TextColor     = Color.Blue;
                        constantLine3.LineStyle.Thickness = 2;
                        constantLine3.Title.ShowBelowLine = true;
                        double       Negative2SD   = Math.Round((double)(results.TargetMean - results.TargetSD * 2), 1, MidpointRounding.AwayFromZero);
                        ConstantLine constantLine6 = new ConstantLine("-2SD", Negative2SD);
                        diagram.AxisY.ConstantLines.Add(constantLine6);
                        constantLine6.Color               = Color.Orange;
                        constantLine6.Title.TextColor     = Color.Orange;
                        constantLine6.LineStyle.Thickness = 2;
                        constantLine6.Title.ShowBelowLine = true;
                        double       Negative3SD   = Math.Round((double)(results.TargetMean - results.TargetSD * 3), 1, MidpointRounding.AwayFromZero);
                        ConstantLine constantLine7 = new ConstantLine("-3SD", Negative3SD);
                        diagram.AxisY.ConstantLines.Add(constantLine7);
                        constantLine7.Color               = Color.Red;
                        constantLine7.Title.TextColor     = Color.Red;
                        constantLine7.LineStyle.Thickness = 2;
                        constantLine7.Title.ShowBelowLine = true;
                        //设置Y轴的图像显示最大值和最小值
                        double VRMin = 0;
                        double VRMax = 0;
                        if (results.TargetSD <= 0.1)
                        {
                            VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 0.5), 1, MidpointRounding.AwayFromZero);
                            VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 0.5), 1, MidpointRounding.AwayFromZero);
                        }
                        else if (results.TargetSD <= 0.3)
                        {
                            VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 2), 1, MidpointRounding.AwayFromZero);
                            VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 2), 1, MidpointRounding.AwayFromZero);
                        }
                        else if (results.TargetSD <= 0.5)
                        {
                            VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 3), 1, MidpointRounding.AwayFromZero);
                            VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 3), 1, MidpointRounding.AwayFromZero);
                        }
                        else if (results.TargetSD <= 1)
                        {
                            VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 5), 1, MidpointRounding.AwayFromZero);
                            VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 5), 1, MidpointRounding.AwayFromZero);
                        }
                        else if (results.TargetSD <= 5)
                        {
                            VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 15), 1, MidpointRounding.AwayFromZero);
                            VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 15), 1, MidpointRounding.AwayFromZero);
                        }
                        else if (results.TargetSD <= 10)
                        {
                            VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 25), 1, MidpointRounding.AwayFromZero);
                            VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 25), 1, MidpointRounding.AwayFromZero);
                        }
                        else if (results.TargetSD <= 20)
                        {
                            VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 40), 1, MidpointRounding.AwayFromZero);
                            VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 40), 1, MidpointRounding.AwayFromZero);
                        }
                        else if (results.TargetSD <= 50)
                        {
                            VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 60), 1, MidpointRounding.AwayFromZero);
                            VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 60), 1, MidpointRounding.AwayFromZero);
                        }
                        else if (results.TargetSD <= 100)
                        {
                            VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 75), 1, MidpointRounding.AwayFromZero);
                            VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 75), 1, MidpointRounding.AwayFromZero);
                        }
                        diagram.AxisY.VisualRange.SetMinMaxValues(VRMin, VRMax);
                        //设置Y轴的最大值和最小值
                        double WRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 100), 1, MidpointRounding.AwayFromZero);
                        double WRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 100), 1, MidpointRounding.AwayFromZero);
                        diagram.AxisY.WholeRange.SetMinMaxValues(WRMin, WRMax);

                        diagram.AxisX.VisualRange.SetMinMaxValues(0, 10);
                        diagram.AxisX.WholeRange.SetMinMaxValues(0, 10);

                        //设置Y轴
                        diagram.AxisY.Title.Text       = "质控品浓度结果".ToString();
                        diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
                        diagram.AxisY.NumericScaleOptions.GridSpacing = 1;
                        diagram.AxisY.NumericScaleOptions.AutoGrid    = false;
                        diagram.AxisY.VisualRange.Auto            = false;
                        diagram.AxisY.VisualRange.AutoSideMargins = false;
                        diagram.AxisY.WholeRange.Auto             = false;
                        diagram.AxisY.WholeRange.AutoSideMargins  = false;
                        diagram.AxisY.MinorCount = 9;
                        //是否允许沿其Y轴滚动窗格
                        diagram.EnableAxisYScrolling = true;
                        diagram.EnableAxisYZooming   = true;

                        //设置X轴
                        diagram.AxisX.Title.Text       = "质控时间".ToString();
                        diagram.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
                        diagram.AxisX.NumericScaleOptions.GridSpacing = 1;
                        diagram.AxisX.NumericScaleOptions.AutoGrid    = false;
                        diagram.AxisX.VisualRange.Auto            = false;
                        diagram.AxisX.VisualRange.AutoSideMargins = false;
                        //diagram.AxisX.WholeRange.Auto = false;
                        //diagram.AxisX.WholeRange.AutoSideMargins = false;
                        diagram.AxisX.MinorCount = 9;
                        //是否允许沿其X轴滚动窗格
                        diagram.EnableAxisXScrolling = true;
                        diagram.EnableAxisXZooming   = true;

                        // 启用X轴缩放
                        //diagram.EnableAxisXZooming = true;
                        //diagram.Panes[0].EnableAxisXZooming = DevExpress.Utils.DefaultBoolean.False;
                        //// 指定键盘和鼠标进行放大缩小
                        diagram.ZoomingOptions.UseKeyboard          = false;
                        diagram.ZoomingOptions.UseKeyboardWithMouse = true;
                        diagram.ZoomingOptions.UseMouseWheel        = true;
                    }
                }
            }
            catch (Exception e)
            {
                LogInfo.WriteErrorLog("质控图异常:" + e.ToString(), Module.QualityControl);
            }
        }
        /// <summary>
        /// Generates the charts one by one.
        /// </summary>
        /// <param name="du"></param>
        private void GenerateCharts(int du)
        {
            Balance bal = new Balance();
            GeneralInfo info = new GeneralInfo();
            info.LoadAll();
            DataTable dtList = new DataTable();
            DataTable dtAmc = new DataTable();
            DataTable dtMOS = new DataTable();
            DataTable dtIss = new DataTable();
            DataTable dtRec = new DataTable();
            DataTable dtBB = new DataTable();
            //CALENDAR:
            //  DataTable dtCons = new DataTable();
            string[] co = { "Ham", "Neh", "Mes", "Tek", "Hed", "Tah", "Tir", "Yek", "Meg", "Miz", "Gen", "Sen" };

            //foreach(string s in co)
            //{
            dtList.Columns.Add("Month");
            dtList.Columns.Add("Value");
            dtList.Columns[1].DataType = typeof(Int64);

            dtMOS.Columns.Add("Month");
            dtMOS.Columns.Add("Value");
            dtMOS.Columns[1].DataType = typeof(decimal);

            dtAmc.Columns.Add("Month");
            dtAmc.Columns.Add("Value");
            dtAmc.Columns[1].DataType = typeof(Int64);

            dtIss.Columns.Add("Month");
            dtIss.Columns.Add("Value");
            dtIss.Columns[1].DataType = typeof(Int64);

            dtRec.Columns.Add("Month");
            dtRec.Columns.Add("Value");
            dtRec.Columns[1].DataType = typeof(Int64);

            dtBB.Columns.Add("Month");
            dtBB.Columns.Add("Value");
            dtBB.Columns[1].DataType = typeof(Int64);

            int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            long[] cons = new long[12];
            double[] amc = new double[12];
            long[] con = new long[12];
            long[] issval = new long[12];
            DataTable dtBal = new DataTable();
            IssueDoc issd = new IssueDoc();
            Items recd = new Items();
            YearEnd yEnd = new YearEnd();
            Int64 bb = yEnd.GetBBalance(_year, _storeId, _itemId, 10);
            object[] objBB = { "Ham", bb };
            dtBB.Rows.Add(objBB);
            //dtDate.Value = DateTime.Now;
            //dtDate.CustomFormat = "MM/dd/yyyy";
            //DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text);

            for (int i = 0; i < mon.Length; i++)
            {
                int cMonth = _dtCurrent.Month;
                //if (!(year == dtCurrent.Year && mon[i] > dtCurrent.Month && mon[i] < 11))
                if (((mon[i] == 11 || mon[i] == 12) && (mon[i] <= cMonth || _year == _dtCurrent.Year)) || (mon[i] < 11 && mon[i] <= cMonth && _year == _dtCurrent.Year))
                {
                    int yr = (mon[i] < 11) ? _year : _year - 1;
                    // dtBal = bal.GetSOH(itemId,storeId,mon[i],yr);
                    con[i] = ((du == 0) ? bal.GetSOH(_itemId, _storeId, mon[i], yr) : bal.GetDUSOH(_itemId, du, mon[i], yr));
                    object xSOH = null;
                    if (con[i] == 0)
                    {
                        for (int li = i; li >= 0; li--)
                        {
                            if (con[li] != 0)
                            {
                                xSOH = 0;
                                break;
                            }
                        }
                    }
                    else
                        xSOH = con[i];
                    object[] str = { co[i], xSOH };
                    amc[i] = ((du == 0) ? Builder.CalculateAverageConsumption(_itemId, _storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly) : bal.CalculateDUAMC(_itemId, du, mon[i], yr, 0));//bal.CalculateAMC(_itemId, _storeId, mon[i], yr)
                    object xAmc = null;
                    if (amc[i] == 0)
                    {
                        for (int li = i; li >= 0; li--)
                        {
                            if (amc[li] != 0)
                            {
                                xAmc = 0;
                                break;
                            }
                        }
                    }
                    else
                        xAmc = amc[i];
                    object[] objAmc = { co[i], xAmc };

                    // for mos check the diff b/n null and zero
                    // And also mos = soh/amc right???
                    decimal mos = (amc[i] > 0) ? (Convert.ToDecimal(con[i]) / Convert.ToDecimal(amc[i])) : 0;
                    object[] objMos = { co[i], mos };
                    int fYear = (mon[i] < 11) ? yr : yr - 1;

                    issval[i] = ((du == 0) ? issd.GetIssuedQuantityByMonth(_itemId, _storeId, mon[i], yr) : issd.GetDUConsumptionByMonth(_itemId, du, mon[i], yr));
                    object xIss = null;
                    if (issval[i] == 0)
                    {
                        for (int li = i; li >= 0; li--)
                        {
                            if (issval[li] != 0)
                            {
                                xIss = 0;
                                break;
                            }
                        }
                    }
                    else
                        xIss = issval[i];
                    object[] objIss = { co[i], xIss };

                    Int64 recVal = ((du == 0) ? recd.GetQuantityReceiveByItemPerMonth(mon[i], _itemId, _storeId, yr) : issd.GetDUReceiveByMonth(_itemId, du, mon[i], yr));
                    object[] objrec = { co[i], recVal };

                    dtList.Rows.Add(str);
                    dtAmc.Rows.Add(objAmc);
                    dtMOS.Rows.Add(objMos);
                    dtIss.Rows.Add(objIss);
                    dtRec.Rows.Add(objrec);
                }
            }

            // string[] str = { ((cons[0] != 0) ? cons[0].ToString("") : "0"), ((cons[1] != 0) ? cons[1].ToString() : "0"), ((cons[2] != 0) ? cons[2].ToString() : "0"), ((cons[3] != 0) ? cons[3].ToString() : "0"), ((cons[4] != 0) ? cons[4].ToString() : "0"), ((cons[5] != 0) ? cons[5].ToString() : "0"), ((cons[6] != 0) ? cons[6].ToString() : "0"), ((cons[7] != 0) ? cons[7].ToString() : "0"), ((cons[8] != 0) ? cons[8].ToString() : "0"), ((cons[9] != 0) ? cons[9].ToString() : "0"), ((cons[10] != 0) ? cons[10].ToString() : "0"), ((cons[11] != 0) ? cons[11].ToString() : "0")};
            chartAmc.Series.Clear(); //AMC
            chartComp.Series.Clear();//Activity
            chartBar.Series.Clear(); //SOH
            chartMOS.Series.Clear(); // MOS
            consuTrend.Series.Clear();

            Series ser = new Series("Stock On Hand", ViewType.Line);
            ser.DataSource = dtList;
            ser.ArgumentScaleType = ScaleType.Qualitative;
            ser.ArgumentDataMember = "Month";
            ser.ValueScaleType = ScaleType.Numerical;
            ser.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            ser.PointOptions.ValueNumericOptions.Precision = 0;
            ser.ValueDataMembers.AddRange(new string[] { "Value" });

            chartBar.Series.Add(ser);
            ((XYDiagram)chartBar.Diagram).AxisY.NumericOptions.Format = NumericFormat.Number;
            ((XYDiagram)chartBar.Diagram).AxisY.NumericOptions.Precision = 0;

            Series serB = new Series("Begining Balance", ViewType.Bar);
            serB.DataSource = dtBB;
            serB.ArgumentScaleType = ScaleType.Qualitative;
            serB.ArgumentDataMember = "Month";
            serB.ValueScaleType = ScaleType.Numerical;
            serB.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            serB.PointOptions.ValueNumericOptions.Precision = 0;
            serB.ValueDataMembers.AddRange(new string[] { "Value" });
            chartComp.Series.Add(serB);

            Series serRec = new Series("Received Qty", ViewType.Bar);
            serRec.DataSource = dtRec;
            serRec.ArgumentScaleType = ScaleType.Qualitative;
            serRec.ArgumentDataMember = "Month";
            serRec.ValueScaleType = ScaleType.Numerical;
            serRec.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            serRec.PointOptions.ValueNumericOptions.Precision = 0;
            serRec.ValueDataMembers.AddRange(new string[] { "Value" });
            chartComp.Series.Add(serRec);

            Series serAmc = new Series("AMC", ViewType.Line);
            serAmc.DataSource = dtAmc;
            serAmc.ArgumentScaleType = ScaleType.Qualitative;
            serAmc.ArgumentDataMember = "Month";
            serAmc.ValueScaleType = ScaleType.Numerical;
            serAmc.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            serAmc.PointOptions.ValueNumericOptions.Precision = 0;
            serAmc.ValueDataMembers.AddRange(new string[] { "Value" });
            chartAmc.Series.Add(serAmc);
            ((XYDiagram)chartAmc.Diagram).AxisY.NumericOptions.Format = NumericFormat.Number;
            ((XYDiagram)chartAmc.Diagram).AxisY.NumericOptions.Precision = 0;

            Series serIss = new Series("Issue Qty", ViewType.Bar);
            serIss.DataSource = dtIss;
            serIss.ArgumentScaleType = ScaleType.Qualitative;
            serIss.ArgumentDataMember = "Month";
            serIss.ValueScaleType = ScaleType.Numerical;
            serIss.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            serIss.PointOptions.ValueNumericOptions.Precision = 0;
            serIss.ValueDataMembers.AddRange(new string[] { "Value" });
            chartComp.Series.Add(serIss);

            //Int64 amcCurent = bal.CalculateAMC(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year);
            double amcCurent = Builder.CalculateAverageConsumption(_itemId, _storeId,
                                                                   _dtCurrent.Subtract(TimeSpan.FromDays(180)),
                                                                   _dtCurrent, CalculationOptions.Monthly);
            double min = info.Min * amcCurent;
            double max = info.Max * amcCurent;
            Int64 nearEOP = Convert.ToInt64(amcCurent * (info.EOP + 0.25));
            ConstantLine target = new ConstantLine();
            ConstantLine targetEOP = new ConstantLine();
            target.AxisValue = min;
            //which min and max to show month
            ((XYDiagram)chartComp.Diagram).AxisY.ConstantLines.Clear();
            target.Visible = true;
            target.Title.Text = "Current Min value is " + Convert.ToInt64(target.AxisValue).ToString("#,###") + " " + lblBUnit.Text;
            target.Color = Color.Red;
            target.LineStyle.Thickness = 2;
            target.LegendText = "Min";
            ((XYDiagram)chartComp.Diagram).AxisY.ConstantLines.Add(target);

            targetEOP = new ConstantLine();
            targetEOP.AxisValue = nearEOP;
            //which min and max to show month
            //((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Clear();
            targetEOP.Visible = true;
            targetEOP.Title.Text = "Current EOP value is " + Convert.ToInt64(targetEOP.AxisValue).ToString("#,###") + " " + lblBUnit.Text;
            targetEOP.Color = Color.Yellow;
            targetEOP.LineStyle.Thickness = 2;
            targetEOP.LegendText = "EOP";
            ((XYDiagram)chartComp.Diagram).AxisY.ConstantLines.Add(targetEOP);

            ConstantLine targetMax = new ConstantLine();
            targetMax.AxisValue = max;
            //which min and max to show month
            targetMax.Visible = true;
            targetMax.Title.Text = "Current Max value is " + Convert.ToInt64(targetMax.AxisValue).ToString("#,###") + " " + lblBUnit.Text;
            targetMax.Color = Color.Blue;
            targetMax.LineStyle.Thickness = 2;
            targetMax.LegendText = "Max";
            ((XYDiagram)chartComp.Diagram).AxisY.ConstantLines.Add(targetMax);

            Series sercons = new Series("Consumption", ViewType.Line);
            sercons.DataSource = dtIss;
            sercons.ArgumentScaleType = ScaleType.Qualitative;
            sercons.ArgumentDataMember = "Month";
            sercons.ValueScaleType = ScaleType.Numerical;
            sercons.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            sercons.PointOptions.ValueNumericOptions.Precision = 0;
            sercons.ValueDataMembers.AddRange(new string[] { "Value" });
            consuTrend.Series.Add(sercons);
            ((XYDiagram)consuTrend.Diagram).AxisY.NumericOptions.Format = NumericFormat.Number;
            ((XYDiagram)consuTrend.Diagram).AxisY.NumericOptions.Precision = 0;

            Series serSOH = new Series("SOH", ViewType.Bar);
            serSOH.DataSource = dtList;
            serSOH.ArgumentScaleType = ScaleType.Qualitative;
            serSOH.ArgumentDataMember = "Month";
            serSOH.ValueScaleType = ScaleType.Numerical;
            serSOH.PointOptions.ValueNumericOptions.Format = NumericFormat.Number;
            ((XYDiagram)chartComp.Diagram).AxisY.NumericOptions.Format = NumericFormat.Number;
            ((XYDiagram)chartComp.Diagram).AxisY.NumericOptions.Precision = 0;
            serSOH.PointOptions.ValueNumericOptions.Precision = 0;

            serSOH.ValueDataMembers.AddRange(new string[] { "Value" });
            chartComp.Series.Add(serSOH);

            Series serMos = new Series("Month Of Stock", ViewType.Line);
            serMos.DataSource = dtMOS;
            serMos.ArgumentScaleType = ScaleType.Qualitative;
            serMos.ArgumentDataMember = "Month";
            serMos.ValueScaleType = ScaleType.Numerical;
            serMos.PointOptions.ValueNumericOptions.Format = NumericFormat.FixedPoint;
            serMos.PointOptions.ValueNumericOptions.Precision = 1;
            serMos.ValueDataMembers.AddRange(new string[] { "Value" });

            chartMOS.Series.Add(serMos);
            if (Convert.ToInt32(((XYDiagram)chartMOS.Diagram).AxisY.Range.MaxValue) <= 12)
            {
                ((XYDiagram)chartMOS.Diagram).AxisY.Range.MaxValue = 12;
            }

            //Int64 soh = bal.GetSOH(itemId,storeId,dtCurrent.Month,year);
            //if (bal.RowCount > 0)
            //{
            //Int64 amcCurent = bal.CalculateAMC(_itemId, _storeId, _dtCurrent.Month, _year);
            amcCurent = Builder.CalculateAverageConsumption(_itemId, _storeId,
                                                                  _dtCurrent.Subtract(TimeSpan.FromDays(180)),
                                                                  _dtCurrent, CalculationOptions.Monthly);
            min = info.Min * amcCurent;
            max = info.Max * amcCurent;
            nearEOP = Convert.ToInt64(amcCurent * (info.EOP + 0.25));
            target = new ConstantLine();
            target.AxisValue = min;
            //which min and max to show month
            ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Clear();
            target.Visible = true;
            target.Title.Text = "Current Min value is " + Convert.ToInt64(target.AxisValue).ToString("#,###") + " " + lblBUnit.Text;
            target.Color = Color.Red;
            target.LineStyle.Thickness = 2;
            target.LegendText = "Min";
            ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Add(target);

            targetEOP = new ConstantLine();
            targetEOP.AxisValue = nearEOP;
            //which min and max to show month
            //((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Clear();
            targetEOP.Visible = true;
            targetEOP.Title.Text = "Current EOP value is " + Convert.ToInt64(targetEOP.AxisValue).ToString("#,###") + " " + lblBUnit.Text;
            targetEOP.Color = Color.Yellow;
            targetEOP.LineStyle.Thickness = 2;
            targetEOP.LegendText = "EOP";
            ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Add(targetEOP);

            targetMax = new ConstantLine();
            targetMax.AxisValue = max;
            //which min and max to show month
            targetMax.Visible = true;
            targetMax.Title.Text = "Current Max value is " + Convert.ToInt64(targetMax.AxisValue).ToString("#,###") + " " + lblBUnit.Text;
            targetMax.Color = Color.Blue;
            targetMax.LineStyle.Thickness = 2;
            targetMax.LegendText = "Max";
            ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Add(targetMax);

            ConstantLine targetMos = new ConstantLine();
            ConstantLine targetMosMin = new ConstantLine();
            ((XYDiagram)chartMOS.Diagram).AxisY.ConstantLines.Clear();
            targetMos = new ConstantLine();
            targetMos.AxisValue = info.Max;
            //which min and max to show month
            targetMos.Visible = true;
            targetMos.Title.Text = "Current Max is " + info.Max.ToString() + " months";
            targetMos.Color = Color.Blue;
            targetMos.LineStyle.Thickness = 2;
            targetMos.LegendText = "Max";
            ((XYDiagram)chartMOS.Diagram).AxisY.ConstantLines.Add(targetMos);

            targetMosMin = new ConstantLine();
            targetMosMin.AxisValue = info.Min;
            //which min and max to show month
            targetMosMin.Visible = true;
            targetMosMin.Title.Text = "Current Min is " + info.Min.ToString() + " months";
            targetMosMin.Color = Color.Red;
            targetMosMin.LineStyle.Thickness = 2;
            targetMosMin.LegendText = "Max";
            ((XYDiagram)chartMOS.Diagram).AxisY.ConstantLines.Add(targetMosMin);
            //}

            // Generate the pie Chart for the Current SOH and EXpired Drugs

            ReceiveDoc rec = new ReceiveDoc();
            chartPie.Series.Clear();
            Items itm = new Items();
            object[] objExp = itm.GetExpiredQtyAmountItemsByID(_itemId, _storeId);
            Int64 expAmount = Convert.ToInt64(objExp[0]);
            Double expCost = Convert.ToDouble(objExp[1]);

            object[] nearObj = itm.GetNearlyExpiredQtyAmountItemsByID(_itemId, _storeId);
            Int64 nearExpAmount = Convert.ToInt64(nearObj[0]);
            double nearExpCost = Convert.ToDouble(nearObj[1]);

            Int64 soh = bal.GetSOH(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year);
            double sohPrice = bal.GetSOHAmount(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year);

            Int64 normal = (soh - nearExpAmount - expAmount);
            Int64 nearExpiry = nearExpAmount;
            Int64 expired = expAmount;

            object[] obj = { normal, nearExpiry, expired };

            DataTable dtSOHList = new DataTable();
            dtSOHList.Columns.Add("Type");
            dtSOHList.Columns.Add("Value");
            dtSOHList.Columns[1].DataType = typeof(Int64);
            double normalPrice = (sohPrice - nearExpCost - expAmount);

            object[] oo = { "Normal : " + normalPrice.ToString("C"), obj[0] };
            dtSOHList.Rows.Add(oo);

            object[] oo3 = { "Expired : " + expCost.ToString("C"), obj[2] };
            dtSOHList.Rows.Add(oo3);

            object[] oo2 = { "Near Expiry : " + nearExpCost.ToString("C"), obj[1] };
            dtSOHList.Rows.Add(oo2);

            Series serExpired = new Series("pie", ViewType.Pie3D);
            if (!(Convert.ToInt32(obj[0]) == 0 && Convert.ToInt32(obj[1]) == 0 && Convert.ToInt32(obj[2]) == 0))
            {
                serExpired.DataSource = dtSOHList;

                serExpired.ArgumentScaleType = ScaleType.Qualitative;
                serExpired.ArgumentDataMember = "Type";
                serExpired.ValueScaleType = ScaleType.Numerical;
                serExpired.ValueDataMembers.AddRange(new string[] { "Value" });
                serExpired.PointOptions.PointView = PointView.ArgumentAndValues;
                serExpired.LegendText = "Key";
                serExpired.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
                serExpired.PointOptions.ValueNumericOptions.Precision = 0;
                ((PieSeriesLabel)serExpired.Label).Position = PieSeriesLabelPosition.TwoColumns;
                // ((PieSeriesLabel)serExpired.Label).ColumnIndent = 2;
                ((PiePointOptions)serExpired.PointOptions).PointView = PointView.ArgumentAndValues;
                // ((PiePointOptions)serExpired.PointOptions).Separator = " , ";
                chartPie.Series.Add(serExpired);
                chartPie.Size = new System.Drawing.Size(1000, 500);
            }
        }
예제 #30
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="parentControl">父容器</param>
        /// <param name="seriesNames">示波器各序列名</param>
        /// <param name="sampleFrequency">绘制曲线颜色</param>
        /// <param name="titleColor">绘制曲线颜色</param>
        /// <param name="chartManager"> 内置图表的的chartManager(可空)</param>
        public WaveformMonitor(
            Panel parentControl,
            string[] seriesNames,
            double sampleFrequency,
            Color titleColor,
            ChartManager chartManager
            )
        {
            _samplingFrequency = sampleFrequency;
            _parentControl     = parentControl;

            _chart                     = new LightningChartUltimate();
            _chart.ChartName           = "Waveform chart";
            _chart.ViewXY.XAxes        = ViewXY.CreateDefaultXAxes();
            _chart.ViewXY.YAxes        = ViewXY.CreateDefaultYAxes();
            _chart.VerticalAlignment   = VerticalAlignment.Top;
            _chart.HorizontalAlignment = HorizontalAlignment.Left;

            _chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Stacked;
            _chart.ViewXY.AxisLayout.SegmentsGap = 10;

            parentControl.Children.Add(_chart);

            _chart.BeginUpdate();
            _chart.ChartManager = chartManager;

            _chart.ViewXY.AxisLayout.AutoAdjustMargins = false;

            _chart.ViewXY.DropOldSeriesData          = true;
            _chart.ChartRenderOptions.AntiAliasLevel = 0; // Disable hw anti-aliasing.

            AxisX axisX = _chart.ViewXY.XAxes[0];

            axisX.Maximum                   = 10;
            axisX.SweepingGap               = 2;
            axisX.ScrollMode                = XAxisScrollMode.Scrolling;
            axisX.Title.Text                = "Range";
            axisX.Title.VerticalAlign       = XAxisTitleAlignmentVertical.Top;
            axisX.Title.HorizontalAlign     = XAxisTitleAlignmentHorizontal.Right;
            axisX.LabelsPosition            = Alignment.Near;
            axisX.LabelsFont                = new WpfFont("Segoe UI", 11, true, false);
            axisX.MajorDivTickStyle.Visible = false;
            axisX.MinorDivTickStyle.Visible = false;
            axisX.MajorGrid.Visible         = false;
            axisX.MinorGrid.Visible         = false;
            axisX.LabelsVisible             = false;
            axisX.SteppingInterval          = 1;
            axisX.MouseScaling              = false;
            axisX.MouseScrolling            = false;
            axisX.AxisThickness             = 1;

            //AxisY axisY = _chart.ViewXY.YAxes[0];
            //axisY.SetRange(-30000, 30000);
            //axisY.Title.Visible = false;
            //axisY.LabelsFont = new WpfFont("Segoe UI", 11, true, false);

            _chart.ViewXY.GraphBackground.GradientDirection = 270;
            _chart.ViewXY.GraphBackground.GradientFill      = GradientFill.Cylindrical;

            Color color = _chart.ViewXY.GraphBackground.Color;

            _chart.ViewXY.GraphBackground.Color = Color.FromArgb(150, color.R, color.G, color.B);

            _chart.Title.Font = new WpfFont("Segoe UI", 14, true, false);

            _chart.Title.Align = ChartTitleAlignment.TopCenter;
            _chart.Title.Offset.SetValues(0, 25);
            _chart.Title.Color = titleColor;

            _chart.ViewXY.Margins = new Thickness(70, 10, 15, 10);
            _chart.ViewXY.ZoomPanOptions.ZoomRectLine.Color = Colors.Lime;

            _chart.ChartBackground.Color             = ChartTools.CalcGradient(titleColor, Colors.Black, 65);
            _chart.ChartBackground.GradientDirection = 0;
            _chart.ChartBackground.GradientFill      = GradientFill.Cylindrical;

            //清除之前的y轴与数据序列
            DisposeAllAndClear(_chart.ViewXY.YAxes);
            DisposeAllAndClear(_chart.ViewXY.SampleDataSeries);
            //添加多序列的y轴属性
            for (int index = 0; index < seriesNames.Count(); index++)
            {
                AxisY axisY = new AxisY(_chart.ViewXY);
                axisY.SetRange(-30000, 30000);
                axisY.Title.Font    = new WpfFont("Segoe UI", 10, false, false);
                axisY.Title.Text    = string.Format(seriesNames[index]);
                axisY.Title.Angle   = 0;
                axisY.Units.Visible = false;
                //axisY.Title.Visible = false;
                axisY.LabelsFont = new WpfFont("Segoe UI", 11, true, false);
                _chart.ViewXY.YAxes.Add(axisY);

                //Add SampleDataSeries
                SampleDataSeries sds = new SampleDataSeries(_chart.ViewXY, axisX, axisY);
                _chart.ViewXY.SampleDataSeries.Add(sds);
                sds.SampleFormat              = SampleFormat.DoubleFloat;
                sds.LineStyle.Color           = DefaultColors.SeriesForBlackBackgroundWpf[index % DefaultColors.SeriesForBlackBackgroundWpf.Length];
                sds.SamplingFrequency         = _samplingFrequency;
                sds.FirstSampleTimeStamp      = 1.0 / _samplingFrequency;
                sds.LineStyle.Width           = 1f;
                sds.LineStyle.AntiAliasing    = LineAntialias.None;
                sds.ScrollModePointsKeepLevel = 1;
                sds.ScrollingStabilizing      = true;
                sds.MouseInteraction          = false;



                //Add the line as a zero level
                ConstantLine cls = new ConstantLine(_chart.ViewXY, axisX, axisY);
                cls.Title.Text       = "Constant line";
                cls.Title.Visible    = false;
                cls.LineStyle.Color  = Colors.BlueViolet;
                cls.Behind           = true;
                cls.LineStyle.Width  = 2;
                cls.MouseInteraction = false;
                cls.Value            = 0;
                _chart.ViewXY.ConstantLines.Add(cls);
            }

            //LineSeriesCursor cursor1 = new LineSeriesCursor(_chart.ViewXY, axisX);
            //cursor1.ValueAtXAxis = 1;
            //cursor1.LineStyle.Width = 6;

            //color = Colors.OrangeRed;
            //cursor1.LineStyle.Color = Color.FromArgb(180, color.R, color.G, color.B);

            //cursor1.FullHeight = true;
            //cursor1.SnapToPoints = true;
            //cursor1.Style = CursorStyle.PointTracking;
            //cursor1.TrackPoint.Color1 = Colors.Yellow;
            //cursor1.TrackPoint.Color2 = Colors.Transparent;
            //cursor1.TrackPoint.Shape = Shape.Circle;
            //_chart.ViewXY.LineSeriesCursors.Add(cursor1);

            _chart.EndUpdate();
        }
예제 #31
0
        void initGantt(List <TaskTree> tasktree, DateTime[] projectDate)
        {
            BandedGridView view = advBandedGridView1 as BandedGridView;

            view.BeginUpdate();     //开始视图的编辑,防止触发其他事件
            view.BeginDataUpdate(); //开始数据的编辑
            view.Bands.Clear();
            DateTime start    = new DateTime(2013, 12, 10);
            DateTime end      = new DateTime(2014, 5, 2);
            GridBand gridBand = view.Bands.AddBand(start.ToString("yy-MM-dd"));

            gridBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            int    days = (end - start).Days;
            string Day  = "日一二三四五六";

            CustomAxisLabel[] customaxislabels = new CustomAxisLabel[days + 1];
            customaxislabels[0] = new CustomAxisLabel(start.ToString("yy-MM-dd"), start);
            for (int i = 0; i <= days + 1; i++)
            {
                try
                {
                    CustomAxisLabel cal = new CustomAxisLabel();
                    cal.AxisValue           = start;
                    cal.Name                = start.ToString("yy-MM-dd");
                    customaxislabels[i + 1] = cal;
                    if (start.DayOfWeek == DayOfWeek.Monday)
                    {
                        gridBand = view.Bands.AddBand(start.ToString("yyyy-MM-dd"));
                        gridBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    }
                    GridBand childen = gridBand.Children.AddBand(Day[(int)start.DayOfWeek] + "");
                    childen.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    childen.Width = 24;
                    start         = start.AddDays(1);
                }
                catch { }
            }
            gcGanttDate.Width = days * 24 + 2;
            view.EndDataUpdate(); //结束数据的编辑
            view.EndUpdate();     //结束视图的编辑

            //设置甘特图属性
            ccProjectGantt.Width = gcGanttDate.Width;
            //chartControl1.Height = 4 * 24;
            ganttDiagram1.AxisX.Visible = false;
            ganttDiagram1.AxisY.CustomLabels.AddRange(customaxislabels);
            ConstantLine progress = new ConstantLine("当前进度", DateTime.Now);

            progress.Color = Color.Red;
            ganttDiagram1.AxisY.ConstantLines.Add(progress);
            ganttDiagram1.AxisY.Range.MinValueInternal = 0;
            ganttDiagram1.AxisY.Range.MaxValueInternal = days * 24;
            ganttDiagram1.AxisY.Visible = false;

            series1.Points.Add(new SeriesPoint("项目进度", new DateTime[] { new DateTime(2013, 12, 12, 0, 0, 0), new DateTime(2014, 4, 30) }));
            SeriesPoint sp = new SeriesPoint();

            series2.Points.Add(new SeriesPoint("产品进度", new DateTime[] { new DateTime(2013, 12, 12), new DateTime(2014, 1, 12) }));
            series2.Points.Add(new SeriesPoint("Task 2", new DateTime[] { new DateTime(2014, 1, 13), new DateTime(2014, 2, 28) }));
            series2.Points.Add(new SeriesPoint("Task 3", new DateTime[] { new DateTime(2014, 3, 1), new DateTime(2014, 3, 30) }));
            series2.Points.Add(new SeriesPoint("Task 4", new DateTime[] { new DateTime(2014, 4, 1), new DateTime(2014, 4, 30) }));
            series2.Points[2].Relations.Add(series2.Points[1]);
            series3.Points.Add(new SeriesPoint("产品进度", new DateTime[] { new DateTime(2013, 12, 12), new DateTime(2014, 1, 12) }));
            series3.Points.Add(new SeriesPoint("Task 2", new DateTime[] { new DateTime(2014, 1, 13), new DateTime(2014, 2, 28) }));
            series3.Points.Add(new SeriesPoint("Task 3", new DateTime[] { new DateTime(2014, 3, 1), new DateTime(2014, 3, 4) }));
            series4.Points.Add(new SeriesPoint("Task 3", new DateTime[] { new DateTime(2014, 3, 4), DateTime.Now }));
        }
예제 #32
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create a new chart.
            ChartControl overlappedGanttChart = new ChartControl();

            // Create two Gantt series.
            Series series1 = new Series("Planned", ViewType.Gantt);
            Series series2 = new Series("Completed", ViewType.Gantt);

            // Set the date-time values scale type for both series,
            // as it is qualitative, by default.
            series1.ValueScaleType = ScaleType.DateTime;
            series2.ValueScaleType = ScaleType.DateTime;

            // Add points to them.
            series1.Points.Add(new SeriesPoint("Market analysis", new DateTime[] {
                new DateTime(2006, 8, 16), new DateTime(2006, 8, 23)
            }));
            series1.Points.Add(new SeriesPoint("Feature planning", new DateTime[] {
                new DateTime(2006, 8, 23), new DateTime(2006, 8, 26)
            }));
            series1.Points.Add(new SeriesPoint("Implementation", new DateTime[] {
                new DateTime(2006, 8, 26), new DateTime(2006, 9, 26)
            }));
            series1.Points.Add(new SeriesPoint("Testing & bug fixing", new DateTime[] {
                new DateTime(2006, 9, 26), new DateTime(2006, 10, 10)
            }));

            series2.Points.Add(new SeriesPoint("Market analysis", new DateTime[] {
                new DateTime(2006, 8, 16), new DateTime(2006, 8, 23)
            }));
            series2.Points.Add(new SeriesPoint("Feature planning", new DateTime[] {
                new DateTime(2006, 8, 23), new DateTime(2006, 8, 26)
            }));
            series2.Points.Add(new SeriesPoint("Implementation", new DateTime[] {
                new DateTime(2006, 8, 26), new DateTime(2006, 9, 10)
            }));

            // Add both series to the chart.
            overlappedGanttChart.Series.AddRange(new Series[] { series1, series2 });

            // Access the view-type-specific options of the series.
            ((GanttSeriesView)series1.View).BarWidth = 0.6;
            ((GanttSeriesView)series2.View).BarWidth = 0.3;

            // Access the type-specific options of the diagram.
            GanttDiagram myDiagram = (GanttDiagram)overlappedGanttChart.Diagram;

            myDiagram.AxisY.Interlaced = true;
            myDiagram.AxisY.DateTimeScaleOptions.GridSpacing = 2;
            myDiagram.AxisY.Label.TextPattern = "{V:MMMM dd}";

            // Add task links for the first Gantt series.
            ((GanttSeriesView)series1.View).LinkOptions.ArrowHeight = 7;
            ((GanttSeriesView)series1.View).LinkOptions.ArrowWidth  = 11;
            for (int i = 1; i < series1.Points.Count; i++)
            {
                series1.Points[i].Relations.Add(series1.Points[i - 1]);
            }

            // Add a progress line.
            ConstantLine progress =
                new ConstantLine("Current progress", new DateTime(2006, 9, 10));

            progress.ShowInLegend    = false;
            progress.Title.Alignment = ConstantLineTitleAlignment.Far;
            myDiagram.AxisY.ConstantLines.Add(progress);

            // Adjust the legend.
            overlappedGanttChart.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right;

            // Add a title to the chart (if necessary).
            overlappedGanttChart.Titles.Add(new ChartTitle());
            overlappedGanttChart.Titles[0].Text = "R&D Schedule";

            // Add the chart to the form.
            overlappedGanttChart.Dock = DockStyle.Fill;
            this.Controls.Add(overlappedGanttChart);
        }
예제 #33
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create a new chart.
            ChartControl ganttChart = new ChartControl();

            // Create two Gantt series.
            Series series1 = new Series("Estimation", ViewType.SideBySideGantt);
            Series series2 = new Series("Implementation", ViewType.SideBySideGantt);

            // Specify the date-time value scale type,
            // because it is qualitative by default.
            series1.ValueScaleType = ScaleType.DateTime;
            series2.ValueScaleType = ScaleType.DateTime;

            // Add points to them.
            series1.Points.Add(new SeriesPoint("Task 1", new DateTime[] {
                new DateTime(2006, 8, 16), new DateTime(2006, 8, 31)
            }));
            series1.Points.Add(new SeriesPoint("Task 2", new DateTime[] {
                new DateTime(2006, 8, 31), new DateTime(2006, 9, 15)
            }));
            series1.Points.Add(new SeriesPoint("Task 3", new DateTime[] {
                new DateTime(2006, 9, 15), new DateTime(2006, 9, 30)
            }));
            series1.Points.Add(new SeriesPoint("Task 4", new DateTime[] {
                new DateTime(2006, 9, 30), new DateTime(2006, 10, 15)
            }));

            series2.Points.Add(new SeriesPoint("Task 1", new DateTime[] {
                new DateTime(2006, 8, 16), new DateTime(2006, 9, 5)
            }));
            series2.Points.Add(new SeriesPoint("Task 2", new DateTime[] {
                new DateTime(2006, 9, 5), new DateTime(2006, 9, 22)
            }));
            series2.Points.Add(new SeriesPoint("Task 3", new DateTime[] {
                new DateTime(2006, 9, 22), new DateTime(2006, 10, 10)
            }));
            series2.Points.Add(new SeriesPoint("Task 4", new DateTime[] {
                new DateTime(2006, 10, 10), new DateTime(2006, 10, 23)
            }));

            // Add both series to the chart.
            ganttChart.Series.AddRange(new Series[] { series1, series2 });

            // Access the view-type-specific options of the second series.
            SideBySideGanttSeriesView myView2 = (SideBySideGanttSeriesView)series2.View;

            myView2.MaxValueMarkerVisibility      = DefaultBoolean.True;
            myView2.MaxValueMarker.Kind           = MarkerKind.Star;
            myView2.MaxValueMarker.StarPointCount = 5;
            myView2.MaxValueMarker.Size           = 10;

            myView2.MinValueMarkerVisibility = DefaultBoolean.True;
            myView2.MinValueMarker.Kind      = MarkerKind.Circle;
            myView2.MinValueMarker.Size      = 10;

            myView2.BarWidth = 0.5;

            // Customize the chart (if necessary).
            GanttDiagram myDiagram = (GanttDiagram)ganttChart.Diagram;

            myDiagram.AxisX.Title.Visibility = DefaultBoolean.True;
            myDiagram.AxisX.Title.Text       = "Tasks";
            myDiagram.AxisY.Interlaced       = true;
            myDiagram.AxisY.DateTimeScaleOptions.GridSpacing = 2;
            myDiagram.AxisY.Label.Angle = -30;
            myDiagram.AxisY.Label.EnableAntialiasing = DefaultBoolean.True;
            myDiagram.AxisY.Label.TextPattern        = "{V:MMMM dd}";

            // Customize the legend (if necessary).
            ganttChart.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right;
            ganttChart.Legend.AlignmentVertical   = LegendAlignmentVertical.TopOutside;
            ganttChart.Legend.Direction           = LegendDirection.LeftToRight;

            // Add a constant line.
            ConstantLine deadline = new ConstantLine("Deadline", new DateTime(2006, 10, 15));

            deadline.ShowInLegend    = false;
            deadline.Title.Alignment = ConstantLineTitleAlignment.Far;
            deadline.Color           = Color.Red;
            myDiagram.AxisY.ConstantLines.Add(deadline);

            // Add a title to the chart (if necessary).
            ganttChart.Titles.Add(new ChartTitle());
            ganttChart.Titles[0].Text = "A Side-by-Side Gantt Chart";

            // Add the chart to the form.
            ganttChart.Dock = DockStyle.Fill;
            this.Controls.Add(ganttChart);
        }