12-04-2020 05:54 AM
Hi,
I have issues that the values on the ColorScaleMarker is scaled by 10. I am quite sure that this has worked before thus I am not sure what the problem is. I have created a simple example (see below) which configure a scale from 5-15, however when the code is started the scale is changed from 50-150. Any idea what the problem is?
<Window.Resources>
<ni:ColorScaleDouble x:Key="colorScale" IsInterpolated="True" Label="Intensity [db]" LabelOrientation="Offset: 180">
<ni:ColorScaleMarker Value="5.0" Color="DarkBlue" />
<ni:ColorScaleMarker Value="7.0" Color="Blue" />
<ni:ColorScaleMarker Value="9.0" Color="Green" />
<ni:ColorScaleMarker Value="12.0" Color="Yellow" />
<ni:ColorScaleMarker Value="15.0" Color="Red" />
</ni:ColorScaleDouble>
</Window.Resources>
<Grid>
<ni:IntensityGraph ColorScale="{Binding Source={StaticResource colorScale}}"/>
</Grid>
Solved! Go to Solution.
12-04-2020 05:02 PM
Unfortunately, I could not reproduce the issue locally, and I am not sure what could cause that behavior. The default Adjuster
is None
, so data values should be be changing the range.
Perhaps try removing the decimal, e.g. changing Value="5.0"
to Value="5"
? (For languages that use a comma ,
instead of period .
as the decimal separator, "5.0" would be equivalent to "50". My understanding is that XAML values are parsed with an invariant culture, but at least that is something to rule out?)
12-04-2020 05:19 PM
You are correct! The issue is the period. If I remove all the decimals it works. That also explain why it worked before since I recently got a new computer and for some reason this computer has , set as separator even though my language (Norwegian) are using . as separator. When I changed windows setting to the period as decimal separator the code also worked with the decimals. Thanks for sorting this out!
Oddvar
12-04-2020 05:29 PM
What I just wrote was not completely true. My language (Norwegian) of course use , comma as decimal separator. However, I always use period as separator when typing code and that has not given me any problems before now. Quite sure the old computer also had comma set as separator as this is default for the language, but for some reason the code then worked. Maybe some other regional setting can fix it without changing from comma to period?
12-07-2020 10:42 AM
After a little more investigation, I believe the parsing difference comes from how we coerce the marker values to handle different scale data types.
This suggests another workaround of using an explicitly typed child element for the value:
<ni:ColorScaleMarker Color="Red">
<ni:ColorScaleMarker.Value>
<system:Double>15.0</system:Double>
</ni:ColorScaleMarker.Value>
</ni:ColorScaleMarker>
(Definitely more verbose, but should ensure consistent parsing on any machine.)
12-09-2020 03:27 AM
Thanks Paul! Yes, this solution works for both comma and period.