/// <summary> /// Copy Constructor /// </summary> public RadarPointList(RadarPointList rhs) { for (int i = 0; i < rhs.Count; i++) { this.Add(rhs.GetAt(i)); } }
/// <summary> /// Copy Constructor /// </summary> public RadarPointList(RadarPointList rhs) { for (var i = 0; i < rhs.Count; i++) { Add(rhs.GetAt(i)); } }
/////////////////////////////////////////////////////////////////////////////////////////////// // Build the Chart private void CreateGraph(ZedGraphControl zgc) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; // Set the Titles myPane.Title.Text = microphone.title; myPane.XAxis.Title.Text = ""; myPane.YAxis.Title.Text = ""; myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsZeroLine = false; myPane.XAxis.Scale.Min = -1; myPane.XAxis.Scale.Max = 1; // По оси Y установим автоматический подбор масштаба myPane.YAxis.Scale.MinAuto = true; myPane.YAxis.Scale.MaxAuto = true; // Создаем список точек RadarPointList points = new RadarPointList(); // Т.к. в списке будет 4 точки, то и окружность будет разбиваться на 4 части // Обход точек будет осуществляться по часовой стрелке points.Clockwise = true; // Первая точка - сверху над началом координат. Расстояние до центра = 1. Второй параметр в большинстве случаев не используется for (int i = 0; i < pointsArray.Length; i++) { points.Add(pointsArray[i], 1); } // Добавляем кривую по этим четырем точкам LineItem myCurve = myPane.AddCurve("", points, Color.Black, SymbolType.None); // Отметим начало координат черным квадратиком BoxObj box = new BoxObj(-0.005, 0.005, 0.01, 0.01, Color.Black, Color.Black); myPane.GraphObjList.Add(box); zgc.AxisChange(); zgc.Invalidate(); }
private void CreateGraph_SpiderPlot( ZedGraphControl z1 ) { GraphPane myPane = z1.GraphPane; RadarPointList rpl = new RadarPointList(); Random rand = new Random(); for ( int i = 0; i < 7; i++ ) { double r = rand.NextDouble() * 10.0 + 1.0; PointPair pt = new PointPair( PointPair.Missing, r, "r = " + r.ToString( "f1" ) ); rpl.Add( pt ); } LineItem curve = myPane.AddCurve( "test", rpl, Color.Green, SymbolType.Default ); // Add the spokes as GraphItems for ( int i = 0; i < 7; i++ ) { ArrowObj arrow = new ArrowObj( 0, 0, (float) rpl[i].X, (float) rpl[i].Y ); arrow.IsArrowHead = false; arrow.Line.Color = Color.LightGray; arrow.ZOrder = ZOrder.E_BehindCurves; myPane.GraphObjList.Add( arrow ); } myPane.XAxis.MajorGrid.IsZeroLine = true; myPane.XAxis.MajorTic.IsAllTics = true; myPane.XAxis.Title.IsTitleAtCross = false; myPane.XAxis.Cross = 0; myPane.XAxis.Scale.IsSkipFirstLabel = true; myPane.XAxis.Scale.IsSkipLastLabel = true; myPane.XAxis.Scale.IsSkipCrossLabel = true; myPane.YAxis.MajorTic.IsAllTics = true; myPane.YAxis.Title.IsTitleAtCross = false; myPane.YAxis.Cross = 0; myPane.YAxis.Scale.IsSkipFirstLabel = true; myPane.YAxis.Scale.IsSkipLastLabel = true; myPane.YAxis.Scale.IsSkipCrossLabel = true; }
private void CreateGraph_RadarPlot( ZedGraphControl z1 ) { GraphPane myPane = z1.GraphPane; RadarPointList rpl = new RadarPointList(); Random rand = new Random(); for ( int i = 0; i < 10; i++ ) { double r = rand.NextDouble() * 10.0 + 10.0; PointPair pt = new PointPair( PointPair.Missing, r, "r = " + r.ToString( "f1" ) ); rpl.Add( pt ); } LineItem curve = myPane.AddCurve( "test", rpl, Color.Blue, SymbolType.Default ); for ( int i = 0; i < 10; i++ ) { LineObj line = new LineObj( 0, 0, (float) rpl[i].X, (float) rpl[i].Y ); line.Line.Color = Color.LightBlue; line.ZOrder = ZOrder.E_BehindCurves; myPane.GraphObjList.Add( line ); } myPane.XAxis.MajorTic.IsAllTics = true; myPane.XAxis.MinorTic.IsAllTics = true; myPane.XAxis.Title.IsTitleAtCross = false; myPane.XAxis.Cross = 0; myPane.XAxis.Scale.IsSkipFirstLabel = true; myPane.XAxis.Scale.IsSkipLastLabel = true; myPane.XAxis.Scale.IsSkipCrossLabel = true; myPane.YAxis.MajorTic.IsAllTics = true; myPane.YAxis.MinorTic.IsAllTics = true; myPane.YAxis.Title.IsTitleAtCross = false; myPane.YAxis.Cross = 0; myPane.YAxis.Scale.IsSkipFirstLabel = true; myPane.YAxis.Scale.IsSkipLastLabel = true; myPane.YAxis.Scale.IsSkipCrossLabel = true; }
public void MakeWindRose(List<int> nValues) { _nValues = nValues; GraphPane pane = mainChart.GraphPane; pane.Title.Text = "Роза ветров"; pane.IsFontsScaled = false; pane.CurveList.Clear(); pane.XAxis.IsVisible = false; pane.YAxis.IsVisible = false; pane.XAxis.MajorGrid.IsVisible = false; pane.YAxis.MajorGrid.IsVisible = false; pane.YAxis.MajorGrid.IsZeroLine = false; // Создаем список точек var points = new RadarPointList {Clockwise = true}; var text = new TextObj[8]; var axText = new TextObj[8]; for (int i = 0; i < 8; i++) points.Add(_nValues[i], 1); int nMax = _nValues.Concat(new[] {0}).Max(); nMax += 1; for (int i = 0; i < points.Count - 1; i++) { text[i] = new TextObj(_nValues[i].ToString(), points[i].X, points[i].Y); text[i].FontSpec.Border.IsVisible = false; Color color; if (_nValues[i] < nMax / 3) color = Color.GreenYellow; else if (_nValues[i] < (nMax / 3) * 2) color = Color.Yellow; else color = Color.OrangeRed; text[i].FontSpec.Fill = new Fill(color); text[i].FontSpec.IsBold = true; pane.GraphObjList.Add(text[i]); } // Добавляем кривую по этим четырем точкам LineItem myCurve = pane.AddCurve("", points, Color.Blue, SymbolType.Triangle); myCurve.Line.Width = 2.5F; // Для наглядности нарисуем расстояния от начала координат до каждой из точек var arrow = new LineObj[8]; arrow[0] = new LineObj(0, 0, 0, nMax); arrow[1] = new LineObj(0, 0, -nMax, 0); arrow[2] = new LineObj(0, 0, 0, -nMax); arrow[3] = new LineObj(0, 0, nMax, 0); arrow[4] = new LineObj(0, 0, nMax, nMax); arrow[5] = new LineObj(0, 0, -nMax, nMax); arrow[6] = new LineObj(0, 0, nMax, -nMax); arrow[7] = new LineObj(0, 0, -nMax, -nMax); axText[0] = new TextObj("с", 0, nMax); axText[1] = new TextObj("з", -nMax, 0); axText[2] = new TextObj("ю", 0, -nMax); axText[3] = new TextObj("в", nMax, 0); axText[4] = new TextObj("с/в", nMax, nMax); axText[5] = new TextObj("с/з", -nMax, nMax); axText[6] = new TextObj("ю/в", nMax, -nMax); axText[7] = new TextObj("ю/з", -nMax, -nMax); for (int i = 0; i < 8; i++) { pane.GraphObjList.Add(axText[i]); pane.GraphObjList.Add(arrow[i]); } // Отметим начало координат черным квадратиком var box = new BoxObj(-0.05, 0.05, 0.1, 0.1, Color.Black, Color.Black); pane.GraphObjList.Add(box); // Устанавливаем интересующий нас интервал по оси X pane.XAxis.Scale.Min = -nMax; pane.XAxis.Scale.Max = nMax; // Устанавливаем интересующий нас интервал по оси Y pane.YAxis.Scale.Min = -nMax; pane.YAxis.Scale.Max = nMax; mainChart.AxisChange(); mainChart.Invalidate(); }
/// <summary> /// Copy Constructor /// </summary> public RadarPointList( RadarPointList rhs ) { for ( int i = 0; i < rhs.Count; i++ ) this.Add( rhs.GetAt(i) ); }