Page 1 of 1

Y2 axis data not updating w/Dplot_AddData

Posted: Thu Jan 06, 2005 3:52 pm
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

Posted: Thu Jan 06, 2005 6:14 pm
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.

Posted: Fri Jan 07, 2005 7:35 am
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!

Posted: Fri Jan 07, 2005 9:04 am
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.

Posted: Fri Jan 07, 2005 9:45 am
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!

Posted: Fri Jan 07, 2005 10:12 pm
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.

Posted: Thu Jan 13, 2005 1:55 pm
by markyland
Many thanks! :)