當前位置: 首頁>>代碼示例>>C#>>正文


C# ChartArea.RecalculateAxesScale方法代碼示例

本文整理匯總了C#中System.Windows.Forms.DataVisualization.Charting.ChartArea.RecalculateAxesScale方法的典型用法代碼示例。如果您正苦於以下問題:C# ChartArea.RecalculateAxesScale方法的具體用法?C# ChartArea.RecalculateAxesScale怎麽用?C# ChartArea.RecalculateAxesScale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.DataVisualization.Charting.ChartArea的用法示例。


在下文中一共展示了ChartArea.RecalculateAxesScale方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RecalculateAxesScale

    private void RecalculateAxesScale(ChartArea area) {
      // Reset the axes bounds so that RecalculateAxesScale() will assign new bounds
      foreach (Axis a in area.Axes) {
        a.Minimum = double.NaN;
        a.Maximum = double.NaN;
      }
      area.RecalculateAxesScale();
      area.AxisX.IsMarginVisible = false;
      area.AxisX2.IsMarginVisible = false;

      if (!Content.VisualProperties.XAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue)) area.AxisX.Minimum = Content.VisualProperties.XAxisMinimumFixedValue;
      if (!Content.VisualProperties.XAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue)) area.AxisX.Maximum = Content.VisualProperties.XAxisMaximumFixedValue;
      if (!Content.VisualProperties.SecondXAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.SecondXAxisMinimumFixedValue)) area.AxisX2.Minimum = Content.VisualProperties.SecondXAxisMinimumFixedValue;
      if (!Content.VisualProperties.SecondXAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.SecondXAxisMaximumFixedValue)) area.AxisX2.Maximum = Content.VisualProperties.SecondXAxisMaximumFixedValue;
      if (!Content.VisualProperties.YAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.YAxisMinimumFixedValue)) area.AxisY.Minimum = Content.VisualProperties.YAxisMinimumFixedValue;
      if (!Content.VisualProperties.YAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.YAxisMaximumFixedValue)) area.AxisY.Maximum = Content.VisualProperties.YAxisMaximumFixedValue;
      if (!Content.VisualProperties.SecondYAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.SecondYAxisMinimumFixedValue)) area.AxisY2.Minimum = Content.VisualProperties.SecondYAxisMinimumFixedValue;
      if (!Content.VisualProperties.SecondYAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.SecondYAxisMaximumFixedValue)) area.AxisY2.Maximum = Content.VisualProperties.SecondYAxisMaximumFixedValue;
      if (area.AxisX.Minimum >= area.AxisX.Maximum) area.AxisX.Maximum = area.AxisX.Minimum + 1;
      if (area.AxisX2.Minimum >= area.AxisX2.Maximum) area.AxisX2.Maximum = area.AxisX2.Minimum + 1;
      if (area.AxisY.Minimum >= area.AxisY.Maximum) area.AxisY.Maximum = area.AxisY.Minimum + 1;
      if (area.AxisY2.Minimum >= area.AxisY2.Maximum) area.AxisY2.Maximum = area.AxisY2.Minimum + 1;
    }
開發者ID:thunder176,項目名稱:HeuristicLab,代碼行數:23,代碼來源:DataTableView.cs

示例2: DtBoxPlot


//.........這裏部分代碼省略.........

            area.AxisX.Title = SummaryMainClass.RestoreData(XaxisName);
            area.AxisY.Title = SummaryMainClass.RestoreData(YaxisName);

            //Temp series (Note this series has to be added BEFORE the BoxPlot series)
            Series tempSeries = new Series("TempSeries");
            tempSeries.ChartArea = area.Name;
            //To hide the series. Setting .Enabled = false will not have the desired effect.
            tempSeries.Color = Color.Transparent;
            tempSeries.Points.AddXY(1, 0); //XValue <> 0, so that it will not be treated as indexed
            this.chart1.Series.Add(tempSeries);

            //BoxPlot series
            Series seriesBox = new Series("BoxPlot");
            seriesBox.Color = Color.FromArgb(60, seriesBox.Color);
            // seriesBox.Palette = ChartColorPalette.SemiTransparent;

            seriesBox.ChartArea = area.Name;
            seriesBox.ChartType = SeriesChartType.BoxPlot;
            seriesBox["BoxPlotSeries"] = bpSeries;//combines series names "Series1;Series2;Series3";
            //seriesBox["BoxPlotShowMedian"] = "true";
            //seriesBox["BoxPlotShowAverage"] = "true";
            //seriesBox["BoxPlotShowUnusualValues"] = "true";
            seriesBox["BoxPlotWhiskerPercentile"] = "10";
            seriesBox["BoxPlotPercentile"] = "30";
            this.chart1.Series.Add(seriesBox);

            chart1.ApplyPaletteColors();

            double[] statistics = new double[] { };
            statistics = ApplyStatisticLines(dtsm, XValues, AdditionalFilter, AdditionalSpecFilter, YaxisName);

            //Get the min and max of chart scale from the plotted data
            //double xmin,ymin,xmax,ymax;
            //         xmin = Convert.ToDouble(chart1.Series[0].Points[0].XValue);
            //         xmax = xmin;
            //         ymin = Convert.ToDouble(chart1.Series[0].Points[0].YValues[0]);
            //         ymax = ymin;

            //     foreach (var series in chart1.Series)
            //     {
            //         foreach (var point in series.Points)
            //         {
            //             xmin = (xmin < Convert.ToDouble(point.XValue)) ? xmin : point.XValue;
            //             ymin = (ymin < Convert.ToDouble(point.YValues[0])) ? ymin : point.YValues[0];
            //             xmax = (xmax > Convert.ToDouble(point.XValue)) ? xmax : point.XValue;
            //             ymax = (ymax > Convert.ToDouble(point.YValues[0])) ? ymax : point.YValues[0];
            //            // point.Color = Color.FromArgb(220, point.Color);
            //         }
            //     }
            //Max(Range(Cells(1, 1), Cells(4, PT.PivotFields("Voltage1").PivotItems.Count)).Offset(row_count - 11, 1)) + (Max(Range(Cells(1, 1), Cells(4, PT.PivotFields("Voltage1").PivotItems.Count)).Offset(row_count - 11, 1)) - Min(Range(Cells(1, 1), Cells(4, PT.PivotFields("Voltage1").PivotItems.Count)).Offset(row_count - 11, 1))) / 20
            //Min(Range(Cells(1, 1), Cells(4, PT.PivotFields("Voltage1").PivotItems.Count)).Offset(row_count - 11, 1)) - (Max(Range(Cells(1, 1), Cells(4, PT.PivotFields("Voltage1").PivotItems.Count)).Offset(row_count - 11, 1)) - Min(Range(Cells(1, 1), Cells(4, PT.PivotFields("Voltage1").PivotItems.Count)).Offset(row_count - 11, 1))) / 20

            //Setup Grids
            area.AxisX.MajorGrid.Enabled = false;
            area.AxisY.MajorGrid.Enabled = false;
            area.AxisX.MinorGrid.Enabled = true;
            area.AxisX.MinorGrid.LineColor = Color.FromArgb(25, seriesBox.Color);
            area.AxisY.MinorGrid.Enabled = true;
            area.AxisY.MinorGrid.LineColor = Color.FromArgb(25, seriesBox.Color);
            area.AxisX.MinorGrid.Interval = 1;

            //To make the chart look nice...
            double minY = statistics.Min();
            double maxY = statistics.Max();

            System.Diagnostics.Debug.Print("min " + minY.ToString() + " Max " + maxY.ToString());

            area.RecalculateAxesScale();
            if ((minY - (maxY - minY) / 20).ToString() != "-Infinity") area.AxisY.Minimum = minY - (maxY - minY) / 20; //area.AxisY.Minimum;//22.4; //
            if ((maxY + (maxY - minY) / 20).ToString() != "Infinity") area.AxisY.Maximum = maxY + (maxY - minY) / 20; //area.AxisY.Maximum + area.AxisY.Maximum * 0.05;//23;//
            area.AxisX.Minimum = 0;// area.AxisX.Minimum;//
            if (XValues.Count > 1) area.AxisX.Maximum = XValues[XValues.Count - 1] + 6 * XValues[1];  //area.AxisX.Maximum;
            seriesBox["MaxPixelPointWidth"] = "20";

            double first = Convert.ToDouble(System.Text.RegularExpressions.Regex.Match(XValues[0].ToString(), @"\d+").Value);
            var XAxis = chart1.ChartAreas[0].AxisX;

            double StartPos = Convert.ToDouble(System.Text.RegularExpressions.Regex.Match(XValues[0].ToString(), @"\d+").Value);
            double EndPos = new int();

            //Truncate the Y axis Values
            chart1.ChartAreas[0].AxisY.LabelStyle.TruncatedLabels = true;

            int icount = 0;
            int labelWidth = 5; //1
            if (XActual.Count > 10) labelWidth = 5;
            if (XActual.Count > 15) labelWidth = 8;
            foreach (int Xval in XValues)
            {
                EndPos = StartPos + labelWidth;

                //chart1.ChartAreas[0].AxisX.CustomLabels.Add(StartPos, EndPos, XActual[icount].ToString(), 0, LabelMarkStyle.None); //StartPos.ToString("f") replaced with  XActual[icount].ToString()
                chart1.ChartAreas[0].AxisX.CustomLabels.Add(StartPos, EndPos, XActual[icount].ToString(), 0, LabelMarkStyle.Box);
                StartPos = Xval + ZoomIndex;
                icount++;
            }
            ChartRedraw();
            return;
        }
開發者ID:sparshgupta1,項目名稱:data-cruncher-analyzer,代碼行數:101,代碼來源:DtPlots.cs


注:本文中的System.Windows.Forms.DataVisualization.Charting.ChartArea.RecalculateAxesScale方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。