/// <summary> /// This method creates a figure. /// </summary> /// <remarks>A figure environment will be placed somewhere according to position settings. /// It is an floating environment.</remarks> /// <param name="caption">Text for figure caption.</param> /// <param name="plot">Plot settings needed for generation.</param> /// <param name="converter">TEX converter.</param> internal static string PlotThreeOrdinatesFigure(string caption, PlotThreeOrdinates plot, ITeXConverter converter) { var isLegendBeside = getIsLegendBeside(plot.AxisOptionsY3.LegendOptions.LegendPosition); var maxLegendEntry = getMaxLegendEntryLength(plot.Plots.Concat <Plot>(plot.PlotsY2).Concat <Plot>(plot.PlotsY3)); adjustAxisDimensionForFigures(plot.AxisOptions, plot.Landscape, isLegendBeside, 90, 40, 70); adjustAxisDimensionForFigures(plot.AxisOptionsY2, plot.Landscape, isLegendBeside, 90, 40, 70); adjustAxisDimensionForFigures(plot.AxisOptionsY3, plot.Landscape, isLegendBeside, 90, 40, 70); if (String.IsNullOrEmpty(plot.AxisOptionsY3.LegendOptions.TextWidth)) { plot.AxisOptionsY3.LegendOptions.TextWidth = getLegendWidth( plot.AxisOptionsY3.LegendOptions.LegendPosition, plot.Landscape, maxLegendEntry); } var pictureText = new PlotWriter(plot.Colors, converter).PictureThreeOrdinates(plot.AxisOptions, plot.AxisOptionsY2, plot.AxisOptionsY3, plot.Plots, plot.PlotsY2, plot.PlotsY3); return(plotFigure(caption, plot, pictureText)); }
private void PlotFigures(string chapterName, List <Coordinate> coordinates, Text chapterTitle = null) { if (chapterTitle == null) { chapterTitle = new Text(chapterName); } _objectsToReport.Add(new Chapter(chapterName, chapterTitle)); var colors = new List <Color>() { Color.Blue, Color.Red }; var axisOptions = new AxisOptions(NoConverter.Instance) { Title = "Test Title", XLabel = "X Axis", YLabel = "Y Axis", YMode = AxisOptions.AxisMode.log, LogTicksWithFixedPoint = true, XAxisPosition = AxisOptions.AxisXLine.bottom, YAxisPosition = AxisOptions.AxisYLine.left, LegendOptions = new LegendOptions { LegendPosition = LegendOptions.LegendPositions.NorthWest }, YMajorGrid = true }; var plotOptions1 = new PlotOptions { LineStyle = PlotOptions.LineStyles.Solid, Marker = PlotOptions.Markers.Triangle, Color = Color.Blue.Name, ErrorBars = true, ShadedErrorBars = true, Thickness = PlotOptions.Thicknesses.UltraThick }; var plot1 = new Plot(coordinates, plotOptions1) { LegendEntry = "legend entry 1" }; var plotItem = new TeXReporting.Items.Plot(colors, axisOptions, new List <Plot> { plot1 }, new Text("Test Figure")); var plotOptions2 = new PlotOptions { LineStyle = PlotOptions.LineStyles.DashDotted, Marker = PlotOptions.Markers.Circle, Color = Color.Red.Name, ErrorBars = true, ThicknessSize = Helper.Length(2, Helper.MeasurementUnits.pt), MarkSize = Helper.Length(3, Helper.MeasurementUnits.pt), MarkColor = Color.Blue.Name, MarkFillColor = String.Format("{0}!{1}", Color.Blue.Name, 20) }; var plot2 = new Plot(coordinates, plotOptions2) { LegendEntry = "0123456789 0123456789 0123456789 0123456789 0123456789 0123456789" }; var plotItem2 = new TeXReporting.Items.Plot(colors, axisOptions, new List <Plot> { plot2 }, new Text("Test Figure 2")); // Two Ordinates Plot var axisOptionsY1 = new AxisOptions(NoConverter.Instance) { EnlargeLimits = true, Title = "Test Title", XLabel = "X Axis", YLabel = "Y Axis", YMin = 0, XTickMin = 2F, XTickMax = 3F, MinorXTickNum = 1, MinorYTickNum = 1, BackgroundColor = "blue!10", YMode = AxisOptions.AxisMode.normal, XAxisPosition = AxisOptions.AxisXLine.bottom, YAxisPosition = AxisOptions.AxisYLine.left, YMajorGrid = true }; var axisOptionsY2 = new AxisOptions(DefaultConverter.Instance) { YLabel = "Y2 Axis", YAxisPosition = AxisOptions.AxisYLine.right, YAxisArrow = false, YScaledTicks = false, YMode = AxisOptions.AxisMode.log, LegendOptions = new LegendOptions { FontSize = LegendOptions.FontSizes.scriptsize, LegendAlignment = LegendOptions.LegendAlignments.left, LegendPosition = LegendOptions.LegendPositions.OuterNorthWest, RoundedCorners = true, Columns = 1, //TextWidth = Helper.GetWidthInPercentageOfTextWidth(30) }, XAxisPosition = AxisOptions.AxisXLine.none }; var plotTwoOrdinates = new PlotTwoOrdinates(colors, axisOptionsY1, new List <Plot> { plot1 }, axisOptionsY2, new List <Plot> { plot2 }, new Text("Test Two Ordinates")); var axisOptionsY3 = new AxisOptions(DefaultConverter.Instance) { YLabel = "Y3 Axis", YAxisPosition = AxisOptions.AxisYLine.right, YAxisArrow = false, YScaledTicks = true, YMin = 0, YDiscontinuity = AxisOptions.Discontinuities.parallel, YMode = AxisOptions.AxisMode.normal, LegendOptions = new LegendOptions { FontSize = LegendOptions.FontSizes.scriptsize, LegendAlignment = LegendOptions.LegendAlignments.left, LegendPosition = LegendOptions.LegendPositions.OuterNorthEast, RoundedCorners = true, Columns = 1, //TextWidth = Helper.GetWidthInPercentageOfTextWidth(30) }, XAxisPosition = AxisOptions.AxisXLine.none }; var plot3 = new Plot(new List <Coordinate> { new Coordinate(2.5F, 5F) }, new PlotOptions { Marker = PlotOptions.Markers.Triangle }) { LegendEntry = "Points" }; var plotThreeOrdinates = new PlotThreeOrdinates(colors, axisOptionsY1, new List <Plot> { plot1 }, axisOptionsY2, new List <Plot> { plot2 }, axisOptionsY3, new List <Plot> { plot3 }, new Text("Test Three Ordinates")); _objectsToReport.Add(new Section("Simple Figure 1")); var axisOptionsNormal = new AxisOptions(NoConverter.Instance) { Title = "Test Title", XLabel = "X Axis", YLabel = "Y Axis", YMode = AxisOptions.AxisMode.normal, LogTicksWithFixedPoint = true, XAxisPosition = AxisOptions.AxisXLine.bottom, YAxisPosition = AxisOptions.AxisYLine.left, LegendOptions = new LegendOptions { LegendPosition = LegendOptions.LegendPositions.NorthWest }, YMajorGrid = true }; var plotItemNormal = new TeXReporting.Items.Plot(plotItem.Colors, axisOptionsNormal, plotItem.Plots, new Text("Test Figure with normal scaled Y-Axis")); _objectsToReport.Add(plotItemNormal); _figureCounter++; _objectsToReport.Add(new Section("Simple Figure 2")); _objectsToReport.Add(plotItem); _figureCounter++; _objectsToReport.Add(new Section("Simple Figure 3")); _objectsToReport.Add(plotItem2); _figureCounter++; _objectsToReport.Add(new Section("Two Ordinates Figure")); _objectsToReport.Add(plotTwoOrdinates); _figureCounter++; _objectsToReport.Add(new Section("Three Ordinates Figure")); _objectsToReport.Add(plotThreeOrdinates); _figureCounter++; }
public override void Build(CurveChart chart, OSPSuiteTracker tracker) { if (!chart.Axes.Any()) { return; } var listToReport = new List <object>(); AxisTypes firstOrdinate; AxisTypes secondOrdinate; AxisTypes thirdOrdinate; var colors = getUsedColors(chart); ChartTypes chartType = checkChartType(chart, out firstOrdinate, out secondOrdinate, out thirdOrdinate); switch (chartType) { case ChartTypes.XYPlot: { var axisOptions = getAxisOptions(chart, firstOrdinate); axisOptions.YAxisPosition = AxisOptions.AxisYLine.box; var plots = getPlots(chart, firstOrdinate); var plot = new OSPSuite.TeXReporting.Items.Plot(colors, axisOptions, plots, new Text(chart.Description)) { Position = FigureWriter.FigurePositions.H }; listToReport.Add(plot); tracker.AddReference(chart, plot); } break; case ChartTypes.XYY2Plot: { var axisOptionsY = getAxisOptions(chart, firstOrdinate); var plotsY = getPlots(chart, firstOrdinate); addOrdinateToLegendEntry(plotsY, firstOrdinate); var axisOptionsY2 = getAxisOptions(chart, secondOrdinate); axisOptionsY2.BackgroundColor = string.Empty; var plotsY2 = getPlots(chart, secondOrdinate); addOrdinateToLegendEntry(plotsY2, secondOrdinate); var plot = new PlotTwoOrdinates(colors, axisOptionsY, plotsY, axisOptionsY2, plotsY2, new Text(chart.Description)) { Position = FigureWriter.FigurePositions.H }; listToReport.Add(plot); tracker.AddReference(chart, plot); } break; case ChartTypes.XYY2Y3Plot: { var axisOptionsY = getAxisOptions(chart, firstOrdinate); var plotsY = getPlots(chart, firstOrdinate); addOrdinateToLegendEntry(plotsY, firstOrdinate); var axisOptionsY2 = getAxisOptions(chart, secondOrdinate); axisOptionsY2.BackgroundColor = string.Empty; var plotsY2 = getPlots(chart, secondOrdinate); addOrdinateToLegendEntry(plotsY2, secondOrdinate); var axisOptionsY3 = getAxisOptions(chart, thirdOrdinate); axisOptionsY3.BackgroundColor = string.Empty; var plotsY3 = getPlots(chart, thirdOrdinate); addOrdinateToLegendEntry(plotsY3, thirdOrdinate); var plot = new PlotThreeOrdinates(colors, axisOptionsY, plotsY, axisOptionsY2, plotsY2, axisOptionsY3, plotsY3, new Text(chart.Description)) { Position = FigureWriter.FigurePositions.H }; listToReport.Add(plot); tracker.AddReference(chart, plot); } break; } _builderRepository.Report(listToReport, tracker); }