コード例 #1
0
        public void SetDataSources(LogAnalyzerLogLevel statistics)
        {
            if (pieChart != null)
            {
                pieChart.Series[0].DataSource = statistics.AsListWithoutTotal();
                return;
            }
            pieChart = new ChartControl();
            pieChart.Titles.Add(new ChartTitle()
            {
                Text = statistics.Name
            });
            pieChart.AllowGesture = true;
            pieChart.Titles.Clear();
            pieChart.Titles.Add(new ChartTitle()
            {
                Text = statistics.Name
            });
            pieChart.Series.Clear();
            // Create a pie series.
            Series series1 = new Series(statistics.Name, ViewType.Pie3D);

            // Bind the series to data.
            series1.DataSource         = statistics.AsListWithoutTotal();
            series1.ArgumentDataMember = nameof(LogAnalyzerSingleDataPoint.Name);
            series1.ValueDataMembers.AddRange(nameof(LogAnalyzerSingleDataPoint.Value));

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

            // Format the the series labels.
            series1.Label.TextPattern = "{A}: {VP:p0} ({V})";

            // Format the series legend items.
            series1.LegendTextPattern = "{A}";

            // Adjust the position of series labels.
            ((PieSeriesLabel)series1.Label).Position = PieSeriesLabelPosition.TwoColumns;

            // Detect overlapping of series labels.
            ((PieSeriesLabel)series1.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;

            // Access the view-type-specific options of the series.
            Pie3DSeriesView myView = (Pie3DSeriesView)series1.View;

            // Specify a data filter to explode points.
            //myView.ExplodedPointsFilters.Add(new SeriesPointFilter(SeriesPointKey.Value_1,
            //    DataFilterCondition.GreaterThanOrEqual, 9));
            //myView.ExplodedPointsFilters.Add(new SeriesPointFilter(SeriesPointKey.Argument,
            //    DataFilterCondition.NotEqual, "Others"));
            //myView.ExplodeMode = PieExplodeMode.UseFilters;
            myView.ExplodedDistancePercentage = 30;
            myView.ExplodeMode = PieExplodeMode.All;

            // Customize the legend.
            pieChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
            // Add the chart to the form.
            pieChart.Dock = DockStyle.Fill;
            this.Controls.Add(pieChart);
        }
コード例 #2
0
 public void setValue(bool IsRight)
 {
     if (IsRight)
     {
         chartControl1.Series[0].Points[0].Values = new double[] { MyGlobal.globalPointSet_Right.OkCnt };
         chartControl1.Series[0].Points[1].Values = new double[] { MyGlobal.globalPointSet_Right.AnchorErrorCnt };
         chartControl1.Series[0].Points[2].Values = new double[] { MyGlobal.globalPointSet_Right.FindEgdeErrorCnt };
         chartControl1.Series[0].Points[3].Values = new double[] { MyGlobal.globalPointSet_Right.ExploreHeightErrorCnt };
         Pie3DSeriesView pie3DSeriesView = (Pie3DSeriesView)chartControl1.Series[0].View;
         int             totalCnt        = MyGlobal.globalPointSet_Right.OkCnt + MyGlobal.globalPointSet_Right.AnchorErrorCnt +
                                           MyGlobal.globalPointSet_Right.FindEgdeErrorCnt + MyGlobal.globalPointSet_Right.ExploreHeightErrorCnt;
         if (totalCnt == 0)
         {
             chartControl1.Series[0].Points[0].Values = new double[] { 1 };
         }
         pie3DSeriesView.Titles[0].Text = $"总产能:{totalCnt}";
     }
     else
     {
         chartControl1.Series[0].Points[0].Values = new double[] { MyGlobal.globalPointSet_Left.OkCnt };
         chartControl1.Series[0].Points[1].Values = new double[] { MyGlobal.globalPointSet_Left.AnchorErrorCnt };
         chartControl1.Series[0].Points[2].Values = new double[] { MyGlobal.globalPointSet_Left.FindEgdeErrorCnt };
         chartControl1.Series[0].Points[3].Values = new double[] { MyGlobal.globalPointSet_Left.ExploreHeightErrorCnt };
         Pie3DSeriesView pie3DSeriesView = (Pie3DSeriesView)chartControl1.Series[0].View;
         int             totalCnt        = MyGlobal.globalPointSet_Left.OkCnt + MyGlobal.globalPointSet_Left.AnchorErrorCnt +
                                           MyGlobal.globalPointSet_Left.FindEgdeErrorCnt + MyGlobal.globalPointSet_Left.ExploreHeightErrorCnt;
         if (totalCnt == 0)
         {
             chartControl1.Series[0].Points[0].Values = new double[] { 1 };
         }
         pie3DSeriesView.Titles[0].Text = $"总产能:{totalCnt}";
     }
 }
コード例 #3
0
 public void DrawPieChartOnForm(string factoryID, Point myPieLocation, Size myPieSize)
 {
     try
     {
         CalculateLegendForFactory(factoryID);
         Series          series    = new Series("Series1", ViewType.Pie3D);
         ChartTitle      testTitle = new ChartTitle();
         Pie3DSeriesView myView    = (Pie3DSeriesView)series.View;
         if (allLegend[0] == 0.0 && allLegend[1] == 0.0 && allLegend[2] == 0.0)
         {
             pnlPieChart.Controls.Clear();
             MessageBox.Show(this, "No data has been taken on any Point in this Plant....", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         else
         {
             double[]  myPiePercent = { allLegend[0], allLegend[1], allLegend[2] };
             Color[]   myPieColors  = { Color.Red, Color.Yellow, Color.Green };
             DataTable chartTable   = new DataTable("Table1");
             chartTable.Columns.Add("Names", typeof(string));
             chartTable.Columns.Add("Value", typeof(double));
             chartTable.Rows.Add("High Alarm", allLegend[0]);
             chartTable.Rows.Add("Low Alarm", allLegend[1]);
             chartTable.Rows.Add("No Alarm", allLegend[2]);
             pieChartControl.Series.Clear();
             pieChartControl.Series.Add(series);
             series.DataSource         = chartTable;
             series.ArgumentScaleType  = ScaleType.Numerical;
             series.ArgumentDataMember = "Value";
             series.ValueScaleType     = ScaleType.Numerical;
             series.ValueDataMembers.AddRange(new string[] { "Value" });
             series.Name = Convert.ToString(SelectedFactory);
             pieChartControl.Titles.Clear();
             myView.Titles.Add(new SeriesTitle());
             myView.Titles[0].Text = series.Name;
             pieChartControl.Dock  = DockStyle.Fill;
         }
     }
     catch { }
 }