I have a pivot viewer that I added a numeric viewer property to. When the values are all possitive, it works fine. When the values are negative, I get an error:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; MS-RTC LM 8; InfoPath.2; .NET4.0C; .NET4.0E) Timestamp: Thu, 23 May 2013 14:20:57 UTC
Message: Unhandled Error in Silverlight Application StartIndex cannot be less than zero.
Parameter name: startIndex at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex, Int32 length)
at Microsoft.Internal.Pivot.Model.HistogramBucketer.CalculateFormatAndFractions(ICollection1 numbers, String& formatString, Decimal& divFactor)
at Microsoft.Internal.Pivot.ViewModels.RangeFacetCategoryViewModel.CalculateFormatAndFractions(ICollection
1 values)
at Microsoft.Internal.Pivot.ViewModels.RangeFacetCategoryViewModel.OnModelChanged(RangeFacetCategory oldModel, RangeFacetCategory newModel)
at Microsoft.Internal.Pivot.ViewModels.ViewModelBase`1.SetModel(Object newModel)
at Microsoft.Internal.Pivot.ViewModels.FilterPaneViewModel.SynchronizeCategories()
at Microsoft.Internal.Pivot.ViewModels.FilterPaneViewModel.b__4()
Line: 1
Char: 1
Code: 0
I can't imagine that I can't have negative values. The values I'm passing in a very small (-.00009825, etc.), but I can't image that makes a difference. Is there a setting I'm missing? Thank you
I thought you were crazy until I tried it myself in a minimal PivotViewer control and got the same error!
After some more experimentation, it seems the problem isn't with negative numbers but rather with a mantissa (the decimal portion) containing four or five leading zeroes, depending on the value of the first non-zero digit.
Values with four leading zeroes like 0.00001, -1.00002, 2.00003, -3.00004 will all cause your error. Mantissas .00005 through 0.00009 do work, presumably because the values are being rounded up, e.g. 0.00005 "=" 0.0001.
The same problem is described here: (http://social.msdn.microsoft.com/Forums/en-US/silverlightpivotviewer/thread/03f0e782-f2d8-4c70-86f2-93560a8d6151/)
Their workaround: round your decimals to four places and you should be fine. If your data are in a super-tight range where you need that degree of precision in PivotViewer, I'd multiply by e.g. 1000 and somehow indicate that the values are scaled.
PS This behavior certainly seems buggy - I'd guess the magic four-decimal limit is related to the fact that, when dragging sliders in a Numeric property's histogram in the filter panel, it displays text indicating the current value of the slider - to four decimal places' precision. Perhaps throwing a fifth decimal place at it makes it go boom?