コード例 #1
0
        public override View GetSampleContent(Context context)
        {
            chart = new SfChart(context);;
            chart.SetBackgroundColor(Color.White);

            chart.PrimaryAxis = new CategoryAxis()
            {
                EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift
            };
            chart.SecondaryAxis = new NumericalAxis {
                Minimum = 0, Maximum = 170
            };

            var stackingAreaSeries = new StackingAreaSeries
            {
                StrokeWidth = 5,
                Alpha       = 0.5f,
                Color       = MainPage.ConvertHexaToColor(0x90FEBE17),
                StrokeColor = MainPage.ConvertHexaToColor(0xFFFEBE17),
                DataSource  = MainPage.GetData1(),
            };

            chart.Series.Add(stackingAreaSeries);

            stackingAreaSeries = new StackingAreaSeries
            {
                StrokeWidth = 5,
                Alpha       = 0.5f,
                Color       = MainPage.ConvertHexaToColor(0x994F4838),
                StrokeColor = MainPage.ConvertHexaToColor(0xFF4F4838),
            };
            chart.Series.Add(stackingAreaSeries);

            stackingAreaSeries = new StackingAreaSeries
            {
                StrokeWidth = 5,
                Alpha       = 0.5f,
                Color       = MainPage.ConvertHexaToColor(0x99C15146),
                StrokeColor = MainPage.ConvertHexaToColor(0xFFC15146),
            };
            chart.Series.Add(stackingAreaSeries);
            UpdateData();
            return(chart);
        }
コード例 #2
0
        public override View GetSampleContent(Context context)
        {
            chart = new SfChart(context);;
            chart.SetBackgroundColor(Color.White);

            chart.PrimaryAxis = new CategoryAxis() { EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift};
            chart.SecondaryAxis = new NumericalAxis {Minimum = 0, Maximum = 170};

            var stackingAreaSeries = new StackingAreaSeries
            {
                StrokeWidth = 5,
                Alpha = 0.5f,
                Color = MainPage.ConvertHexaToColor(0x90FEBE17),
                StrokeColor = MainPage.ConvertHexaToColor(0xFFFEBE17),
                DataSource = MainPage.GetData1(),

            };
            chart.Series.Add(stackingAreaSeries);

            stackingAreaSeries = new StackingAreaSeries
            {
                StrokeWidth = 5,
                Alpha = 0.5f,
                Color = MainPage.ConvertHexaToColor(0x994F4838),
                StrokeColor = MainPage.ConvertHexaToColor(0xFF4F4838),
            };
            chart.Series.Add(stackingAreaSeries);

            stackingAreaSeries = new StackingAreaSeries
            {
                StrokeWidth = 5,
                Alpha = 0.5f,
                Color = MainPage.ConvertHexaToColor(0x99C15146),
                StrokeColor = MainPage.ConvertHexaToColor(0xFFC15146),
            };
            chart.Series.Add(stackingAreaSeries);
            UpdateData();
            return chart;
        }
コード例 #3
0
ファイル: StackingArea.cs プロジェクト: chinochuy/Xamarin
        public override View GetSampleContent(Context context)
        {
            chart                = new SfChart(context);;
            chart.Title.Text     = "Industrial Production Growth";
            chart.Title.TextSize = 15;
            chart.SetBackgroundColor(Color.White);
            chart.Legend.Visibility             = Visibility.Visible;
            chart.Legend.ToggleSeriesVisibility = true;
            chart.Legend.DockPosition           = ChartDock.Bottom;
            chart.Legend.IconHeight             = 14;
            chart.Legend.IconWidth        = 14;
            chart.ColorModel.ColorPalette = ChartColorPalette.Natural;

            CategoryAxis PrimaryAxis = new CategoryAxis();

            PrimaryAxis.Title.Text            = "Year";
            PrimaryAxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift;
            PrimaryAxis.ShowMajorGridLines    = false;
            chart.PrimaryAxis = PrimaryAxis;

            NumericalAxis numericalAxis = new NumericalAxis();

            numericalAxis.Title.Text = "Production (%)";
            numericalAxis.Minimum    = 0;
            numericalAxis.Maximum    = 30;
            numericalAxis.Interval   = 5;
            chart.SecondaryAxis      = numericalAxis;

            StackingAreaSeries stackingAreaSeries = new StackingAreaSeries();

            stackingAreaSeries.EnableAnimation = true;
            stackingAreaSeries.ItemsSource     = MainPage.GetStackedAreaData1();
            stackingAreaSeries.XBindingPath    = "XValue";
            stackingAreaSeries.YBindingPath    = "YValue";
            stackingAreaSeries.Label           = "US";
            chart.Series.Add(stackingAreaSeries);

            StackingAreaSeries stackingAreaSeries1 = new StackingAreaSeries();

            stackingAreaSeries1.EnableAnimation = true;
            stackingAreaSeries1.ItemsSource     = MainPage.GetStackedAreaData2();
            stackingAreaSeries1.XBindingPath    = "XValue";
            stackingAreaSeries1.YBindingPath    = "YValue";
            stackingAreaSeries1.Label           = "Indonesia";
            chart.Series.Add(stackingAreaSeries1);

            StackingAreaSeries stackingAreaSeries2 = new StackingAreaSeries();

            stackingAreaSeries2.EnableAnimation = true;
            stackingAreaSeries2.ItemsSource     = MainPage.GetStackedAreaData3();
            stackingAreaSeries2.XBindingPath    = "XValue";
            stackingAreaSeries2.YBindingPath    = "YValue";
            stackingAreaSeries2.Label           = "Russia";
            chart.Series.Add(stackingAreaSeries2);

            StackingAreaSeries stackingAreaSeries3 = new StackingAreaSeries();

            stackingAreaSeries3.EnableAnimation = true;
            stackingAreaSeries3.ItemsSource     = MainPage.GetStackedAreaData4();
            stackingAreaSeries3.XBindingPath    = "XValue";
            stackingAreaSeries3.YBindingPath    = "YValue";
            stackingAreaSeries3.Label           = "Bangladesh";
            chart.Series.Add(stackingAreaSeries3);

            stackingAreaSeries.TooltipEnabled  = true;
            stackingAreaSeries1.TooltipEnabled = true;
            stackingAreaSeries2.TooltipEnabled = true;
            stackingAreaSeries3.TooltipEnabled = true;

            stackingAreaSeries.EnableAnimation  = true;
            stackingAreaSeries1.EnableAnimation = true;
            stackingAreaSeries2.EnableAnimation = true;
            stackingAreaSeries3.EnableAnimation = true;

            return(chart);
        }
コード例 #4
0
        public override View GetSampleContent(Context context)
        {
            chart                = new SfChart(context);
            chart.Title.Text     = "Trend in Sales of Ethical Produce";
            chart.Title.TextSize = 15;
            chart.SetBackgroundColor(Color.White);
            chart.Legend.Visibility             = Visibility.Visible;
            chart.Legend.ToggleSeriesVisibility = true;
            chart.Legend.DockPosition           = ChartDock.Bottom;
            chart.Legend.IconHeight             = 14;
            chart.Legend.IconWidth        = 14;
            chart.ColorModel.ColorPalette = ChartColorPalette.Natural;

            CategoryAxis primaryAxis = new CategoryAxis();

            primaryAxis.Interval = 2;
            primaryAxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift;
            primaryAxis.ShowMajorGridLines    = false;
            chart.PrimaryAxis = primaryAxis;

            NumericalAxis numericalAxis = new NumericalAxis();

            numericalAxis.Minimum                 = 0;
            numericalAxis.Maximum                 = 7;
            numericalAxis.Interval                = 1;
            numericalAxis.Title.Text              = "Spends";
            numericalAxis.LineStyle.StrokeWidth   = 0;
            numericalAxis.MajorTickStyle.TickSize = 0;
            numericalAxis.LabelStyle.LabelFormat  = "##.##B ";
            chart.SecondaryAxis = numericalAxis;

            StackingAreaSeries stackingAreaSeries = new StackingAreaSeries();

            stackingAreaSeries.EnableAnimation = true;
            stackingAreaSeries.ItemsSource     = MainPage.GetStackedAreaData1();
            stackingAreaSeries.XBindingPath    = "XValue";
            stackingAreaSeries.YBindingPath    = "YValue";
            stackingAreaSeries.Label           = "Organic";
            stackingAreaSeries.LegendIcon      = ChartLegendIcon.SeriesType;
            chart.Series.Add(stackingAreaSeries);

            StackingAreaSeries stackingAreaSeries1 = new StackingAreaSeries();

            stackingAreaSeries1.EnableAnimation = true;
            stackingAreaSeries1.ItemsSource     = MainPage.GetStackedAreaData2();
            stackingAreaSeries1.XBindingPath    = "XValue";
            stackingAreaSeries1.YBindingPath    = "YValue";
            stackingAreaSeries1.Label           = "Fair-trade";
            stackingAreaSeries1.LegendIcon      = ChartLegendIcon.SeriesType;
            chart.Series.Add(stackingAreaSeries1);

            StackingAreaSeries stackingAreaSeries2 = new StackingAreaSeries();

            stackingAreaSeries2.EnableAnimation = true;
            stackingAreaSeries2.ItemsSource     = MainPage.GetStackedAreaData3();
            stackingAreaSeries2.XBindingPath    = "XValue";
            stackingAreaSeries2.YBindingPath    = "YValue";
            stackingAreaSeries2.Label           = "Veg Alternatives";
            stackingAreaSeries2.LegendIcon      = ChartLegendIcon.SeriesType;
            chart.Series.Add(stackingAreaSeries2);

            StackingAreaSeries stackingAreaSeries3 = new StackingAreaSeries();

            stackingAreaSeries3.EnableAnimation = true;
            stackingAreaSeries3.ItemsSource     = MainPage.GetStackedAreaData4();
            stackingAreaSeries3.XBindingPath    = "XValue";
            stackingAreaSeries3.YBindingPath    = "YValue";
            stackingAreaSeries3.Label           = "Others";
            stackingAreaSeries3.LegendIcon      = ChartLegendIcon.SeriesType;
            chart.Series.Add(stackingAreaSeries3);

            stackingAreaSeries.TooltipEnabled  = true;
            stackingAreaSeries1.TooltipEnabled = true;
            stackingAreaSeries2.TooltipEnabled = true;
            stackingAreaSeries3.TooltipEnabled = true;

            stackingAreaSeries.EnableAnimation  = true;
            stackingAreaSeries1.EnableAnimation = true;
            stackingAreaSeries2.EnableAnimation = true;
            stackingAreaSeries3.EnableAnimation = true;

            return(chart);
        }
コード例 #5
0
        public async void InitGraph()
        {
            var idLogin = await BlobCache.LocalMachine.GetObject <string>("loginCookie");

            string    graphId      = null;
            GraphItem graphContent = null;


            //Set the cookiee manually (propertie 'UseCookies = false')
            //Or use cookieContainer
            using (var client = new HttpClient(new HttpClientHandler {
                UseCookies = false
            }))
            {
                client.DefaultRequestHeaders.Add("Cookie", idLogin);
                var dashboardUrl = new Uri("http://app.casterstats.com/dashboard");
                var resp         = await client.GetAsync(dashboardUrl);

                string content = await resp.Content.ReadAsStringAsync();


                List <Dashboard> dashboards = JsonConvert.DeserializeObject <List <Dashboard> >(content);
                foreach (var dashboard in dashboards)
                {
                    graphId = dashboard.DashboardComponents.FirstOrDefault(x => x.Name.Equals("Graph")).Id;
                }

                if (graphId != null)
                {
                    dashboardUrl = new Uri("http://app.casterstats.com/dashboard/component/graph/" + graphId + "");
                    resp         = await client.GetAsync(dashboardUrl);

                    content = await resp.Content.ReadAsStringAsync();



                    graphContent = JsonConvert.DeserializeObject <GraphItem>(content);
                }
            }
            //Display content
            SfChart chart = new SfChart();

            DateTimeAxis timeAxis = new DateTimeAxis()
            {
                Interval     = 30,
                IntervalType = DateTimeIntervalType.Minutes
            };

            timeAxis.LabelStyle.LabelFormat = "HH:mm";
            chart.PrimaryAxis = timeAxis;


            NumericalAxis userAxis = new NumericalAxis();

            userAxis.Title.Text = "Users";
            chart.SecondaryAxis = userAxis;

            if (graphContent != null)
            {
                //if (graphContent.NbUsers == null &&  graphContent.HStream == null)
                //{
                //    graphContent.NbUsers = new List<int>();
                //    graphContent.HStream = new List<DateTime>();
                //}
                //;

                var nbStream = graphContent.GraphDatas[0].Count;
                nbStream = nbStream - 1;
                var idUser = 1;
                var idDate = 0;


                for (var s = 0; s < nbStream; s++)
                {
                    var data      = new GraphStackAreaViewModel();
                    var graphData = 0;
                    foreach (var t in graphContent.GraphDatas)
                    {
                        if (t[idDate] == null || t[idUser] == null)
                        {
                            continue;
                        }

                        data.Nusers.Add(int.Parse(t[idUser]));

                        var dt = DateTime.Parse(t[idDate]);
                        data.HmStream.Add(dt);
                        graphData++;
                    }
                    if (graphData > 0)
                    {
                        var splineArea = new StackingAreaSeries
                        {
                            BindingContext = graphData,
                            ItemsSource    = data.GetGraphData(),
                            Label          = graphContent.Streams[idUser - 1],
                            XBindingPath   = "HStream",
                            YBindingPath   = "NbUsers",
                            EnableTooltip  = true
                        };

                        chart.Series.Add(splineArea);
                        chart.Legend = new ChartLegend();
                        var tool = new ChartTooltipBehavior
                        {
                            BackgroundColor = Color.White,
                            TextColor       = Color.Black,
                            Duration        = 5
                        };
                        chart.ChartBehaviors.Add(tool);
                    }
                    idUser++;
                }
            }

            //var chart = new RadCartesianChart
            //{
            //    HorizontalAxis = new DateTimeContinuousAxis
            //    {
            //        LabelFormat = "HH:mm",
            //        LabelFitMode = AxisLabelFitMode.MultiLine,
            //        MajorStepUnit = TimeInterval.Minute,
            //        MajorStep = 30
            //    },
            //    VerticalAxis = new NumericalAxis(),
            //    BindingContext = new GraphSplineAreaViewModel()
            //};

            //var series = new SplineAreaSeries();
            //series.SetBinding(ChartSeries.ItemsSourceProperty, new Binding("GraphData"));
            //series.ValueBinding = new PropertyNameDataPointBinding("NbUsers");
            //series.CategoryBinding = new PropertyNameDataPointBinding("HStream");

            //chart.Series.Add(series);


            //this.Content = chart;


            this.Content = chart;
        }