10-19-2014 09:16 AM
Please check out the attached image. I need to leave only discrete ticks (and lines) at X axis, e.g. 1, 2, 3, 4... There are some measurements where X axis is an index, not a continuous value, so 1.2 is meaningless.
Solved! Go to Solution.
10-20-2014 10:53 AM
The simplest way to customize the divisions would be to use an interval value for the Mode
on the MajorDivisions
:
<ni:AxisDouble x:Name="xAxis"
Orientation="Horizontal">
<ni:AxisDouble.MajorDivisions>
<ni:RangeLabeledDivisions Mode="Interval: 0, 1" />
</ni:AxisDouble.MajorDivisions>
</ni:AxisDouble>
10-26-2014 01:16 PM
10-27-2014 01:47 PM
The other approach would be to derive from RangeDivisionsMode
and provide a custom GetDivisions
implementation (either calling an existing implementation and filtering the results, or generating your own values based on the incoming range; e.g. wpf graph scale with dynamic ticks).
10-28-2014 05:06 AM
Please check out the attachment. Gridlines are not in the right place (marker is at 19).
I've used Interval: 0, 2
10-28-2014 09:36 AM
When I tried to reproduce the issue with an interval Mode
, it generated the expected set of divisions (16, 18, 20, 22, 24, 26, 27):
<ni:AxisDouble Orientation="Horizontal" Range="16, 27, System.Double">
<ni:AxisDouble.MajorDivisions>
<ni:RangeLabeledDivisions Mode="Interval: 0, 2" />
</ni:AxisDouble.MajorDivisions>
</ni:AxisDouble>
However, based on the irregular label values and their regular spacing, it looks more like a count mode is being used. For example, Count: 5
generates 16, 18.75, 21.5, 24.25, 27; if the division values are rounded when they are formatted, you would see 16, 19, 21, 24, 27 from the screenshot.
10-28-2014 09:48 AM
That's not the issue, as if I pan the graph a little, I can move the gridline to be from the other side of the marker. Also this happens with interval 0,1 too
10-28-2014 10:08 AM
Try to start the range from 16.3 for example...
10-28-2014 10:21 AM
I was able to reproduce the new issue with the grid lines becoming out of sync with the divisions. This appears to be caused by the generated division values staying the same, even though they are placed at offset locations (whenever the minimum or maximum changes, it introduces a new division to the collection and I see the grid lines redraw). I have created a task to address this issue.
As a workaround, I was able to force grid line updates with a custom division mode that changed the total number of divisions by adding duplicating elements:
public sealed class CustomDivisionsMode : RangeDivisionsMode {
bool duplicateFlag;
public override IList<TData> GetDivisions<TData>( IRangeDataMapper<TData> mapper, int divisionsEstimate ) {
IList<TData> divisions = ...
// Change the number of duplicated elements to force an update.
duplicateFlag = !duplicateFlag;
divisions.Add( divisions[divisions.Count - 1] );
if( duplicateFlag )
divisions.Insert( 0, divisions[0] );
return divisions;
}
}
10-28-2014 10:29 AM
Currently I use
AxisX.MajorDivisions.Mode = RangeDivisionsMode.CreateIntervalMode(0, AxisX.Range.Maximum > 20 ? Math.Round( AxisX.Range.Maximum / 10 ) : 1);
How do I switch to CustomDivisionsMode ?