Skip to content

Commit 2450c57

Browse files
authored
Merge pull request #18 from rebelinux/dev
Sync data
2 parents 61d8ab8 + 1eb1c64 commit 2450c57

4 files changed

Lines changed: 230 additions & 160 deletions

File tree

Sources/AsBuiltReportChart.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public static class MainEntry
66
{
77
public static void Main(string[] args)
88
{
9-
double[] values = new double[] { 3, 2 };
10-
string[] labels = new string[] { "Cassa", "Carro" };
9+
double[] values = new double[] { 3};
10+
string[] labels = new string[] { "Cassa"};
1111

1212
Chart.EnableLegend = true;
1313
Chart.LegendFontColor = BasicColors.Black;
@@ -31,15 +31,15 @@ public static void Main(string[] args)
3131

3232
// Chart.ColorPalette = ColorPalettes.Dark;
3333

34-
Chart.AreaOrientation = Orientations.Horizontal;
34+
Chart.AreaOrientation = Orientations.Vertical;
3535
Bar PieBar = new Bar();
3636
Chart.Format = Formats.png;
3737

3838
Chart.EnableCustomColorPalette = true;
3939
Chart.InvertCustomColorPalette = true;
4040
Chart.CustomColorPalette = new string[] { "#DFF0D0", "#FFF4C7", "#FEDDD7", "#878787", "#77a898", "#5e9584", "#458370", "#2a715d", "#005f4b" };
4141

42-
PieBar.Chart(values, labels, width: 600, height: 400, filename: "PieChartExample");
42+
PieBar.Chart(values, labels, width: 600, height: 600, filename: "PieChartExample");
4343
}
4444
}
4545
}

Sources/BarChart.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,20 @@ public object Chart(double[] values, string[] labels, string filename = "output"
187187
// Set margins settings
188188
myPlot.Axes.Margins(left: AxesMarginsLeft, right: AxesMarginsRight, bottom: AxesMarginsDown, top: AxesMarginsTop);
189189

190-
// Set filepath
190+
// Set axis limits if values are empty or contain only one value to prevent auto-scaling issues
191+
if (values.Length == 1)
192+
{
193+
if (AreaOrientation == Orientations.Horizontal)
194+
{
195+
myPlot.Axes.SetLimits(0, 0, -2, 2);
196+
}
197+
else
198+
{
199+
myPlot.Axes.SetLimits(-2, 2, 0, 0);
200+
}
201+
}
191202

203+
// Set filepath
192204
string Filepath = _outputFolderPath ?? System.IO.Directory.GetCurrentDirectory();
193205

194206
// Save Plot

0 commit comments

Comments
 (0)