Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

can waveformgraph zoom more than once?

Hi -

I'm using Measurement Studio 8.0.1 with .NET2.0 and ASP.NET 2.0, and I've got the WaveFormGraph plotting data, and I can zoom by selecting a rectangle on the graph. Once I try to zoom a second time, though, the chart goes blank and I have to rebind it to get anything to show up.

Do you know what could be causing this?

Thanks!
Terry
0 Kudos
Message 1 of 12
(4,794 Views)
Can you send more information about exactly what you are trying to do?
 
Brock
0 Kudos
Message 2 of 12
(4,760 Views)
Here's my markup:
<ni:WaveformGraph ID="Graph" runat="server" Height="418px" Width="590px" InteractionMode="ZoomX, ZoomY, EditRange, PlotAreaClick" PlotAreaColor="WhiteSmoke" ImageType="Jpeg" Selectable="True" SelectionColor="Yellow">


I can plot some data on it. Highlight an area to zoom, good. Highlight in that new area (the zoomed in one) to zoom in again, and the chart goes blank.

Thanks!
Terry
0 Kudos
Message 3 of 12
(4,756 Views)
It works for me. Here is my graph control :
 
 <ni:WaveformGraph ID="Graph" runat="server" Height="418px" Width="590px" InteractionMode="ZoomX, ZoomY, ZoomAroundPoint, EditRange" PlotAreaColor="WhiteSmoke" ImageType="Jpeg" Selectable="True" SelectionColor="Yellow">
            <XAxes>
                <ni:XAxis>
                </ni:XAxis>
            </XAxes>
            <Plots>
                <ni:WaveformPlot XAxis="XAxes[0]" YAxis="YAxes[0]" />
            </Plots>
            <YAxes>
                <ni:YAxis>
                </ni:YAxis>
            </YAxes>
        </ni:WaveformGraph>
 

I don't think you want the PlotAreaClick interaction. This just causes a postback and doesn't actually do a zoom. All the other interactions don't do a postback but rather a XMLHttpRequest. So In my example I don't use it.

Here is my code behind.

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // I don't need to plot every time because the data is stored in the Session State
            // between postbacks by default. See XYPlot.DataStateManagement property.
            Graph.PlotY(new double[] { 0, 1, 2, 3, 4, 5 });
        }
    }

To zoom, left click the mouse and drag in the graph. To undo, Shift-LeftClick

Brock

0 Kudos
Message 4 of 12
(4,746 Views)
No success yet. Could it have anything to do with the way I'm feeding data to the graph? I'm creating plots one at a time, depending on the number of series given, and adding it to the graph's collection. Like this:

    Public Sub BindData()
        Clear()
        SetupGraph()
        Dim count As Integer = 0
        For Each s As Series In m_data.TestDataViewChartSettings.Series
            Dim plot As NationalInstruments.UI.WaveformPlot = AddPlot(s, count)
            count += 1
            Legend1.Items.Add(New NationalInstruments.UI.LegendItem(plot, s.ColumnName))
            'Graph.Cursors.Add(New NationalInstruments.UI.XYCursor(plot))
        Next
    End Sub

    Private Function AddPlot(ByVal s As Series, ByVal plotNumber As Integer) As NationalInstruments.UI.WaveformPlot
        Dim p As New NationalInstruments.UI.WaveformPlot(Graph.XAxes(0), Graph.YAxes(s.YAxisIndex))
        p.LineWidth = 2
        p.PlotY(m_presenter.GetSeriesDataPoints(s))
        p.LineColor = GetColor(plotNumber)
        Graph.Plots.Add(p)
        Return p
    End Function

BindData() is called for every postback, but the page doesn't seem to be performing a postback. Again, zoom works once, but trying to zoom in on already-zoomed-data causes the chart to go blank (not the legend, just the plotted data).
0 Kudos
Message 5 of 12
(4,721 Views)
During a client callback (zoom operation) the page goes through a shortened lifecycle. It executes the Init, LoadViewState, and Load functions of the lifecycle. SaveViewState and Render, however are not called. I am not sure where the DataBind() function is being called from but if it is called from one of the three functions above that get executed during a client callback (should be Load), that would explain why you are seeing it get called even though a postback was not issued.
 
LoadViewState not executing in the client callback could be significant here (this is how ASP.NET works with a client callback and we can't do anything about this). It looks like you are adding plots dynamically, which relies on the ViewState mechinism to add those plots on the next page load. This may explain why you are seeing it work the first time. Again, it is hard for me to tell with the code posted. There are several functions like Clear() and SetupGraph() which are not defined. But image this scenario:
 
1. First page request I add a plot and plot data to it. The newly added plot is saved in the SaveViewState lifecyle.
2. I do a zoom and the shortened page lifecyle of the client callback adds the plot from the previous lifecyle via the ViewState in the LoadViewState phase. It also adds its data from the SessionState (if the XYPlot.DataStateMangement is set accordingly). Now the zoom is executed on the graph and the new image is taken and sent back to the client. Notice no LoadViewstate is executed here. So if plots where added at this time they are going to be lost on the next zoom or postback. They will show up in the new image sent back with the 1st zoom, but another zoom will cause the added plot to be lost.
 
Client callbacks are meant for little operations because certain state (like ViewState) is not preserved. They are light weight operations and meant to be quick. When doing client callbacks it is important to avoid dependences on state changes on the graph (like adding plots, changing colors, etc). Only the data and various zoom operations are preserved.
0 Kudos
Message 6 of 12
(4,713 Views)
I tested out what you said, and even though BindData is called from the page's load handler, it's only called if !Page.isPostBack. I stepped through it during a zoom operation, and it doesn't call BindData. If I read what you said correctly, if I was rebinding data on one of the chart's callbacks (which I'm not) and was tweaking the data that gets bound to the chart, I'd see some strange behavior. If I misunderstood, feel free to tell me 🙂

I found another thread that describes a problem similar to the one I'm having.
http://forums.ni.com/ni/board/message?board.id=232&message.id=3801&query.id=74658#M3801

Any idea what else could cause this behavior? Would it help if I reproduced it with a simpler project and sent you that code?

Thanks!
Terry


0 Kudos
Message 7 of 12
(4,707 Views)
Yes, reproduce it in a simple project and send the code.
 
Brock
0 Kudos
Message 8 of 12
(4,701 Views)
You were right, it had to do with viewstate. We were using a custom viewstate manager that stored it with session, and on the 2nd callback the data was lost.

Thanks for the tip!

Also, what's the maximum number of data points that the waveform graph can plot?

Thanks again!
Terry
0 Kudos
Message 9 of 12
(4,678 Views)
Theoretically, there is no limit to the number of points (data) to be plotted. The amount of virtual memory is the limitation. However, in a web application it is always a good idea to be sensitive to the size of the data. By default, our controls store the data in the Session state. If you are using the InProc model, it uses the server memory to hold the data.
 
Brock
0 Kudos
Message 10 of 12
(4,666 Views)