|
<chart:SfChart TrackballCreated="SfChart_TrackballCreated">
….
<chart:SfChart.ChartBehaviors>
<chart:ChartTrackballBehavior LabelDisplayMode="GroupAllPoints" ShowLine="True"/>
</chart:SfChart.ChartBehaviors>
</chart:SfChart> |
|
private void SfChart_TrackballCreated(object sender, ChartTrackballCreatedEventArgs e)
{
foreach (var item in e.ChartPointsInfo)
{
….
{
var data = item.DataPoint as ChartDataModel;
item.Label = item.Series.Label + " : " + data.YValue;
if (Device.RuntimePlatform != Device.UWP)
item.LabelStyle.TextColor = item.Series.Color;
}
}
} |
|
<DataTemplate x:Key="trackballTemplate">
<Frame BackgroundColor="White">
<StackLayout Orientation="Vertical" BackgroundColor="White">
<Label TextColor="Black" >
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding XValue}" FontAttributes="Bold"/>
</FormattedString>
</Label.FormattedText>
</Label>
<Label TextColor="Red" >
<Label.FormattedText>
<FormattedString>
<Span Text=" Veg : "/>
<Span Text="{Binding YValue2}" FontAttributes="Bold"/>
</FormattedString>
</Label.FormattedText>
</Label>
<Label TextColor="Green" >
<Label.FormattedText>
<FormattedString>
<Span Text=" Fair-trade : "/>
<Span Text="{Binding YValue1}" FontAttributes="Bold"/>
</FormattedString>
</Label.FormattedText>
</Label>
….
</StackLayout>
</Frame>
</DataTemplate>
…
<chart:StackingAreaSeries x:Name="series3"
ItemsSource="{Binding Data}" XBindingPath="XValue"
YBindingPath="YValue2" Label="Veg" LegendIcon="SeriesType" Color="Orange"
ShowTrackballInfo="True"
TrackballLabelTemplate="{StaticResource trackballTemplate}" />
…. |
|
foreach (var item in e.ChartPointsInfo)
{
var data = item.DataPoint as Model;
item.Label = item.Series.Label + " : " + data.Value;
item.LabelStyle.BackgroundColor = Color.Gray;
. . . .
}
|