Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help creating Graph

Status
Not open for further replies.

garry1

Programmer
Dec 6, 2002
49
US
I am trying to create a cummulative line graph. I have problem displaying the cummulative value. For example on x axis I am displaying days monday, tuesday. If I worked 4 hrs on monday and 3 hrs on tuesday, I would like to show 4 hrs on monday and 7 hrs on tuesday. How do I add up the previous value to the current value.
 
You'll need to do work on the column value (Hours?) being passed to the graph before it gets there. Look to the GroupSection's OnRow( ) maybe. You'll need a static parameter, say CombinedHours. When you read in the datarow, you'll need something like

Hours = CombinedHours + Hours
CombinedHours = CombinedHours + Hours

The first pass will be the column value. Each subsequent pass will accumulate the hours and pass it on as if it were straight form the database. Reset CombinedHours in the Finish( ) if needed.
 
I am using series key as employee name.There are 3 employees. I need to the show the cummulative hours line graph for each employee per each day. How to calculate the cummulative hours for each employee per day. Thanks.
 
I wish this forum had the capabilities to include attachments with the messages.... But, I'll try to map it out in text. I created a table with Name, day and hours. My design was as follows:

ReportRoot
-Content-ReportSection
-Connection
-DataStream
-DataRow
-Content - Frame
-DetailGraph

DetailGraph has the following properties:

ChartTpeSpecific -
ChartType: ChartLine
ShowLines: True
ShowSymbols: True

Expressions -
SeriesExp: [Table1.Name]
XLabelExp: [Table1.Day]
XValueExp: [Table1.Day]
YValueExp: [Table1.hours]

Finally, you'll need to create a couple static variables to
1. Check current group key to previous group key (name)
2. Accumulate your hours

What I did was create a global, FirstTime, initialized to True. In the DataRow OnRead( ) I have:

Sub OnRead( )
Super::OnRead( )
' Insert your code here

Static HourAccum As Integer
Static KeyVal AS String

If FirstTime Then
FirstTime = False
KeyVal = Table1_Name
End If

If KeyVal = Table1_Name Then
HourAccum = HourAccum + Table1_Hours
Table1_Hours = HourAccum
Else
HourAccum = Table1_Hours
KeyVal = Table1_Name
End If


End Sub

Needless to say the code is crude, but for an example... what can I say? You may want to consider doing this in your Fetch( ) method instead, depending on the complexity of your code and what additional things you may need to do.

See if this can get you in the right direction at least. This provided a chart with lines which (of course) increased as they progressed.


Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top