Пример #1
0
        public BarSeriesHorizontal()
        {
            InitializeComponent();

            var model = new MainViewModel();

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

            var grid = new CartesianChartGrid();

            var chart = new Telerik.XamarinForms.Chart.RadCartesianChart
            {
                VerticalAxis   = new Telerik.XamarinForms.Chart.CategoricalAxis(),
                HorizontalAxis = new Telerik.XamarinForms.Chart.NumericalAxis(),
                HeightRequest  = 400,
                Grid           = grid,
            };

            grid.MajorLinesVisibility = GridLineVisibility.XY;
            grid.MajorXLineDashArray  = Device.OnPlatform(null, new double[] { 4, 2 }, new double[] { 4, 2 });
            grid.StripLinesVisibility = GridLineVisibility.X;

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


            grid.MajorLinesVisibility = GridLineVisibility.XY;

            //grid.MajorYLineDashArray = new double[] { 10, 10 };
            //grid.MajorXLineDashArray = new double[] { 5, 15 };
            grid.StripLinesVisibility = GridLineVisibility.None;
            //grid.XStripeColor = Color.FromRgba(255, 0, 0, 50);
            //grid.XStripeAlternativeColor = Color.FromRgba(0, 255, 0, 50);

            //grid.YStripeColor = Color.FromRgba(255, 0, 0, 50);
            //grid.YStripeAlternativeColor = Color.FromRgba(0, 255, 0, 50);
            grid.MajorLineColor     = Color.Gray;
            grid.MajorLineThickness = 0.5;

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


            this.Content = chart;
        }
        public BarSeriesPage()
        {
            InitializeComponent();

            var model = new MainViewModel();

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

            var grid = new CartesianChartGrid();

            var chart = new Telerik.XamarinForms.Chart.RadCartesianChart
            {
                VerticalAxis = new Telerik.XamarinForms.Chart.NumericalAxis()
                {
                    LabelFitMode = AxisLabelFitMode.MultiLine,
                },
                HorizontalAxis = new Telerik.XamarinForms.Chart.CategoricalAxis()
                {
                    LabelFitMode = AxisLabelFitMode.MultiLine,
                },
                Grid = grid,
            };

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

            grid.YStripeColor = Color.Transparent;

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

            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"
            };


            //series.Stroke = Color.Gray;
            //series.StrokeThickness = 4;

            chart.Series.Add(series);

            this.Content = chart;
        }
        public ChartGridLinesPage()
        {
            InitializeComponent();

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

            var grid = new CartesianChartGrid();

            var chart = new Telerik.XamarinForms.Chart.RadCartesianChart
            {
                HorizontalAxis = new Telerik.XamarinForms.Chart.CategoricalAxis() 
                {
                    LabelFitMode = AxisLabelFitMode.MultiLine
                },
                VerticalAxis = new Telerik.XamarinForms.Chart.NumericalAxis(),
                HeightRequest = 400,
                Grid = grid,
            };

            chart.HorizontalAxis.LabelFitMode = AxisLabelFitMode.MultiLine;
            grid.MajorLinesVisibility = GridLineVisibility.XY;

            //grid.MajorYLineDashArray = new double[] { 10, 10 };
            //grid.MajorXLineDashArray = new double[] { 5, 15 };
            grid.StripLinesVisibility = GridLineVisibility.None;
            //grid.XStripeColor = Color.FromRgba(255, 0, 0, 50);
            //grid.XStripeAlternativeColor = Color.FromRgba(0, 255, 0, 50);

            //grid.YStripeColor = Color.FromRgba(255, 0, 0, 50);
            //grid.YStripeAlternativeColor = Color.FromRgba(0, 255, 0, 50);
            grid.MajorLineColor = Color.Gray;
            grid.MajorLineThickness = 1;

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


            this.Content = chart;
        }
        public StackBarHorizontal()
        {
            InitializeComponent();

            var model = new MainViewModel();

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

            var grid = new CartesianChartGrid();

            var chart = new Telerik.XamarinForms.Chart.RadCartesianChart
            {
                HorizontalAxis = new Telerik.XamarinForms.Chart.NumericalAxis(),
                VerticalAxis   = new Telerik.XamarinForms.Chart.CategoricalAxis(),
                Grid           = grid,
            };

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

            grid.XStripeColor = Color.Transparent;

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


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

            series.CombineMode = Telerik.XamarinForms.Chart.ChartSeriesCombineMode.Stack;
            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 series2 = new Telerik.XamarinForms.Chart.BarSeries();

            series2.CombineMode = Telerik.XamarinForms.Chart.ChartSeriesCombineMode.Stack;
            series2.ItemsSource = model.Data2;

            series2.ValueBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
            {
                PropertyName = "Value"
            };

            series2.CategoryBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
            {
                PropertyName = "Category"
            };

            chart.Series.Add(series2);

            this.Content = chart;
        }
        public SelectionSeriesPage()
        {
            InitializeComponent();

            var model = new MainViewModel();

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

            var grid = new CartesianChartGrid();

            var chart = new Telerik.XamarinForms.Chart.RadCartesianChart
            {
                VerticalAxis   = new Telerik.XamarinForms.Chart.NumericalAxis(),
                HorizontalAxis = new Telerik.XamarinForms.Chart.CategoricalAxis()
                {
                    LabelFitMode = Telerik.XamarinForms.Chart.AxisLabelFitMode.MultiLine
                },
                Grid          = grid,
                HeightRequest = 400
            };

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

            grid.YStripeColor = Color.Transparent;

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


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

            series.StackGroupKey = 1;
            series.CombineMode   = Telerik.XamarinForms.Chart.ChartSeriesCombineMode.Stack;
            series.ItemsSource   = model.Data1;

            series.ValueBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
            {
                PropertyName = "Value"
            };

            series.CategoryBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
            {
                PropertyName = "Category"
            };
            series.AllowSelect = true;

            chart.Series.Add(series);

            var series2 = new Telerik.XamarinForms.Chart.BarSeries();

            series2.StackGroupKey = 1;
            series2.CombineMode   = Telerik.XamarinForms.Chart.ChartSeriesCombineMode.Stack;
            series2.ItemsSource   = model.Data2;

            series2.ValueBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
            {
                PropertyName = "Value"
            };

            series2.CategoryBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding
            {
                PropertyName = "Category"
            };
            series2.AllowSelect = true;

            chart.PaletteName          = PaletteNames.Light;
            chart.SelectionPaletteName = PaletteNames.LightSelected;

            chart.Series.Add(series2);
            beh = new Telerik.XamarinForms.Chart.ChartSelectionBehavior
            {
                DataPointSelectionMode = Telerik.XamarinForms.Chart.ChartSelectionMode.Single,
                SeriesSelectionMode    = ChartSelectionMode.None
            };
            chart.Behaviors.Add(beh);

            this.Content = chart;
        }
Пример #6
0
        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;
        }