I have a problem trying to plot regardless the field, here is my json deserialization.
namespace SyncFusion2
{
public class RootObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
ObservableCollection feeds = new ObservableCollection();
public ObservableCollection Feeds
{
get { return feeds; }
set
{
feeds = value;
NotifyPropertyChanged();
}
}
protected virtual void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public class Feed
{
public DateTime Created_at { get; set; }
public int Entry_id { get; set; }
public string Field1 { get; set; }
public string Field2 { get; set; }
public string Field3 { get; set; }
public string Field4 { get; set; }
public string Field5 { get; set; }
public string Field6 { get; set; }
public string Field7 { get; set; }
public string Field8 { get; set; }
}
public partial class MainPage : ContentPage
{
private const string Url = "https://thingspeak.com/channels/613888/feed.json";
private HttpClient _client = new HttpClient();
public ObservableCollection _data;
public MainPage()
{
InitializeComponent();
}
protected override async void OnAppearing()
{
var content = await _client.GetStringAsync(Url);
var data = JsonConvert.DeserializeObject(content);
rootObject.Feeds = new ObservableCollection(data.Feeds);
//series.ItemsSource = _data;
//series.XBindingPath = "Created_at";
//series.YBindingPath = "Entry_id";
base.OnAppearing();
}
void OnAdd(object sender, System.EventArgs e)
{
}
void OnUpdate(object sender, System.EventArgs e)
{
}
void OnDelete(object sender, System.EventArgs e)
{
}
}
and my drip page
namespace SyncFusion2
{
class DripPage : ContentPage
{
private const string Url = "https://thingspeak.com/channels/613888/feed.json";
private HttpClient _client = new HttpClient();
private ObservableCollection _data;
SfChart chart;
LineSeries series;
public DripPage()
{
chart = new SfChart();
series = new LineSeries();
Content = chart;
}
protected override async void OnAppearing()
{
var content = await _client.GetStringAsync(Url);
var data = JsonConvert.DeserializeObject(content);
_data = new ObservableCollection(data.Feeds);
series.ItemsSource = _data;
series.XBindingPath = "Created_at";
series.YBindingPath = "Field1";
chart.Series.Add(series);
base.OnAppearing();
}
void OnAdd(object sender, System.EventArgs e)
{
}
void OnUpdate(object sender, System.EventArgs e)
{
}
void OnDelete(object sender, System.EventArgs e)
{
}
}
}