Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
151242 | Feb 5,2020 02:26 AM UTC | Feb 6,2020 01:13 PM UTC | Xamarin.Forms | 3 |
![]() |
Tags: SfChart |
<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);
… |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.