/// <summary> /// Add chart series to pane. /// </summary> /// <param name="series"></param> public virtual void Add(ChartSeries series) { this.Add(series, false, false); }
/// <summary> /// Add chart series to pane. /// </summary> public virtual void Add(ChartSeries series, bool usePaneColorSelector, bool replaceSeriesWithSameName) { if (replaceSeriesWithSameName) { this.RemoveByName(series.Name); } if (_series.Contains(series)) {// Already present. return; } if (usePaneColorSelector) { _colorSelector.SetupSeries(series); } //if (series.ChartType == ChartSeries.ChartTypeEnum.ColoredArea) //{// Colored areas better be inserted first, in rendering they will not overlap other drawings. // _series.Insert(0, series); //} //else //{ _series.Add(series); //} series.SeriesUpdatedEvent += new ChartSeries.SeriesUpdatedDelegate(series_SeriesUpdatedEvent); series.AddedToChart(this.StateId); UpdateDrawingSpace(); this.Invalidate(); }
protected virtual void series_SeriesUpdatedEvent(ChartSeries series, bool updateUI) { //TracerHelper.TraceEntry(); WinFormsHelper.BeginFilteredManagedInvoke(this, TimeSpan.FromMilliseconds(100), UpdateDrawingSpace); if (updateUI) { WinFormsHelper.BeginFilteredManagedInvoke(this, TimeSpan.FromMilliseconds(100), Invalidate); } }
/// <summary> /// Helper function allowing to setup a menu with context items related to properties of this series. /// Pass EITHER a menu to get filled with the items OR an item to get filled with subItems. No need to pass both. /// </summary> /// <param name="series"></param> /// <param name="menu"></param> void SetupMenuToSeriesProperties(ChartSeries series, ToolStrip menu, ToolStripMenuItem menuItem) { SystemMonitor.CheckError(menu == null || menuItem == null, "Pass only a menu or a menuItem."); string[] seriesTypeNames = series.ChartTypes; if (menu != null) { menu.Items.Clear(); menu.Tag = series; } if (menuItem != null) { menuItem.DropDownItems.Clear(); menuItem.Tag = series; } for (int j = 0; j < seriesTypeNames.Length; j++) { ToolStripMenuItem item = new ToolStripMenuItem(seriesTypeNames[j]); if (menu != null) { menu.Items.Add(item); } if (menuItem != null) { menuItem.DropDownItems.Add(item); } item.Click += new EventHandler(MenuSeriesItem_Click); item.Checked = series.SelectedChartType == seriesTypeNames[j]; if (item.Checked) {// Mark the currently selected item item.Image = (Image)(_resources.GetObject("imageDot")); } item.Tag = seriesTypeNames[j]; } ToolStripItem propertiesMenuItem = null; if (menu != null) { menu.Items.Add(new ToolStripSeparator()); propertiesMenuItem = menu.Items.Add("Properties"); } if (menuItem != null) { menuItem.DropDownItems.Add(new ToolStripSeparator()); propertiesMenuItem = menuItem.DropDownItems.Add("Properties"); } if (propertiesMenuItem != null) { propertiesMenuItem.Click += new EventHandler(seriesPropertiesMenuItem_Click); propertiesMenuItem.Tag = series; } }
public virtual bool Remove(ChartSeries series) { if (_series.Remove(series)) { series.SeriesUpdatedEvent -= new ChartSeries.SeriesUpdatedDelegate(series_SeriesUpdatedEvent); series.RemovedFromChart(); UpdateDrawingSpace(); this.Invalidate(); return true; } return false; }
/// <summary> /// Does NOT consider series visibility. /// </summary> protected void GetSingleSeriesMinMax(ChartSeries series, int? startIndex, int? endIndex, ref float min, ref float max) { if (series.Visible) { series.GetTotalMinimumAndMaximum(startIndex, endIndex, ref min, ref max); } if (min < float.MaxValue && float.IsNaN(min) == false && max > float.MinValue && float.IsNaN(max) == false) { // Provide a 5% advance on min and max. float differencePart = Math.Abs(max - min) / 20f; max += differencePart; min -= differencePart; } }
protected override void series_SeriesUpdatedEvent(ChartSeries series, bool updateUI) { if (updateUI) { SynchronizeWithMasterPane(); } base.series_SeriesUpdatedEvent(series, updateUI); }
public override void Add(ChartSeries series, bool usePaneColorSelector, bool replaceSeriesWithSameName) { base.Add(series, usePaneColorSelector, replaceSeriesWithSameName); SynchronizeWithMasterPane(); }
public void SetupSeries(ChartSeries inputSeries) { if (inputSeries is TradeChartSeries) { TradeChartSeries series = (TradeChartSeries)inputSeries; switch (_seriesIndex) { case 0: { series.RisingBarPen = Pens.DarkSeaGreen; series.RisingBarFill = null; series.FallingBarPen = Pens.IndianRed; series.FallingBarFill = (SolidBrush)Brushes.IndianRed; } break; case 1: { series.RisingBarPen = Pens.LightBlue; series.RisingBarFill = null; series.FallingBarPen = Pens.LightBlue; series.FallingBarFill = (SolidBrush)Brushes.LightBlue; } break; case 2: { series.RisingBarPen = Pens.LightSlateGray; series.RisingBarFill = null; series.FallingBarPen = Pens.LightSlateGray; series.FallingBarFill = (SolidBrush)Brushes.LightSlateGray; } break; case 3: { series.RisingBarPen = Pens.Lavender; series.RisingBarFill = null; series.FallingBarPen = Pens.Lavender; series.FallingBarFill = (SolidBrush)Brushes.Lavender; } break; case 4: { series.RisingBarPen = Pens.OrangeRed; series.RisingBarFill = null; series.FallingBarPen = Pens.OrangeRed; series.FallingBarFill = (SolidBrush)Brushes.OrangeRed; } break; case 5: { series.RisingBarPen = Pens.Gold; series.RisingBarFill = null; series.FallingBarPen = Pens.Gold; series.FallingBarFill = (SolidBrush)Brushes.Gold; } break; case 6: { series.RisingBarPen = Pens.GreenYellow; series.RisingBarFill = null; series.FallingBarPen = Pens.GreenYellow; series.FallingBarFill = (SolidBrush)Brushes.GreenYellow; } break; case 7: { series.RisingBarPen = Pens.BlueViolet; series.RisingBarFill = null; series.FallingBarPen = Pens.BlueViolet; series.FallingBarFill = (SolidBrush)Brushes.BlueViolet; } break; } } _seriesIndex++; }