private RadCartesianChartView createChart() { //Create the Chart View RadCartesianChartView chart = new RadCartesianChartView(this.Activity); //Create the bar series and attach axes and value bindings. BarSeries barSeries = new BarSeries(); barSeries.ValueBinding = new ValueBinding(); barSeries.CategoryBinding = new CategoryBinding(); LinearAxis verticalAxis = new LinearAxis(); //The values in the linear axis will not have values after the decimal point. verticalAxis.LabelFormat = "%.0f"; CategoricalAxis horizontalAxis = new CategoricalAxis(); barSeries.VerticalAxis = verticalAxis; barSeries.HorizontalAxis = horizontalAxis; //Bind series to data barSeries.Data = this.getData(); //Add series to chart chart.Series.Add(barSeries); CartesianPlotBandAnnotation annotation = new CartesianPlotBandAnnotation(verticalAxis, 6, 8); chart.Annotations.Add(annotation); annotation.FillColor = Color.Argb(150, 0, 148, 255); annotation.StrokeColor = Color.Argb(150, 0, 74, 127); annotation.StrokeColor = 4; annotation.ZIndex = 1001; return chart; }
public PlotBandAnnotationsPage() { InitializeComponent(); var model = new MainViewModel(); var data = MainViewModel.GetCategoricalData(); model.Data1 = data; var startTreshold = data.Average(c => c.Value) * 0.9; var endTreshold = data.Average(c => c.Value) * 1.1; var chart = new Telerik.XamarinForms.Chart.RadCartesianChart { HorizontalAxis = new Telerik.XamarinForms.Chart.CategoricalAxis() { LabelFitMode = Telerik.XamarinForms.Chart.AxisLabelFitMode.MultiLine, PlotMode = Telerik.XamarinForms.Chart.AxisPlotMode.OnTicks }, VerticalAxis = new Telerik.XamarinForms.Chart.NumericalAxis(), HeightRequest = 400 }; var series = new Telerik.XamarinForms.Chart.AreaSeries(); series.ItemsSource = model.Data1; series.ValueBinding = new PropertyNameDataPointBinding { PropertyName = "Value" }; series.CategoryBinding = new PropertyNameDataPointBinding { PropertyName = "Category" }; chart.Series.Add(series); var annotation = new CartesianPlotBandAnnotation() { Axis = chart.VerticalAxis, From = startTreshold, To = endTreshold, Stroke = Color.Green, Fill = Color.FromHex("2F66FF33"), StrokeThickness = 2 }; chart.Annotations.Add(annotation); this.Content = chart; }
private RadCartesianChartView createChart() { //Create the Chart View RadCartesianChartView chart = new RadCartesianChartView(this.Activity); //Create the bar series and attach axes and value bindings. BarSeries barSeries = new BarSeries(); barSeries.ValueBinding = new ValueBinding(); barSeries.CategoryBinding = new CategoryBinding(); LinearAxis verticalAxis = new LinearAxis(); //The values in the linear axis will not have values after the decimal point. verticalAxis.LabelFormat = "%.0f"; CategoricalAxis horizontalAxis = new CategoricalAxis(); barSeries.VerticalAxis = verticalAxis; barSeries.HorizontalAxis = horizontalAxis; //Bind series to data barSeries.Data = this.getData(); //Add series to chart chart.Series.Add(barSeries); CartesianPlotBandAnnotation annotation = new CartesianPlotBandAnnotation(verticalAxis, 6, 8); chart.Annotations.Add(annotation); annotation.FillColor = Color.Argb(150, 0, 148, 255); annotation.StrokeColor = Color.Argb(150, 0, 74, 127); annotation.StrokeColor = 4; annotation.ZIndex = 1001; return(chart); }
/// <summary> /// Initializes a new instance of the <see cref="CartesianPlotBandAnnotationAutomationPeer"/> class. /// </summary> public CartesianPlotBandAnnotationAutomationPeer(CartesianPlotBandAnnotation owner) : base(owner) { }
public MainPage() { InitializeComponent(); BackgroundColor = Xamarin.Forms.Device.OnPlatform(Xamarin.Forms.Color.White, Xamarin.Forms.Color.White, Xamarin.Forms.Color.Transparent); var chart = new RadCartesianChart { HorizontalAxis = new Telerik.XamarinForms.Chart.CategoricalAxis() { LabelFitMode = AxisLabelFitMode.MultiLine, }, VerticalAxis = new Telerik.XamarinForms.Chart.NumericalAxis() { LabelFitMode = AxisLabelFitMode.MultiLine, RangeExtendDirection = NumericalAxisRangeExtendDirection.Both, MajorStep = 30, }, }; var series = new BarSeries(); chart.Series.Add(series); this.Content = chart; series.ValueBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding { PropertyName = "Value" }; series.CategoryBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding { PropertyName = "Category" }; series.ItemsSource = MainViewModel.GetCategoricalData(); var grid = new CartesianChartGrid(); grid.MajorLinesVisibility = GridLineVisibility.Y; grid.MajorYLineDashArray = Device.OnPlatform(null, new double[] { 4, 2 }, new double[] { 4, 2 }); grid.StripLinesVisibility = GridLineVisibility.Y; grid.YStripeColor = Color.FromRgba(99, 99, 99, 100); grid.YStripeAlternativeColor = Color.FromRgba(169, 169, 169, 31); grid.MajorLineColor = Color.FromRgb(211, 211, 211); grid.MajorLineThickness = Device.OnPlatform(0.5, 2, 2); chart.Grid = grid; var treshold = MainViewModel.GetCategoricalData().Average(c => c.Value); var startTreshold = treshold * 0.95; var endTreshold = treshold * 1.05; var lineAnnotation = new CartesianGridLineAnnotation() { Axis = chart.VerticalAxis, Value = treshold, Stroke = Color.FromRgb(255, 0, 0), StrokeThickness = Device.OnPlatform(0.5, 2, 2), DashArray = new double[] { 4, 2 }, }; var bandAnnotation = new CartesianPlotBandAnnotation() { Axis = chart.VerticalAxis, From = startTreshold, To = endTreshold, Fill = Color.FromRgba(255, 0, 0, 50), StrokeThickness = 2, Stroke = Color.Transparent, }; chart.Annotations.Add(bandAnnotation); chart.Annotations.Add(lineAnnotation); }
public MainPage() { InitializeComponent(); BackgroundColor = Xamarin.Forms.Device.OnPlatform(Xamarin.Forms.Color.White, Xamarin.Forms.Color.White, Xamarin.Forms.Color.Transparent); var chart = new RadCartesianChart { HorizontalAxis = new Telerik.XamarinForms.Chart.CategoricalAxis() { LabelFitMode = AxisLabelFitMode.MultiLine, }, VerticalAxis = new Telerik.XamarinForms.Chart.NumericalAxis() { LabelFitMode = AxisLabelFitMode.MultiLine, RangeExtendDirection = NumericalAxisRangeExtendDirection.Both, MajorStep = 30, }, }; var series = new BarSeries(); chart.Series.Add(series); this.Content = chart; series.ValueBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding { PropertyName = "Value" }; series.CategoryBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding { PropertyName = "Category" }; series.ItemsSource = MainViewModel.GetCategoricalData(); var grid = new CartesianChartGrid(); grid.MajorLinesVisibility = GridLineVisibility.Y; grid.MajorYLineDashArray = Device.OnPlatform(null, new double[] { 4, 2 }, new double[] { 4, 2 }); grid.StripLinesVisibility = GridLineVisibility.Y; grid.YStripeColor = Color.FromRgba(99, 99, 99, 100); grid.YStripeAlternativeColor = Color.FromRgba(169, 169, 169, 31); grid.MajorLineColor = Color.FromRgb(211, 211, 211); grid.MajorLineThickness = Device.OnPlatform(0.5, 2, 2); chart.Grid = grid; var treshold = MainViewModel.GetCategoricalData().Average(c => c.Value); var startTreshold = treshold * 0.95; var endTreshold = treshold * 1.05; var lineAnnotation = new CartesianGridLineAnnotation() { Axis = chart.VerticalAxis, Value = treshold, Stroke = Color.FromRgb(255, 0, 0), StrokeThickness = Device.OnPlatform(0.5, 2, 2), DashArray = new double[] { 4, 2 }, }; var bandAnnotation = new CartesianPlotBandAnnotation() { Axis = chart.VerticalAxis, From = startTreshold, To = endTreshold, Fill = Color.FromRgba(255, 0, 0, 50), StrokeThickness = 2, Stroke = Color.Transparent, }; chart.Annotations.Add(bandAnnotation); chart.Annotations.Add(lineAnnotation); }
public GridLineAnnotationsPage() { InitializeComponent(); var model = new MainViewModel(); var data = MainViewModel.GetCategoricalData(); model.Data1 = data; var treshold = data.Average(c => c.Value); var startTreshold = treshold * 0.95; var endTreshold = treshold * 1.05; var chart = new Telerik.XamarinForms.Chart.RadCartesianChart { HorizontalAxis = new Telerik.XamarinForms.Chart.CategoricalAxis() { LabelFitMode = Telerik.XamarinForms.Chart.AxisLabelFitMode.MultiLine, }, VerticalAxis = new Telerik.XamarinForms.Chart.NumericalAxis(), HeightRequest = 400 }; var series = new Telerik.XamarinForms.Chart.BarSeries(); series.ItemsSource = model.Data1; series.ValueBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding { PropertyName = "Value" }; series.CategoryBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding { PropertyName = "Category" }; chart.Series.Add(series); var lineAnnotation = new CartesianGridLineAnnotation() { Axis = chart.VerticalAxis, Value = treshold, Stroke = Color.FromHex("0E72F6"), StrokeThickness = Device.OnPlatform(0.5, 2, 2), DashArray = new double[] { 4, 2 } }; var bandAnnotation = new CartesianPlotBandAnnotation() { Axis = chart.VerticalAxis, From = startTreshold, To = endTreshold, Fill = Color.FromHex("33A9A9A9"), StrokeThickness = 2, Stroke = Color.Transparent, }; chart.Annotations.Add(lineAnnotation); chart.Annotations.Add(bandAnnotation); this.Content = chart; }