public void SetLegenedPosition(LegendPosition position) { foreach (ToolStripMenuItem menuItem in legendPossitionToolStripMenuItem.DropDownItems) { menuItem.Checked = (LegendPosition)menuItem.Tag == position; } switch (position) { case LegendPosition.LeftMiddle: chart.LegendPosition = LegendPosition.LeftMiddle; break; case LegendPosition.RightMiddle: chart.LegendPosition = LegendPosition.RightMiddle; break; case LegendPosition.TopCenter: chart.LegendPosition = LegendPosition.TopCenter; break; case LegendPosition.BottomCenter: chart.LegendPosition = LegendPosition.BottomCenter; break; } legendToolStripMenuItem.Visible = true; lastPossition = chart.LegendPosition; }
/// <summary> /// Plots the holdout metric. /// </summary> /// <param name="experiments">Experiments.</param> /// <param name="metricName">Metric name.</param> /// <param name="selector">Selector.</param> /// <param name="errorSelector">Error selector.</param> /// <param name="yLim">Y lim.</param> /// <param name="legendPosition">Legend position.</param> /// <param name="showPlots">If set to <c>true</c> show plots.</param> public static void PlotHoldoutMetric( IList <Experiment> experiments, string title, string metricName, Func <HoldoutMetricsCollection, IList <double> > selector, Func <HoldoutMetricsCollection, IList <double> > errorSelector, Tuple <double, double> yLim = null, LegendPosition legendPosition = LegendPosition.Best, bool showPlots = true) { // Plot cumulative log prob var plotter = new Plotter { Title = "Hold-out " + metricName, XLabel = "# instances", YLabel = metricName, Series = experiments.Select( ia => new ErrorLineSeries { X = selector(ia.HoldoutMetrics), ErrorValues = errorSelector(ia.HoldoutMetrics), Label = ia.Name }).ToArray(), YLim = yLim, LegendPosition = legendPosition, ScriptName = title.ToLower().Replace(" ", "-") + "-holdout-" + metricName.ToLower(), // + DateTime.UtcNow.ToString("s"), Show = showPlots }; plotter.Plot(); }
/// <summary> /// Export the graph to the specified 'bitmap' /// </summary> /// <param name="bitmap">Bitmap to write to</param> /// <param name="legendOutside">Put legend outside of graph?</param> public void Export(Bitmap bitmap, bool legendOutside) { this.plot1.Dock = DockStyle.None; this.plot1.Width = bitmap.Width; this.plot1.Height = bitmap.Height; LegendPosition savedLegendPosition = LegendPosition.RightTop; if (legendOutside) { savedLegendPosition = this.plot1.Model.LegendPosition; this.plot1.Model.LegendPlacement = LegendPlacement.Outside; this.plot1.Model.LegendPosition = LegendPosition.RightTop; } this.plot1.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height)); if (legendOutside) { this.plot1.Model.LegendPlacement = LegendPlacement.Inside; this.plot1.Model.LegendPosition = savedLegendPosition; } this.plot1.Dock = DockStyle.Fill; }
/// <summary> /// Plots the cumulative metric. /// </summary> /// <param name="experiments">Experiments.</param> /// <param name="metricName">Metric name.</param> /// <param name="selector">Selector.</param> /// <param name="errorSelector">Error selector.</param> /// <param name="skip">Number to skip at start.</param> /// <param name="yLim">Y limits.</param> /// <param name="legendPosition">Legend position.</param> /// <param name="showPlots">If set to <c>true</c> show plots.</param> public static void PlotCumulativeMetric( IList <Experiment> experiments, string title, string metricName, Func <MetricsCollection, IList <double> > selector, Func <MetricsCollection, IList <double> > errorSelector, int skip, Tuple <double, double> yLim = null, LegendPosition legendPosition = LegendPosition.Best, bool showPlots = true) { // Plot cumulative log prob var plotter = new Plotter { Title = "Cumulative " + metricName, XLabel = "# instances", YLabel = metricName, Series = experiments.Select( ia => new ErrorLineSeries { X = Enumerable.Range(0, ia.Metrics.MinimumLength).Select(x => x + 1.0).Skip(skip), Y = selector(ia.Metrics).Skip(skip), ErrorValues = errorSelector(ia.Metrics).Skip(skip), Label = ia.Name }).ToArray(), YLim = yLim, LegendPosition = legendPosition, ScriptName = title.ToLower().Replace(" ", "-") + "-cumulative-" + metricName.ToLower(), // + DateTime.UtcNow.ToString("s"), Show = showPlots }; plotter.Plot(); }
public static void SetLegendPosition(this PlotModel plot, LegendPosition position) { foreach (LegendBase legend in plot.Legends) { legend.LegendPosition = position; } }
/// <summary> /// Export the graph to the specified 'bitmap' /// </summary> /// <param name="bitmap">Bitmap to write to</param> /// <param name="legendOutside">Put legend outside of graph?</param> public void Export(Bitmap bitmap, bool legendOutside) { //TODO: This will only save the last bitmap. Might need to change the interface. foreach (PlotView plot in plots) { DockStyle saveStyle = plot.Dock; plot.Dock = DockStyle.None; plot.Width = bitmap.Width; plot.Height = bitmap.Height; LegendPosition savedLegendPosition = LegendPosition.RightTop; if (legendOutside) { savedLegendPosition = plot.Model.LegendPosition; plot.Model.LegendPlacement = LegendPlacement.Outside; plot.Model.LegendPosition = LegendPosition.RightTop; } plot.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height)); if (legendOutside) { plot.Model.LegendPlacement = LegendPlacement.Inside; plot.Model.LegendPosition = savedLegendPosition; } plot.Dock = saveStyle; } }
/// <summary> /// Export the graph to the specified 'bitmap' /// </summary> /// <param name="bitmap">Bitmap to write to</param> /// <param name="legendOutside">Put legend outside of graph?</param> public void Export(ref Bitmap bitmap, Rectangle r, bool legendOutside) { //TODO: This will only save the last bitmap. Might need to change the interface. foreach (PlotView plot in plots) { ///DockStyle saveStyle = plot.Dock; ///plot.Dock = DockStyle.None; ///plot.Width = bitmap.Width; ///plot.Height = bitmap.Height; LegendPosition savedLegendPosition = LegendPosition.RightTop; if (legendOutside) { savedLegendPosition = plot.Model.LegendPosition; plot.Model.LegendPlacement = LegendPlacement.Outside; plot.Model.LegendPosition = LegendPosition.RightTop; } System.IO.MemoryStream stream = new System.IO.MemoryStream(); PngExporter pngExporter = new PngExporter(); pngExporter.Width = r.Width; pngExporter.Height = r.Height; pngExporter.Export(plot.Model, stream); bitmap = new Bitmap(stream); if (legendOutside) { plot.Model.LegendPlacement = LegendPlacement.Inside; plot.Model.LegendPosition = savedLegendPosition; } // plot.Dock = saveStyle; } }
public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if (AnnotationPosition != null) { hashCode = hashCode * 59 + AnnotationPosition.GetHashCode(); } if (AnnotationTail != null) { hashCode = hashCode * 59 + AnnotationTail.GetHashCode(); } if (AnnotationText != null) { hashCode = hashCode * 59 + AnnotationText.GetHashCode(); } if (AxisTitleText != null) { hashCode = hashCode * 59 + AxisTitleText.GetHashCode(); } if (ColorbarPosition != null) { hashCode = hashCode * 59 + ColorbarPosition.GetHashCode(); } if (ColorbarTitleText != null) { hashCode = hashCode * 59 + ColorbarTitleText.GetHashCode(); } if (LegendPosition != null) { hashCode = hashCode * 59 + LegendPosition.GetHashCode(); } if (LegendText != null) { hashCode = hashCode * 59 + LegendText.GetHashCode(); } if (ShapePosition != null) { hashCode = hashCode * 59 + ShapePosition.GetHashCode(); } if (TitleText != null) { hashCode = hashCode * 59 + TitleText.GetHashCode(); } return(hashCode); } }
public XYChart(ChartFormat fmt) : base(fmt) { this.ShowAxisMargin = false; this.ShowXAxisLines = true; this.LegendPosition = LegendPosition.Right; }
public PlotView ChartCreator() { PlotView myPlot = new PlotView(); MyModel = new PlotModel { Title = Title }; for (int i = 0; i < Colors.Count; i++) { var lineSeries = new LineSeries { Color = OxyColor.FromArgb(a: Colors[i].A, r: Colors[i].R, g: Colors[i].G, b: Colors[i].B), MarkerFill = OxyColors.Transparent, DataFieldX = XName, DataFieldY = YName, Background = OxyColor.FromArgb( a: BackgroundColor.A, r: BackgroundColor.R, g: BackgroundColor.G, b: BackgroundColor.B) }; if (ShowLegend) { lineSeries.Title = ValuesNames[i]; } for (int j = 0; j < XValues[i].Count; j++) { lineSeries.Points.Add(new DataPoint(XValues[i][j], YValues[i][j])); } MyModel.Series.Add(lineSeries); } if (ShowLegend) { MyModel.LegendTitle = LegendTitle; LegendPosition legendPosition = (LegendPosition)LegendPositionAsInt; MyModel.LegendPosition = legendPosition; } MyModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = XName }); MyModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = YName }); myPlot.Model = MyModel; myPlot.Dock = System.Windows.Forms.DockStyle.Bottom; myPlot.Location = new Point(0, 0); myPlot.Size = new Size(GraphWidth, GraphHeight); myPlot.TabIndex = 0; return(myPlot); }
protected MSCHART.Docking GetLegendDockingPosition(LegendPosition pos) { if (pos == LegendPosition.Bottom) { return(MSCHART.Docking.Bottom); } else if (pos == LegendPosition.Right) { return(MSCHART.Docking.Right); } else { throw new System.ArgumentException(); } }
/// <summary> /// Constructor /// </summary> /// <param name="fontTemplate"></param> /// <param name="show"></param> /// <param name="lineColor"></param> /// <param name="lineDrawStyle"></param> /// <param name="lineWidth"></param> /// <param name="orientation"></param> /// <param name="orientationAngle"></param> /// <param name="flip"></param> /// <param name="elementPostion"></param> /// <param name="elementAlignment"></param> /// <param name="extent"></param> /// <param name="bgColor"></param> /// <param name="showLabel"></param> public StyleTemplateSetting(FontSetting fontTemplate, bool show, string lineColor, LineDrawStyle lineDrawStyle, int lineWidth, TextOrientation orientation, int orientationAngle, bool flip, LegendPosition elementPostion, StringAlignment elementAlignment, int extent, string bgColor, bool showLabel) { this._FontTemplate = fontTemplate; this._Show = show; this._LineColor = lineColor; this._LineStyle = lineDrawStyle; this._LineWidth = lineWidth; this._Orientation = orientation; this._OrientationAngle = orientationAngle; this._Flip = flip; this._ElementPosition = elementPostion; this._ElementAlignment = elementAlignment; this._Extent = extent; this._BgColor = bgColor; this._ShowLabel = showLabel; }
private void radDropDownListLegendPosition_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e) { LegendPosition position = (LegendPosition)this.radDropDownListLegendPosition.SelectedValue; this.radChartView1.ChartElement.LegendPosition = position; if (position == LegendPosition.Float) { this.radSpinEditorLegendX.Enabled = true; this.radSpinEditorLegendY.Enabled = true; } else { this.radSpinEditorLegendX.Enabled = false; this.radSpinEditorLegendY.Enabled = false; } }
public static PlotModel getPlotModel( String title, TitleHorizontalAlignment titleHorizontalAlignment, String legendTitle, LegendOrientation legendOrientation, LegendPlacement legendPlacement, LegendPosition legendPosition) { return(new PlotModel { Title = title, TitleHorizontalAlignment = titleHorizontalAlignment, LegendTitle = legendTitle, LegendOrientation = legendOrientation, LegendPlacement = legendPlacement, LegendPosition = legendPosition }); }
private ST_LegendPos FromLegendPosition(LegendPosition position) { switch (position) { case LegendPosition.Bottom: return(ST_LegendPos.b); case LegendPosition.Left: return(ST_LegendPos.l); case LegendPosition.Right: return(ST_LegendPos.r); case LegendPosition.Top: return(ST_LegendPos.t); case LegendPosition.TopRight: return(ST_LegendPos.tr); default: throw new ArgumentException(); } }
private ST_LegendPos FromLegendPosition(LegendPosition position) { switch (position) { case LegendPosition.BOTTOM: return(ST_LegendPos.b); case LegendPosition.LEFT: return(ST_LegendPos.l); case LegendPosition.RIGHT: return(ST_LegendPos.r); case LegendPosition.TOP: return(ST_LegendPos.t); case LegendPosition.TOP_RIGHT: return(ST_LegendPos.tr); default: throw new ArgumentException(); } }
public static ICanvasImage CreateLegend(ICanvasResourceCreator resourceCreator, LegendStyle style, List <string> serieLabels, List <Color> colorSpace, LegendPosition legendPosition) { if (serieLabels?.Count > 0 && colorSpace?.Count >= serieLabels.Count) { var commandList = new CanvasCommandList(resourceCreator); using (var drawSession = commandList.CreateDrawingSession()) { var cancasTextArray = serieLabels.Select(o => CreateCanvasText(resourceCreator, o, style.LabelFormat)).ToArray(); var textRectHeight = cancasTextArray.Select(o => o.DrawBounds.Height).Max(); var groupHeight = (float)Math.Max(textRectHeight, style.ColorBlockHeight); var colorBlockYOffset = (float)(textRectHeight - style.ColorBlockHeight) / 2; var startXOffset = 0f; var startYOffset = colorBlockYOffset; for (int i = 0; i < serieLabels.Count; i++) { drawSession.FillRectangle(startXOffset, startYOffset, style.ColorBlockWidth, style.ColorBlockHeight, colorSpace[i]); drawSession.DrawTextLayout(cancasTextArray[i], startXOffset + style.ColorBlockWidth + style.LabelFormat.Thickness.Left, startYOffset - colorBlockYOffset - (float)cancasTextArray[i].DrawBounds.Y, ColorConverter.ConvertHexToColor(style.LabelFormat.Foreground)); if (legendPosition == LegendPosition.Bottom) { startXOffset += style.ColorBlockWidth; startXOffset += style.LabelFormat.Thickness.Left; startXOffset += (float)cancasTextArray[i].LayoutBounds.Width; startXOffset += style.LabelFormat.Thickness.Right; } else if (legendPosition == LegendPosition.Right) { startYOffset += groupHeight; startYOffset += style.LabelFormat.Thickness.Bottom; } cancasTextArray[i].Dispose(); } } return(commandList); } return(null); }
public PlotView ChartCreator() { PlotView myPlot = new PlotView(); MyModel = new PlotModel { Title = Settings.Title }; for (int i = 0; i < Elements.Data.ValuesNames.Count; i++) { if (Elements.Data.DataTypes[i].TypeOfData == 0) { AddLineSeries(MyModel, Elements.Data.DataTypes[i], Elements.Data.ValuesNames[i], Elements.Data.XValues[i], Elements.Data.YValues[i]); } else { AddPointSeries(MyModel, Elements.Data.DataTypes[i], Elements.Data.ValuesNames[i], Elements.Data.XValues[i], Elements.Data.YValues[i]); } } MyModel.LegendTitle = Elements.Legend.Title; LegendPosition legendPosition = (LegendPosition)Elements.Legend.Position; MyModel.LegendPosition = legendPosition; MyModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = Settings.Axis.XAxisName }); MyModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = Settings.Axis.YAxisName }); myPlot.Model = MyModel; myPlot.Dock = System.Windows.Forms.DockStyle.Bottom; myPlot.Location = new Point(0, 0); myPlot.Size = new Size(Settings.Sizes.Width, Settings.Sizes.Height); myPlot.TabIndex = 0; return(myPlot); }
public void CombinatorAddsDeclaredProperties() { LegendConfigurator a = new(); LegendConfigurator b = new(); const LegendPlacement placement = LegendPlacement.Inside; const LegendPosition position = LegendPosition.LeftTop; b.Placement.Set(placement); a.Position.Set(position); Combinator <LegendConfigurator> combinator = new(a, b); LegendConfigurator combined = combinator.Combine(); Assert.True(combined.Placement.IsSet); Assert.True(combined.Position.IsSet); Assert.Equal(placement, combined.Placement.Value); Assert.Equal(position, combined.Position.Value); }
/// <summary> /// Converte o tipo para o formato do c3 /// </summary> /// <param name="legendPosition">Define o lado da legenda no gráfico.</param> /// <returns></returns> string ObterLegendPosition(LegendPosition legendPosition) { string result = null; switch (legendPosition) { case LegendPosition.Right: result = "right"; break; case LegendPosition.Inset: result = "inset"; break; case LegendPosition.Bottom: result = "bottom"; break; } return(result); }
private void UpdateThrottlerUnlocked() { // before measure every element in the chart // we copy the properties that might change while we are updating the chart // this call should be thread safe // ToDo: ensure it is thread safe... viewDrawMargin = chartView.DrawMargin; controlSize = chartView.ControlSize; yAxes = chartView.YAxes.Select(x => x.Copy()).ToArray(); xAxes = chartView.XAxes.Select(x => x.Copy()).ToArray(); measureWorker = new object(); series = chartView.Series.Select(series => { // a good implementation of ISeries<T> // must use the measureWorker to identify // if the points are already fetched. // this way no matter if the Series.Values collection changes // the fetch method will always return the same collection for the // current measureWorker instance series.Fetch(this); return(series); }).ToArray(); legendPosition = chartView.LegendPosition; legendOrientation = chartView.LegendOrientation; legend = chartView.Legend; // ... this is a reference type.. this has no sense tooltipPosition = chartView.TooltipPosition; tooltipFindingStrategy = chartView.TooltipFindingStrategy; tooltip = chartView.Tooltip; //... no sense again... animationsSpeed = chartView.AnimationsSpeed; easingFunction = chartView.EasingFunction; Measure(); }
public static string ToDescriptionString(this LegendPosition val) { var attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }
private ST_LegendPos FromLegendPosition(LegendPosition position) { switch (position) { case LegendPosition.Bottom: return ST_LegendPos.b; case LegendPosition.Left: return ST_LegendPos.l; case LegendPosition.Right: return ST_LegendPos.r; case LegendPosition.Top: return ST_LegendPos.t; case LegendPosition.TopRight: return ST_LegendPos.tr; default: throw new ArgumentException(); } }
/// <summary> /// The position of the legend in relation to the chart. One of: \"top\", \"bottom\", \"left\", \"right\", or \"float\". If set to \"float\", then the legend box will be positioned at the point denoted by the x and y parameters. Defaults to: \"bottom\" /// </summary> public virtual ChartLegend.Builder Position(LegendPosition position) { this.ToComponent().Position = position; return(this as ChartLegend.Builder); }
/// <summary> /// Get legend view bounds. /// </summary> /// <returns></returns> protected virtual Rectangle GetLegendBounds(Rectangle plotViewBounds, LegendType type, LegendPosition position) { if (!this.showLegend) { return(new Rectangle(0, 0, 0, 0)); } var clientRect = this.ClientBounds; Size legendSize = Size.Zero; switch (type) { default: case LegendType.PrimaryLegend: legendSize = this.PrimaryLegend.GetPreferredSize(); break; } switch (position) { case LegendPosition.Left: return(new Rectangle(0, plotViewBounds.Y + (plotViewBounds.Height - legendSize.Height) / 2, legendSize.Width, legendSize.Height)); default: case LegendPosition.Right: return(new Rectangle(clientRect.Right - legendSize.Width, plotViewBounds.Y + (plotViewBounds.Height - legendSize.Height) / 2, legendSize.Width, legendSize.Height)); case LegendPosition.Top: return(new Rectangle(plotViewBounds.X + (plotViewBounds.Width - legendSize.Width) / 2, 0, legendSize.Width, legendSize.Height)); case LegendPosition.Bottom: return(new Rectangle(plotViewBounds.X + (plotViewBounds.Width - legendSize.Width) / 2, plotViewBounds.Bottom - legendSize.Height, legendSize.Width, legendSize.Height)); } }
public LegendOptions Position(LegendPosition position) { return SetValue(Field.Position, position.ToString().ToLower()); }
private ST_LegendPos FromLegendPosition(LegendPosition position) { switch (position) { case LegendPosition.BOTTOM: return ST_LegendPos.b; case LegendPosition.LEFT: return ST_LegendPos.l; case LegendPosition.RIGHT: return ST_LegendPos.r; case LegendPosition.TOP: return ST_LegendPos.t; case LegendPosition.TOP_RIGHT: return ST_LegendPos.tr; default: throw new ArgumentException(); } }
/// <summary> /// Adds an empty line graph to the given figure /// </summary> /// <param name="figure">The ID of the figure</param> /// <param name="title">The header for the graph</param> /// <param name="xAxis">The x-axis label</param> /// <param name="yAxis">The y-axis label</param> /// <param name="showLegend">Switch to disable legend</param> /// <param name="position">Enum for legend position</param> /// <returns>A valid GUID if successful otherwise zeros</returns> public Guid AddLineGraph(Guid figure, string title, string xAxis, string yAxis, bool showLegend = true, LegendPosition position = LegendPosition.TopLeft) { try { return(service.AddLineGraph(figure, title, xAxis, yAxis, showLegend, position)); } catch (Exception) { return(Guid.Empty); } }
public Guid AddLineGraph(Guid figure, string title, string xAxis, string yAxis, bool showLegend, LegendPosition position) { try { return(Channel.AddLineGraph(figure, title, xAxis, yAxis, showLegend, position)); } catch (Exception) { return(Guid.Empty); } }
public LegendOptions Position(LegendPosition position) { return(SetValue(Field.Position, position.ToString().ToLower())); }
/// <summary> /// Adds an empty line graph to the current graph group /// </summary> /// <param name="title">The graph title</param> /// <param name="xAxis">The x-axis label</param> /// <param name="yAxis">The y-axis label</param> /// <param name="showLegend">Boolean indicationg if legend is shown</param> /// <param name="position">Enumeration indication position of legend</param> /// <returns>void</returns> public LineGraph AddLineGraph(string title, string xAxis, string yAxis, bool showLegend = true, LegendPosition position = LegendPosition.TopLeft) { LineGraph graph = null; Dispatcher.Invoke(new Action(() => { graph = new LineGraph(title, xAxis, yAxis, showLegend, position); AddGraph(graph); })); return(graph); }
public void Visualize(double[] x, double[] y, double[] yse, OxyColor color, Type seriestype, double linewidth, LineStyle linestyle, string title = "", string xtitle = "", string ytitle = "", bool isclear = true, LegendPosition legendposition = LegendPosition.RightTop) { Visualize(new Dictionary <string, double[]>() { [""] = x }, new Dictionary <string, double[]>() { [""] = y }, yse != null ? new Dictionary <string, double[]>() { [""] = yse } : null, new Dictionary <string, OxyColor>() { [""] = color }, new Dictionary <string, Type>() { [""] = seriestype }, new Dictionary <string, double> { [""] = linewidth }, new Dictionary <string, LineStyle> { [""] = linestyle }, title, xtitle, ytitle, isclear, legendposition); }
public void Visualize(double[] x, Dictionary <string, double[]> y, Dictionary <string, double[]> yse, Dictionary <string, OxyColor> color, Dictionary <string, Type> seriestype, Dictionary <string, double> linewidth, Dictionary <string, LineStyle> linestyle, string title = "", string xtitle = "", string ytitle = "", bool isclear = true, LegendPosition legendposition = LegendPosition.RightTop) { Visualize(y.ToDictionary(i => i.Key, i => x), y, yse, color, seriestype, linewidth, linestyle, title, xtitle, ytitle, isclear, legendposition); }
protected MSCHART.Docking GetLegendDockingPosition(LegendPosition pos) { if (pos == LegendPosition.Bottom) { return MSCHART.Docking.Bottom; } else if (pos == LegendPosition.Right) { return MSCHART.Docking.Right; } else { throw new System.ArgumentException(); } }
public void SetLegenedPosition(LegendPosition position) { foreach (ToolStripMenuItem menuItem in legendPossitionToolStripMenuItem.DropDownItems) menuItem.Checked = (LegendPosition)menuItem.Tag == position; switch (position) { case LegendPosition.LeftMiddle: chart.LegendPosition = LegendPosition.LeftMiddle; break; case LegendPosition.RightMiddle: chart.LegendPosition = LegendPosition.RightMiddle; break; case LegendPosition.TopCenter: chart.LegendPosition = LegendPosition.TopCenter; break; case LegendPosition.BottomCenter: chart.LegendPosition = LegendPosition.BottomCenter; break; } legendToolStripMenuItem.Visible = true; lastPossition = chart.LegendPosition; }
public void Visualize(Dictionary <string, double[]> x, Dictionary <string, double[]> y, Dictionary <string, double[]> yse, Dictionary <string, OxyColor> color, Dictionary <string, Type> seriestype, Dictionary <string, double> linewidth, Dictionary <string, LineStyle> linestyle, string title = "", string xtitle = "", string ytitle = "", bool isclear = true, LegendPosition legendposition = LegendPosition.RightTop) { if (!Visible) { Visible = true; Parent.Visible = true; } if (isclear) { Model.Series.Clear(); ylo = double.NaN; yhi = double.NaN; xlo = double.NaN; xhi = double.NaN; } foreach (var u in y.Keys.ToList()) { var point = new ScatterSeries() { Title = u, MarkerSize = linewidth[u], MarkerFill = color[u], MarkerStrokeThickness = 0, MarkerType = MarkerType.Circle, TrackerFormatString = "{0}\nX: {2:0.0}\nY: {4:0.0}" }; var line = new LineSeries() { Title = u, StrokeThickness = linewidth[u], Color = color[u], LineStyle = linestyle[u], TrackerFormatString = "{0}\nX: {2:0.0}\nY: {4:0.0}" }; var error = new ScatterErrorSeries() { ErrorBarStopWidth = 2, ErrorBarStrokeThickness = linewidth[u], ErrorBarColor = OxyColor.FromAColor(180, line.Color), MarkerSize = 0, TrackerFormatString = "{0}\nX: {2:0.0}\nY: {4:0.0}" }; for (var i = 0; i < x[u].Length; i++) { if (seriestype[u] == typeof(ScatterSeries)) { point.Points.Add(new ScatterPoint(x[u][i], y[u][i])); } else if (seriestype[u] == typeof(LineSeries)) { line.Points.Add(new DataPoint(x[u][i], y[u][i])); } var cyse = 0.0; if (yse != null && yse.ContainsKey(u)) { error.Points.Add(new ScatterErrorPoint(x[u][i], y[u][i], 0, yse[u][i])); cyse = yse[u][i]; } if (yhi == double.NaN) { yhi = y[u][i] + cyse; ylo = y[u][i] - cyse; } if (xhi == double.NaN) { xhi = x[u][i]; xlo = x[u][i]; } yhi = Math.Max(yhi, y[u][i] + cyse); ylo = Math.Min(ylo, y[u][i] - cyse); xhi = Math.Max(xhi, x[u][i]); xlo = Math.Min(xlo, x[u][i]); } if (point.Points.Count > 0) { Model.Series.Add(point); } if (line.Points.Count > 0) { Model.Series.Add(line); } if (error.Points.Count > 0) { Model.Series.Add(error); } } if (Model.DefaultXAxis != null) { Model.DefaultXAxis.Maximum = xhi + 0.01 * (xhi - xlo); Model.DefaultXAxis.Minimum = xlo - 0.01 * (xhi - xlo); Model.DefaultYAxis.Maximum = yhi + 0.01 * (yhi - ylo); Model.DefaultYAxis.Minimum = ylo - 0.01 * (yhi - ylo); Model.DefaultXAxis.Reset(); Model.DefaultYAxis.Reset(); } if (!isupdated) { if (Model.DefaultXAxis != null) { Model.DefaultXAxis.MaximumPadding = 0.005; Model.DefaultXAxis.MinimumPadding = 0.005; Model.DefaultYAxis.MaximumPadding = 0.005; Model.DefaultYAxis.MinimumPadding = 0.005; Model.DefaultXAxis.TickStyle = OxyPlot.Axes.TickStyle.Outside; Model.DefaultXAxis.Title = xtitle; Model.DefaultYAxis.TickStyle = OxyPlot.Axes.TickStyle.Outside; Model.DefaultYAxis.Title = ytitle; Model.Title = title; Model.LegendPosition = legendposition; isupdated = true; } } Model.InvalidatePlot(true); }