public override View GetSampleContent(Android.Content.Context con) { /**************** **Linear Gauge** ****************/ SfLinearGauge linearGauge = new SfLinearGauge(con); ObservableCollection <LinearScale> scales = new ObservableCollection <LinearScale>(); ObservableCollection <LinearPointer> pointers = new ObservableCollection <LinearPointer>(); ObservableCollection <LinearRange> ranges = new ObservableCollection <LinearRange>(); linearGauge.SetX(0); linearGauge.SetY(0); linearGauge.SetBackgroundColor(Color.Rgb(255, 255, 255)); linearGauge.SetOrientation(SfLinearGauge.Orientation.Horizontal); var density = con.Resources.DisplayMetrics.Density; //Annotation LinearGaugeAnnotation annotation = new LinearGaugeAnnotation(); annotation.ScaleValue = 15; annotation.ViewMargin = new PointF(0, 30); ImageView imageView = new ImageView(con); imageView.SetImageResource(Resource.Drawable.Low); LinearLayout layout = new LinearLayout(con); layout.LayoutParameters = new LinearLayout.LayoutParams((int)(80 * density), 60); layout.SetGravity(GravityFlags.Center); layout.AddView(imageView); annotation.View = layout; linearGauge.Annotations.Add(annotation); //Annotation1 LinearGaugeAnnotation annotation1 = new LinearGaugeAnnotation(); annotation1.ScaleValue = 45; annotation1.ViewMargin = new PointF(0, 30); ImageView imageView1 = new ImageView(con); imageView1.SetImageResource(Resource.Drawable.Moderate); LinearLayout layout1 = new LinearLayout(con); layout1.LayoutParameters = new LinearLayout.LayoutParams((int)(80 * density), 60); layout1.SetGravity(GravityFlags.Center); layout1.AddView(imageView1); annotation1.View = layout1; linearGauge.Annotations.Add(annotation1); //Annotation2 LinearGaugeAnnotation annotation2 = new LinearGaugeAnnotation(); annotation2.ScaleValue = 75; annotation2.ViewMargin = new PointF(0, 30); ImageView imageView2 = new ImageView(con); imageView2.SetImageResource(Resource.Drawable.High); LinearLayout layout2 = new LinearLayout(con); layout2.LayoutParameters = new LinearLayout.LayoutParams((int)(80 * density), 60); layout2.SetGravity(GravityFlags.Center); layout2.AddView(imageView2); annotation2.View = layout2; linearGauge.Annotations.Add(annotation2); //Annotation3 LinearGaugeAnnotation annotation3 = new LinearGaugeAnnotation(); annotation3.ScaleValue = 15; annotation3.ViewMargin = new PointF(0, 80); TextView text = new TextView(con); text.Text = "Low"; text.SetTextColor(Color.ParseColor("#30b32d")); LinearLayout layout3 = new LinearLayout(con); layout3.LayoutParameters = new LinearLayout.LayoutParams((int)(60 * density), 60); layout3.SetGravity(GravityFlags.Center); layout3.AddView(text); annotation3.View = layout3; linearGauge.Annotations.Add(annotation3); //Annotation4 LinearGaugeAnnotation annotation4 = new LinearGaugeAnnotation(); annotation4.ScaleValue = 45; annotation4.ViewMargin = new PointF(0, 80); TextView text1 = new TextView(con); text1.Text = "Moderate"; text1.SetTextColor(Color.ParseColor("#ffdd00")); LinearLayout layout4 = new LinearLayout(con); layout4.LayoutParameters = new LinearLayout.LayoutParams((int)(90 * density), 60); layout4.SetGravity(GravityFlags.Center); layout4.AddView(text1); annotation4.View = layout4; linearGauge.Annotations.Add(annotation4); //Annotation5 LinearGaugeAnnotation annotation5 = new LinearGaugeAnnotation(); annotation5.ScaleValue = 75; annotation5.ViewMargin = new PointF(0, 80); TextView text2 = new TextView(con); text2.Text = "High"; text2.SetTextColor(Color.ParseColor("#f03e3e")); LinearLayout layout5 = new LinearLayout(con); layout5.LayoutParameters = new LinearLayout.LayoutParams((int)(60 * density), 60); layout5.SetGravity(GravityFlags.Center); layout5.AddView(text2); annotation5.View = layout5; linearGauge.Annotations.Add(annotation5); //Annotation6 LinearGaugeAnnotation annotation6 = new LinearGaugeAnnotation(); annotation6.ScaleValue = 45; annotation6.ViewMargin = new PointF(0, -50); LinearLayout layout6 = new LinearLayout(con); layout6.LayoutParameters = new LinearLayout.LayoutParams((int)(200 * density), 100); layout6.SetGravity(GravityFlags.Center); layout6.AddView(new TextView(con) { Text = "CPU Utilization", TextSize = 20 }); annotation6.View = layout6; linearGauge.Annotations.Add(annotation6); //OuterScale LinearScale outerScale = new LinearScale(); outerScale.Minimum = 0; outerScale.Maximum = 90; outerScale.ShowLabels = false; outerScale.ScaleBarColor = Color.Transparent; outerScale.Offset = -50; outerScale.MinorTicksPerInterval = 1; outerScale.ScaleBarSize = 13; outerScale.ScaleDirection = LinearScaleDirection.Backward; //OuterScale MajorTicksSettings LinearTickSettings outerScale_majorTicksSettings = new LinearTickSettings(); outerScale_majorTicksSettings.Color = Color.Transparent; outerScale_majorTicksSettings.Length = 0; outerScale_majorTicksSettings.StrokeWidth = 1; outerScale.MajorTickSettings = outerScale_majorTicksSettings; //OuterScale MinorTicksSettings LinearTickSettings outerScale_minorTicksSettings = new LinearTickSettings(); outerScale_minorTicksSettings.Color = Color.Transparent; outerScale_minorTicksSettings.Length = 0; outerScale_minorTicksSettings.StrokeWidth = 1; outerScale.MinorTickSettings = outerScale_minorTicksSettings; //Symbol Pointer SymbolPointer outerScale_needlePointer = new SymbolPointer(); outerScale_needlePointer.Value = pointervalue; outerScale_needlePointer.StrokeWidth = 12; outerScale_needlePointer.Color = Color.Red; outerScale_needlePointer.MarkerShape = MarkerShape.InvertedTriangle; pointers.Add(outerScale_needlePointer); outerScale.Pointers = pointers; //Symbol Range LinearRange range = new LinearRange(); range.StartWidth = 60; range.EndWidth = 60; range.Color = Color.ParseColor("#30b32d"); range.StartValue = 0; range.EndValue = 30; ranges.Add(range); //Symbol Range1 LinearRange range1 = new LinearRange(); range1.StartWidth = 60; range1.EndWidth = 60; range1.Color = Color.ParseColor("#ffdd00"); range1.StartValue = 30; range1.EndValue = 60; ranges.Add(range1); //Symbol Range2 LinearRange range2 = new LinearRange(); range2.StartWidth = 60; range2.EndWidth = 60; range2.Color = Color.ParseColor("#f03e3e"); range2.StartValue = 60; range2.EndValue = 90; ranges.Add(range2); outerScale.Ranges = ranges; scales.Add(outerScale); linearGauge.Scales = scales; //Main Gauge Layout LinearLayout mainLinearGaugeLayout = new LinearLayout(con); mainLinearGaugeLayout.Orientation = Android.Widget.Orientation.Vertical; mainLinearGaugeLayout.SetBackgroundColor(Color.Rgb(255, 255, 255)); mainLinearGaugeLayout.SetGravity((GravityFlags)17); //Linear Gauge Layout LinearLayout linearGaugeLayout = new LinearLayout(con); linearGaugeLayout.SetGravity((GravityFlags)17); linearGaugeLayout.SetBackgroundColor(Color.Rgb(255, 255, 255)); mainLinearGaugeLayout.AddView(linearGaugeLayout); mainLinearGaugeLayout.AddView(linearGauge); return(mainLinearGaugeLayout); }
public LinearGauge_Default() { InitializeComponent(); //Scale ObservableCollection <LinearScale> scales = new ObservableCollection <LinearScale>(); LinearScale scale = new LinearScale(); scale.MinimumValue = 0; scale.MaximumValue = 100; scale.Interval = 20; scale.ScaleBarLength = 100; scale.ScaleBarColor = Color.FromRgb(250, 236, 236); scale.LabelColor = Color.FromRgb(84, 84, 84); scale.MinorTicksPerInterval = 1; scale.ScaleBarSize = 13; scale.ScalePosition = ScalePosition.BackWard; //Major Ticks setting LinearTickSettings major = new LinearTickSettings(); major.Length = 10; major.Color = Color.FromRgb(175, 175, 175); major.Thickness = 1; scale.MajorTickSettings = major; //Minor Ticks setting LinearTickSettings minor = new LinearTickSettings(); minor.Length = 10; minor.Color = Color.FromRgb(175, 175, 175); minor.Thickness = 1; scale.MinorTickSettings = minor; List <LinearPointer> pointers = new List <LinearPointer>(); //SymbolPointer SymbolPointer symbolPointer = new SymbolPointer(); symbolPointer.Value = 50; symbolPointer.Offset = 0.0; symbolPointer.Thickness = 3; symbolPointer.Color = Color.FromRgb(65, 77, 79); //BarPointer BarPointer rangePointer = new BarPointer(); rangePointer.Value = 50; rangePointer.Color = Color.FromRgb(206, 69, 69); if (Device.Idiom == TargetIdiom.Phone) { rangePointer.Thickness = 30; } rangePointer.Thickness = 10; pointers.Add(symbolPointer); pointers.Add(rangePointer); scale.Pointers = pointers; //Range LinearRange symbolRange = new LinearRange(); symbolRange.StartValue = 0; symbolRange.EndValue = 50; symbolRange.Color = Color.FromRgb(234, 248, 249); symbolRange.StartWidth = 10; symbolRange.EndWidth = 10; if (Device.OS == TargetPlatform.Windows) { symbolRange.Offset = -0.07; } else { symbolRange.Offset = -0.17; } scale.Ranges.Add(symbolRange); //Range LinearRange pointerRange = new LinearRange(); pointerRange.StartValue = 50; pointerRange.EndValue = 100; pointerRange.Color = Color.FromRgb(50, 184, 198); pointerRange.StartWidth = 10; pointerRange.EndWidth = 10; if (Device.OS == TargetPlatform.Windows) { pointerRange.Offset = -0.07; if (Device.Idiom == TargetIdiom.Tablet) { gettingStarted.FontSize = 25; } } else { pointerRange.Offset = -0.17; } scale.Ranges.Add(pointerRange); scales.Add(scale); linearGauge.BindingContext = scales; }
public override View GetSampleContent(Android.Content.Context con) { /**************** **Linear Gauge** ****************/ SfLinearGauge linearGauge = new SfLinearGauge(con); ObservableCollection <LinearScale> scales = new ObservableCollection <LinearScale>(); ObservableCollection <LinearPointer> pointers = new ObservableCollection <LinearPointer>(); linearGauge.SetX(0); linearGauge.SetY(0); linearGauge.SetBackgroundColor(Color.Rgb(255, 255, 255)); linearGauge.SetOrientation(SfLinearGauge.Orientation.Horizontal); //OuterScale outerScale = new LinearScale(); outerScale.Minimum = 0; outerScale.Maximum = 100; outerScale.ScaleBarSize = 40; outerScale.Interval = 10; outerScale.ScaleBarColor = Color.ParseColor("#e0e9f9"); outerScale.MinorTicksPerInterval = 0; outerScale.LabelFontSize = 14; outerScale.LabelColor = Color.ParseColor("#424242"); outerScale.CornerRadius = 20; outerScale.CornerRadiusType = CornerRadiusType.End; //OuterScale MajorTicksSettings LinearTickSettings outerScale_majorTicksSettings = new LinearTickSettings(); outerScale_majorTicksSettings.Color = Color.ParseColor("#9E9E9E");// outerScale_majorTicksSettings.Length = 10; outerScale_majorTicksSettings.StrokeWidth = 1; outerScale.MajorTickSettings = outerScale_majorTicksSettings; //Symbol Pointer outerScale_needlePointer = new SymbolPointer(); outerScale_needlePointer.SymbolPosition = SymbolPointerPosition.Away; outerScale_needlePointer.Value = pointervalue; outerScale_needlePointer.StrokeWidth = 12; outerScale_needlePointer.Color = Color.ParseColor("#5b86e5"); outerScale_needlePointer.MarkerShape = MarkerShape.Triangle; outerScale_needlePointer.EnableAnimation = false; pointers.Add(outerScale_needlePointer); //Bar Pointer rangePointer = new BarPointer(); rangePointer.Value = barvalue; rangePointer.StrokeWidth = 30; rangePointer.EnableAnimation = false; rangePointer.CornerRadius = 15; rangePointer.CornerRadiusType = CornerRadiusType.End; rangePointer.GradientStops = new ObservableCollection <GaugeGradientStop>() { new GaugeGradientStop() { Value = 0, Color = Color.ParseColor("#36d1dc") }, new GaugeGradientStop() { Value = 75, Color = Color.ParseColor("#5b86e5") } }; pointers.Add(rangePointer); outerScale.Pointers = pointers; scales.Add(outerScale); linearGauge.Scales = scales; //Linear Gauge Layout LinearLayout linearGaugeLayout = new LinearLayout(con); linearGaugeLayout.SetBackgroundColor(Color.Rgb(255, 255, 255)); linearGaugeLayout.AddView(linearGauge); return(linearGaugeLayout); }
public override View GetSampleContent(Context con) { SfLinearGauge linearGauge = new SfLinearGauge(con); // linearGauge.LayoutParameters =new LinearLayout.LayoutParams(parentLayout.getMeasuredWidth(),parentLayout.getMeasuredHeight()-150); ObservableCollection <LinearScale> scales = new ObservableCollection <LinearScale> (); ObservableCollection <LinearPointer> pointers = new ObservableCollection <LinearPointer> (); ObservableCollection <LinearRange> ranges = new ObservableCollection <LinearRange> (); linearGauge.SetX(0); linearGauge.SetY(0); linearGauge.SetBackgroundColor(Color.Rgb(255, 255, 255)); linearGauge.SetOrientation(SfLinearGauge.Orientation.Vertical); // adding new scale LinearScale outerScale = new LinearScale(); outerScale.Minimum = 0; outerScale.Maximum = 100; outerScale.ScaleBarSize = 50; outerScale.ScaleBarLength = 100; outerScale.Interval = 20; outerScale.ScaleBarColor = Color.ParseColor("#FAECEC"); outerScale.MinorTicksPerInterval = 2; outerScale.LabelFontSize = 17; outerScale.LabelColor = Color.ParseColor("#545454"); outerScale.LabelPostfix = "%"; //adding major ticks LinearTickSettings outerScale_majorTicksSettings = new LinearTickSettings(); outerScale_majorTicksSettings.Color = Color.ParseColor("#AFAFAF"); // outerScale_majorTicksSettings.Length = 20; outerScale_majorTicksSettings.StrokeWidth = 5; outerScale_majorTicksSettings.Offset = 0; outerScale.MajorTickSettings = outerScale_majorTicksSettings; //adding minor ticks LinearTickSettings outerScale_minorTicksSettings = new LinearTickSettings(); outerScale_minorTicksSettings.Color = Color.ParseColor("#AFAFAF"); outerScale_minorTicksSettings.Length = 10; outerScale_minorTicksSettings.StrokeWidth = 5; outerScale_minorTicksSettings.Offset = 0; outerScale.MinorTickSettings = outerScale_minorTicksSettings; // adding Symbol Pointer SymbolPointer outerScale_needlePointer = new SymbolPointer(); outerScale_needlePointer.Value = pointervalue; outerScale_needlePointer.StrokeWidth = 0; outerScale_needlePointer.Offset = 0.3f; outerScale_needlePointer.Color = Color.ParseColor("#414D4F"); pointers.Add(outerScale_needlePointer); //adding Bar Pointer BarPointer rangePointer = new BarPointer(); rangePointer.Value = barvalue; rangePointer.Color = Color.ParseColor("#CE4545"); // rangePointer.StrokeWidth = 20; pointers.Add(rangePointer); outerScale.Pointers = pointers; //adding ranges LinearRange lowerRange = new LinearRange(); lowerRange.StartWidth = 30; lowerRange.EndWidth = 30; lowerRange.Color = Color.ParseColor("#67d6db"); lowerRange.StartValue = 0; lowerRange.EndValue = 50; lowerRange.Offset = -.3; ranges.Add(lowerRange); LinearRange higherRange = new LinearRange(); higherRange.StartWidth = 30; higherRange.EndWidth = 30; higherRange.Color = Color.ParseColor("#32B8C6"); higherRange.StartValue = 50; higherRange.EndValue = 100; higherRange.Offset = -.3; ranges.Add(higherRange); outerScale.Ranges = ranges; scales.Add(outerScale); linearGauge.Scales = scales; TextView textview = new TextView(con); textview.Text = "Memory Usage"; textview.TextSize = 20; textview.SetTextColor(Color.ParseColor("#CE4545")); LinearLayout ln = new LinearLayout(con); ln.Orientation = Orientation.Vertical; ln.SetBackgroundColor(Color.Rgb(255, 255, 255)); ln.SetGravity((GravityFlags)17); LinearLayout ln1 = new LinearLayout(con); ln1.AddView(textview); ln1.SetGravity((GravityFlags)17); ln1.SetBackgroundColor(Color.Rgb(255, 255, 255)); ln.AddView(ln1); ln.AddView(linearGauge); return(ln); }
public override View GetSampleContent(Android.Content.Context con) { /**************** **Linear Gauge** ****************/ SfLinearGauge linearGauge = new SfLinearGauge(con); ObservableCollection <LinearScale> scales = new ObservableCollection <LinearScale>(); ObservableCollection <LinearPointer> pointers = new ObservableCollection <LinearPointer>(); ObservableCollection <LinearRange> ranges = new ObservableCollection <LinearRange>(); linearGauge.SetX(0); linearGauge.SetY(0); linearGauge.SetBackgroundColor(Color.Rgb(255, 255, 255)); linearGauge.SetOrientation(SfLinearGauge.Orientation.Horizontal); //OuterScale LinearScale outerScale = new LinearScale(); outerScale.Minimum = 0; outerScale.Maximum = 100; outerScale.ScaleBarSize = 2; outerScale.Interval = 10; outerScale.ScaleBarColor = Android.Graphics.Color.ParseColor("#9e9e9e"); outerScale.MinorTicksPerInterval = 4; outerScale.LabelFontSize = 14; outerScale.LabelColor = Color.ParseColor("#424242"); outerScale.OpposedPosition = true; //OuterScale MajorTicksSettings LinearTickSettings outerScale_majorTicksSettings = new LinearTickSettings(); outerScale_majorTicksSettings.Color = Color.ParseColor("#9E9E9E");// outerScale_majorTicksSettings.Length = 30; outerScale_majorTicksSettings.StrokeWidth = 1.5; outerScale.MajorTickSettings = outerScale_majorTicksSettings; //OuterScale MinorTicksSettings LinearTickSettings outerScale_minorTicksSettings = new LinearTickSettings(); outerScale_minorTicksSettings.Color = Color.ParseColor("#9E9E9E"); outerScale_minorTicksSettings.Length = 15; outerScale_minorTicksSettings.StrokeWidth = 0.9; outerScale.MinorTickSettings = outerScale_minorTicksSettings; //Symbol Pointer SymbolPointer outerScale_needlePointer = new SymbolPointer(); outerScale_needlePointer.SymbolPosition = SymbolPointerPosition.Away; outerScale_needlePointer.Value = pointervalue; outerScale_needlePointer.StrokeWidth = 12; outerScale_needlePointer.Color = Color.ParseColor("#9E9E9E"); outerScale_needlePointer.MarkerShape = MarkerShape.Triangle; pointers.Add(outerScale_needlePointer); outerScale.Pointers = pointers; scales.Add(outerScale); linearGauge.Scales = scales; //Linear Gauge Layout LinearLayout linearGaugeLayout = new LinearLayout(con); linearGaugeLayout.SetBackgroundColor(Color.Rgb(255, 255, 255)); linearGaugeLayout.AddView(linearGauge); return(linearGaugeLayout); }
public override View GetSampleContent (Context con) { SfLinearGauge linearGauge = new SfLinearGauge (con); // linearGauge.LayoutParameters =new LinearLayout.LayoutParams(parentLayout.getMeasuredWidth(),parentLayout.getMeasuredHeight()-150); ObservableCollection<LinearScale> scales = new ObservableCollection<LinearScale> (); ObservableCollection<LinearPointer> pointers = new ObservableCollection<LinearPointer> (); ObservableCollection<LinearRange> ranges = new ObservableCollection<LinearRange> (); linearGauge.SetX (0); linearGauge.SetY (0); linearGauge.SetBackgroundColor (Color.Rgb (255, 255, 255)); linearGauge.SetOrientation (SfLinearGauge.Orientation.Vertical); // adding new scale LinearScale outerScale = new LinearScale (); outerScale.Minimum = 0; outerScale.Maximum = 100; outerScale.ScaleBarSize = 50; outerScale.ScaleBarLength = 100; outerScale.Interval = 20; outerScale.ScaleBarColor = Color.ParseColor ("#FAECEC"); outerScale.MinorTicksPerInterval = 2; outerScale.LabelFontSize = 17; outerScale.LabelColor = Color.ParseColor ("#545454"); outerScale.LabelPostfix = "%"; //adding major ticks LinearTickSettings outerScale_majorTicksSettings = new LinearTickSettings (); outerScale_majorTicksSettings.Color = Color.ParseColor ("#AFAFAF");// outerScale_majorTicksSettings.Length = 20; outerScale_majorTicksSettings.StrokeWidth = 5; outerScale_majorTicksSettings.Offset = 0; outerScale.MajorTickSettings = outerScale_majorTicksSettings; //adding minor ticks LinearTickSettings outerScale_minorTicksSettings = new LinearTickSettings (); outerScale_minorTicksSettings.Color = Color.ParseColor ("#AFAFAF"); outerScale_minorTicksSettings.Length = 10; outerScale_minorTicksSettings.StrokeWidth = 5; outerScale_minorTicksSettings.Offset = 0; outerScale.MinorTickSettings = outerScale_minorTicksSettings; // adding Symbol Pointer SymbolPointer outerScale_needlePointer = new SymbolPointer (); outerScale_needlePointer.Value = pointervalue; outerScale_needlePointer.StrokeWidth = 0; outerScale_needlePointer.Offset = 0.3f; outerScale_needlePointer.Color = Color.ParseColor ("#414D4F"); pointers.Add (outerScale_needlePointer); //adding Bar Pointer BarPointer rangePointer = new BarPointer (); rangePointer.Value = barvalue; rangePointer.Color = Color.ParseColor ("#CE4545");// rangePointer.StrokeWidth = 20; pointers.Add (rangePointer); outerScale.Pointers = pointers; //adding ranges LinearRange lowerRange = new LinearRange (); lowerRange.StartWidth = 30; lowerRange.EndWidth = 30; lowerRange.Color = Color.ParseColor ("#67d6db"); lowerRange.StartValue = 0; lowerRange.EndValue = 50; lowerRange.Offset = -.3; ranges.Add (lowerRange); LinearRange higherRange = new LinearRange (); higherRange.StartWidth = 30; higherRange.EndWidth = 30; higherRange.Color = Color.ParseColor ("#32B8C6"); higherRange.StartValue = 50; higherRange.EndValue = 100; higherRange.Offset = -.3; ranges.Add (higherRange); outerScale.Ranges = ranges; scales.Add (outerScale); linearGauge.Scales = scales; TextView textview = new TextView (con); textview.Text = "Memory Usage"; textview.TextSize = 20; textview.SetTextColor (Color.ParseColor ("#CE4545")); LinearLayout ln = new LinearLayout (con); ln.Orientation = Orientation.Vertical; ln.SetBackgroundColor (Color.Rgb (255, 255, 255)); ln.SetGravity ((GravityFlags)17); LinearLayout ln1 = new LinearLayout (con); ln1.AddView (textview); ln1.SetGravity ((GravityFlags)17); ln1.SetBackgroundColor (Color.Rgb (255, 255, 255)); ln.AddView (ln1); ln.AddView (linearGauge); return ln; }
public LinearGauge() { //InitializeComponent (); linearGauge = new SfLinearGauge(); linearGauge.BackgroundColor = Color.White; linearGauge.Orientation = Syncfusion.SfGauge.XForms.Orientation.OrientationVertical; //Scale ObservableCollection <LinearScale> scales = new ObservableCollection <LinearScale> (); LinearScale scale = new LinearScale(); scale.MinimumValue = 0; scale.MaximumValue = 100; scale.Interval = 20; scale.ScaleBarLength = 100; // scale.LabelPostfix = "%"; scale.ScaleBarColor = Color.FromRgb(250, 236, 236); scale.LabelColor = Color.FromRgb(84, 84, 84); scale.MinorTicksPerInterval = 1; scale.ScaleBarSize = 13; scale.ScalePosition = ScalePosition.BackWard; List <LinearPointer> pointers = new List <LinearPointer> (); //SymbolPointer SymbolPointer symbolPointer = new SymbolPointer(); symbolPointer.Value = 50; symbolPointer.Offset = 0.0; symbolPointer.Thickness = 3; symbolPointer.Color = Color.FromRgb(65, 77, 79); //BarPointer BarPointer rangePointer = new BarPointer(); rangePointer.Value = 50; rangePointer.Color = Color.FromRgb(206, 69, 69); rangePointer.Thickness = 10; pointers.Add(symbolPointer); pointers.Add(rangePointer); //Range LinearRange range = new LinearRange(); range.StartValue = 0; range.EndValue = 50; range.Color = Color.FromRgb(234, 248, 249); range.StartWidth = 10; range.EndWidth = 10; if (Device.OS == TargetPlatform.Windows) { range.Offset = -0.07; } else { range.Offset = -0.17; } scale.Ranges.Add(range); //Range LinearRange range2 = new LinearRange(); range2.StartValue = 50; range2.EndValue = 100; range2.Color = Color.FromRgb(50, 184, 198); range2.StartWidth = 10; range2.EndWidth = 10; if (Device.OS == TargetPlatform.Windows) { range2.Offset = -0.07; } else { range2.Offset = -0.17; } scale.Ranges.Add(range2); //Minor Ticks setting LinearTickSettings minor = new LinearTickSettings(); minor.Length = 10; minor.Color = Color.FromRgb(175, 175, 175); minor.Thickness = 1; scale.MinorTickSettings = minor; //Major Ticks setting LinearTickSettings major = new LinearTickSettings(); major.Length = 10; major.Color = Color.FromRgb(175, 175, 175); major.Thickness = 1; scale.MajorTickSettings = major; scale.Pointers = pointers; scales.Add(scale); linearGauge.Scales = scales; Label label; if (Device.OS == TargetPlatform.iOS) { label = new Label() { Text = "Memory Usage", HorizontalOptions = LayoutOptions.Center, HeightRequest = 50, TextColor = Color.Black }; label.FontAttributes = FontAttributes.Bold; label.FontSize = 25; } else { label = new Label() { Text = "Memory Usage", HorizontalOptions = LayoutOptions.Center, HeightRequest = 50, TextColor = Color.Black }; label.FontAttributes = FontAttributes.Bold; label.FontSize = 25; } var mainStack = new StackLayout { BackgroundColor = Color.White, Spacing = 10, Padding = Device.OnPlatform(iOS: 10, Android: 10, WinPhone: 50), Children = { label, linearGauge } }; mainStack.SizeChanged += (object sender, EventArgs e) => { linearGauge.HeightRequest = mainStack.Height - 150; linearGauge.WidthRequest = mainStack.Width - 50; }; this.ContentView = mainStack; //this.BackgroundColor = Color.Black; }
public LinearGauge () { //InitializeComponent (); linearGauge = new SfLinearGauge (); linearGauge.BackgroundColor = Color.White; linearGauge.Orientation = Syncfusion.SfGauge.XForms.Orientation.OrientationVertical; //Scale ObservableCollection<LinearScale> scales = new ObservableCollection<LinearScale> (); LinearScale scale = new LinearScale (); scale.MinimumValue = 0; scale.MaximumValue = 100; scale.Interval = 20; scale.ScaleBarLength = 100; // scale.LabelPostfix = "%"; scale.ScaleBarColor = Color.FromRgb (250, 236, 236); scale.LabelColor = Color.FromRgb (84, 84, 84); scale.MinorTicksPerInterval = 1; scale.ScaleBarSize = 13; scale.ScalePosition = ScalePosition.BackWard; List<LinearPointer> pointers = new List<LinearPointer> (); //SymbolPointer SymbolPointer symbolPointer = new SymbolPointer (); symbolPointer.Value = 50; symbolPointer.Offset = 0.0; symbolPointer.Thickness = 3; symbolPointer.Color = Color.FromRgb (65, 77, 79); //BarPointer BarPointer rangePointer = new BarPointer (); rangePointer.Value = 50; rangePointer.Color = Color.FromRgb (206, 69, 69); rangePointer.Thickness = 10; pointers.Add (symbolPointer); pointers.Add (rangePointer); //Range LinearRange range = new LinearRange (); range.StartValue = 0; range.EndValue = 50; range.Color = Color.FromRgb (234, 248, 249); range.StartWidth = 10; range.EndWidth = 10; if (Device.OS == TargetPlatform.Windows) { range.Offset = -0.07; } else range.Offset = -0.17; scale.Ranges.Add (range); //Range LinearRange range2 = new LinearRange (); range2.StartValue = 50; range2.EndValue = 100; range2.Color = Color.FromRgb (50, 184, 198); range2.StartWidth = 10; range2.EndWidth = 10; if (Device.OS == TargetPlatform.Windows) { range2.Offset = -0.07; } else range2.Offset = -0.17; scale.Ranges.Add (range2); //Minor Ticks setting LinearTickSettings minor = new LinearTickSettings (); minor.Length = 10; minor.Color = Color.FromRgb (175, 175, 175); minor.Thickness = 1; scale.MinorTickSettings = minor; //Major Ticks setting LinearTickSettings major = new LinearTickSettings (); major.Length = 10; major.Color = Color.FromRgb (175, 175, 175); major.Thickness = 1; scale.MajorTickSettings = major; scale.Pointers = pointers; scales.Add (scale); linearGauge.Scales = scales; Label label; if (Device.OS == TargetPlatform.iOS) { label = new Label () { Text = "Memory Usage",HorizontalOptions = LayoutOptions.Center, HeightRequest = 50, TextColor = Color.Black }; label.FontAttributes = FontAttributes.Bold; label.FontSize = 25; } else { label = new Label () { Text = "Memory Usage",HorizontalOptions = LayoutOptions.Center, HeightRequest = 50, TextColor = Color.Black }; label.FontAttributes = FontAttributes.Bold; label.FontSize = 25; } var mainStack = new StackLayout { BackgroundColor = Color.White, Spacing = 10, Padding = Device.OnPlatform (iOS: 10, Android : 10, WinPhone : 50), Children = { label, linearGauge } }; mainStack.SizeChanged += (object sender, EventArgs e) => { linearGauge.HeightRequest = mainStack.Height - 150; linearGauge.WidthRequest = mainStack.Width - 50; }; this.ContentView = mainStack; //this.BackgroundColor = Color.Black; }