Graphing and Charting in Measurement Studio Web Forms Applications
Primary Software: Measurement Studio>>Enterprise Edition (Full Development System)
Primary Software Version: 8.1
Primary Software Fixed Version: 8.1
Secondary Software: N/A
Problem: What are some best practices for graphing and charting in Measurement Studio Web Forms applications?
Solution: A Web Forms application delivers content on demand. For example, while a user can access a Web page at any time, the content and data are only given to the user when the user asks for it, and the user must refresh the page or the page must AutoRefresh for the user to receive updates. Data can become outdated quickly if a user does not refresh at the same rate as the data is acquired. In contrast, a Windows Forms application can automatically update to display data as it becomes available.
Measurement Studio gives you the ability to chart data on the ScatterGraph, WaveformGraph, and ComplexGraph. You use different plot methods to chart the data:
ScatterGraph
- PlotXYAppend
- PlotXYAppendMultiple
- PlotYXAppendMultiple
WaveformGraph
- PlotWaveformAppend
- PlotWaveformsAppend
- PlotWaveformsAppendMultiple
- PlotXAppend
- PlotXAppendMultiple
- PlotYAppend
- PlotYAppendMultiple
ComplexGraph
If you are developing Web applications, you should not use the methods listed above in live data scenarios. For example, you can acquire a sine wave and send one point at a time to a Web application through a network variable. When a user requests the Web page, you call
PlotYAppend with the latest point on the server.
Note: The scenario in this document uses
PlotYAppend; however, the same information applies to all methods in the previous list.
This approach is problematic for the following reasons:
- Users who request the Web page only get one data point and must refresh to view additional points.
- Users refresh the page at different intervals. Users who refresh slowly lose data points sent to the server between refreshing; therefore, users cannot view all the points sent to the Web server. When users view the resulting graph, it does not look like a sine wave. In contrast, if a user refreshes the page too fast, then the user receives stale data. When users view the graph, it does not look like a sine wave.
- Multiple users who connect to the same server receive different views of the data. Data plotted on the graph is dependant on when and how often users make requests to the Web server.
Sending more than one data point at a time will not correct these issues. Appending new data points to old data points results in users viewing an outdated history.
Instead of using
PlotYAppend in Web applications, use the following approach:
- Maintain a revolving history of the latest points acquired on the data acquisition process and send the array of data to the Web server. For example, maintain an array of the latest 1000 points acquired and send the array to the Web server.
- On the Web server, call
PlotY instead of PlotYAppend, and pass PlotY the latest 1000 points.
This approach guarantees that users view the latest 1000 points acquired each time they request the Web page. Viewing the latest 1000 points gives users data history without requiring them to refresh multiple times. Also, requests from multiple clients at approximately the same time will show the same, or nearly the same, view of the acquired data.
Note: Separating a Web application (Web server) from data acquisition is a best practice. The Web server should deliver Web pages to users as fast as possible. Dedicate a separate process for data acquisition, such as a Windows service, console application, or a Windows Forms application, then pass the data through a network variable. Retrieving data from a network variable is easy with the NetworkVariableDataSource control. Support for the Network Variable library was introduced in Measurement Studio 8.1.
Related Links:
Attachments:
Report Date: 10/26/2006
Last Updated: 04/09/2007
Document ID: 42PFKO5B