MS Chart Reliability - Radar Chart / 3D Pie Chart
I see a lot of issues with MS chart.... I'm mostly coding my charts (not using MS Chart), but I'm stuck with the Radar Chart ... I haven't found any examples to work on and I need this chart badly (a polygon with nine corners - a nonagon).
Any feedback on MS Chart? Is it reliable and stable? If it is I might end up using it to create my radar chart, but I'm not sure MS Chart can make a Radar Chart... if not then:
The image I've attached shows what I want to code.
Does anybody have any code regarding a RADAR CHART? (not an Active X, source code)
Thanks
_________________________________________________________________
Edited by - vbprog1144 on 5/19/2005 11:48:26 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Radar Chart In VB
As the subject says, how the heck do i go about doing this, i just have 4 lines drawn on my screen for now. Not sure what kinda calculation i need to make for it link with each other. You might looked at the radar chart in Excel, I am working on the exact same implentation. Anybody has any ideas on how to start with this ???
"Phantom moves faster than the eye can see" ... Old Jungle Saying
Radar Chart - Nonagon / How Can I Code It?
I need to create a Radar Chart, a Nonagon like the ones you can create in Excel... MS Chart does not have the option.... how can I code it? It will be pulling data to chart from an Access 2002 DB - from nine fields. I've attached a jpeg example of the chart I need.
vbprog1144
Embedded Chart In A Worksheet And A Chart Exisiting On Its Own Sheet
what is the difference between a Chart embedded in a worksheet and a chart existing on their own sheets. i mean what is the difference between being embedded in a worksheet and existing on their own sheets.
i came across the statement on the MSDN site
Note Charts embedded in a worksheet are members of the ChartObjects collection, whereas charts that exist on their own sheets belong to the Charts collection.
Is There A Good Graph/Chart Tool Anywhere??? MS Chart Isn't Working For Me!!!
I need to graph 4 columns of data against a time (x-axis) produced from a SQL select in VS.net. I've tried working with the MS chart, but its hard to work with and looks even worse.
I'm looking for something that can produce a "smooth" line chart.
Does anyone know of a GOOD graph/chart tool compatible with VS.net (windows app though, not Web app.)???
And if it is a free tool, that would be even better!!!
Julez
Create Chart In Access Using Chart Object
Code:
Dim rpt As Access.Report
Dim ctlObjFrame As Access.ObjectFrame
Dim SQL As String
Dim cw_rs As DAO.Recordset
SQL = "SELECT (Format([Date1],'DDDDD')),Sum([Events]) AS [SumOfEvents] FROM [Data] GROUP BY (Int([Date1])),(Format([Date1],'DDDDD'))"
Set rpt = CreateReport
Set ctlObjFrame = CreateReportControl(rpt.Name, acObjectFrame, , "", "", 100, 100)
Set cw_rs = CodeDb.OpenRecordset(SQL, dbopendynaset)
cw_rs.MoveFirst
ctlObjFrame.OleData= cw_rs!ChartObject
DoCmd.Restore
I got the above code from a site. It creates a new report & an objectFrame. But during run-time it gives error in "ctlObjFrame.OleData" as "Items not found in the collections" error. Can anyone please tell me why i get this error.
Chart Director Chart Viewer
i have a sample code here for my graph:
Public Sub createChart(viewer As Object, img As String)
Dim cd As New ChartDirector.API
Dim i As Integer
'The XY points for the scatter chart
Dim dataX0()
dataX0 = Array(summationx)
Dim dataY0()
dataY0 = Array(summationy)
' Dim dataX1((frminput.txtx(i - 1)))
' dataX1 = Array((frminput.txty(i - 1)))
'
' Dim dataY1()
' dataY1 = Array()
'Create a XYChart object of size 450 x 420 pixels
Dim c As XYChart
Set c = cd.XYChart(1000, 1000)
'Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey
'border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light
'grey color (0xc0c0c0)
Call c.setPlotArea(55, 65, 350, 300, -1, -1, &HC0C0C0, &HC0C0C0, -1)
'Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12
'pts Times Bold Italic font. Set the background and border color to Transparent.
Call c.addLegend(50, 30, False, "timesbi.ttf", 12).setBackground(cd.Transparent)
'Add a title to the chart using 18 pts Times Bold Itatic font.
'Call c.addTitle("Center of Gravity", "timesbi.ttf", 18)
'Set the axes line width to 3 pixels
Call c.xAxis().setWidth(3)
Call c.yAxis().setWidth(3)
'Add an orange (0xff9933) scatter chart layer, using 13 pixel diamonds as symbols
For i = 0 To UBound(arrX)
Call c.addScatterLayer(arrX, arrY, "", cd.DiamondSymbol, 13, &HFF9933)
Next
'Add a green (0x33ff33) scatter chart layer, using 11 pixel triangles as symbols
Call c.addScatterLayer(dataX0, dataY0, "Strategic Area", cd.TriangleSymbol, 13, _
&H33FF33)
'output the chart
Set viewer.Picture = c.makePicture()
'include tool tip for the chart
viewer.ImageMap = c.getHTMLImageMap("clickable", "", _
"title='[{dataSetName}] X = {x} , Y = {value} '")
End Sub
Private Sub ChartViewer1_ClickHotSpot(hotSpot As Collection, Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Private Sub Command1_Click()
frminput.Show
Unload Me
End Sub
Private Sub Form_Load()
createChart Me.ChartViewer1.Object, Me.Picture1
End Sub
but it seems that when ever i would put a label for the the orange point in my graph it would multiply itself like it is being arrayed. i know its kinda confusing but if you want i could post my whole program here so that you could all understand me. thanx!!!
Save A Chart Using Chart Director
Have anyone here use a activeX call Chart Director to create chart? I've successful create the chart i want but i cant seem to save the file. Here is the code i got for the save button:
Code:
Private Sub CmdSave_Click()
Dim c As XYChart
Dim strsavefile As String
With CommonDialog1
'.Filter = "Pictures (*.bmp)|*.bmp"
.DefaultExt = "JPG"
.CancelError = False
.ShowSave
strsavefile = .FileName
If strsavefile = "" Then Exit Sub
End With
Call c.makeChart("strsavefile")
End Sub
I keep getting a object or variable not set. How do i fix this?
Clustered Chart With Stacked Chart
hi,
os XP
VB.NET WITH EXCEL 2000
i can creat charts with stacked column.
now i need create a chart with a combination of clustered and staked column.
how to create it?
is it possible with excel 2000 or not?
thanks
sudarleo
Print Contents Of A CHART (MS CHART)
Kindly help me in printing the contents of a Chart control along with the contents of a picture box control. I have the code to print the contents of the Chart. But I want to print a bitmap as the heading of the Chart. This bitmap is assigned to a picture box during runtime. The output should be :
The bitmap which will serve as the heading followed by the Chart.
Thank you for your time.
K. Ravi
How To Copy A Chart From One OLE Excel Sheet To An OLE Excel Chart Object
Hi all,
Kinda stuck here and I have been searching for the way to do this all day. I have a spreadsheet with Charts in one VB OLE container (Excel.Sheet.8)and I want to copy one of the charts to another VB OLE container (Excel.Chart.8) and have it sized to fit in my OLE container. I cant seem to get it to work. Any help?
Where OLE1 = spreadsheets with charts
and OLE2 is a chart
Code:
OLE1.Class = "Excel.Sheet.8"
OLE1.SourceDoc = App.Path & "Data5.xlt"
OLE1.Action = 0
'... Work with the spreadsheet...
OLE2.Class = "Excel.Chart.8"
OLE2.Action = 0
Set OLE2.object = OLE1.object.Charts(1) 'Doesnt Work
OLE2.object.Height = 5000 'Doesnt Work
OLE2.object.Width = 10000
3D Pie Chart
i try to generate a 2d bar, 3d bar, 2d pie, 3d pie chart. I use MSchart but can't create a 3D Pie chart -do you know how to do it?
Chart Help
I have included an attached JPG of what I need to do. I am trying to create a graph that combines two different data sets.
The top graph contains data from B2:M3 in a stacked format, and the bottom contains data from B4:M4 in a normal bar format.
I want to combine these results in 1 graph. The stacked bars will combine to show the totals and the "Should Be" bars will be right next to them for comparison.
Can anyone help, I cannot figure this one out?
Thanks,
Joe
Pie Chart In VBA
Hi, I'm working on a simple Excel program to process form results and I've come to a problem.
I'm trying to make a new sheet with a pie chart that uses the number of times a certain value shows up. For example:
5 shows up 356 times
4 shows up 476 times
etc.
I can't find any way to do this in Excel otherwise I could just record a macro and use the same code.
In summary: How do make a pie chart in VBA that counts the occurrences of values in a column to use as pie data?
P.S. Sorry if my post is hard to understand, I'm not the best with words.
Thanks,
Timmy-d
Help With Chart
Hello,
I am trying to draw a chart. Its trying to show a number of things at the same time and wasnt sure if it was possible. i have tried for hours to figure if it can be done or not - so some expert advice from here would be much appreciated.
i have attached s/sheet with some data.
Basically the data is showing forecast of expenditure over the next 5 years within different stages (stages 1-5). This expenditure gets revised and reforcasted every month. Now I want to be able to show in a stacked bar chart (or other) the forecast expenditure in each stage compared to what it was last month for each year 2005-10.
I guess you would have the month and years on the x axis with expenditure on the y axis - but I have tried loads of things (within my capabilities) without any joy.
Can anyone help?
Thanks
Chart Help
I know this isn't VBA, but I need an answer quick (it's almost 5 on friday in Chicago!). If anyone can help, great. If not, thanks anyways!
I need to create a 2 axis line chart using a table similar to:
Reach506070
Level150250350
Cost$1,000$1,500$2,000
Where along the left side it would have Level, on the bottom Reach and on the right axis would be the cost. One point would represent three values. The first point would be plotted at 150 Left, 50 bottom, 1000 right. No matter what I try I get all points coming out separately. I have tried using the custom type of lines on 2 axes but I just cannot get it to work.
Thanks for any help.
Chart
Hi all.
I have this code that generate a chart:
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("tempex").Range("A4:B12"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = False
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = False
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowValue, LegendKey:=False
ActiveChart.HasDataTable = False
ActiveWindow.Zoom = 75
ActiveChart.PlotArea.Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlNone
End With
My problem is that the code give me the chart on the fixed range "A4:B12" .
Is it possibile to make the chart on a variable selection: for example i select the range on my sheet then i run the macro and it generate the chart on the range i've selected.
Thank you for help.
Francesco
VBA Chart
Hi,
Can Any one tell me how to write User Defined Chart Using VBA Macro for Excel ...
I want to write VBA for 2D Chart... then i have to extend it to 3D
Can any tell me how to Go Ahead...
Or if u send some example that would be great helpful to me
regards
3-D Chart In VB 6.0
I have an array that I would like represented in a 3-D chart on a form in my program (without using Excel).
Dim Array(200,200) As Integer
..... Array(Row,Column)= Positive Integers
Integer Row and Column Index values would be the X and Y Axis of the chart.
And the integer contents of Array(Row,Column) would be the Z-Axis.
The chart would end up looking like a skyline, with tall skyscrapers where large numbers exist in the arrray, and flat land where zeros exist in the Array.
Can VB 6.0 do this?
Right now I am using an Excel file template with the chart already in there. My code puts data into the spreadsheet which then makes the chart take shape.
I would very much like to eliminate the Excel part and generate the chart right on the Form.
Any direction or example would be greatly appreciated.
-Regards.
MS Chart
Hi,
I am using MSChart to create Bar/line/pie Graphs.
Once the Chart is created.
I am pasting the data from MSGraph to a RichtextBox.
Every thing works fine but my X-Y Axis data is very blur
and when i make a print out the axis data is unreadable.
how do i make this clear and readable.
it looks like Microsoft graph is clearer do any one have
any links to MS Graph or graphlite examples.
Any help,links or suggestion would be helpfull.
Thanks in Advance.
Rann.
Vb Bar Chart & API
i am using the Vb bar chart ocx. it works great but is there a way to send it to the printer without using the form.Printform??
it would be clearer if it was a direct print.
maybe using the API.
Bar Chart
hi, to all expert here, i need some help
how can i create a bar chart??
i want create bar chart, i just wanna get database from my table and display the bar chart onli
inmy table is stock table,i want display from january until december stock have purchase??
any one can give me an idea how 2 start??
Pls Help Me In Chart
I want configure mschart to display series end point along with the lines
is it possible?
something like this(I drew it in mspaint)
excuse me in my bad english
thanks
Ms Chart Help
Hi all,
Now I'm stuck again because ms chart...
can you give example creating ms chart with data from database?
I already have example from planet source code but still i need more because it to simple...
this my code
Private Sub SSTab1_Click(PreviousTab As Integer)
adostudent.Refresh
adostudent.RecordSource = " select student.studentid,student.gradeA,student.gradeB from student where student.class ='" +dtcboclass + "'"
adostudent.Refresh
With MSChart1
.ShowLegend = True
Set .DataSource adostudent.recordset
End With
End Sub
-----------------------------------
if I write the sql statement like this
adostudent.Refresh
adostudent.RecordSource = " select student.studentid,student.gradeA,student.gradeB from student"
adostudent.refresh
it will show all the data but what I need now only specific class from selection(dtcboclass)
thanks
2D Chart For VB6
Colleagues,
Could you recommend a 2D chart control for my application that can work with VB6? I need to plot an EEG signal on the screen in real time. The update rate of the chart will be on the order of 200ms to 1000ms, and I want to display 1000 points. Ideally, the whole chart would scroll to the left as new values are added on the right.
I’ve tried the MSChart, it would work ok, but I don’t know how to get rid of flickering.
Thanks and have a happy new year!
- Nick
Chart
I have download the code to create a chart.
My I know What the purpose of VAL ?
Code:
Text2.text = 5000 - Val(TextA)
Can somebody explain the use of that code? How it create the line?
Code:
For i = 1 To 1500
Picture1.Line (0 + i, Text2.Text)-(0 + i, Picture1.Height), vbRed
Next i
Chart VB6
I get a lot of excel files with 2 charts in it. I want them as a jpg file. Now I'm doing it via opening every excel file and via copy/paste to paint and save as jpg file. This cost a lot of time and that's why I want to write a visual basic program to do it all automatic. The filenames of the grapics are important and can be conducted from the filenames of the excel file.
Can somebody give me some hints? I have some experience with VB6.
Thanks in advanced,
Frans
MS Chart
I want to create a chart which displays one field against another field from a databse i have in ms access. Ive been looking around for hours on how to do this, and i found this code. I dont know if it is what i should be using, but if it is, i dont understand what the part in red is meant to be. If anyone knows a website which gives a really simple step by step guide on how to do this i would be really grateful. thanks.
VB Code:
Private rsProducts As ADODB.RecordsetPrivate cn As ADODB.Connection Private Sub Form_Load() Set cn = New ADODB.Connection MSChart1.ToDefaults ' Establish the connection using the connection string. [color=Red] [b]cn.ConnectionString = _"Provider=SQLOLEDB.1;Password=XXXXXXX;" & _ "Persist Security Info=True; User ID=sa;" & _ "Initial Catalog=TestWiz; Data Source=XPHTEK"[/b][/color] ' Open the connection. cn.Open Dim strQuery As String ' SQL query string. ' Create a query that retrieves only four fields. 'strQuery = "SELECT ProductName, UnitPrice, 'UnitsInStock, UnitsOnOrder FROM Products" strQuery = "SELECT ProductName, UnitPrice, UnitsInStock, UnitsOnOrder FROM Products" Set rsProducts = New ADODB.Recordset ' Open the recordset. rsProducts.CursorLocation = adUseClient rsProducts.Open strQuery, cn, adOpenKeyset ' Set the DataSource to the recordset. With MSChart1 .ShowLegend = True Set .DataSource = rsProducts End WithEnd Sub
Chart In VB
I'm looking for chart in VB.
What is you reccomendation?
currently i'm look on http://www.rmchart.com
Chart In VB6
Hi
I have a vb6 form that is connected to an SQL server 2000 database.
The database contains a table called "Books" Which contains a field "CategoryID";and the Category table contains 10 CategoryID.
I am using the following query to see the number of occurence of each category in the table Books.
Rs.open"Select * from Category",cnn,adopenstatic,adlockoptimistic
Rs.movefirst
Do while not rs.EOF
Rs1.open"Select * from Books where CategoryID=" & Rs!CategoryID,cnn,adopenstatic,adlockoptimistic
scategory=Rs!Category
snumoccurence=Rs1.recordcount
For each category I want to find its number of occurence and display the results in a chart?
How can i do it?
thanks in advance
Ms Chart
Hi,
I am using a MSCHART control and need some help with setting some of the "astetic" properties.. What I mean by that is how do I change the color of the data line (using a 2D line graph)? Also, how do I change the thinkness of that line?
Here is my code so far (Which works, except for the two items I mentioned above):
VB Code:
mschart.chartType = VtChChartType2dLine mschart.MousePointer = VtMousePointerNoDrop mschart.ChartData = ArrayData
MS-Chart
I am attaching a file which is a format of the graph to be created.X axis refers to the Date and Y axis is the Percentage of amount collected.Each line in the graph refers to the executive names.
I have also attached a database from which the graph is to be created.
Is it possible to create using MS-Chart
MS Chart
Is it possible to print the MS Chart? and if so how is it done?
Thanks in advance
MS Chart Help
Does anyone know any good sites explaining how to use various features of MS Chart?
Chart
hi,
I have a table with four colums in an Access database.I want to plot a graph based on those data.
Can somebody help plzzz?/
Chart?????
Hi
Anyone knows how to create a 1 Line Chart in VB where the data source is a Recorset?
Pie Chart
I want to create a 3d Pie chart in VB. I tried using the MSCHART control but it supports only 2d pie graph...where can i find an alternative one?
Vb Ms-chart
hi friends,
help me for below matter
how to do combination charts
using ms-chart ?
---
friend
Bar Chart
Hi there,
I'm using the following code to try and plot a simple bar chart in a picture box. I'm not getting any error messages but it won't work, nothing is showing in the picture box.
Code:
Private Sub BarChart(picPlot As Control, N As Integer, X() As Single, Y() As Single)
Dim Xmin As Single, Xmax As Single
Dim Ymin As Single, Ymax As Single
Dim I As Integer
Xmin = X(0): Xmax = X(0)
Xmin = Y(0): Ymax = Y(0)
For I = 1 To N - 1
If X(I) < Xmin Then Xmin = X(I)
If X(I) > Xmax Then Xmax = X(I)
If Y(I) < Ymin Then Ymin = X(I)
If Y(I) > Ymax Then Ymax = X(I)
Next I
Ymin = (1 - 0.05 * Sgn(Ymin)) * Ymin 'Extend Ymin by 5%
Ymax = (1 + 0.05 * Sgn(Ymax)) * Ymax 'Extend Ymax by 5%
picPlot.Scale (Xmin, Ymax)-(Xmax, Ymin)
picPlot.Cls
For I = 1 To N - 1
picPlot.Line (X(I), 0)-(X(I), Y(I)), vbBlue
Next I
End Sub
Private Sub Form_Activate()
'Open File, load data in arrays
Dim N As Integer
Dim X(10) As Single, Y(10) As Single
Open App.Path + "mar95.csv" For Input As #1
N = 0
Do Until EOF(1)
Input #1, X(N), Y(N)
N = N + 1
Loop
'Call bar chart routine
Call BarChart(picPlot, N, X, Y)
End Sub
Have I missed something?
MS Chart
Hi All,
I am wroking with the MS Chart and I just wondered how is
change the Y axis to have a different scale
I have draw my graph and want it drawn differently
Thanks
Louby
Chart
Hi my name is Karine!
I have a program and I want to do a function that return a chart , but I dont know how to
- call my function
-how to write my function. (juste the first line)
-how to return it.( return tab)
thanks a lot
Pie Chart
How would i go about making a pie chart in vb.
say i wanted to have half a circle red, 18 percent blue, and the rest green?
i dont care if i use the shape control, draw stuff on the form, or use some sorf of DirectX/opengl graphic drawing or whatever.
thanks!
Chart
Hi,
where can i find a good sample of drowing a cpu chart ??? somthing line "Task Manager" in NT???
Thanks
Help Help! (MS Chart)
hello, i've been looking it up for ages and im going mental
i have some data in a datagrid, linked to a database, and i want to graph some of it on a chart
there is two variables to graph, O2 and CO2
and it's Vs time, but the time values are not evenly scaled
how do i do this? can i link it directly to the datagrid? or do i have to put it in an array? how do i get it to graph the 2 things vs the time values?
any help would be warmly welcomed
Chart In VB
hi
Is there Componant that drow chart in my form "the value of drowing came from query"
thanks
MS Chart
I have made a Chart using Data Wizard. When I change the series color in Properties to a different color from the default (red) this change isn't applied at run time. Are the colors set automatically? Where can I change them?
MS Chart
I have a strange problem! I am using the same MS Chart in two different projects, in the first one everything is OK, but when using it in nr. 2 an error occurs "Type Mismatch" and the Chart is only shown as the figure that appears before running the program.
What could be wrong?
Here's my source code that works fine.
And by the way: If I use the app.path in the third line the directory is VB98 and not the current working directory. Could this be true? What would then happen when exporting? How can the database be found then?
Code:
Private Const MARGIN_SIZE = 60 'In Twips
Private Const SHAPE_COMMAND = "SHAPE {select Length,Temperature from Tester Order by Length} AS ChildCommand COMPUTE ChildCommand, SUM(ChildCommand.[Temperature]) AS [Temperature] BY [Length]"
Private Const CONNECT_STRING = "PROVIDER=MSDataShape;Data Source=C:Documents and SettingslrhplMy DocumentsLogstor StaTechLR_StaTech.mdb;Data Provider=Microsoft.Jet.OLEDB.4.0"
Private Const FIELD_X = "Length"
Private Const FIELD_Y = "Temperature"
Private Const FIELD_Z = ""
Private Const VBERR_INVALID_PROCEDURE_CALL = 5
Private Const MARKERS_VISIBLE = 0
Private Const BRACKET_LEFT = "["
Private Const BRACKET_RIGHT = "]"
Private Const SPACE_CHAR = " "
Private Sub cmdClose_Click()
Unload Me
End Sub
'-------------------------------------------------------------------------
'Purpose: Display an error message to the user
'In:
' [oError]
' Error object containing error information
'-------------------------------------------------------------------------
Private Sub DisplayError(oError As ErrObject)
MsgBox oError.Description, vbExclamation, App.Title
End Sub
Private Sub Form_Load()
Dim conShape As ADODB.Connection
Dim recShape As ADODB.Recordset
On Error GoTo Form_Load_Error
'Create and open connection to the Data Shape provider
Set conShape = New ADODB.Connection
conShape.Open CONNECT_STRING
'Create and open a recordset
Set recShape = New ADODB.Recordset
recShape.Open SHAPE_COMMAND, conShape
'Fill the chart with the recordset data
ShowRecordsInChart recShape, FIELD_X, FIELD_Y, FIELD_Z
'Show or hide markers
ShowMarkers MARKERS_VISIBLE
Exit Sub
Form_Load_Error:
DisplayError Err
Exit Sub
End Sub
Private Sub Form_Resize()
Dim sngButtonTop As Single
Dim sngScaleWidth As Single
Dim sngScaleHeight As Single
On Error GoTo Form_Resize_Error
With Me
sngScaleWidth = .ScaleWidth
sngScaleHeight = .ScaleHeight
'Move Close button to the lower right corner
With .cmdClose
sngButtonTop = sngScaleHeight - (.Height + MARGIN_SIZE)
.Move sngScaleWidth - (.Width + MARGIN_SIZE), sngButtonTop
End With
.chtReport.Move MARGIN_SIZE, _
MARGIN_SIZE, _
sngScaleWidth - (2 * MARGIN_SIZE), _
sngButtonTop - (2 * MARGIN_SIZE)
End With
Exit Sub
Form_Resize_Error:
'An error will occur if the user sizes
'the form so small that negative heights
'or widths are calculated
Resume Next
End Sub
'-------------------------------------------------------------------------
'Purpose: Determines if the passed key is being used in the
' passed collection.
'In:
' [cCol] The collection to check for key use in.
' [sKey] The key to look for.
'Return: If the key is being used by the collection, true
' is returned. Otherwise, false is returned.
'-------------------------------------------------------------------------
Private Function IsKeyInCollection(cCol As Collection, sKey As String) As Boolean
Dim v As Variant
On Error Resume Next
v = cCol.Item(sKey)
'It is important to check for error 5, rather than checking for
'any error, because an error could occur even if the key is valid.
'If the key existed, but it was associated with an element that
'was an object, an error would occur because 'Set' wasn't used
'to assign it to 'v'.
IsKeyInCollection = (Err.Number <> VBERR_INVALID_PROCEDURE_CALL)
Err.Clear
End Function
'----------------------------------------------------------
'Purpose: Shows or Hides series markers, according to the
' parameter.
'In:
' [bShow] If true, all the series markers will be shown.
' Otherwise, all the series markers will be hidden.
'----------------------------------------------------------
Private Sub ShowMarkers(bShow As Boolean)
Dim i As Long
On Error GoTo ShowMarkers_Click_Error
With chtReport.Plot
For i = 1 To .SeriesCollection.Count
.SeriesCollection(i).SeriesMarker.Show = bShow
Next
End With
Exit Sub
ShowMarkers_Click_Error:
DisplayError Err
Exit Sub
End Sub
'----------------------------------------------------------
'Purpose: Displays the data summarized in the passed recordset
' in the Chart.
'In:
' [recParent]
' A recordset created using a Shape command, that
' groups by one or two fields, and summarizes one.
' [sFldX]
' The name of the field to group by on the X axis.
' [sFldY]
' The name of the field to summarize on the Y axis.
' [sFldZ]
' The name of the field to group by on the Z axis. This
' field should be a zero length string, if the recordset
' only groups by one field.
'----------------------------------------------------------
Private Sub ShowRecordsInChart(recParent As Recordset, _
sFldX As String, _
sFldY As String, _
sFldZ As String)
Dim bUseZ As Boolean
Dim cRows As Collection
Dim cCols As Collection
Dim lCol As Long
Dim lRow As Long
Dim lMaxCol As Long
Dim lMaxRow As Long
Dim sValue As String
On Error GoTo ShowRecordsInChart_Error
If Len(sFldZ) = 0 Then bUseZ = False Else bUseZ = True
Set cRows = New Collection
Set cCols = New Collection
With Me.chtReport
'Turn off chart painting
.Repaint = False
With .DataGrid
'Clear the chart
.DeleteRows 1, .RowCount
.DeleteColumns 1, .ColumnCount
.DeleteColumnLabels 1, .ColumnLabelCount
.DeleteRowLabels 1, .RowLabelCount
'Make sure there is one level of labels
.InsertColumnLabels 1, 1
.InsertRowLabels 1, 1
'If the Z axis is not being used, make
'sure there is one column
If Not bUseZ Then .InsertColumns 1, 1
recParent.MoveFirst
Do Until recParent.EOF
'Make sure a row is added for this X field
sValue = FixNull(recParent.Fields(sFldX).Value, False)
If Not IsKeyInCollection(cRows, sValue) Then
lMaxRow = lMaxRow + 1
lRow = lMaxRow
'Store the row index associated with
'the Row name
cRows.Add lRow, sValue
.InsertRows lRow, 1
.RowLabel(lRow, 1) = sValue
Else
lRow = cRows.Item(sValue)
End If
'Make sure a column is added for this Z field
If bUseZ Then
sValue = FixNull(recParent.Fields(sFldZ).Value, False)
If Not IsKeyInCollection(cCols, sValue) Then
lMaxCol = lMaxCol + 1
lCol = lMaxCol
'Store the column index associated with
'the column name
cCols.Add lCol, sValue
.InsertColumns lCol, 1
.ColumnLabel(lCol, 1) = sValue
Else
lCol = cCols.Item(sValue)
End If
'Set the datapoint value for this record's row and column
.SetData lRow, lCol, FixNull(recParent.Fields.Item(sFldY).Value, True), 0
Else
'Set the datapoint value for this record's row
'There is only one column in this case
.SetData lRow, 1, FixNull(recParent.Fields.Item(sFldY).Value, True), 0
End If
'Move the recordset to the next record
recParent.MoveNext
Loop
End With
'Turn painting back on
.Repaint = True
End With
Exit Sub
ShowRecordsInChart_Error:
'Make sure the charts painting is turned back on
Me.chtReport.Repaint = True
DisplayError Err
Exit Sub
End Sub
'-------------------------------------------------------------------------
'Purpose: Checks a variant value for null. If the value is null, returns
' a vbNullString or a zero.
'In:
' [vField]
' The variant to check for null.
' [bNumericRequired]
' If true, return 0 if the variant is null. Otherwise, return
' vbNullString.
'-------------------------------------------------------------------------
Private Function FixNull(vField As Variant, _
bNumericRequired As Boolean) As Variant
If IsNull(vField) Then
If bNumericRequired Then
FixNull = 0
Else
FixNull = vbNullString
End If
Else
FixNull = vField
End If
End Function
|