나는 모든 노드가 이중 목록을 나타내는 treeView
element
을가집니다.Microsoft 차트 컨트롤 - 실패 후 차트 다시 그리기 (적색 십자가)
list
에 값을 표시하려면 DataVisualization.Charting
컨트롤을 사용하고 있습니다.
일부 목록에 대해서는 예외가 발생합니다. RecalculateAxesScale
(System.OverflowException: Value was either too large or too small for a Decimal).
이 오류를 무시하고 차트에 큰 적색 십자가가 표시됩니다.
이제 다른 노드를 클릭하면 유효하지만이 차트의 차트를 표시하려고하지만 차트가 다시 그려지지 않습니다. 그것은 항상 빨간색 X를 표시
내 코드 : dblList의
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
//Refresh chart:
chart1.Series.Clear();
chart1.ResetAutoValues();
chart1.ResetText();
//plot new doublelist
var series = new Series
{
Name = "name",
Color = color,
ChartType = SeriesChartType.Line,
ChartArea = "chartName"
};
this.chart1.Series.Add(series);
series.Points.DataBindY(doubleList);
var chartArea = chart1.ChartAreas["chartName"];
chartArea.RecalculateAxesScale();
chartArea.AxisX.Minimum = 1;
chartArea.AxisX.Maximum = doubleList.Count;
chartArea.CursorX.AutoScroll = true;
chartArea.CursorY.AutoScroll = true;
// Allow user to select area for zooming
chartArea.CursorX.IsUserEnabled = true;
chartArea.CursorX.IsUserSelectionEnabled = true;
// Set automatic zooming`<br>
chartArea.AxisX.ScaleView.Zoomable = true;
chartArea.AxisY.ScaleView.Zoomable = true;
chartArea.AxisX.ScrollBar.IsPositionedInside = true;
//reset zoom
chartArea.AxisX.ScaleView.ZoomReset();
chart1.Invalidate();
}
[편집]
유형 : 예외의
List<double> doubleList= (from s in myData select s.value).ToList();
전체 스택 :
{System.OverflowException: Value was either too large or too small for a Decimal.
at System.Decimal.FCallMultiply(Decimal& d1, Decimal& d2)
at System.Decimal.op_Multiply(Decimal d1, Decimal d2)
at System.Windows.Forms.DataVisualization.Charting.Axis.RoundedValues(Double inter, Boolean shouldStartFromZero, Boolean autoMax, Boolean autoMin, Double& min, Double& max)
at System.Windows.Forms.DataVisualization.Charting.Axis.EstimateNumberAxis(Double& minimumValue, Double& maximumValue, Boolean shouldStartFromZero, Int32 preferredNumberOfIntervals, Boolean autoMaximum, Boolean autoMinimum)
at System.Windows.Forms.DataVisualization.Charting.Axis.EstimateAxis(Double& minimumValue, Double& maximumValue, Boolean autoMaximum, Boolean autoMinimum)
at System.Windows.Forms.DataVisualization.Charting.Axis.EstimateAxis()
at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetDefaultAxesValues()
at System.Windows.Forms.DataVisualization.Charting.ChartArea.SetData(Boolean initializeAxes, Boolean checkIndexedAligned)
at System.Windows.Forms.DataVisualization.Charting.ChartArea.RecalculateAxesScale()
,
[EDIT 2
예에서 :
List<double> dblList = new List<double>();
dblList.Add(0.0);
dblList.Add(-7.4876421623346545E-36);
dblList.Add(1.0);
dblList.Add(-26697097281536.0);
dblList.Add(-6.8163553952838136E+28); //problem!!!!!
마지막 값 (예외없이 적십자사) 문제를 생성한다. 그래서 목록을 변환하기위한 최소값과 최대 값이 적절하지 않은 것 같습니다. 그것에 대한 아이디어가 있습니까?
double min = (double)Decimal.MinValue; //min = -7.9228162514264338E+28
double max = (double)Decimal.MaxValue; //max = 7.9228162514264338E+28
내 대답은 쓸모 없으므로 여기로 이동하십시오. 값 자체는 괜찮지 만 System.Decimal은 언더 플로/오버플로에 대한 산술 연산을 위해 throw됩니다. 그리고 체크/체크되지 않은 요구 사항을 무시합니다 ... –
문제가 무엇인지 알 수 있습니까? 어떻게 처리 할 수 있습니까? 너무 높거나 낮은 값을 일종의 표준 값으로 대체해야합니까? – purbsel
예, 솔루션 일 수도 있지만 줌을 처리해야합니다 (축이 다시 계산 될 수 있으므로). –