<chart:SfChart x:Name="chart1" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<chart:SfChart.PrimaryAxis>
<chart:NumericalAxis RangePadding="Additional" />
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis RangePadding="Additional"/>
</chart:SfChart.SecondaryAxis>
<chart:LineSeries ItemsSource="{Binding LineData1}"
XBindingPath="XVal"
YBindingPath="YValue">
<chart:LineSeries.DataMarker>
<chart:ChartDataMarker
ShowLabel="True"
ShowMarker="True"/>
</chart:LineSeries.DataMarker>
</chart:LineSeries>
</chart:SfChart> |
public class LineSeriesViewModel
{
public ObservableCollection<ChartModel> LineData1 { get; set; }
public LineSeriesViewModel()
{
LineData1 = new ObservableCollection<ChartModel>
{
new ChartModel(7, 45),
};
}
} |
…
chart = new SfChart() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand};
DateTimeAxis dateTimeAxis = new DateTimeAxis();
dateTimeAxis.LabelStyle.LabelFormat = "dd-MMM";
dateTimeAxis.LabelRotationAngle = 90;
dateTimeAxis.RangePadding = DateTimeRangePadding.Additional;
NumericalAxis secondaryAxis = new NumericalAxis()
{
RangePadding = NumericalPadding.Additional,
};
chart.PrimaryAxis = dateTimeAxis;
chart.SecondaryAxis = secondaryAxis;
LineSeries lineSeries = new LineSeries()
{
ItemsSource = viewModel.DateData,
XBindingPath = "Date",
YBindingPath = "YValue",
};
lineSeries.DataMarker = new ChartDataMarker()
{
ShowLabel = true,
ShowMarker = true,
UseSeriesPalette = true,
MarkerType = DataMarkerType.Ellipse,
MarkerHeight = 10,
MarkerWidth = 10,
LabelStyle = new DataMarkerLabelStyle()
{
BackgroundColor = Color.Transparent,
TextColor = Color.Black,
LabelPosition = DataMarkerLabelPosition.Auto, //This is default value
},
};
chart.Series.Add(lineSeries);
… |