03-19-2020 11:17 AM
Hi,
I am trying to scale the vertical axis of a wpf IntensityGraph
Solved! Go to Solution.
04-21-2020 05:18 PM
I believe the Scale Axis Values question would cover the display part? For example, using the CustomSampleRateFormatter
from the second link with Rate="2"
will display from 0 to 400:
<ni:IntensityGraph.VerticalAxis>
<ni:AxisDouble Label="Intensity Y Axis">
<ni:AxisDouble.MajorDivisions>
<ni:RangeLabeledDivisions>
<local:CustomSampleRateFormatter Rate="2" />
</ni:RangeLabeledDivisions>
</ni:AxisDouble.MajorDivisions>
</ni:AxisDouble>
</ni:IntensityGraph.VerticalAxis>
You can further override the formatter’s TryParse
method to control how interactive range editing works, or handle the RangeChanged
event on the axis.
05-05-2020 09:22 AM
Thanks for the help Paul! The solution works for the scaling, but I still have some issues/questions. When adding arrays of size 2000 with Rate = 2, the scale will be from -1 to 4000. I guess this has to do with the fact that first pixel runs from -.5 to 0.5? Any solution to run axis from 0 to 3999? I also normally has interaction mode set to edit range, but when I enter 1000 as new maxvalue this is changed to 2000 as this is also scaled with 2, which is not wanted. Any ideas?
05-05-2020 09:27 AM
Sorry Paul I didn't read the part where you already recomended to override the formatter’s TryParse
method to control how interactive range editing works. Do you have an example on this?
05-06-2020 12:10 PM
For TryParse
, reverse the scaling done in FormatCore
:
public override bool TryParse<TData>( string value, ValuePresenterArgs args, out TData parsedValue ) {
if( !base.TryParse( value, args, out parsedValue ) )
return false;
double result = (Convert.ToDouble( parsedValue ) - Start) / Rate;
parsedValue = (TData)Convert.ChangeType( result, typeof( TData ) );
return true;
}
The intensity renderer displays samples centered on the X and Y values passed in. For arrays, this does mean samples will be centered on integer indices (e.g. the sample at index (0,0) would be drawn from −0.5 to +0.5). If you are still using the FixedSizeIntensityChartCollection
from earlier questions, you could change the row and column values to be centered between integer indices instead:
SequenceBufferPool.CreateIntervalBuffer( rowCount, Unit.None, 0.5, 1.0 )
05-07-2020 07:33 AM
Thanks, works perfectly!!