private static GroupOptions getGroupOptions(LegendOptions.LegendPositions legendPosition, int columns) { var groupOptions = new GroupOptions { Title = "This is my Group Title using = and ,.", Columns = 2, Rows = 2, HorizontalSep = Helper.Length(2, Helper.MeasurementUnits.em), VerticalSep = Helper.Length(8, Helper.MeasurementUnits.ex), XLabelsAt = GroupOptions.GroupXPositions.EdgeBottom, XTickLabelsAt = GroupOptions.GroupXPositions.EdgeBottom, YLabelsAt = GroupOptions.GroupYPositions.EdgeLeft, YTickLabelsAt = GroupOptions.GroupYPositions.EdgeLeft, GroupLegendOptions = new GroupLegendOptions { LegendEntries = new[] { "Male", "Female" }, LegendOptions = new LegendOptions { Columns = columns, LegendPosition = legendPosition } } }; return(groupOptions); }
/// <summary> /// This method arranges the width of legends by specifying max text width. /// </summary> /// <remarks> /// The legend entries get then word wrapped automatically. /// </remarks> /// <param name="position"></param> /// <param name="isLandscape"></param> /// <param name="maxLegendEntry"></param> /// <returns>Good adjusted width string.</returns> private static string getLegendWidth(LegendOptions.LegendPositions position, bool isLandscape, int maxLegendEntry) { var isInnerPosition = position == LegendOptions.LegendPositions.NorthWest || position == LegendOptions.LegendPositions.NorthEast || position == LegendOptions.LegendPositions.SouthEast || position == LegendOptions.LegendPositions.SouthWest; var isLegendBeside = getIsLegendBeside(position); var isLegendWide = position == LegendOptions.LegendPositions.OuterNorth || position == LegendOptions.LegendPositions.OuterSouth || position == LegendOptions.LegendPositions.OuterSouthEast || position == LegendOptions.LegendPositions.OuterSouthWest; if (isInnerPosition && maxLegendEntry > 40) { return(Helper.GetLengthInPercentageOfTextWidth(40)); } if (isLegendBeside && !isLandscape && maxLegendEntry > 25) { return(Helper.GetLengthInPercentageOfTextWidth(25)); } if (isLegendWide && maxLegendEntry > 100) { return(Helper.GetLengthInPercentageOfTextWidth(90)); } if (maxLegendEntry > 40 && !isLegendWide) { return(Helper.GetLengthInPercentageOfTextWidth(40)); } return(String.Empty); }
private static AxisOptions getAxisOptions(LegendOptions.LegendPositions legendPosition) { var axisOptions = new AxisOptions(NoConverter.Instance) { Title = "Test Title", YLabel = "Y Axis", YMode = AxisOptions.AxisMode.normal, YMin = 0F, XMin = 0F, XMax = 4F, XTicks = new[] { 1F, 2F, 3F }, XTickLabels = new[] { "Group A", "Group B", "Group C" }, XAxisPosition = AxisOptions.AxisXLine.bottom, YAxisPosition = AxisOptions.AxisYLine.left, YMajorGrid = true, YAxisArrow = true, EnlargeLimits = false, LegendOptions = new LegendOptions { Columns = 1, LegendPosition = legendPosition } }; axisOptions.GroupLines.Add(new AxisOptions.GroupLine(1F, 2F, "A-B", 1)); return(axisOptions); }
private static bool getIsLegendBeside(LegendOptions.LegendPositions legendPosition) { var isLegendBeside = legendPosition == LegendOptions.LegendPositions.OuterNorthEast || legendPosition == LegendOptions.LegendPositions.OuterNorthWest; return(isLegendBeside); }
private static GroupPlot getGroupPlot(List <Color> colors, LegendOptions.LegendPositions legendPosition, int columns) { var axisOptionsForGroup = getAxisOptionsForGroup(); var plotOptions1 = getBoxPlotOptions(15F, 20F, 25F, 30F, 35F, 1F, Color.Blue.Name); var plotOptions2 = getBoxPlotOptions(26F, 31F, 34F, 41F, 44F, 1F, Color.Red.Name); var plotOptions3 = getBoxPlotOptions(18F, 22F, 27F, 32F, 38F, 2F, Color.Blue.Name); var plotOptions4 = getBoxPlotOptions(27F, 31F, 35F, 39F, 47F, 2F, Color.Red.Name); var coordinates = new List <Coordinate> { new Coordinate(0F, 5F) }; var boxplot1 = new Plot(coordinates, plotOptions1); var boxplot2 = new Plot(coordinates, plotOptions2); var boxplot3 = new Plot(new List <Coordinate>(), plotOptions3); var boxplot4 = new Plot(new List <Coordinate>(), plotOptions4); var groupOptions = getGroupOptions(legendPosition, columns); var groupedPlots = new List <IBasePlot>(); var plots = new List <Plot> { boxplot1, boxplot2, boxplot3, boxplot4 }; var axisOptionsForPlotWithoutGroupLines = getAxisOptionsForPlot(); var axisOptionsForPlot = getAxisOptionsForPlot(); axisOptionsForPlot.GroupLines.Add(new AxisOptions.GroupLine(1F, 2F, "All", 1)); axisOptionsForPlot.GroupLines.Add(new AxisOptions.GroupLine(1F, 2F, "Total", 2)); var groupedPlot1 = new BasePlot(new AxisOptions(NoConverter.Instance) { IsEmptyGroupPlot = true }, new List <Plot>()); var groupedPlot2 = new BasePlot(axisOptionsForPlotWithoutGroupLines, plots); var groupedPlot3 = new BasePlot(axisOptionsForPlot, plots); groupedPlots.Add(groupedPlot1); groupedPlots.Add(groupedPlot2); groupedPlots.Add(groupedPlot3); groupedPlots.Add(groupedPlot3); var plotItem = new GroupPlot(colors, axisOptionsForGroup, groupOptions, groupedPlots, new Text("Test Figure With Grouped Plots")) { Position = FigureWriter.FigurePositions.H }; return(plotItem); }
private static AxisOptions getAxisOptionsForInterval(LegendOptions.LegendPositions legendPosition) { var axisOptions = new AxisOptions(NoConverter.Instance) { Title = "Test Title", YLabel = "Y Axis", YMode = AxisOptions.AxisMode.normal, YMin = 0F, XTicks = new[] { 1F, 2F, 3F, 4F }, XAxisPosition = AxisOptions.AxisXLine.bottom, YAxisPosition = AxisOptions.AxisYLine.left, YMajorGrid = true, YAxisArrow = true, EnlargeLimits = false, LegendOptions = new LegendOptions { Columns = 1, LegendPosition = legendPosition } }; return(axisOptions); }
private int getLegendColumnsFor(int numberOfLegendEntries, LegendOptions.LegendPositions legendPosition) { switch (legendPosition) { case LegendOptions.LegendPositions.SouthWest: case LegendOptions.LegendPositions.SouthEast: case LegendOptions.LegendPositions.NorthWest: case LegendOptions.LegendPositions.NorthEast: case LegendOptions.LegendPositions.OuterNorthEast: case LegendOptions.LegendPositions.OuterNorthWest: case LegendOptions.LegendPositions.OuterSouthEast: case LegendOptions.LegendPositions.OuterSouthWest: return(1); case LegendOptions.LegendPositions.OuterSouth: case LegendOptions.LegendPositions.South: case LegendOptions.LegendPositions.OuterNorth: case LegendOptions.LegendPositions.North: return(numberOfLegendEntries); default: throw new ArgumentOutOfRangeException("legendPosition"); } }
protected virtual GroupOptions GetGroupOptions(int numberOfPanes, string title, string[] legendEntries, LegendOptions.LegendPositions legendPosition) { var groupOptions = new GroupOptions { Title = title, Columns = 1, Rows = numberOfPanes, HorizontalSep = Helper.Length(2, Helper.MeasurementUnits.em), VerticalSep = Helper.Length(8, Helper.MeasurementUnits.ex), XLabelsAt = GroupOptions.GroupXPositions.EdgeBottom, XTickLabelsAt = GroupOptions.GroupXPositions.All, YLabelsAt = GroupOptions.GroupYPositions.All, YTickLabelsAt = GroupOptions.GroupYPositions.All, GroupLegendOptions = { LegendEntries = legendEntries, LegendOptions = new LegendOptions { Columns = getLegendColumnsFor(legendEntries.Count(), legendPosition), LegendPosition = legendPosition, FontSize = LegendOptions.FontSizes.scriptsize } } }; return(groupOptions); }
protected override GroupOptions GetGroupOptions(int numberOfPanes, string title, string[] legendEntries, LegendOptions.LegendPositions legendPosition) { var groupOptions = base.GetGroupOptions(numberOfPanes, title, legendEntries, legendPosition); groupOptions.XLabelsAt = GroupOptions.GroupXPositions.EdgeBottom; groupOptions.XTickLabelsAt = GroupOptions.GroupXPositions.EdgeBottom; return(groupOptions); }