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;
        }
Example #2
0
        public AreaSeriesPage()
        {
            InitializeComponent();

            var grid = new CartesianChartGrid();

            var model = new MainViewModel();
            model.Data1 = MainViewModel.GetCategoricalData();
            model.Data2 = MainViewModel.GetCategoricalData();

            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(),
                Grid = grid,
            };

            grid.MajorLinesVisibility = GridLineVisibility.Y;
            grid.MajorYLineDashArray = Device.OnPlatform(null, new double[] { 4, 2 }, new double[] { 4, 2 });


            grid.MajorLineColor = Color.FromHex("D3D3D3");
            grid.MajorLineThickness = Device.OnPlatform(0.5, 2, 2);

            var series = new Telerik.XamarinForms.Chart.AreaSeries();

            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);


            this.Content = chart;


        }