5 Answers, 1 is accepted
You can directly set the EmptyContent property of the Chart to a string of your choice. I am here adding example on how to do it in a custom renderer for the Xamarin.Forms chart:
As "this.Control" is basically the RadCartesianChartView, you can also directly set it to the instance of the RadCartesianChartView that you have created.
Have a great rest of the week.
But how can I change its color? Is it possible using RadCartesianChartView control API? Default color is black. I need to change it to white.
Also the text in EmptyContent property is displayed always (for cases when there is some data too - see attached screenshot). Should we check this manually?
In CartensianChart the visual element inside the Chart is private by default and it can’t be customized. Only the text in the TextView can be changed through a custom renderer.
What I can suggest you is to use a Label positioned over the Chart and set its Text in case the Chart does not contain any data. In this way you could easily set the TextColor of the "No Data" message. I have prepared a sample example to demonstrate how this would work.
Please check the following files inside the attached project:
- ViewModel.cs, StartPage.xaml.cs and StartPage.xaml files in the Portable project
I hope such an approach would be suitable for you.Regards,
The native iOS chart does not provide such a message when there is no data loaded. Note that the iOS and Android Charts are two different controls and do not have 100% matching-appearance across all platforms.
Solution for iOS:
So, to resolve this, you could add a Label containing the Message over the Chart and manually update its Text. I have attached a sample app to demonstrate how this would work.