Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Disappearing plot line when zoomed

Solved!
Go to solution

I am having a problem with my CNiGraph plot line disappearing when the axes min and max are explicitly defined and they are substantially smaller than they would be if the graph were autoscaled.  I am using measurement studio 8.6.1.465 and NiDaqmx 9.0.2 on windows XP.  I am controlling axis scale either by SetAutoScale() or SetMinMax().  My code is rather large, so I am including snippets of what I am doing below.    

 

I noticed a thread with a similar problem at: http://forums.ni.com/ni/board/message?board.id=232&message.id=3769&query.id=1275984#M3769 

Please help!  I have tried window invalidation, turning on/off immediate updates to the graph, setting axes visible/invisible, etc.

 

-drew 

 

Setup code:

        CNiPlot plot = m_pGraph->GetPlots().Add();
        CNiCursor cursor = m_pGraph->GetCursors().Add();
        //cursor.SetSnapMode(CNiCursor::SnapPointsOnPlot);
        cursor.SetSnapMode(CNiCursor::SnapNearestPoint);
        cursor.SetVisible(true);
        cursor.SetPointStyle(CNiCursor::PointCross);
        cursor.SetCrosshairStyle(CNiCursor::CrosshairNone);
        cursor.SetColor(CNiColor(255,255,255));
        cursor.SetPlot(plot);

        CNiAxes axes = m_pGraph->GetAxes();
        CNiAxis xAxis, yAxis;
        xAxis = axes.Item(1);
        yAxis = axes.Item(2);

        yAxis.FormatString = ".##e";
        xAxis.FormatString = "hh:nn:ss";
        CNiColor lineColor(m_plotArray[i]->m_lineColor);
        plot.LineColor = lineColor;

        plot.XAxis.GetTicks().SetMajorGrid(true);
        plot.YAxis.GetTicks().SetMajorGrid(true);

        plot.XAxis.GetTicks().SetMajorGridColor(CNiColor(60,60,60));
        plot.YAxis.GetTicks().SetMajorGridColor(CNiColor(60,60,60));

    m_pGraph->ChartLength = m_graphLength;
    m_pGraph->ChartStyle = CNiGraph::ChartStrip;
    m_pGraph->SetImmediateUpdates(true);

 

Graphing:

 

CNiReal64Matrix newData;

 

m_pGraph->GetPlots().Item(i+1).ChartXY(newData);
m_pGraph->GetCursors().Item(i+1).SetPosition(newData(0,maxCol),
                                                                    newData(1,maxCol));

0 Kudos
Message 1 of 2
(6,219 Views)
Solution
Accepted by topic author ThaDrewid

I managed to fix this problem, noticing that panning the graph caused the line to redraw properly.  I added a very small amount of 'jitter' to the X axis each time after ChartXY is called. Since autoscale mode seems to refresh just fine, i only introduce jitter if the axis min/max is set explicitly:

 

if (!m_pGraph->Axes.Item("XAxis").GetAutoScale()){
        static double plusMinus = 1.0;
        m_pGraph->Axes.Item("XAxis").SetMinMax(m_pGraph->Axes.Item("XAxis").GetMinimum()+(plusMinus*0.000000001),
                                                m_pGraph->Axes.Item("XAxis").GetMaximum()+(plusMinus*0.000000001));
        plusMinus *= -1.0;

}

 

It seems this is a bug in the graph control since there is no problem with the cursor drawing properly and I should not need to write code like this to keep my plot lines from disappearing?

 

-drew

0 Kudos
Message 2 of 2
(6,205 Views)