private RadCartesianChartView createChart(){ //Create the Chart View RadCartesianChartView chart = new RadCartesianChartView(this.Activity); //Create the bar series and attach axes and value bindings. ScatterBubbleSeries scatterBubbleSeries = new ScatterBubbleSeries(); scatterBubbleSeries.BubbleScale = 1000; scatterBubbleSeries.XValueBinding = new XValueBinding(); scatterBubbleSeries.YValueBinding = new YValueBinding(); scatterBubbleSeries.BubbleSizeBinding = new AreaValueBinding(); LinearAxis verticalAxis = new LinearAxis(); //The values in the linear axis will not have values after the decimal point. verticalAxis.LabelFormat = "%.2f"; LinearAxis horizontalAxis = new LinearAxis(); horizontalAxis.LabelFormat = "%.2f"; scatterBubbleSeries.VerticalAxis = verticalAxis; scatterBubbleSeries.HorizontalAxis = horizontalAxis; //Bind series to data scatterBubbleSeries.Data = this.getData(); //Add series to chart chart.Series.Add(scatterBubbleSeries); ChartTooltipBehavior ttBehavior = new ChartTooltipBehavior(this.Activity); ttBehavior.TriggerMode = TooltipTriggerMode.Tap; chart.Behaviors.Add(ttBehavior); return chart; }
public override View GetSampleContent(Context context) { chart = new SfChart(context); chart.Title.Text = "Food Comparison Chart"; chart.Title.TextSize = 15; chart.SetBackgroundColor(Color.White); chart.Legend.Visibility = Visibility.Visible; chart.Legend.DockPosition = ChartDock.Bottom; chart.Legend.IconHeight = 14; chart.Legend.IconWidth = 14; chart.Legend.ToggleSeriesVisibility = true; chart.Legend.OverflowMode = ChartLegendOverflowMode.Wrap; PyramidSeries pyramid = new PyramidSeries(); pyramid.XBindingPath = "XValue"; pyramid.YBindingPath = "YValue"; pyramid.ItemsSource = MainPage.GetPyramidData(); pyramid.ColorModel.ColorPalette = ChartColorPalette.Natural; pyramid.TooltipEnabled = true; pyramid.StrokeWidth = 1; pyramid.StrokeColor = Color.White; chart.Series.Add(pyramid); ChartTooltipBehavior tooltipBehavior = new ChartTooltipBehavior(); tooltipBehavior.LabelFormat = "##.## cal"; chart.Behaviors.Add(tooltipBehavior); Spinner selectLabelMode = new Spinner(context, SpinnerMode.Dialog); overflowMode = new List <String>() { "Wrap", "Scroll" }; ArrayAdapter <String> dataAdapter = new ArrayAdapter <String> (context, Android.Resource.Layout.SimpleSpinnerItem, overflowMode); dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line); selectLabelMode.Adapter = dataAdapter; selectLabelMode.ItemSelected += SelectLabelMode_ItemSelected; LinearLayout linearLayout = new LinearLayout(context); linearLayout.SetPadding(20, 0, 20, 30); linearLayout.SetBackgroundColor(Color.Rgb(236, 235, 242)); linearLayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); linearLayout.Orientation = Orientation.Vertical; linearLayout.SetBackgroundColor(Color.White); linearLayout.AddView(selectLabelMode); linearLayout.AddView(chart); return(linearLayout); }
private RadCartesianChartView createChart() { //Create the Chart View RadCartesianChartView chart = new RadCartesianChartView(this.Activity); //Create the bar series and attach axes and value bindings. ScatterBubbleSeries scatterBubbleSeries = new ScatterBubbleSeries(); scatterBubbleSeries.BubbleScale = 1000; scatterBubbleSeries.XValueBinding = new XValueBinding(); scatterBubbleSeries.YValueBinding = new YValueBinding(); scatterBubbleSeries.BubbleSizeBinding = new AreaValueBinding(); LinearAxis verticalAxis = new LinearAxis(); //The values in the linear axis will not have values after the decimal point. verticalAxis.LabelFormat = "%.2f"; LinearAxis horizontalAxis = new LinearAxis(); horizontalAxis.LabelFormat = "%.2f"; scatterBubbleSeries.VerticalAxis = verticalAxis; scatterBubbleSeries.HorizontalAxis = horizontalAxis; //Bind series to data scatterBubbleSeries.Data = this.getData(); //Add series to chart chart.Series.Add(scatterBubbleSeries); ChartTooltipBehavior ttBehavior = new ChartTooltipBehavior(this.Activity); ttBehavior.TriggerMode = TooltipTriggerMode.Tap; chart.Behaviors.Add(ttBehavior); return(chart); }
public override View GetSampleContent(Context context) { var chart = new SfChart(context); chart.SetBackgroundColor(Color.White); chart.Title.Text = "Weather Report"; chart.Title.TextSize = 15; NumericalStripLine numericalStripLines1 = new NumericalStripLine(); numericalStripLines1.Start = 10; numericalStripLines1.Width = 10; numericalStripLines1.Text = "Low Temperature"; numericalStripLines1.LabelStyle.TextSize = 12; numericalStripLines1.FillColor = Color.ParseColor("#f9d423"); NumericalStripLine numericalStripLines2 = new NumericalStripLine(); numericalStripLines2.Start = 20; numericalStripLines2.Width = 10; numericalStripLines2.Text = "Average Temperature"; numericalStripLines2.LabelStyle.TextSize = 12; numericalStripLines2.FillColor = Color.ParseColor("#fc902a"); NumericalStripLine numericalStripLines3 = new NumericalStripLine(); numericalStripLines3.Start = 30; numericalStripLines3.Width = 10; numericalStripLines3.Text = "High Temperature"; numericalStripLines3.LabelStyle.TextSize = 12; numericalStripLines3.FillColor = Color.ParseColor("#ff512f"); NumericalAxis numericalAxis = new NumericalAxis(); numericalAxis.Minimum = 10; numericalAxis.Maximum = 40; numericalAxis.LabelStyle.LabelFormat = "##.##°C"; numericalAxis.StripLines.Add(numericalStripLines1); numericalAxis.StripLines.Add(numericalStripLines2); numericalAxis.StripLines.Add(numericalStripLines3); chart.PrimaryAxis = new CategoryAxis(); (chart.PrimaryAxis as CategoryAxis).LabelPlacement = LabelPlacement.BetweenTicks; chart.SecondaryAxis = numericalAxis; var lineSeries = new LineSeries { StrokeWidth = 2, ItemsSource = MainPage.GetStripLineData(), XBindingPath = "XValue", YBindingPath = "YValue", Color = Color.White }; chart.Series.Add(lineSeries); ChartTooltipBehavior toolTip = new ChartTooltipBehavior(); toolTip.TextColor = Color.Black; chart.Behaviors.Add(toolTip); lineSeries.DataMarker.ShowLabel = false; lineSeries.DataMarker.ShowMarker = true; lineSeries.DataMarker.MarkerWidth = 10; lineSeries.DataMarker.MarkerHeight = 10; lineSeries.DataMarker.MarkerColor = Color.ParseColor("#666666"); lineSeries.DataMarker.MarkerStrokeColor = Color.ParseColor("#ffffff"); lineSeries.DataMarker.MarkerStrokeWidth = 4; lineSeries.TooltipEnabled = true; return(chart); }
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; }