Y2 axis data not updating w/Dplot_AddData

Q&A for Visual Basic, Visual Basic .NET, and PowerBasic developers using DPlot

Moderator: DPlotAdmin

Post Reply
markyland
Posts: 4
Joined: Thu Jan 06, 2005 3:37 pm

Y2 axis data not updating w/Dplot_AddData

Post by markyland »

Hello,

Bad news about the forum trouble :( . Last month I posted a question about enabling the second Y axis, to which you suggested code like:

Code: Select all

	DPlot_Command glDocNum, "[ManualScale(0,0,.05,1,0,400)][SelectCurve(3)][MultipleYAxes(2,2,0)]"
Works well, the second Y axis appears on the right side of the DPlotJr window. The trouble is that data for Curve 3 (assigned above) isn't updating in real time with the DplotLib.dll function "DPlot_AddData". Data for Curve 1 updates ok. If I force a redraw of the window using the "ViewRedraw()" command then the Curve is updated to that point, but no new data is displayed. I thought of using the ViewRedraw() command after every data point, but that results in too much flicker.

Here's how I'm creating the DplotJr window (using PowerBASIC):

Code: Select all

	ghDPlot = DPlot_Start(0, DPlotWasActive)

	' Get the screen work area, for positioning the DPlot window
	SystemParametersInfo %SPI_GETWORKAREA, 0, rcWork, 0

	' Move DPlot to lower right corner of screen
	GetWindowRect(ghDlg, rc)
	cx = 550
	cy = 425
	SetWindowPos ghDPlot, %HWND_TOPMOST, rcWork.nRight - cx, rcWork.nBottom - cy, cx, cy, %SWP_HIDEWINDOW

	' Use MsgBox to report errors
	DPlot_SetErrorMethod(2)

	' Create a new document
	glDocNum = DPlot_Command(0, "[FileNew()]")

	' Instruct DPLOT to allocate space for 3 curves, 2 hour's worth of data each
	DPlot_Command glDocNum, "[FileArrays(3,7200)]"

	' Set a few plot parameters: .03" line width, solid line
	DPlot_Command glDocNum,  "[LineWidth(1,30)][LineWidth(2,30)][LineWidth(3,30)]"
	DPlot_Command glDocNum, "[LineType(1,1)][LineType(2,1)][LineType(3,1)]"

	' Curve colors
	DPlot_Command glDocNum, "[Color(1,255,0,0)][Color(2,0,0,255)][Color(3,0,255,0)]"

	DPlot_Command glDocNum, "[ManualScale(0,0,.05,1,0,400)][AutoSize()]" & _
		"[SelectCurve(3)][MultipleYAxes(2,2,0)]" & _
		"[NumTicks(1,12,10)]" & "[NumberFormat(0,5)][TimeFormat(" & $DQ & "mm:ss" & $DQ & ")]"

	' Set labels, titles, fonts
	DPlot_Command glDocNum, "[XAxisLabel(" & $DQ & "Time" & $DQ & ")]" & _
		"[YAxisLabel(" & $DQ & "l/min" & $DQ & ")]" & _
		"[Y2AxisLabel(" & $DQ & "kPa" & $DQ & ")]" & _
	  	"[FontPoints(1,10)][FontPoints(2,12)][FontPoints(4,12)][FontPoints(6,10)]" & _
		"[Caption(" & $DQ & "VFC Tools" & $DQ & ")]"

	' Legend config
	DPlot_Command glDocNum, "[LegendParams(0.25,3,1,1,.05,.05)]" & _
		"[Legend(1," & $DQ & "Curve 1" & $DQ & ")][Legend(2," & $DQ & "Curve 2" & $DQ & ")]" & _
		"[Legend(3," & $DQ & "Curve 3" & $DQ & ")]"

	' Hide menus & such
	DPlot_Command glDocNum, "[MenuUpdates(0)]"
	DPlot_Command glDocNum, "[ViewToolBar(0,0)]"
	DPlot_Command glDocNum, "[MenuHide()]"
	DPlot_Command glDocNum, "[ViewStatusBar(0)]"

' And to add the data for curves 1 and 3:
DPlot_AddData glDocNum, %DATA_XYXY, 1, 1, fTimeData, fYdata
DPlot_AddData glDocNum, %DATA_XYXY, 1, 3, fTimeData, fY2Data

Any ideas?

Thanks,

Mark
Mark Newman
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Oops. Your points are being scaled to the first axis, not the second. My guess is they're outside the range 0-1 and so aren't shown. There's nothing you can do about this at your end; I'll have this fixed in the next update.
Visualize Your Data
support@dplot.com
markyland
Posts: 4
Joined: Thu Jan 06, 2005 3:37 pm

Post by markyland »

Thanks for the reply. Just so I'm clear on this, forcing a full plot redraw causes the data to be scaled correctly against the Y2 axis, but the runtime addition of data using Dplot_AddData() doesn't?

I just rescaled my Y-axis from 0-1000 and presto, the Y2 data appears and updates normally. However it is scaled correctly against the *Y2* axis and not the Y axis.

Hmmm, what to do? The issue I'm facing is that both the Y and Y2 axis scaling can vary quite a bit (depending on the units of measure the user selected), with the Y axis scaling often smaller than the Y2 axis.

Would it be possible to get an updated version, by say, um, today? :wink: (Don't you just hate it when people ask for immediate changes to free software?!) I'd happily accept a beta version, as my software is also at a beta level, but it's due on Monday! (Gads, why did I commit to that date? :oops: ) Anyway, to show I'm no ingrate, I'd happily buy a copy of DPlot in appreciation.

Thanks!
Mark Newman
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

I didn't state the problem quite correctly and yeah, the values are scaled correctly. The points are simply ignored if they're outside the extents, but the code was checking against the wrong extents. This is fixed. I have a few other issues to work out before uploading a beta version late tonight. I'll let you know when it's available by e-mail.
Visualize Your Data
support@dplot.com
markyland
Posts: 4
Joined: Thu Jan 06, 2005 3:37 pm

Post by markyland »

Good to hear!

Just FYI, I was able to use the ViewRedraw command to redraw the plot by bracketing it with the LockWindowUpdate API call:

Code: Select all

	LockWindowUpdate ghDPlot
	DPlot_Command glDocNum, "[ViewRedraw()]"
	LockWindowUpdate ByVal %NULL
There's still an occasional "flick" but it's certainly good enough for my beta needs, so don't kill yourself trying to get a beta out tonight.

Thanks!
Mark Newman
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Beta version of DPlot Jr is here: http://www.dplot.com/beta/dplotjr_setup.exe. Full evaluation version is here: http://www.dplot.com/beta/dplotsetup.exe. You can read about all recent changes here: http://www.dplot.com/revisions.htm#1980. All changes other than bug fixes are subject to change.

Edit: Links changed to normal downloads, which include all changes mentioned.
Last edited by DPlotAdmin on Wed Apr 19, 2006 10:52 pm, edited 2 times in total.
Visualize Your Data
support@dplot.com
markyland
Posts: 4
Joined: Thu Jan 06, 2005 3:37 pm

Post by markyland »

Many thanks! :)
Mark Newman
Post Reply