473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Formatting Charts

rcollins
234 100+
I have a union query that I built so that I can include location average along with corporate average. I then sort the info on the graph so it is lowest to highes, so now the corporate average sits amongst the middle of the group. This givs a visual to where the locations compare to corporate. The problem is, I want the corporate one to be a different colo so it stands out. I know how to change it manually, but as the corporate average can move from quarter to quarter, I would like to use something like criteria where I can say if corp make datapoint dark blue. Is this even possible? If so how would I do this?
Aug 7 '09 #1
21 11787
ADezii
8,834 Expert 8TB
@rcollins
  1. First, set a Reference to the Microsoft Graph XX.X Object Library.
  2. Set the Color Property of an Interior Object, for a specific Member of the SeriesCollection Collection (Series Object):
    Expand|Select|Wrap|Line Numbers
    1. If YaDaYaDaYaDa Then
    2.   'By Series Name or Index
    3.   Me![chtTest].SeriesCollection("2002").Interior.Color = vbBlue
    4.                              'OR
    5.   Me![chtTest].SeriesCollection(2).Interior.Color = vbBlue
    6. Else
    7.   Me![chtTest].SeriesCollection("2002").Interior.Color = vbYellow
    8.                              'OR
    9.   Me![chtTest].SeriesCollection(2).Interior.Color = vbYellow
    10. End If
Aug 9 '09 #2
ADezii
8,834 Expert 8TB
@rcollins
Sorry rcollins, but you can elimate Step #1 in the prior Post since this Reference is not needed.
Aug 9 '09 #3
rcollins
234 100+
ok, so my graph is Graph2, my x axis is CountyOfSurvey and Y axis is Expr1. "Corp" is always one of the values in CountyOfSurvey, this is the one I want to be dark blue. I am assuming I put this in the VB editor under graph2? Can you help to make sure I get the code right?
Aug 10 '09 #4
ADezii
8,834 Expert 8TB
@rcollins
Try:
Expand|Select|Wrap|Line Numbers
  1. Me![Graph2].SeriesCollection("Corp").Interior.Color = vbBlue
Aug 10 '09 #5
rcollins
234 100+
this isnt changing anything. What am I doing wrong?
Expand|Select|Wrap|Line Numbers
  1. Private Sub Graph2_Updated(Code As Integer)
  2. Me![Graph2].SeriesCollection("Corp").Interior.Color = vbYellow
  3.  
  4. End Sub
Aug 10 '09 #6
ADezii
8,834 Expert 8TB
@rcollins
Are you sure that 'Corp' is the Series that is plotted?
Aug 10 '09 #7
rcollins
234 100+
Corp is one of the data in the series, the series is CountyofSurvey
Aug 11 '09 #8
ADezii
8,834 Expert 8TB
@rcollins
You would then have to check the value of the Data Point, then modify the Color of the Data Series, so the code to change the Color, depending on the Point Value would be:
Expand|Select|Wrap|Line Numbers
  1. Me![Graph2].SeriesCollection("CountyofSurvey").Interior.Color = vbYellow 
P.S. - If you are still stuck, and you don't mind, I'll send you my E-Mail Address in a Private Message. You could then Send the Database to me as an Attachment, and as soon as I get a chance, I'll take a look at it. It is up to you.
Aug 11 '09 #9
ADezii
8,834 Expert 8TB
This was a little more complicated then initially envisioned, but rather than going into a detailed, boring, discussion about this possible solution, I'll simply post the code. Should you have any further questions, feel free to ask. This code will replace the existing code in the Charts Command Button (Command17) on the OPCriteria Form.
Expand|Select|Wrap|Line Numbers
  1. 'Seed the Random Number Generator
  2. Randomize
  3.  
  4. 'At a bare minimum, there must be Quarter specified in the 1st Drop Down
  5. 'since this Value is used as a Criteria in multiple, relevant, Queries
  6. If IsNull(Me![Combo28]) Then
  7.   MsgBox "You must enter at least 1 Quarter to analyze", vbExclamation, _
  8.          "No Quarter Defined"
  9.   Me![Combo28].SetFocus
  10.   Me![Combo28].Dropdown
  11.     Exit Sub
  12. End If
  13.  
  14. 'Open the Sub-Report as a Stand-Alone Report, apart from the context
  15. 'of the Main Form. This report is opened in Design/Hidden Mode
  16. DoCmd.OpenReport "OverallBySite", acViewDesign, , , acHidden
  17.  
  18. 'Modify the Interior Color of the Point corresponding to Corp Value. This Interior
  19. 'Color will be assigned 1 of 16 possible Random Values (0 - 14) which will be
  20. 'passed to the QBColor() Function.
  21. Reports!OverallBySite.Report![Graph2].SeriesCollection(1).Points(9).Interior.Color = QBColor(Int(Rnd * 15) + 1)
  22.  
  23. 'Close the Sub-Report containing the Chart, and Save the changes made
  24. DoCmd.Close acReport, "OverallBySite", acSaveYes
  25.  
  26. 'Open the Main Report containing the Sub-Report
  27. DoCmd.OpenReport "OPGraphs", acPreview
P.S. - There is an occasional Error relating to Loading the ActiveX Control which I will leave to you to figure out.
Aug 12 '09 #10
rcollins
234 100+
So, I got that done, and it always randoms the color, but here is the thing. I think I have you backwards. I need the color set to be random on point nine. "Corp" Does not fall on point 9 every time. It is the point I need to compare, if it is "Corp" no matter where it sits is what I need to vary. Sorry for the confusion.
Aug 13 '09 #11
ADezii
8,834 Expert 8TB
@rcollins
I guess you would have to iterate through all the Points in the Single Series, and see if its DataLabel is 'Corp'. If so then modify the Color. The pseudo code, NOT TESTED and intentionally kept lengthy for display purposes, would be analogous to:

Expand|Select|Wrap|Line Numbers
  1. Dim intCounter As Integer
  2.  
  3. For intCounter = 1 To Reports!OverallBySite.Report![Graph2].SeriesCollection(1).Points.Count
  4.   If Reports!OverallBySite.Report![Graph2].SeriesCollection(1).Points(intCounter).DataLabel.Text = "Corp" Then
  5.     Reports!OverallBySite.Report![Graph2].SeriesCollection(1).Points(intCounter).Interior.Color = vbYellow
  6.   End If
  7. Next
Aug 14 '09 #12
ADezii
8,834 Expert 8TB
You could also try to reference the Point by Name instead of Index, as in:
Expand|Select|Wrap|Line Numbers
  1. Reports!OverallBySite.Report![Graph2].SeriesCollection(1).Points("Corp").Interior.Color = vbYellow
Aug 14 '09 #13
rcollins
234 100+
So would this go in palce of the code in the previous post? It gives me an error that OverallBySite is misspelled or refers to a report that isn't open or doent exist, If I have the report open, it errors Object doesnt support this property or method. If I have the report in design view, it opens but the color doesnt change. Any advice?
Aug 14 '09 #14
ADezii
8,834 Expert 8TB
@rcollins
I actually have the Database on my other PC at home and will not be able to access it until tonight or tomorrow. At that time, I'll see if I can achieve the requested results.
Aug 14 '09 #15
rcollins
234 100+
That will be fine. I am focusing on another report in the database so I have something to keep me busy until then
Aug 14 '09 #16
ADezii
8,834 Expert 8TB
@rcollins
I've been wrestling with this problem for awhile now, and the only thing that I can come up with is this rather clumsy, and somewhat complex, solution which has a fairly high degree of accuracy with the data tested. I iterate through the Points in the specified Series, and compare each point's DataLabel against a DLookup() on the RowSource for the specified Point. If there is a match, the Interior Color of the Point is set to Yellow, otherwise the Interior Color is set to a Default (Blue in this case). Hopefully, you may be able to play with it and improve on the accuracy as well as the logic itself, since I simply do not have the time. Replace the existing code in the Click() Event of the Command Button with this code. Should you wish to modify the Point Referenced, change the value of the Constant conPOINT_TO_COMPARE to any other Point. Good Luck, and let me know how you make out.
Expand|Select|Wrap|Line Numbers
  1. Dim intPtCounter As Integer
  2. Const conPOINT_TO_COMAPARE As String = "Corp"
  3.  
  4. 'At a bare minimum, there must be Quarter specified in the 1st Drop Down
  5. 'since this Value is used as a Criteria in multiple, relevant, Queries
  6. If IsNull(Me![Combo28]) Then
  7.   MsgBox "You must enter at least 1 Quarter to analyze", vbExclamation, _
  8.          "No Quarter Defined"
  9.   Me![Combo28].SetFocus
  10.   Me![Combo28].Dropdown
  11.     Exit Sub
  12. End If
  13.  
  14.  
  15. 'Open the Sub-Report as a Stand-Alone Report, apart from the context
  16. 'of the Main Form. This report is opened in Design/Hidden Mode
  17. DoCmd.OpenReport "OverallBySite", acViewDesign, , , acHidden
  18.  
  19. For intPtCounter = 1 To Reports!OverallBySite.Report![Graph2].SeriesCollection(1).Points.Count
  20.   If Reports!OverallBySite.Report![Graph2].SeriesCollection(1).Points(intPtCounter).DataLabel.Text = _
  21.      FormatNumber(DLookup("[Expr1]", "OverallBySite", "[CountyOfSurvey]='" & conPOINT_TO_COMAPARE & "'"), 2) Then
  22.        Reports!OverallBySite.Report![Graph2].SeriesCollection(1).Points(intPtCounter).Interior.Color = vbYellow
  23.   Else
  24.     Reports!OverallBySite.Report![Graph2].SeriesCollection(1).Points(intPtCounter).Interior.Color = vbBlue
  25.   End If
  26. Next
  27.  
  28. 'Close the Sub-Report containing the Chart, and Save the changes made
  29. DoCmd.Close acReport, "OverallBySite", acSaveYes
  30.  
  31. 'Open the Main Report containing the Sub-Report
  32. DoCmd.OpenReport "OPGraphs", acPreview
Aug 15 '09 #17
ADezii
8,834 Expert 8TB
@ADezii
P.S. - The reason for the other than 100% accuracy is that you are comparing the DataLabel of the Point, which has 2 Decimal places of Precision to the actual Point Value which has a higher Degree of Precision, as in:

Corp with 2009 Quarter2 results with the following comparison:
Expand|Select|Wrap|Line Numbers
  1. 3.93 <==> 3.93331635684577
Aug 15 '09 #18
ADezii
8,834 Expert 8TB
@ADezii
I use FormatNumber to force 2 Decimal Places, but it seems as though the comparison now becomes:
Expand|Select|Wrap|Line Numbers
  1. 3.93 <==> 3.94
In any event, I'm sure you'll work out this minor point. To confuse you even more so, when you use a single Quarter of 2009 Quarter 2, the Test Results are perfect on all 15 Points. Figure that out, and therein lies your answer!!!
Aug 15 '09 #19
rcollins
234 100+
I really appriciate your help. I have it working to the extent that you did, and set the values to be 2 dec places. I will keep working on this since the only qwuarter that changes color is 2009 quarter 2. I wish I had more data than 3 quarters, but we will get there.
Aug 17 '09 #20
rcollins
234 100+
So when I go into the properties of the graph to set percision, I realized that every time I rerun the report, the settings are not there. The query where the info comes from is a union, and I am not sure how to set precision in sql. Here is the query I am using for this chart
Expand|Select|Wrap|Line Numbers
  1. SELECT OPQuestionAvg1.CountyofSurvey, OPQuestionAvg1.SurveyCode, Avg(([1]+[2]+[3]+[4]+[5]+[6]+[7]+[8]+[9]+[10]+[11]+[12]+[13]+[14]+[15]+[16])/16) AS Expr1
  2. FROM OPQuestionAvg1
  3. GROUP BY OPQuestionAvg1.CountyofSurvey, OPQuestionAvg1.SurveyCode
  4. UNION SELECT "Corp" AS CountyOfSurvey, OPQuestionAvg1.SurveyCode, Avg(([1]+[2]+[3]+[4]+[5]+[6]+[7]+[8]+[9]+[10]+[11]+[12]+[13]+[14]+[15]+[16])/16) AS Expr1
  5. FROM OPQuestionAvg1
  6. GROUP BY OPQuestionAvg1.SurveyCode
  7. ORDER BY Expr1;
  8.  
Thanks
Aug 17 '09 #21
ADezii
8,834 Expert 8TB
@rcollins
not sure how to set precision in sql
I think you are referring to the Scale which is the number of Digits to the right of the Decimal Point. This Setting does not exist in Access Databases, but does in *.adps and SQL Server Tables. I didn't give up yet, there must be a way to directly access the actual value of a Data Point for a given Series, but it still eludes me.
Aug 17 '09 #22

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MT | last post by:
Hello Everyone: I would like to make some charts based on data I am retrieving from my DB. The charts should be things like bar-charts, pie-charts, line-graphs etc. Th charts can be in any...
4
by: Paul Gardella | last post by:
Folks, Does anyone know of a Python module for building organization charts? I've looked at gdchart and JPGraph, but neither of them do org charts, as far as I can tell. Seems it can be done...
1
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
5
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
0
by: STeve | last post by:
Hey guys, I just want to thank you guys in advance. I am currently having problems displaying some dynamically generated charts using office web components. If I am an admin on the server, I...
3
by: vanisathish | last post by:
Hi All, Is there a way to draw charts from SQL Server Data using ASP.?Is it possible to use the SQL Reporting Services using ASp
3
by: NickJ | last post by:
Dear all, I've encountered an unusual problem having just recently upgraded an Access 97 database to Access 2000 format and was hoping somebody could point me in the direction of a solution. ...
2
by: Arina Soukhoroukova | last post by:
Hello, i'm currently programming on a web application for stock data. Now i want to create very fancy ;-) stock charts images (jpegs/gifs/pneg), like line charts for stock data and bar charts for...
4
by: Wayne | last post by:
I have posted this problem a couple of times over the last few years but have been unable to find a solution that works. Sometimes charts in reports will display showing the design data instead of...
6
by: chaelon | last post by:
I'm trying to gather info on whether VB.NET would be right for my application needs. I need to create basic charts, such as line charts, bar charts, pie charts, etc., with maybe regression lines...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.