public void SetAreaAxisX <TInvoker>(int index, Axis value, TInvoker Invoker = null) where TInvoker : Control { if (Invoker != null) { //lock (Locker[ChartMain]) Abbreviate.FormsControls.Invoke(Invoker, () => SetAreaAxisX <TInvoker>(index, value, null)); UpdateTime.SetNow(); return; } ChartMain.ChartAreas[index].AxisX = value; }
public void SetSeries <TInvoker>(string name, Series value, TInvoker Invoker = null) where TInvoker : Control { if (Invoker != null) { //lock (Locker[ChartMain]) Abbreviate.FormsControls.Invoke(Invoker, () => SetSeries <TInvoker>(name, value, null)); UpdateTime.SetNow(); return; } ChartMain.Series[name] = value; }
/// <summary> /// adds new data point to series specified by name /// </summary> /// <typeparam name="TInvoker"></typeparam> /// <param name="name"></param> /// <param name="point"></param> /// <param name="Invoker"></param> public void Add <TInvoker>(string name, DataPoint point, TInvoker Invoker = null) where TInvoker : Control { if (Invoker != null) { //lock (Locker[ChartMain]) Abbreviate.FormsControls.Invoke(Invoker, () => Add <TInvoker>(name, point, null)); UpdateTime.SetNow(); return; } ChartMain.Series[name].Points.Add(point); }
/// <summary> /// Clears all series /// </summary> /// <param name="invoked"></param> public void ClearSeries <TInvoker>(TInvoker Invoker = null) where TInvoker : Control { if (Invoker != null) { //lock (Locker[ChartMain]) Abbreviate.FormsControls.Invoke(Invoker, () => ClearSeries <TInvoker>(null)); UpdateTime.SetNow(); return; } ChartMain.Series.Clear(); Reset(); }
/// <summary> /// Clears all series /// </summary> /// <param name="invoked"></param> public void ClearSeries() { if (!this.IsHandleCreated) { return; } Invoker.Invoke((MethodInvoker)(() => { ChartMain.Series.Clear(); Reset(); })); UpdateTime.SetNow(); }
/// <summary> /// Adds new series /// </summary> /// <typeparam name="TInvoker"></typeparam> /// <param name="name"></param> /// <param name="type"></param> /// <param name="Invoker"></param> public void Add(string name, SeriesChartType type) { Series series = new Series(); series.Name = name; series.ChartType = type; Invoker.Invoke((MethodInvoker)(() => { ChartMain.Series.Add(series); })); UpdateTime.SetNow(); }
/// <summary> /// Clears all points and keeps series attributes /// </summary> public void ClearPoints() { if (!this.IsHandleCreated) { return; } Invoker.Invoke((MethodInvoker)(() => { foreach (Series series in ChartMain.Series) { series.Points.Clear(); } Reset(); })); UpdateTime.SetNow(); }
public void SetAreaAxisLabelStyle <TInvoker>( TInvoker Invoker, int index, AreaAxis aaxis, string Format = null ) where TInvoker : Control { if (Invoker != null) { //lock (Locker[ChartMain]) Abbreviate.FormsControls.Invoke(Invoker, () => SetAreaAxisLabelStyle <TInvoker>(null, index, aaxis, Format)); UpdateTime.SetNow(); return; } Axis axis = null; if (aaxis == AreaAxis.X) { axis = ChartMain.ChartAreas[index].AxisX; } else if (aaxis == AreaAxis.Y) { axis = ChartMain.ChartAreas[index].AxisY; } else if (aaxis == AreaAxis.X2) { axis = ChartMain.ChartAreas[index].AxisX2; } else if (aaxis == AreaAxis.Y2) { axis = ChartMain.ChartAreas[index].AxisY2; } if (Format != null) { axis.LabelStyle.Format = Format; } }
/// <summary> /// Adds new series /// </summary> /// <typeparam name="TInvoker"></typeparam> /// <param name="name"></param> /// <param name="type"></param> /// <param name="Invoker"></param> public void Add <TInvoker>(string name, SeriesChartType type, TInvoker Invoker = null) where TInvoker : Control { if (Invoker != null) { //lock (Locker[ChartMain]) Abbreviate.FormsControls.Invoke(Invoker, () => Add <TInvoker>(name, type, null)); UpdateTime.SetNow(); return; } Series series = new Series(); series.Name = name; series.ChartType = type; //series.IsVisibleInLegend = false; // ChartMain.Series.Add(series); }
public void SetCandlestickSettings <TInvoker>( TInvoker Invoker, string series, Color PriceUpColor, Color PriceDownColor, Color SticksColor, Color BorderColor ) where TInvoker : Control { if (Invoker != null) { //lock (Locker[ChartMain]) Abbreviate.FormsControls.Invoke(Invoker, () => SetCandlestickSettings <TInvoker>(null, series, PriceUpColor, PriceDownColor, SticksColor, BorderColor)); UpdateTime.SetNow(); return; } ChartMain.Series[series]["PriceUpColor"] = PriceUpColor.ToArgb().ToString(); ChartMain.Series[series]["PriceDownColor"] = PriceDownColor.ToArgb().ToString(); ChartMain.Series[series].Color = SticksColor; ChartMain.Series[series].BorderColor = BorderColor; }
public void UpdateRange <TInvoker>(TInvoker Invoker, string name, DataPoint[] points, ChartValueType?XValueType = null, ChartValueType?YValueType = null) where TInvoker : Control { if (points.Length <= 0) { return; } if (Invoker != null) { //lock (Locker[ChartMain]) Abbreviate.FormsControls.Invoke(Invoker, () => UpdateRange <TInvoker>(null, name, points, XValueType, YValueType)); UpdateTime.SetNow(); return; } double xMin = ScaleX.ViewMinimum; double xMax = ScaleX.ViewMaximum; bool found = false; foreach (DataPoint point in points) { found = false; for (int i = ChartMain.Series[name].Points.Count - 1; i >= 0; i--) { if (ChartMain.Series[name].Points[i].XValue == point.XValue) { ChartMain.Series[name].Points[i] = point; found = true; break; } } //else if (ChartMain.Series[name].Points[i].XValue < point.XValue) break; if (!found) { ChartMain.Series[name].Points.Add(point); } if (MinX == null || MinX.XValue > point.XValue) { MinX = point; } if (MaxX == null || MaxX.XValue < point.XValue) { MaxX = point; } } if (XValueType != null) { ChartMain.Series[name].XValueType = (ChartValueType)XValueType; } if (YValueType != null) { ChartMain.Series[name].YValueType = (ChartValueType)YValueType; } Area.AxisX.IsStartedFromZero = false; Area.AxisY.IsStartedFromZero = false; Area.RecalculateAxesScale(); Area.RecalculateAxesScale(); DataPoint last = ChartMain.Series[name].Points.Last(); if (!Doubles.IsNaN(xMax, xMin) && last.XValue > xMax) { double change = (xMax - last.XValue); ScaleX.Zoom(xMin + change, last.XValue); } this.RescaleY(); }