|
public class CustomNativeChart : SfChartExt
{
public CustomNativeChart(Android.Content.Context context) : base(context)
{
}
protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
{
base.OnLayout(changed, left, top, right, bottom);
if (Legend != null)
{
PropertyInfo property = typeof(Native.SfChart).GetProperty("ChartLegendlayout", BindingFlags.NonPublic | BindingFlags.Instance);
var legendLayout = (Native.ChartLegendLayout)property.GetValue(this, null);
var legendWidth = legendLayout.Width;
legendLayout.SetX(this.Width - legendWidth);
legendLayout.SetY(legendLayout.Height);
}
}
} |
|
public class CustomNativeChart : Native.SFChart
{
public CustomNativeChart()
{
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
if (this.Legend != null)
{
PropertyInfo property = typeof(Native.SFChart).GetProperty("LegendView", BindingFlags.NonPublic | BindingFlags.Instance);
//Convert the LegendView as NsView for macOS
var legendView = (UIView)property.GetValue(this, null);
if (legendView.Frame.Width > 0)
{
legendView.Frame = new CGRect(this.Frame.Width - legendView.Frame.Width, legendView.Frame.Height, legendView.Frame.Width, legendView.Frame.Height);
legendView.SetNeedsLayout();
legendView.SetNeedsDisplay();
property.SetValue(this, legendView);
}
}
} |
|
public class CustomChartRenderer : SfChartRenderer
{
Native.SfChart nativechart;
protected override void OnElementChanged(ElementChangedEventArgs<SfChart> e)
{
base.OnElementChanged(e);
nativechart = Control;
}
protected override Size ArrangeOverride(Size finalSize)
{
if (this.nativechart.Legend != null)
{
var legend = nativechart.Legend as Native.ChartLegend;
PropertyInfo property = typeof(Native.ChartLegend).GetProperty("ArrangeRect", BindingFlags.NonPublic | BindingFlags.Instance);
var legendLayout = (Windows.Foundation.Rect)property.GetValue(nativechart.Legend, null);
legendLayout = new Windows.Foundation.Rect(nativechart.DesiredSize.Width - legend.DesiredSize.Width,legend.DesiredSize.Height,legend.DesiredSize.Width,legend.DesiredSize.Height);
property.SetValue(nativechart.Legend, legendLayout);
}
return base.ArrangeOverride(finalSize);
}
} |
|
public class CustomNativeChart : SfChartExt
{
public CustomNativeChart(Android.Content.Context context) : base(context)
{
}
protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
{
base.OnLayout(changed, left, top, right, bottom);
if (Legend != null)
{
PropertyInfo property = typeof(Native.SfChart).GetProperty("ChartLegendlayout", BindingFlags.NonPublic | BindingFlags.Instance);
var legendLayout = (Native.ChartLegendLayout)property.GetValue(this, null);
var legendWidth = legendLayout.Width;
Legend.DockPosition = Native.ChartDock.Floating;
Legend.OffsetX = this.Width - legendWidth;
Legend.OffsetY = 0;
}
}
} |
|
public class CustomNativeChart : Native.SFChart
{
public CustomNativeChart()
{
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
if (this.Legend != null)
{
PropertyInfo property = typeof(Native.SFChart).GetProperty("LegendView", BindingFlags.NonPublic | BindingFlags.Instance);
//Convert the LegendView as NsView for macOS
var legendView = (UIView)property.GetValue(this, null);
if (legendView.Frame.Width > 0)
{
legendView.Frame = new CGRect(this.Frame.Width - legendView.Frame.Width, legendView.Frame.Height, legendView.Frame.Width, legendView.Frame.Height);
legendView.SetNeedsLayout();
legendView.SetNeedsDisplay();
property.SetValue(this, legendView);
}
}
} |
|
public class CustomChartRenderer : SfChartRenderer
{
Native.SfChart nativechart;
protected override void OnElementChanged(ElementChangedEventArgs<SfChart> e)
{
base.OnElementChanged(e);
nativechart = Control;
}
protected override Size ArrangeOverride(Size finalSize)
{
if (this.nativechart.Legend != null)
{
var legend = nativechart.Legend as Native.ChartLegend;
PropertyInfo property = typeof(Native.ChartLegend).GetProperty("ArrangeRect", BindingFlags.NonPublic | BindingFlags.Instance);
var legendLayout = (Windows.Foundation.Rect)property.GetValue(nativechart.Legend, null);
legendLayout = new Windows.Foundation.Rect(nativechart.DesiredSize.Width - legend.DesiredSize.Width,legend.DesiredSize.Height,legend.DesiredSize.Width,legend.DesiredSize.Height);
property.SetValue(nativechart.Legend, legendLayout);
}
return base.ArrangeOverride(finalSize);
}
private void Control_SeriesBoundsChanged(object sender, Native.ChartSeriesBoundsEventArgs e)
{
var nativeChart = sender as Native.SfChart;
if (nativeChart.Legend != null)
{
var legend = nativeChart.Legend as Native.ChartLegend;
legend.DockPosition = Native.ChartDock.Floating;
legend.OffsetX = (DesiredSize.Width - legend.DesiredSize.Width);
legend.OffsetY = 0;
}
}
} |