public Sparkline_Phone() { InitializeComponent(); var dataModel = new SparkViewModel(); stack.BindingContext = dataModel; area = new SfAreaSparkline { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; area.ItemsSource = dataModel.Datas; area.YBindingPath = "Performance"; areaLabel = new Label { Text = "Area", FontSize = 14, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }; stack.Children.Add(area); stack.Children.Add(areaLabel); line = new SfLineSparkline { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; line.ItemsSource = dataModel.Datas; line.YBindingPath = "Performance"; lineLabel = new Label { Text = "Line", FontSize = 14, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }; stack.Children.Add(line); stack.Children.Add(lineLabel); column = new SfColumnSparkline { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; column.ItemsSource = dataModel.ColumnDatas; column.YBindingPath = "YearPerformance"; columnLabel = new Label { Text = "Column", FontSize = 14, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }; stack.Children.Add(column); stack.Children.Add(columnLabel); winLoss = new SfWinLossSparkline { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; winLoss.ItemsSource = dataModel.ColumnDatas; winLoss.YBindingPath = "YearPerformance"; winLossLabel = new Label { Text = "Win/Loss", FontSize = 14, HorizontalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold }; stack.Children.Add(winLoss); stack.Children.Add(winLossLabel); if (Device.RuntimePlatform == Device.iOS) { stack.SizeChanged += Layout_SizeChanged; } else { area.Margin = new Thickness(0, 5, 0, 5); line.Margin = new Thickness(0, 5, 0, 5); column.Margin = new Thickness(0, 5, 0, 5); winLoss.Margin = new Thickness(0, 5, 0, 5); } }
public override View GetSampleContent(Context context) { var AreaData = new List <SparklineModel> { new SparklineModel { Value = 0.8 }, new SparklineModel { Value = 1.8 }, new SparklineModel { Value = 1.3 }, new SparklineModel { Value = 1.1 }, new SparklineModel { Value = 1.6 }, new SparklineModel { Value = 2.0 }, new SparklineModel { Value = 1.7 }, new SparklineModel { Value = 2.3 }, new SparklineModel { Value = 2.7 }, new SparklineModel { Value = 2.3 }, new SparklineModel { Value = 1.9 }, new SparklineModel { Value = 1.4 }, new SparklineModel { Value = 1.2 }, new SparklineModel { Value = 0.8 }, }; var LineData = new List <SparklineModel> { new SparklineModel { Value = 1.1 }, new SparklineModel { Value = 0.9 }, new SparklineModel { Value = 1.1 }, new SparklineModel { Value = 1.3 }, new SparklineModel { Value = 1.1 }, new SparklineModel { Value = 1.8 }, new SparklineModel { Value = 2.1 }, new SparklineModel { Value = 2.3 }, new SparklineModel { Value = 1.7 }, new SparklineModel { Value = 1.5 }, new SparklineModel { Value = 2.5 }, new SparklineModel { Value = 1.9 }, new SparklineModel { Value = 1.3 }, new SparklineModel { Value = 0.9 }, }; var ColumnData = new List <SparklineModel> { new SparklineModel { Value = 34 }, new SparklineModel { Value = -12 }, new SparklineModel { Value = 43 }, new SparklineModel { Value = 66 }, new SparklineModel { Value = 26 }, new SparklineModel { Value = 10 } }; var WinLossData = new List <SparklineModel> { new SparklineModel { Value = 34 }, new SparklineModel { Value = 23 }, new SparklineModel { Value = -31 }, new SparklineModel { Value = 0 }, new SparklineModel { Value = 26 }, new SparklineModel { Value = 44 } }; float width = context.Resources.DisplayMetrics.WidthPixels; float height = context.Resources.DisplayMetrics.HeightPixels; LayoutInflater layoutInflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService); View view = layoutInflater.Inflate(Resource.Layout.SfSparkline, null); lineSparkLine = new SfLineSparkline(context); columnSparkLine = new SfColumnSparkline(context); areaSparLine = new SfAreaSparkline(context); winLossSparkLine = new SfWinLossSparkline(context); int layoutPadding = 30; int topPadding = 80; TextView lineSparkLineLabel = new TextView(context); lineSparkLineLabel.Text = "Line"; lineSparkLineLabel.SetPadding(0, topPadding, 0, 0); lineSparkLineLabel.Typeface = Typeface.Create((Typeface)null, TypefaceStyle.Bold); lineSparkLineLabel.Gravity = GravityFlags.Center; TextView columnSparkLineLabel = new TextView(context); columnSparkLineLabel.Text = "Column"; columnSparkLineLabel.SetPadding(0, topPadding, 0, 0); columnSparkLineLabel.Typeface = Typeface.Create((Typeface)null, TypefaceStyle.Bold); columnSparkLineLabel.Gravity = GravityFlags.Center; TextView areaSparLineLabel = new TextView(context); areaSparLineLabel.Text = "Area"; areaSparLineLabel.SetPadding(0, topPadding, 0, 0); areaSparLineLabel.Typeface = Typeface.Create((Typeface)null, TypefaceStyle.Bold); areaSparLineLabel.Gravity = GravityFlags.Center; TextView winLossSparkLineLabel = new TextView(context); winLossSparkLineLabel.Text = "WinLoss"; winLossSparkLineLabel.SetPadding(0, topPadding, 0, 0); winLossSparkLineLabel.Typeface = Typeface.Create((Typeface)null, TypefaceStyle.Bold); winLossSparkLineLabel.Gravity = GravityFlags.Center; RelativeLayout lineSparkLineLayout = view.FindViewById <RelativeLayout>(Resource.Id.lineSparkLineLayout); lineSparkLineLayout.SetPadding(0, layoutPadding, 0, 0); lineSparkLineLayout.SetGravity(GravityFlags.Center); var lineParams = new RelativeLayout.LayoutParams((int)width / 2, (int)height / 10); lineParams.AddRule(LayoutRules.AlignParentTop); lineSparkLine.LayoutParameters = lineParams; var lineLabelParams = new RelativeLayout.LayoutParams((int)width / 2, (int)height); lineLabelParams.AddRule(LayoutRules.AlignBaseline, lineSparkLine.Id); lineSparkLineLabel.LayoutParameters = lineLabelParams; lineSparkLineLayout.AddView(lineSparkLine, lineParams); lineSparkLineLayout.AddView(lineSparkLineLabel, lineLabelParams); RelativeLayout columnSparkLineLayout = view.FindViewById <RelativeLayout>(Resource.Id.columnSparkLineLayout); columnSparkLineLayout.SetPadding(0, layoutPadding, 0, 0); columnSparkLineLayout.SetGravity(GravityFlags.Center); var columnParams = new RelativeLayout.LayoutParams((int)width / 2, (int)height / 10); columnParams.AddRule(LayoutRules.AlignParentTop); columnSparkLine.LayoutParameters = columnParams; var columnLabelParams = new RelativeLayout.LayoutParams((int)width / 2, (int)height); columnLabelParams.AddRule(LayoutRules.Below, columnSparkLine.Id); columnSparkLineLabel.LayoutParameters = columnLabelParams; columnSparkLineLayout.AddView(columnSparkLine, columnParams); columnSparkLineLayout.AddView(columnSparkLineLabel, columnLabelParams); RelativeLayout areaSparLineLayout = view.FindViewById <RelativeLayout>(Resource.Id.areaSparLineLayout); areaSparLineLayout.SetPadding(0, layoutPadding, 0, 0); areaSparLineLayout.SetGravity(GravityFlags.Center); var areaParams = new RelativeLayout.LayoutParams((int)width / 2, (int)height / 10); areaParams.AddRule(LayoutRules.AlignParentTop); areaSparLine.LayoutParameters = areaParams; var areaLabelParams = new RelativeLayout.LayoutParams((int)width / 2, (int)height); areaLabelParams.AddRule(LayoutRules.Below, areaSparLine.Id); areaSparLineLabel.LayoutParameters = areaLabelParams; areaSparLineLayout.AddView(areaSparLine, areaParams); areaSparLineLayout.AddView(areaSparLineLabel, areaLabelParams); RelativeLayout winLossSparkLineLayout = view.FindViewById <RelativeLayout>(Resource.Id.winLossSparkLineLayout); winLossSparkLineLayout.SetPadding(0, layoutPadding, 0, 0); winLossSparkLineLayout.SetGravity(GravityFlags.Center); var winLossParams = new RelativeLayout.LayoutParams((int)width / 2, (int)height / 10); winLossParams.AddRule(LayoutRules.AlignParentTop); winLossSparkLine.LayoutParameters = winLossParams; var winLossLabelParams = new RelativeLayout.LayoutParams((int)width / 2, (int)height); winLossLabelParams.AddRule(LayoutRules.Below, winLossSparkLine.Id); winLossSparkLineLabel.LayoutParameters = winLossLabelParams; winLossSparkLineLayout.AddView(winLossSparkLine, winLossParams); winLossSparkLineLayout.AddView(winLossSparkLineLabel, winLossLabelParams); lineSparkLine.ItemsSource = LineData; lineSparkLine.YBindingPath = "Value"; lineSparkLine.Marker.Visibility = ViewStates.Visible; columnSparkLine.ItemsSource = ColumnData; columnSparkLine.YBindingPath = "Value"; areaSparLine.ItemsSource = AreaData; areaSparLine.YBindingPath = "Value"; areaSparLine.Marker.Visibility = ViewStates.Visible; winLossSparkLine.ItemsSource = WinLossData; winLossSparkLine.YBindingPath = "Value"; return(view); }
public Sparkline() { var AreaData = new List <SparklineModel> { new SparklineModel { Value = 0.8 }, new SparklineModel { Value = 1.8 }, new SparklineModel { Value = 1.3 }, new SparklineModel { Value = 1.1 }, new SparklineModel { Value = 1.6 }, new SparklineModel { Value = 2.0 }, new SparklineModel { Value = 1.7 }, new SparklineModel { Value = 2.3 }, new SparklineModel { Value = 2.7 }, new SparklineModel { Value = 2.3 }, new SparklineModel { Value = 1.9 }, new SparklineModel { Value = 1.4 }, new SparklineModel { Value = 1.2 }, new SparklineModel { Value = 0.8 }, }; var LineData = new List <SparklineModel> { new SparklineModel { Value = 1.1 }, new SparklineModel { Value = 0.9 }, new SparklineModel { Value = 1.1 }, new SparklineModel { Value = 1.3 }, new SparklineModel { Value = 1.1 }, new SparklineModel { Value = 1.8 }, new SparklineModel { Value = 2.1 }, new SparklineModel { Value = 2.3 }, new SparklineModel { Value = 1.7 }, new SparklineModel { Value = 1.5 }, new SparklineModel { Value = 2.5 }, new SparklineModel { Value = 1.9 }, new SparklineModel { Value = 1.3 }, new SparklineModel { Value = 0.9 }, }; var ColumnData = new List <SparklineModel> { new SparklineModel { Value = 34 }, new SparklineModel { Value = 23 }, new SparklineModel { Value = -31 }, new SparklineModel { Value = 66 }, new SparklineModel { Value = 26 }, new SparklineModel { Value = 44 } }; var WinLossData = new List <SparklineModel> { new SparklineModel { Value = 24 }, new SparklineModel { Value = 32 }, new SparklineModel { Value = 14 }, new SparklineModel { Value = -29 }, new SparklineModel { Value = 33 }, new SparklineModel { Value = 44 } }; areaLabel = new UILabel(); areaLabel.Text = "Area"; areaLabel.Font = UIFont.FromName("HelveticaNeue-Bold", 13f); areaLabel.TextAlignment = UITextAlignment.Center; lineLabel = new UILabel(); lineLabel.Text = "Line"; lineLabel.Font = UIFont.FromName("HelveticaNeue-Bold", 13f); lineLabel.TextAlignment = UITextAlignment.Center; columnLabel = new UILabel(); columnLabel.Text = "Column"; columnLabel.Font = UIFont.FromName("HelveticaNeue-Bold", 13f); columnLabel.TextAlignment = UITextAlignment.Center; winLossLabel = new UILabel(); winLossLabel.Text = "WinLoss"; winLossLabel.Font = UIFont.FromName("HelveticaNeue-Bold", 13f); winLossLabel.TextAlignment = UITextAlignment.Center; area = new SfAreaSparkline(); //area.Marker = new SparklineMarker() { IsVisible = true, Color= UIColor.Clear }; area.ItemsSource = AreaData; area.YBindingPath = "Value"; area.StrokeColor = UIColor.FromRGB(166.0f / 255.0f, 173.0f / 255.0f, 134.0f / 255.0f); //area.HighPointColor = UIColor.Green; //area.LowPointColor = UIColor.Red; area.Color = UIColor.FromRGBA(166.0f / 255.0f, 173.0f / 255.0f, 134.0f / 255.0f, 0.5f); line = new SfLineSparkline(); //line.Marker = new SparklineMarker() { IsVisible = true, Color = UIColor.Clear }; line.ItemsSource = LineData; line.StrokeColor = UIColor.FromRGB(166.0f / 255.0f, 173.0f / 255.0f, 134.0f / 255.0f); //line.HighPointColor = UIColor.Green; //line.LowPointColor = UIColor.Red; line.YBindingPath = "Value"; column = new SfColumnSparkline(); column.ItemsSource = ColumnData; column.YBindingPath = "Value"; column.Color = UIColor.FromRGB(86.0f / 255.0f, 140.0f / 255.0f, 233.0f / 255.0f); column.FirstPointColor = UIColor.FromRGB(86.0f / 255.0f, 140.0f / 255.0f, 233.0f / 255.0f); column.LastPointColor = UIColor.FromRGB(86.0f / 255.0f, 140.0f / 255.0f, 233.0f / 255.0f); column.HighPointColor = UIColor.FromRGBA(166.0f / 255.0f, 173.0f / 255.0f, 134.0f / 255.0f, 0.9f); column.LowPointColor = UIColor.FromRGB(252.0f / 255.0f, 98.0f / 255.0f, 93.0f / 255.0f); winLoss = new SfWinLossSparkline(); winLoss.ItemsSource = WinLossData; winLoss.YBindingPath = "Value"; winLoss.Color = UIColor.FromRGB(86.0f / 255.0f, 140.0f / 255.0f, 233.0f / 255.0f); winLoss.FirstPointColor = UIColor.FromRGB(86.0f / 255.0f, 140.0f / 255.0f, 233.0f / 255.0f); winLoss.LastPointColor = UIColor.FromRGB(86.0f / 255.0f, 140.0f / 255.0f, 233.0f / 255.0f); winLoss.HighPointColor = UIColor.FromRGBA(166.0f / 255.0f, 173.0f / 255.0f, 134.0f / 255.0f, 0.9f); winLoss.LowPointColor = UIColor.FromRGB(252.0f / 255.0f, 98.0f / 255.0f, 93.0f / 255.0f);; winLoss.NeutralPointsColor = UIColor.FromRGB(86.0f / 255.0f, 140.0f / 255.0f, 233.0f / 255.0f); this.AddSubview(areaLabel); this.AddSubview(lineLabel); this.AddSubview(columnLabel); this.AddSubview(winLossLabel); this.AddSubview(area); this.AddSubview(line); this.AddSubview(column); this.AddSubview(winLoss); }