public MainPage()
{
InitializeComponent();
//Trigger label created event to change the axis label
this.numericalAxis.LabelCreated += NumericalAxis_LabelCreated;
}
private void NumericalAxis_LabelCreated(object sender, ChartAxisLabelEventArgs e)
{
string label = e.LabelContent;
//Changing the axis label
switch (label)
{
case "1":
e.LabelContent = "One";
break;
case "2":
e.LabelContent = "Two";
break;
case "3":
e.LabelContent = "Three";
break;
case "4":
e.LabelContent = "Four";
break;
case "5":
e.LabelContent = "Five";
break;
case "6":
e.LabelContent = "Six";
break;
}
} |
<chart:StackingBarSeries ItemsSource="{Binding Data}"
XBindingPath="XValue" YBindingPath="YValue"> <chart:StackingBarSeries.DataMarker> <chart:ChartDataMarker LabelContent="DataMarkerLabel" LabelTemplate="{StaticResource dataTemplate}" ShowMarker="true" MarkerHeight="10" MarkerWidth="10"> <chart:ChartDataMarker.LabelStyle> <chart:DataMarkerLabelStyle LabelPosition="Outer" /> </chart:ChartDataMarker.LabelStyle> </chart:ChartDataMarker> </chart:StackingBarSeries.DataMarker> </chart:StackingBarSeries> <ContentPage.Resources>
<ResourceDictionary> <DataTemplate x:Key="dataTemplate"> <StackLayout> <Label Text="{Binding Data.YValue}" FontSize="9" BackgroundColor="{Binding BackgroundColor}" TextColor="White"/> </StackLayout> </DataTemplate> </ResourceDictionary> </ContentPage.Resources> |
<chart:SfChart x:Name="binaryChart" HeightRequest="170" Margin="0,5,5,0">
<chart:SfChart.PrimaryAxis>
<chart:NumericalAxis x:Name="binaryChartSecondaryAxis" Minimum="0" Interval="0.1" Maximum="0.7">
<chart:NumericalAxis.MajorTickStyle>
<chart:ChartAxisTickStyle StrokeWidth="0"/>
</chart:NumericalAxis.MajorTickStyle>
</chart:NumericalAxis>
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis x:Name="yAxisVoltage" Minimum="0.00" Maximum="1.30">
<chart:NumericalAxis.Title>
<chart:ChartAxisTitle Text="t/s" TextColor="Black" FontSize="10"/>
</chart:NumericalAxis.Title>
</chart:NumericalAxis>
</chart:SfChart.SecondaryAxis>
<chart:SfChart.Series>
<chart:BarSeries x:Name="vc1PlusSeries"/>
</chart:SfChart.Series>
</chart:SfChart> |
private void BinaryChartSecondaryAxis_LabelCreated(object sender, ChartAxisLabelEventArgs e)
{
string label = e.LabelContent;
//Changing the axis label
switch (label)
{
case "0.2":
e.LabelContent = "AUX Open";
break;
case "0.5":
e.LabelContent = "AUX Close";
break;
default:
e.LabelContent = "";
break;
}
} |