本文整理汇总了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;
}
示例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;
}