Page 1 of 1

RMChart - dynamic chart w/ incomplete data.

Posted: Fri Jun 03, 2011 9:39 pm
by jassing
I'm trying to create a chart that shows "income" over the span of the day
In the code below, it creates a graph and runs it -- however, it shows a line "to zero" after the last data point.

ie: a day has 40 data points (7am to 5pm every 15 minutes there's a new data point)
Ok -- so at 8am there's only 5 data points (7,7:15,7:30, 7:45,8:00) but after the 8am data point, the line drops to zero.
Image

I've tried saying there's only "5 data ponits" but then it graphs all the way across.

Anyone have an idea how to do this so it doesn't 'drop to zero'?
I would rather not try to draw a custom object line with a dynamically resized graph (unless I'm missing something, this task seems not as easy as it shoudl be)

Thanks
-josh

Code: Select all

nHours = 10

nDataPoints = nHours * 4
Dim aData(0)
Dim aGoal.d( nDataPoints )
For x = 0 To nDataPoints-1
	aGoal(x) = 100
Next

nCount = 1
Dim aTotal.d(nCount)
aTotal(0)=0

OpenWindow(0, 393, 59, 780, 250, "Daily Income", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
hParentDlg = WindowID(0)

RMC_CreateChart(hParentDlg,1,10,10,760,240,#ColorDefault,#RMC_CTRLSTYLE3D,#False,"","Tahoma", 0, #ColorDefault)
RMC_AddRegion(1,5,5,-5,-5,"",#False) 
RMC_AddGrid(1,1,#ColorDefault,#False,0,0,0,0,#RMC_BICOLOR_NONE) 
RMC_AddDataAxis(1,1,#RMC_DATAAXISLEFT,0,0,11,8,#ColorDefault,#ColorDefault,#RMC_LINESTYLESOLID,0,"$","","",#RMC_TEXTCENTER) 

sTemp.s = "7**^**8**^**9**^**10**^**11**^**12**^**1**^**2**^**3**^**4**^**5"
RMC_AddLabelAxis(1,1, sTemp,1,nDataPoints,#RMC_LABELAXISBOTTOM,8,#ColorDefault,#RMC_TEXTCENTER,#ColorDefault,#RMC_LINESTYLESOLID,"") 

RMC_AddLineSeries(1,1, @aData(0), 0,0,0,#RMC_LINE,#RMC_LINE_FLAT,#RMC_LSTYLE_LINE,#True,#ColorRed,#RMC_SYMBOL_NONE,1,#RMC_VLABEL_NONE,#RMC_HATCHBRUSH_OFF) 

RMC_SetSeriesData(1,1,1,@aTotal(0),nDataPoints)

RMC_AddLineSeries(1,1, @aData(0), 0,0,0,#RMC_LINE,#RMC_LINE_FLAT,#RMC_LSTYLE_LINE,#True,#ColorRed,#RMC_SYMBOL_NONE,1,#RMC_VLABEL_NONE,#RMC_HATCHBRUSH_OFF) 
RMC_SetSeriesData(1,1,2,@aGoal(0),nDataPoints)

RMC_Draw(1)

Repeat 
	h = WaitWindowEvent(1000)
	If h = 0 And nCount < nDataPoints
	Debug h
	nCount+1
	ReDim aTotal(nCount)
	aTotal(nCount-1) = aTotal(nCount-2)+Int(Random(10))
	RMC_SetSeriesData(1,1,1,@aTotal(0),nDataPoints)
	RMC_Draw(1)
	EndIf
	If h = #PB_Event_CloseWindow
		CloseWindow(0)
		Break
	EndIf
	
ForEver

Re: RMChart - dynamic chart w/ incomplete data.

Posted: Sat Jun 04, 2011 8:23 pm
by IdeasVacuum
Make the Axis tick count the same as the max value?

Re: RMChart - dynamic chart w/ incomplete data.

Posted: Sat Jun 04, 2011 9:13 pm
by jassing
well; that's one way -- but then as the data grows, the chart resizes -- what I'm after is a graph that shows the full range and only plots to the point that it has... so it adds to the chart as needed -- but doesn't redraw with new ratios.

Re: RMChart - dynamic chart w/ incomplete data.

Posted: Sat Jun 04, 2011 11:50 pm
by IdeasVacuum
Hey, you changed the question? Edit: Ah, may be not, I thought my previous suggestion was on this: http://www.purebasic.fr/english/viewtop ... =5&t=46541 :?

It should be possible to draw 2 graphs - 1st one is the full size chart without data, saved and displayed as an image. 2nd graph superimposed on the image, redrawn each time there is a change, and only has the range of it's current data.

Re: RMChart - dynamic chart w/ incomplete data.

Posted: Sun Jun 05, 2011 9:45 pm
by jassing
Thanks -- gives me something to try -- but when I did try something similar (two graphs) I couldn't get the alignment just right.

And I know what you mean - - they were similar; indeed -- I woke up this morning thining "Shit, did I reply as if he posted to the other..."

Thanks
-j