App crashes with negative donut chart value, can't catch exception


#1

I realize that a negative donut chart value doesn’t make much sense. I’m displaying financial info and one slice is “invested” and the other is “earned”. In this case, I had my first test of a stock that has lost money, hence a negative “earned” value. My issue is that I didn’t realize this was the problem because Shinobi Charts just straight up killed my app, not throwing an exception at all, which made it very hard to track down the cause of the problem. In looking at the output window, my only clue was a strangely worded message saying:

“ShinobiCharts: Datapoint.yValue must be positive.”

This didn’t help me much because I’m not setting yValues anywhere with a donut chart. I’m setting a name and a value field in SChartRadialDataPoint for each item in my chart.

Anyway, could it please throw an exception? Something that would let me gracefully handle the error. Or barring that, an updated debug message that gets printed that makes sense for the chart type being used. I’m using the C# Xamarin library for iOS. Thanks.


#2

Hi Architekt,

Thanks for bringing this to our attention. I’m sorry the error message made it difficult to track down the problem. We’ve logged an issue to improve both the error message and the error handling in this case, and will update this topic when the issue has been resolved.

I guess you’ve already done this by now, but until the issue is resolved I’d suggest changing your code to check for negative values before adding them to a donut or pie series.

Kind regards,

Alison