Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Querying two cursors for one graph
Message
From
20/03/1998 11:21:53
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00085921
Message ID:
00086019
Views:
28
>I have a cursor called "authorized" which keeps a running total of amounts authorized over time (thanks Mike Levy and Ed Pikman for helping me make it) and another cursor called "expended" which shows, of course, amounts expended over time. My user wants to see both amounts in one graph. Typical data values look like this:
>
>Authorized:
>approvaldate	SumOfauthorizedMH
>12/1/97	               200
>1/12/98	               882
>1/28/98	              4522
>2/9/98	              7971
>3/12/98                 8971
>
>Expended:
>spenddate               spenthours
>2/18/98	               40
>2/25/98		40
>3/4/98     	40
>3/11/98    	53
>
>So I combined the cursors with a UNION SELECT like so:
>
>datefield               authorized                                   expended
>
>12/1/97                       200	
>1/12/98                       882	
>1/28/98                     4522	
>2/9/98                       7971	
>2/18/98                                                                        40
>2/25/98                                                                        40
>3/4/98                                                                          40
>3/11/98                                                                        53
>3/12/98                     8971	
>3/18/98                                                                        64.5
>
>When I try to graph this cursor in Microsoft Graph 97, the last two isolated points aren't graphed. Also, the user wants the "authorized" line to continue at the max amount all the way to the right edge. Graph97 doesn't seem very flexible, and Excel graphing looks the same to me, so I think I need a cursor like this:
>
>datefield               authorized                                   expended
>
>12/1/97                       200	
>1/12/98                       882	
>1/28/98                     4522	
>2/9/98                       7971	
>2/18/98                     7971                                           40
>2/25/98                     7971                                           40
>3/4/98                       7971                                           40
>3/11/98                     7971                                           53
>3/12/98                     8971	                                      53
>3/18/98                     8971                                            64.5
>
>Can anyone think of a SELECT that would make such a thing?
>
>This looks like a toughy. Thank you.
Where is the problem. In selecting or graphing ?
For selecting :
select nvl(a.approvaldate,b.spenddate) as "datefield", ;
       a.SumOfauthorizedMH as authorized, ;
       b.spenthours as "Expended" ;
       from Authorized a ;
           full join Expended b ;
           on a.approvaldate = b.spenddate ;
       into cursor myCursor
Here I didn't fill .null. values for one side with last value because actually no value for it on that date.

For graphing :
*Form.init
#DEFINE TAB CHR(9)
#DEFINE CRLF CHR(13)+CHR(10)
M.CGDATA = "Date"+TAB
scan
    m.cgdata = m.cgdata+TAB+dtoc(datefield)
endscan
go top
M.CGDATA = M.CGDATA+CRLF+"Authorized"+TAB+"Expanded"+CRLF
scan
    m.cgdata = m.cgdata+TAB+str(nvl(authorized,0))
endscan
go top
M.CGDATA = M.CGDATA+CRLF+"Expanded"+TAB
scan
    m.cgdata = m.cgdata+TAB+str(nvl(expended,0))
endscan

<color=green>* Could do with one pass scan..endscan
* but couldn't get "plotby" prop of Graph8
* into work yet - So I put the values for row order
</color>
create cursor test (gen1 g)
append blank
append general gen1 class "msgraph.chart.8" DATA M.CGData
this.addobject("myGraph","Oleboundcontrol")
with this.myGraph
  .height = this.height - 2
  .width = this.width-2
  .left = 1
  .top = 1
  .ControlSource = "test.Gen1"
  .HasLegend = .t.
  .autoformat(4, 1)
  .visible = .t.
endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform