Hello everyone my name is Genti and I am new in this forum, I am writing here because I need help regarding my project.
I want to use Infragistics charts for my project. My project consist on getting data from a sensor and they are dynamically updated. The data is displayed very well on gauges but now I want to display all data collected on a chart but I get only a blank page. Can anyone please help me, I am trying to using category chart.
Thank you.
Hello Genti,
Thank you for your update on this matter.
From your update, I am under the impression that you are binding your List<DataSensor> in this case. Unfortunately, from the code provided, I can’t actually be certain of this, but I also cannot be certain of why the XamCategoryChart is showing up blank. To be more certain of that, I would need to see your DataSensor class.
With that said, if you are updating the List<DataSensor> at runtime and are adding new DataSensor objects, this could be the reason the XamCategoryChart is blank if the List<DataSensor> is initially blank when your application loads. The reason for this is that the List object does not implement INotifyCollectionChanged, and so when items are added or removed, the UI will not know about it. You can test this being the reason by changing your List<DataSensor> to be ObservableCollection<DataSensor> as ObservableCollection implements INotifyCollectionChanged by default.
Please let me know if you have any other questions or concerns on this matter.
Hello Andrew, thank you for your response. I read the link that you suggest me and I tested the example and it works fine but the problem is that my code is more complicated and there have many differences between my code and the example. I am posting a part of my code here to get maybe a suggestion how to implement charts on my code.
Thanks.
public class BLEConncetViewModel : BindableBase { private INavigationService _navigationService; private IAdapter _btAdapter; private IDevice _btDevice;
private float _temperature; private float _humidity; private float _soil; private readonly List<int> dSensorList;
private List<DataSensor> _datasensor;
private List<DataSensor> DataSensor
{ get { return _datasensor; } set { _datasensor = value; RaisePropertyChanged(); } }
public float Temperature { get { return _temperature; } set { SetProperty(ref _temperature, value); } } public float Humidity { get { return _humidity; } set { SetProperty(ref _humidity, value); }
} public float Soil { get { return _soil; } set { SetProperty(ref _soil, value); }
}
private DataSensor dataSensor;
public ICommand OnClickCommand { get; set; }
private bool _isScanning;
public bool IsScanning { get { return _isScanning; } set { SetProperty(ref _isScanning, value); } }
private string _statusText;
public string StatusText { get { return _statusText; } set { SetProperty(ref _statusText, value); } } public BLEConncetViewModel(INavigationService navigationService, IAdapter btAdapter) { _navigationService = navigationService; _btAdapter = btAdapter; _btAdapter.DeviceDiscovered += OnDeviceDiscovered; OnClickCommand = new DelegateCommand(OnClick); }
private void OnDeviceDiscovered(object sender, DeviceEventArgs e) { if (!string.IsNullOrWhiteSpace(e.Device.Name) && e.Device.Name.Contains("GNHC-01S")) { _btDevice = e.Device; NavigationParameters p = new NavigationParameters { { "Device", _btDevice } };
_navigationService.NavigateAsync(new Uri(nameof(MainMenu), UriKind.Relative), p); } }
private async void OnClick() { IsScanning = !IsScanning;
if (_isScanning) { PermissionStatus status = PermissionStatus.Denied;
if (status != PermissionStatus.Granted) { var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location);
//Check that the key exists and if so, assign it to status. if (results.ContainsKey(Permission.Location)) status = results[Permission.Location]; } await _btAdapter.StartScanningForDevicesAsync();
I have been investigating into your requirement to use the category chart in this case, and I believe it is likely that the reason that your XamCategoryChart is not showing up could potentially be due to the data structure you are using – assuming that you have successfully bound the ItemsSource of the control and it is still showing up blank.
For a reference on how to bind data to the XamCategoryChart, I would recommend utilizing the following online documentation article: https://ko.infragistics.com/help/wpf/categorychart-binding-to-data.
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.