Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Discrete ticks

Solved!
Go to solution

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.

0 Kudos
Message 1 of 16
(6,394 Views)

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>

~ Paul H
0 Kudos
Message 2 of 16
(6,371 Views)
This does work indeed. But when I don't know max X, it works not good when max is is say 200. I assume that I can change the step every time data is changed, but maybe there is another way to do that?
0 Kudos
Message 3 of 16
(6,300 Views)

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

~ Paul H
0 Kudos
Message 4 of 16
(6,283 Views)

Please check out the attachment. Gridlines are not in the right place (marker is at 19).

I've used Interval: 0, 2

0 Kudos
Message 5 of 16
(6,272 Views)

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.

~ Paul H
0 Kudos
Message 6 of 16
(6,262 Views)

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

0 Kudos
Message 7 of 16
(6,259 Views)

Try to start the range from 16.3 for example...

0 Kudos
Message 8 of 16
(6,253 Views)
Solution
Accepted by topic author eugenem

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;
        }
    }

~ Paul H
0 Kudos
Message 9 of 16
(6,252 Views)

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 ?

 

0 Kudos
Message 10 of 16
(6,250 Views)