Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Intensityr Graph scale

Solved!
Go to solution

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>

0 Kudos
Message 1 of 6
(1,928 Views)

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?)

~ Paul H
0 Kudos
Message 2 of 6
(1,902 Views)

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

0 Kudos
Message 3 of 6
(1,896 Views)

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?

0 Kudos
Message 4 of 6
(1,893 Views)
Solution
Accepted by topic author OddvarC

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.)

~ Paul H
0 Kudos
Message 5 of 6
(1,873 Views)

Thanks Paul! Yes, this solution works for both comma and period.

0 Kudos
Message 6 of 6
(1,862 Views)