hi,
Sorry i wanted the data to be really displayed on a sfcircular guage as the data that i am using is coming from a device i created that measures a water meter pulse.
Is this possible?
All i need is for the field1 data to show on the circular guage like an actual water meter
Thanks
Carlo chan
Hi
So i would like to bind data to only field 1. And only create a circular guage for Field1 jason Data.
see below
Thanks
public class Feed
{
public double Field1 { get; set; } //This JASON field Only as the value of the needle pointer
public DateTime Created_at { get; set; }
public int Entry_id { get; set; }
My Scenario - Gauge Code behind
using System.Net.Http;
using Newtonsoft.Json;
using Xamarin.Forms;
using System.Collections.ObjectModel;
using Syncfusion.SfGauge.XForms;
using System.Collections;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace Drip
{
public partial class Guage : ContentPage
{
private const string Url = "https://thingspeak.com/channels/301726/field/1.json"; // my JASON DATA
private HttpClient _client = new HttpClient();
private ObservableCollection<Feed> _data2;
SfCircularGauge circular;
NeedlePointer needlePointer;
public Guage()
{
InitializeComponent();
circular = new SfCircularGauge();
circular.VerticalOptions = LayoutOptions.FillAndExpand;
circular.BackgroundColor = Color.Black;
Header header = new Header();
header.Text = "Water Meter";
header.TextSize = 20;
header.Position = new Point(0.50, 0.7);
header.ForegroundColor = Color.Gray;
circular.Headers.Add(header);
ObservableCollection<Scale> scales = new ObservableCollection<Scale>();
Scale scale = new Scale();
scale.LabelPostfix = "Litres";
scale.StartValue = 0;
scale.EndValue = 100;
scale.Interval = 10;
scale.StartAngle = 135;
scale.SweepAngle = 270;
scale.RimThickness = 20;
scale.RimColor = Color.White;
scale.MinorTicksPerInterval = 0;
scales.Add(scale);
Range range = new Range();
range.StartValue = 80;
range.EndValue = 100;
range.Color = Color.DarkRed;
range.Thickness = 10;
scale.Ranges.Add(range);
circular.Scales = scales;
ObservableCollection<NeedlePointer> needle = new ObservableCollection<NeedlePointer>();
needlePointer = new NeedlePointer();
needlePointer.Color = Color.Gray;
needlePointer.KnobColor = Color.Red;
needlePointer.Thickness = 5;
needlePointer.KnobRadius = 20;
needlePointer.LengthFactor = 0.8;
needlePointer.Value = 37;
scale.Pointers.Add(needlePointer);
Content = circular;
}
protected override async void OnAppearing()
{
var content = await _client.GetStringAsync(Url);
var data = JsonConvert.DeserializeObject<RootObject>(content);
_data2 = new ObservableCollection<Feed>(data.Feeds);
this.BindingContext = _data2[0];
needlePointer.SetBinding(Pointer.ValueProperty, "Field1");
}
}
}
My Models from Jason data
public class RootObject
{
public IList<Feed> Feeds { get; set; }
}
public class Channel
public class Feed
{
public double Field1 { get; set; } //want this JASON field to be binded with Needle pointer
public DateTime Created_at { get; set; }
public int Entry_id { get; set; }