Here's the GetChart method that the RelativeLayout uses to get the chart and lay it out:
private SfChart GetChart()
{
// Create Graph Chart
var graphPane = new SfChart
{
BackgroundColor = Color.White,
PrimaryAxis = new CategoryAxis { Interval = 1, PlotOffset = 0, AxisLineOffset = 0, MajorTickStyle = new ChartAxisTickStyle { TickSize = 0 }, ShowMajorGridLines = true, LabelStyle = new ChartAxisLabelStyle { LabelsPosition = AxisElementPosition.Outside, Margin = new Thickness(0,5 ,0,0) }, AxisLineStyle = new ChartLineStyle { StrokeColor = Color.FromRgb(215, 215, 215), StrokeWidth = 1 }, MajorGridLineStyle = new ChartLineStyle { StrokeColor = Color.FromRgb(241, 241, 241) }, },
SecondaryAxis = new NumericalAxis { PlotOffset = 0, AxisLineOffset = 0, LabelStyle = new ChartAxisLabelStyle { LabelsPosition = AxisElementPosition.Outside, Margin = new Thickness(0,0,0,0) }, AxisLineStyle = new ChartLineStyle { StrokeColor = Color.FromRgb(215, 215, 215), StrokeWidth = 1 }, MajorTickStyle = new ChartAxisTickStyle { TickSize = 0 }, MajorGridLineStyle = new ChartLineStyle { StrokeColor = Color.FromRgb(241, 241, 241) } },
};
graphPane.HorizontalOptions = LayoutOptions.StartAndExpand;
// Create Data Series
// 1. Demo Series
demoSeries = new LineSeries
{
EnableDataPointSelection = true,
Color = Color.FromRgb(81,146, 216),
DataMarker = new ChartDataMarker { ShowLabel = false },
StrokeWidth = 1,
};
// 2. Sales Series
salesSeries = new LineSeries
{
Color = Color.FromHex("fecb2f"),
DataMarker = new ChartDataMarker { ShowLabel = false },
StrokeWidth = 1
};
// Add Series to Chart
graphPane.Series.Add(demoSeries);
graphPane.Series.Add(salesSeries);
return graphPane;
}
The data is added top both series separately and as you can see from the attached image, it looks great with data in it.
The question, as said, is all about the white margin.