public DataFrameBuilder(GraphPane graphPane, CurveItem curveItem) { GraphPane = graphPane; CurveItem = curveItem; var msPointList = curveItem.Points as MSPointList; if (msPointList != null) { Points = msPointList.FullList; } else { Points = curveItem.Points; } XAxis = curveItem.GetXAxis(graphPane); YAxis = curveItem.GetYAxis(graphPane); BaseAxis = curveItem.BaseAxis(graphPane); ValueAxis = curveItem.ValueAxis(graphPane); }
public static void AddRandomSpikes(CurveItem ci, double size, int count) { if (ci.Points.Count / 100 < count) { count = ci.Points.Count / 100; } var nums = Enumerable.Range(0, ci.Points.Count).ToList(); while (count-- > 0) { var tmp = Rnd.Next(0, nums.Count); var i = nums[tmp]; nums.RemoveAt(tmp); var sign = Rnd.Next(0, 2); ci.Points[i].Y += sign > 0 ? size : -size; } }
/// <summary> /// Find the closest curve/point to the cursor. /// </summary> /// <param name="curveList">List of curves to check.</param> /// <param name="maxDistance">Maximum distance from curve allowed.</param> /// <param name="pt">Cursor coordinates.</param> /// <param name="closestCurve">Returns the closest curve (or null if none is close enough).</param> /// <param name="closestPoint">Returns the closest point on the curve.</param> public void FindClosestCurve(IEnumerable <CurveItem> curveList, PointF pt, int maxDistance, out CurveItem closestCurve, out PointF closestPoint) { // Determine boundaries of point search in graph coordinates. double xLo, xHi, y; ReverseTransform(new PointF(pt.X - maxDistance, 0), out xLo, out y); ReverseTransform(new PointF(pt.X + maxDistance, 0), out xHi, out y); closestCurve = null; closestPoint = new PointF(); double closestDistanceSquared = maxDistance * maxDistance; // Iterate through each curve, finding the closest one within the distance limit (closestDistanceSquared). foreach (var curve in curveList) { FindClosestPoint(curve, xLo, xHi, pt, ref closestCurve, ref closestPoint, ref closestDistanceSquared); } }
public bool MoveMouse(MouseButtons buttons, Point point) { // Pan if (ModifierKeys.HasFlag(Keys.Control) && buttons.HasFlag(MouseButtons.Left)) { AdjustLocations(zedGraphControl.GraphPane); } CurveItem nearestCurveItem = null; var index = -1; if (TryGetNearestCurveItem(point, ref nearestCurveItem, ref index)) { var lineItem = nearestCurveItem as LineItem; if (lineItem == null || index < 0 || index >= lineItem.Points.Count || lineItem[index].Tag == null) { return(false); } _selectedRow = (FoldChangeBindingSource.FoldChangeRow)lineItem[index].Tag; zedGraphControl.Cursor = Cursors.Hand; if (_tip == null) { _tip = new NodeTip(this); } _tip.SetTipProvider(new FoldChangeRowTipProvider(_selectedRow), new Rectangle(point, new Size()), point); return(true); } else { if (_tip != null) { _tip.HideTip(); } _selectedRow = null; return(false); } }
public void DrawFilled(Graphics g, GraphPane pane, CurveItem curve, float scaleFactor) { var source = this; var yAxis = curve.GetYAxis(pane); var xAxis = curve.GetXAxis(pane); var basePix = yAxis.Scale.Transform(0.0); using (var pen = source.GetPen(pane, scaleFactor)) { var list1 = new List <PointF>(); var list2 = new List <PointF>(); for (var i = 0; i < curve.Points.Count; i++) { var pt = curve.Points[i]; if (pt.X != PointPair.Missing && pt.Y != PointPair.Missing && !Double.IsNaN(pt.X) && !Double.IsNaN(pt.Y) && !Double.IsInfinity(pt.X) && !Double.IsInfinity(pt.Y) && (!xAxis.Scale.IsLog || pt.X > 0.0) && (!yAxis.Scale.IsLog || pt.Y > 0.0)) { var pixY = yAxis.Scale.Transform(curve.IsOverrideOrdinal, i, pt.Y); var pixX = xAxis.Scale.Transform(curve.IsOverrideOrdinal, i, pt.X); var pixZ = yAxis.Scale.Transform(curve.IsOverrideOrdinal, i, pt.Z); list1.Add(new PointF(pixX, pixY)); list2.Add(new PointF(pixX, pixZ)); } } list2.Reverse(); list1.AddRange(list2); var points = list1.ToArray(); g.SmoothingMode = SmoothingMode.AntiAlias; g.FillPolygon(Fill.Brush, points); g.DrawPolygon(pen, points); } }
private void zedGraphControl_Click(object sender, EventArgs e) { CurveItem nearestCurve = null; int nearestIndex = 0; Point screenPoint = zedGraphControl.PointToClient(Cursor.Position); zedGraphControl.GraphPane.FindNearestPoint( new PointF(screenPoint.X, screenPoint.Y), out nearestCurve, out nearestIndex); if (nearestCurve != null && nearestIndex >= 0) { DateTime time = XDate.XLDateToDateTime(nearestCurve[nearestIndex].X); LogViewerControl lvc = GetParentControl(); if (lvc != null) { lvc.SelectNodeByDate(time); } } }
/// <summary> /// The hien thong tin tren moi diem ve /// </summary> /// <param name="curve"></param> /// <param name="pointIdx"></param> /// <returns></returns> private string PointValueEventPrice(CurveItem curve, int pointIdx) { if (!Settings.sysChartShowDescription) { return(null); } if (pointIdx >= myData.Open.Values.Length) { return(null); } DateTime dt = DateTime.FromOADate(curve[pointIdx].X); string retVal = ""; switch (this.ChartTimeScale.Type) { case AppTypes.TimeScaleTypes.RealTime: case AppTypes.TimeScaleTypes.Minnute: case AppTypes.TimeScaleTypes.Hour: retVal = Languages.Libs.GetString("time") + " : " + dt.ToString(); break; case AppTypes.TimeScaleTypes.Day: retVal = Languages.Libs.GetString("date") + " : " + dt.ToShortDateString(); break; case AppTypes.TimeScaleTypes.Week: retVal = Languages.Libs.GetString("week") + " : " + common.dateTimeLibs.WeekOfYear(dt).ToString() + "/" + dt.Year.ToString(); break; case AppTypes.TimeScaleTypes.Month: retVal = Languages.Libs.GetString("month") + " : " + dt.Month.ToString() + "/" + dt.Year.ToString(); break; case AppTypes.TimeScaleTypes.Year: retVal = Languages.Libs.GetString("year") + " : " + dt.Year.ToString(); break; } retVal += common.Consts.constCRLF + Languages.Libs.GetString("openPrice") + " : " + myData.Open.Values[pointIdx].ToString(Settings.sysMaskPrice) + common.Consts.constCRLF + Languages.Libs.GetString("highPrice") + " : " + myData.High.Values[pointIdx].ToString(Settings.sysMaskPrice) + common.Consts.constCRLF + Languages.Libs.GetString("lowPrice") + " : " + myData.Low.Values[pointIdx].ToString(Settings.sysMaskPrice) + common.Consts.constCRLF + Languages.Libs.GetString("closePrice") + " : " + myData.Close.Values[pointIdx].ToString(Settings.sysMaskPrice) + common.Consts.constCRLF + Languages.Libs.GetString("volume") + " : " + myData.Volume.Values[pointIdx].ToString(Settings.sysMaskQty); TradePointInfo info = findTradePointInfo(pointIdx); if (info != null) { retVal += common.Consts.constCRLF + Languages.Libs.GetString("targetPrice") + " : " + info.BusinessInfo.Short_Target + common.Consts.constCRLF + Languages.Libs.GetString("resistance") + " : " + info.BusinessInfo.Short_Resistance + common.Consts.constCRLF + Languages.Libs.GetString("support") + " : " + info.BusinessInfo.Short_Support; } return(retVal); }
/// <summary> /// Formats the tooltip popups /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="pane">The parameter is not used.</param> /// <param name="curve">The curve containing the points</param> /// <param name="iPt">The index of the point of interest</param> /// <returns>A tooltip string</returns> string zedChart_PointValueEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, int iPt) { // TODO: Update tooltip for report view string tooltip = string.Empty; string id = curve.Tag as string; DateTime date = XDate.XLDateToDateTime(curve[iPt].X); // 5 sec foreach (CriticalLineDefinition def in GlobalSettings.Instance.CriticalPowerLines) { if (def.ReferenceId == id) { tooltip = def.Name + "\r\n"; break; } } // 11/13/2010 tooltip += date.ToShortDateString() + "\r\n"; // 508 watts tooltip += curve[iPt].Y.ToString("0", CultureInfo.CurrentCulture); switch (GlobalSettings.Instance.ReportChart) { case Common.TrackType.Cadence: tooltip += " " + CommonResources.Text.LabelRPM; break; case Common.TrackType.HR: tooltip += " " + CommonResources.Text.LabelBPM; break; case Common.TrackType.Power: tooltip += " " + CommonResources.Text.LabelWatts; break; case Common.TrackType.Grade: tooltip += " %"; break; } return(tooltip); }
public void AddCurve(PlanetId id, OrbitInfoType kind) { if (!IsCurveAdded(id, kind)) { OrbitSpec spec = this[id, kind]; CurveItem curve = null; if (kind == OrbitInfoType.Longitude || (kind >= OrbitInfoType.Ascending && kind <= OrbitInfoType.Apogee)) { curve = Frame.CurveOf(spec); } else if (kind.ToString().EndsWith("Latitude")) { curve = spec.OriginalCurve; curve.IsY2Axis = true; thePane.Y2Axis.IsVisible = true; Double max = Math.Max(Math.Abs(spec.MaxY), Math.Abs(spec.MinY)); if (max > thePane.Y2Axis.Scale.Max) { SetY2Scale(max); } } else { thePane.Y2AxisList[1].IsVisible = true; curve = spec.OriginalCurve; curve.IsY2Axis = true; curve.YAxisIndex = 1; Double max = Math.Max(Math.Abs(spec.MaxY), Math.Abs(spec.MinY)); if (max > thePane.Y2AxisList[1].Scale.Max) { SetY3Scale(max); } } AddCurve(curve); } }
void initGC() { GC.IsEnableHPan = true; GC.IsEnableVPan = true; GC.IsEnableVZoom = false; GC.GraphPane.XAxis.IsVisible = true; GC.GraphPane.X2Axis.IsVisible = false; GC.GraphPane.Y2Axis.IsVisible = true; SetXAxis(GC.GraphPane.XAxis); SetYAxis(GC.GraphPane.YAxis); SetYAxis(GC.GraphPane.Y2Axis); GC.GraphPane.YAxis.Title.Text = "温度"; GC.GraphPane.Y2Axis.Title.Text = "湿度"; var yA = GC.GraphPane.YAxis; yA.Scale.Max = 50; yA.Scale.Min = 0; yA.Type = ZedGraph.AxisType.Linear; CurveItem c = GC.GraphPane.AddCurve("T1", LTopTemp, Color.Blue, SymbolType.None); c = GC.GraphPane.AddCurve("T2", LBMTTemp, Color.YellowGreen, SymbolType.None); c = GC.GraphPane.AddCurve("H1", LTopHR, Color.MediumVioletRed, SymbolType.None); c.IsY2Axis = true; c = GC.GraphPane.AddCurve("H2", LBMTHR, Color.BlueViolet, SymbolType.None); c.IsY2Axis = true; GC.GraphPane.Title.IsVisible = false; GC.GraphPane.Legend.IsVisible = true; GC.GraphPane.Legend.FontSpec.Size = 8; GC.AxisChange(); GC.Refresh(); }
// // // // // **** Update Curve Definition **** // private void UpdateCurveDefinition(ZedGraphControl zg1, CurveDefinition zNewCurve) { CurveItem curve = zg1.GraphPane.CurveList[zNewCurve.CurveName]; if (curve == null) { // curve name does not yet exist. User wants us to create a new one. if (zNewCurve.Type == CurveDefinition.CurveType.Curve) { curve = zg1.GraphPane.AddCurve(zNewCurve.CurveName, new PointPairList(), zNewCurve.CurveColor, zNewCurve.Symbol); } //else if (zNewCurve.Type == CurveDefinition.CurveType.Bar) // curve = zg1.GraphPane.AddBar(zNewCurve.CurveName, new PointPairList(), zNewCurve.CurveColor, zNewCurve.Symbol); else { return; // failed to create new curve } } // Update properties of found curve. if (zNewCurve.Type == CurveDefinition.CurveType.Curve) { LineItem li = (LineItem)curve; li.Line.Style = zNewCurve.DashStyle; li.Line.Width = zNewCurve.CurveWidth; li.Symbol.Type = zNewCurve.Symbol; li.Symbol.Fill = new Fill(zNewCurve.SymbolFillColor); li.Symbol.Size = zNewCurve.SymbolSize; li.Line.IsVisible = zNewCurve.IsLineVisible; curve.Color = zNewCurve.CurveColor; if (!String.IsNullOrEmpty(zNewCurve.GraphName)) { zg1.Name = zNewCurve.GraphName; } } else if (zNewCurve.Type == CurveDefinition.CurveType.Bar) { // TODO: implement bars if (!String.IsNullOrEmpty(zNewCurve.GraphName)) { zg1.Name = zNewCurve.GraphName; } } }//UpdateCurveDefintion()
public static void Trend(CurveItem ci, int SizeWindow) { var input_dots = GraphConverter.GetPointPairListFromCurve(ci); for (var i = 1; i < SizeWindow; i += 2) { var average = Analyser.GetAverageOnRange(input_dots, 0, i); ci.Points[i / 2].Y = average; } for (var i = 0; i < ci.Points.Count - SizeWindow; i++) { var average = Analyser.GetAverageOnRange(input_dots, i, i + SizeWindow); ci.Points[i + SizeWindow / 2].Y = average; } for (var i = SizeWindow; i >= 1; i -= 2) { var average = Analyser.GetAverageOnRange(input_dots, input_dots.Count - i - 1, input_dots.Count - 1); ci.Points[ci.Points.Count - 1 - i / 2].Y = average; } }
private void AddPoint(CurveItem curve, double x, double y) { if (x < _minXValue) { _minXValue = x; } if (x > _maxXValue) { _maxXValue = x; } if (y < _minYValue) { _minYValue = y; } if (y > _maxYValue) { _maxYValue = y; } curve.AddPoint(x, y); }
/// <summary> /// Draw the this <see c_ref="Bar"/> to the specified <see c_ref="Graphics"/> /// device as a bar at each defined point. This method /// is normally only called by the <see c_ref="BarItem.Draw"/> method of the /// <see c_ref="BarItem"/> object /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see c_ref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see c_ref="CurveItem"/> object representing the /// <see c_ref="Bar"/>'s to be drawn.</param> /// <param name="baseAxis">The <see c_ref="Axis"/> class instance that defines the base (independent) /// axis for the <see c_ref="Bar"/></param> /// <param name="valueAxis">The <see c_ref="Axis"/> class instance that defines the value (dependent) /// axis for the <see c_ref="Bar"/></param> /// <param name="barWidth"> /// The width of each bar, in pixels. /// </param> /// <param name="pos"> /// The ordinal position of the this bar series (0=first bar, 1=second bar, etc.) /// in the cluster of bars. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see c_ref="GraphPane"/> object using the /// <see c_ref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void DrawBars(Graphics g, GraphPane pane, CurveItem curve, Axis baseAxis, Axis valueAxis, float barWidth, int pos, float scaleFactor) { // For non-cluster bar types, the position is always zero since the bars are on top // of eachother BarType barType = pane._barSettings.Type; if (barType == BarType.Overlay || barType == BarType.Stack || barType == BarType.PercentStack || barType == BarType.SortedOverlay) { pos = 0; } // Loop over each defined point and draw the corresponding bar for (int i = 0; i < curve.Points.Count; i++) { DrawSingleBar(g, pane, curve, i, pos, baseAxis, valueAxis, barWidth, scaleFactor); } }
/// <summary> /// 鼠标移动到点上时要表示的值 /// </summary> /// <param name="sender"></param> /// <param name="pane"></param> /// <param name="curve"></param> /// <param name="iPt"></param> /// <returns></returns> private string Point_SetFormatEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, int iPt) { string strValue = string.Empty; if (m_cureMap.Count <= 0) { return(strValue); } LineItem curveItem = (LineItem)curve; double range = m_cureMap[curveItem].to - m_cureMap[curveItem].from; double xVlaue = curve.Points[iPt].X; double yVlaue = curve.Points[iPt].Y; yVlaue *= 1000; strValue = Comm.ConvertIntDateTime(yVlaue).ToString() + "," + (xVlaue * range / 100 + m_cureMap[curveItem].from).ToString(); return(strValue); }
private void button4_Click(object sender, EventArgs e) { string str = Application.StartupPath; str = str + @"\配置文件\"; //str = str + "1.txt"; str = str + "chartform" + ".txt"; System.IO.StreamWriter streamwriter = new StreamWriter(str); int curvecount = z1.GraphPane.CurveList.Count; for (int m = 0; m < curvecount; m++) { CurveItem mycurve = z1.GraphPane.CurveList[m]; str = mycurve.Label.Text; streamwriter.WriteLine(str); } streamwriter.Flush(); streamwriter.Close(); }
private string zGC_PointValueEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, int iPt) { PointPair point = curve[iPt]; //double[] res = new double[results.ElementAt(0).ConvertPortfolio().Length]; Portfolio p = sp; foreach (var t in results) { if (t.Profit == point.Y && t.Risk == point.X) { p = t; } } DoTable(p); string result = string.Format("Риск: {0:F2}%\nДоходность: {1:F2}%", point.X, point.Y); return(result); }
string zg_PointValueEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, int iPt) { if (_configuring) { return(""); } else { string time = ""; if (!_enableOffset) { time = (new XDate(curve[iPt].X)).DateTime.ToShortTimeString(); } string val = string.Format("{0:0.##} " + _unit.ToString(), curve[iPt].Y); int index = _curves.IndexOf(curve); string name = GetSelectionLabel(_statistics[index]); return(name + " " + time + " " + val); } }
public static void RemoveSpikes(CurveItem ci, double s) { for (var i = 0; i < ci.Points.Count; i++) { if (!(Math.Abs(ci.Points[i].Y) > 2 * s)) { continue; } var max = i; for (var j = i + 1; j < ci.Points.Count; j++) { if (Math.Abs(ci.Points[j].Y) < 2 * s) { break; } max = j; } if (i == 0 || max == ci.Points.Count - 1) { for (var j = i; j <= max; j++) { ci.RemovePoint(j); j--; max--; } } else { var average = (ci.Points[i - 1].Y + ci.Points[max + 1].Y) / 2; for (var j = i; j <= max; j++) { ci.Points[j].Y = average; } i += max - i; } } }
/// <summary> /// Draw the specified single bar (an individual "point") of this series to the specified /// <see c_ref="Graphics"/> device. This method is not as efficient as /// <see c_ref="DrawBars"/>, which draws the bars for all points. It is intended to be used /// only for <see c_ref="BarType.SortedOverlay"/>, which requires special handling of each bar. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see c_ref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see c_ref="CurveItem"/> object representing the /// <see c_ref="Bar"/>'s to be drawn.</param> /// <param name="baseAxis">The <see c_ref="Axis"/> class instance that defines the base (independent) /// axis for the <see c_ref="Bar"/></param> /// <param name="valueAxis">The <see c_ref="Axis"/> class instance that defines the value (dependent) /// axis for the <see c_ref="Bar"/></param> /// <param name="pos"> /// The ordinal position of the this bar series (0=first bar, 1=second bar, etc.) /// in the cluster of bars. /// </param> /// <param name="index"> /// The zero-based index number for the single bar to be drawn. /// </param> /// <param name="barWidth"> /// The width of each bar, in pixels. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see c_ref="GraphPane"/> object using the /// <see c_ref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void DrawSingleBar(Graphics g, GraphPane pane, CurveItem curve, Axis baseAxis, Axis valueAxis, int pos, int index, float barWidth, float scaleFactor) { // Make sure that a bar value exists for the current curve and current ordinal position if (index >= curve.Points.Count) { return; } // For Overlay and Stack bars, the position is always zero since the bars are on top // of eachother if (pane._barSettings.Type == BarType.Overlay || pane._barSettings.Type == BarType.Stack || pane._barSettings.Type == BarType.PercentStack) { pos = 0; } // Draw the specified bar DrawSingleBar(g, pane, curve, index, pos, baseAxis, valueAxis, barWidth, scaleFactor); }
static bool[] DimensionContainsNonZeroData(CurveItem curve) { bool[] ret = new bool[3]; for (int i = 0; i < curve.NPts; i++) { PointPair pp = curve.Points[i]; if (pp.X != 0) { ret[0] = true; } if (pp.Y != 0) { ret[1] = true; } if (pp.Z != 0) { ret[2] = true; } } return(ret); }
void showlinearRegression(double[,] newArray2D) { GraphPane myPane = zgc.GraphPane; double[] y = new double[2]; double[] x = new double[2]; x[0] = -System.Math.Abs(2 * calculator.MinAge); x[1] = System.Math.Abs(2 * calculator.MaxAge); for (int i = 0; i < y.Length; i++) { y[i] = calculator.linearRegression(x[i]); } CurveItem reggresionLine = myPane.AddCurve("prosta regresji", x, y, Color.Blue, SymbolType.Circle); Console.WriteLine("done"); zgc.Refresh(); }
private static CurveItem makeMSGraphItem(IMSGraphItemInfo item) { CurveItem newCurve = item.GraphItemDrawMethod == MSGraphItemDrawMethod.line ? new LineItem(item.Title, new MSPointList(item.Points), item.Color, SymbolType.None) : new StickItem(item.Title, new MSPointList(item.Points), item.Color); if (item.GraphItemDrawMethod == MSGraphItemDrawMethod.line) { ((LineItem)newCurve).Line.IsAntiAlias = true; } IMSGraphItemExtended extended = item as IMSGraphItemExtended; if (extended != null) { extended.CustomizeCurve(newCurve); } newCurve.Tag = item; return(newCurve); }
public bool RemoveCurveOf(String label) { CurveItem toBeDropped = null; foreach (CurveItem curve in thePane.CurveList) { if (curve.Label.Text != label) { continue; } toBeDropped = curve; break; } if (toBeDropped == null) { return(false); } else { thePane.CurveList.Remove(toBeDropped); if (toBeDropped.IsY2Axis) { int index = toBeDropped.GetYAxisIndex(thePane); if (index == 0) { SetY2Scale(); } else if (index == 1) { SetY3Scale(); } } Zed.Invalidate(); return(true); } }
private string PointValueEventIndicator(CurveItem curve, int pointIdx) { DateTime dt = DateTime.FromOADate(curve[pointIdx].X); string retVal = ""; switch (this.ChartTimeScale.Type) { case AppTypes.TimeScaleTypes.RealTime: case AppTypes.TimeScaleTypes.Minnute: case AppTypes.TimeScaleTypes.Hour: retVal = Languages.Libs.GetString("time") + " : " + dt.ToString(); break; case AppTypes.TimeScaleTypes.Day: retVal = Languages.Libs.GetString("date") + " : " + dt.ToShortDateString(); break; case AppTypes.TimeScaleTypes.Week: retVal = Languages.Libs.GetString("week") + " : " + common.dateTimeLibs.WeekOfYear(dt).ToString() + "/" + dt.Year.ToString(); break; case AppTypes.TimeScaleTypes.Month: retVal = Languages.Libs.GetString("month") + " : " + dt.Month.ToString() + "/" + dt.Year.ToString(); break; case AppTypes.TimeScaleTypes.Year: retVal = Languages.Libs.GetString("year") + " : " + dt.Year.ToString(); break; } retVal += common.Consts.constCRLF + curve.Label.Text + " : " + curve[pointIdx].Y.ToString(Settings.sysMaskGeneralValue); return(retVal); }
private bool zedGraphControl_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e) { // Save the mouse location PointF mousePt = new PointF(e.X, e.Y); // Find the Chart rect that contains the current mouse location GraphPane pane = ((ZedGraphControl)sender).MasterPane.FindChartRect(mousePt); if (pane != null) { // Determine if the clicked point exists object nearestCurve; int iNearest; bool isSelected = zedGraphControl.GraphPane.FindNearestObject(mousePt, zedGraphControl.CreateGraphics(), out nearestCurve, out iNearest); if (isSelected) { TargetcurveItem = (CurveItem)nearestCurve; TarfgetIndex = iNearest; } } return(true); }
public void HighlightIndex(int index, int curveIndex, Color color) { if (curveIndex >= mCurveList.Count) { return; } CurveItem curve = mCurveList[curveIndex]; int selectedIndex = index / decimation; if (selectedIndex >= curve.Points.Count) { return; } PointPair p = curve.Points[selectedIndex]; LineItem li = new LineItem("", new double[] { p.X }, new double[] { p.Y }, color, SymbolType.UserDefined, 1); li.Symbol = GraphSymbol.GetSymbol("Highlight", color); highlightList.Clear(); highlightList.Add(li); DisplayCurves(); }
public CurveItem AddGraphItem(MSGraphPane pane, IMSGraphItemInfo item, bool setScale) { if (item.GraphItemType != pane.CurrentItemType) { pane.CurveList.Clear(); pane.CurrentItemType = item.GraphItemType; pane.ZoomStack.PopAll(pane); item.CustomizeXAxis(pane.XAxis); item.CustomizeYAxis(pane.YAxis); } CurveItem newItem = makeMSGraphItem(item); pane.CurveList.Add(newItem); // If you are adding multiple graph items, it is quickest to set the scale // once at the end. if (setScale) { pane.SetScale(CreateGraphics()); } return(newItem); }
private void zedGraphControl_MouseClick(object sender, MouseEventArgs e) { if (isStartDraw) { GraphPane myPane = zedGraphControl.GraphPane; // Save the mouse location PointF mousePt = new PointF(e.X, e.Y); // Find the Chart rect that contains the current mouse location GraphPane pane = ((ZedGraphControl)sender).MasterPane.FindChartRect(mousePt); // If pane is non-null, we have a valid location. Otherwise, the mouse is not // within any chart rect. if (pane != null) { double x, y; // Convert the mouse location to X, and Y scale values pane.ReverseTransform(mousePt, out x, out y); // Determine if the clicked point exists object nearestCurve; int iNearest; bool isSelected = zedGraphControl.GraphPane.FindNearestObject(mousePt, zedGraphControl.CreateGraphics(), out nearestCurve, out iNearest); if (isSelected && iNearest == 0) { CurveItem curveItem = (CurveItem)nearestCurve; x = curveItem.Points[iNearest].X; y = curveItem.Points[iNearest].Y; } LineItem myCurve = (LineItem)pane.CurveList[pane.CurveList.Count - 1]; IPointListEdit newlist = myCurve.Points as IPointListEdit; newlist.Add(x, y); zedGraphControl.AxisChange(); zedGraphControl.Refresh(); } } }
private void removeCurve(ZedGraphControl zed, CurveItem curve) { zed.GraphPane.CurveList.Remove(curve); List <TextObj> toBeRemoved = new List <TextObj>(); foreach (GraphObj obj in zed.GraphPane.GraphObjList) { if (obj is TextObj) { TextObj text = obj as TextObj; if (text.Text[0] == curve.Label.Text[0]) { toBeRemoved.Add(obj as TextObj); } } } foreach (TextObj text in toBeRemoved) { zed.GraphPane.GraphObjList.Remove(text); } }
/// <summary> /// Copy the properties of this <see cref="ZedGraphWebCurveItem"/> to the specified /// <see cref="CurveItem"/> object. /// </summary> /// <param name="item">The destination <see cref="CurveItem"/> object</param> internal void CopyTo( CurveItem item ) { item.Label.Text = this.Label; item.Color = this.Color; item.Label.IsVisible = this.IsLegendLabelVisible; item.IsY2Axis = this.IsY2Axis; item.IsVisible = this.IsVisible; }