<chart:SfChart.Series>
<chart:StackingColumnSeries ItemsSource="{Binding Data1}" XBindingPath="XValue" YBindingPath="YValue"/>
<chart:StackingColumnSeries ItemsSource="{Binding Data2}" DataMarkerLabelCreated="StackingColumnSeries_DataMarkerLabelCreated" XBindingPath="XValue" YBindingPath="YValue">
<chart:StackingColumnSeries.DataMarker>
<chart:ChartDataMarker ShowLabel="True">
<chart:ChartDataMarker.LabelStyle>
<chart:DataMarkerLabelStyle LabelPosition="Outer"/>
</chart:ChartDataMarker.LabelStyle>
</chart:ChartDataMarker>
</chart:StackingColumnSeries.DataMarker>
</chart:StackingColumnSeries>
</chart:SfChart.Series> |
private void StackingColumnSeries_DataMarkerLabelCreated(object sender, ChartDataMarkerLabelCreatedEventArgs e)
{
if (Device.RuntimePlatform == Device.UWP)
{
e.DataMarkerLabel.Label = e.DataMarkerLabel.YPosition.ToString();
}
else
{
Point point = new Point(e.DataMarkerLabel.XPosition, e.DataMarkerLabel.YPosition);
e.DataMarkerLabel.Label = Math.Round(chart.SecondaryAxis.PointToValue(point)).ToString();
}
} |