Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Creating Charts In VB6


Hi All,

I'm by no means a whiz kid at programming and I don't understand a lot of the terminology used, but what I do create works, and thats the main thing. However I'm at a total loss as to how to create X/Y graphs.

I use Excel to do this without any problems so I thought that this would be the best way to go - BUT HOW?

I've scoured the intenet, magazines and numerous books and I've yet to find anything that gives you an example to follow and modify as required. I even left messages at Microsoft, but to date have not received any answers.

Is it that difficult!! All I ant to do is place values in cells and create 8 to 10 graph lines on a standard X/Y chart.

PLEASE HELP BEFORE I GOT COMPLETELY BALD

Best Rgds
Dave R




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Creating Charts
Hi All,

Im trying to create a macro that will create a chart for each row within my data. Reason being is this is a weekly report so the number of rows will vary on a week to week basis.

my code is below, alough:

Code:
Sheets("CHART RAW DATA").Select
rnum = Selection.Rows.Count
For i = rnum + 1 To Rows.Count
If rnum >= 1 Then
Charts.Add
ActiveChart.SetSourceData Source:=Range("CHART RAW DATA!($C2 & rnum &"":$N2" & rnum)
ActiveChart.SeriesCollection(1).XValues = "='CHART RAW DATA'!$C$1:$N$1"
ActiveChart.SeriesCollection(1).Name = "=""NEW STORE SALES"""
ActiveChart.SeriesCollection(2).Values = range("'CHART RAW DATA'!$O2" & rnum & ":$Z2" & rnum)
end if
next i
end sub
$C$1:$N$1 - x axis (date)

All help is greatly appreciated
Sam

Creating Charts From Db
I have an application that connects to a database. I need to create a form that will show a chart based on the results of a query (i.e. number of clients per agency during a given month). How can I do this? Is there any tool in VB6 that will allow me to do this with little code?

Thanks.

Creating Pie Charts In VB
I have created a macro to create a pie chart and all its associated properties, text size, font, pie chart size, etc. This works great! Next I tryed creating a macro to update my slices of the pie chart. I am concerned that the data full of errors the way its being done in macros because the code reads:
ActiveChart.SeriesCollection(1).Points(2).Select (depending on how many pie slices I have I could have up to Points(26) so how does this macro know which one to update (i.e. all my park area should be green but the park area does not always appear on Points(2) it could be on Points (23). I am hoping to use this code to create approximately 30 pie charts in various areas of town (some pie charts might not have a park in the area).

So the code I am looking for should read the row to get the appropriate land designation (park) then find park in the pie chart and apply the assigned color to it.

P.S. I am very beginner - thanks

Creating Pie Charts In VB
I have created a macro to create a pie chart and all its associated properties, text size, font, pie chart size, etc. This works great! Next I tryed creating a macro to update my slices of the pie chart. I am concerned that the data full of errors the way its being done in macros because the code reads:
ActiveChart.SeriesCollection(1).Points(2).Select (depending on how many pie slices I have I could have up to Points(26) so how does this macro know which one to update (i.e. all my park area should be green but the park area does not always appear on Points(2) it could be on Points (23). I am hoping to use this code to create approximately 30 pie charts in various areas of town (some pie charts might not have a park in the area).

So the code I am looking for should read the row to get the appropriate land designation (park) then find park in the pie chart and apply the assigned color to it.

P.S. I am very beginner - thanks

Creating Charts
I can not seem to find a good way to create charts.
you should be able to use vb to reference an excell object and crate charts and graphs
but i am unable to find excalty what i am looking for.

Does anyone know of some good tutorials or examples that would help me.

I would like to create a dll to use on my web pages to create charts and graphs.

Any information on this subject would be greate.

Thanks.

Creating Charts In Excel Using VB
Hi, I cant seem to find a thread on this site which explains this so here goes.

I want to creat a chart in excel using VB.
This is what I have done so far (I got most of this from the microsoft knowledge base), my code falls over when I try to select the type of chart


Sub createExcelGraphs()
Dim oXL As Object ' Excel application
Dim oBook As Object ' Excel workbook
Dim oSheet As Object ' Excel Worksheet
Dim oChart As Object ' Excel Chart
Dim iRow As Integer ' Index variable for the number of Rows
Dim iCol As Integer ' Index variable for the number of Cols

Set oXL = CreateObject("Excel.application")
Set oBook = oXL.Workbooks.Add
Set oSheet = oBook.Worksheets.Item(1)

Set oChart = oSheet.chartObjects.Add(50, 40, 300, 200).chart

iRow = 10
iCol = 2

' This line gives the error - "Object required"
oChart.ChartType = Excel.XlChartType.xlLine

oChart.SetSourceData Source:=oSheet.Range("b1").Resize(iRow, iCol)
oXL.UserControl = True
End Sub

Creating Excel Charts Using Vba
I am writing a vba to to open a specific file manipulate the data to a usable form and create a chart, but the when I try to create the chart I get error code 400 here is my code any help would be greatly appreciated
Code:
Sub Iab_data()
Workbooks.OpenText Filename:= _
"C:Documents and Settings514029Desktopomb simlsbFINAL", Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15 _
, 1))
'moves the data into correct columns
Worksheets("Final").Cells(3, 4).Delete Shift:=xlShiftToLeft
Worksheets("Final").Cells(4, 3).Insert Shift:=xlShiftToRight
'puts data in a usable form
For i = 0 To 36 'number of data points for each down range value
Worksheets("Final").Cells(i + 5, 5).Copy 'Cells(c,r): copies crossrange values
ActiveSheet.Paste Destination:=Worksheets("Final").Cells(3, 18 + i)
Worksheets("Final").Cells(i * 37 + 5, 4).Copy
ActiveSheet.Paste Destination:=Worksheets("Final").Cells(4 + i, 17)
For j = 0 To 32
Worksheets("Final").Cells(j * 37 + i + 5, 11).Copy
ActiveSheet.Paste Destination:=Worksheets("Final").Cells(4 + j, 18 + i)
Next j
Next i



'adds suface pots
With Charts.Add
ActiveChart.ChartType = xlSurfaceTopView
ActiveChart.SetSourceData Source:=Sheets("FINAL").Range("Q3:BB36"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "title"
.Axes(xlCategory).HasTitle = True
.Axes(xlCategory).AxisTitle.Characters.Text = "x-axis"
.Axes(xlSeries).HasTitle = True
.Axes(xlSeries).AxisTitle.Characters.Text = "y-axis"
.Axes(xlValue).HasTitle = True
.Axes(xlValue).AxisTitle.Characters.Text = "z-axis"
End With
End With
Sheets("Final").Select
End Sub



thanks matt

Creating Excel Charts In VBA
Hi,

I am populating charts in excel by running macros to automatically enter values for 2 reasons:
1) the size of the problem I am charting changes so this automatically adds/deletes series without me manually having to change the cell references each time
2) the values i am plotting are actually created in a macro themselves, so my code creates the charts directly from an array of values in the macro, instead of printing all the data into an excel spreadsheet (ie. there are no cell references in my charts). the file would grow very quickly if i were to have sheets full of data (there are quite a lot of graphs).

The problem I am having is that when you enter sets of values such as ={1,2,3,4,5,6,7,8,9,10} into the "Values" input box in the chart's Source Data/Series window using a macro, it only allows about 25 data points, whereas if I had this Values box reading a cell reference I could have thousands.

Is there any way to get around this (without actually putting all my data into cells) as the more data points I can use the more accurate my graphs are?

I hope this is clear, any questions please ask.

Thanks!

Creating And Using Charts In Word 2000
hello everybody.

I'm currently working on a Word 2000 template for report generation.

I would like to know if it's possile to insert a chart (Excel) that's automatically updated with data from another table within the same doc template. (this is not an excel table). what is the code for this?.., if there's a possibility, is there a way to manipulate the source data, execute some calculations, and then display the calculated values in the chart???

Thanx a lot. The idea is to make this on a Word Document, exclusively.

Creating Charts In Excel With VBScript
I have four servers with a total of 20 modems that I want to generate a report based on the number of calls taken by each server. I have written a VBscript that parses all the log files and writes all the into a tab-delimited text files. Then the script opens the text file and reads all the data into Excel. I am fine up to that point. Now, I have divided the data into three different ranges based on the three different applications from which the data belongs. Now, I would like the script to generate a separate chart for each range. Here is a sample of the code that I written so far:

wb.Charts.Add
wb.ActiveChart.ChartType = 97
wb.ActiveChart.Name = "App1"
wb.ActiveChart.HasTitle = True
wb.ActiveChart.ChartTitle.Text = "App1"
wb.ActiveChart.SetSourceData("rngApp1, 2") 'xlColumns
wb.ActiveChart.SeriesCollection.NewSeries
wb.ActiveChart.SeriesCollection(1).Name = "# of Calls"
wb.ActiveChart.SeriesCollection(1).Values = xlsheet.Range("E2:E12")
wb.ActiveChart.SeriesCollection(1).XValues = xlsheet.Range("A2:B12")

My problem is that when I debug the script and get down the line in bold, I am getting a runtime error: type mismatch 'wb.ActiveChart.SetSourceData'. I have tried searched trying to find out what I am doing wrong to no avail. Any help at this point would be greatly appreciated.

Creating Pie Charts Using A Circle Method
Hieveryone

I need to create a pie chart using colours for different angles, but need to use a circle.

Does anyone have any suggestions?

Thanks

Tracey

Component For Creating Professional Bar Graphs/charts?
I am looking for a VB component that is affordable and allows creation of highly professional 3d bar graphs & charts. Does anyone know of an affordable one?

Thanks
Tom

Pie Charts And Bar Charts (written By An Utter Novice)
Good evening everyone,

i am new to the world of VB, and im making a system to aid our golakeepers at my football team (you will undoubtably be seeing many more questions from me in next 2 weeks :-) )

Basically, at the moment, i have a three text boxes, that for example, say 25, 65 and 10

What i want is a pie chart to represent those figures? Can some one throw some code at me, please :-)

ALso, how easy is it to do bar charts, off, for example, the same figures??

Many thanks everyone!

Great site by the way

How Do You Handle Graphic Charts? (IE: Pie Charts And Other Graphs)
MS Chart?
Crystal Reports?
Export to Excel?
Custom?
Something else?

How To Label Charts ???? Anybody Charts ??
I work with VB from Excel.
I managed to building charts from my sheets, however, I cannot get any label in the X axis as a whole serie.
The online help, does not give any example as for what I need.

This is what I use for creating a simple chart

Charts(N).SeriesCollection.Add Source:=Worksheets("X").Range(Worksheets("X").Cells(row, col), Worksheets("X").Cells(row+n, col))

and works fine, however, I would like to give another serie (as a range same as above ex.), for adding the labels corresponding to that serie and not having to label each individual point of the chart with an itaration.

Appreciate any help. Thanks.

Hide Charts, Name Charts
Hi,
i would like to change the visibility of a chart in a worksheet.

I tried first

worksheets("temp").ChartObjects(2).Chart.visible= true
later (with the helpfile)
worksheets("temp").ChartObjects(2).Chart.visible = xlsheethidden
also
set worksheets("temp").chartObjects(2).Chart.xlSheetVisibility = _ xlsheet hidden

the error told me, the types donnot fit

another thing, I want to be sure that always the same chart is hidden (i have got serveral), so what happens to the indices, if the user deletes one? Can I name the chartobjects like Worksheets? How (set ... .name =?) ?

Thanks

Pie Charts
i have two numbers lets say x and y and i want to have a pie chart showing the ratio between them

also i want the pie chart to be a certain size lets say z

and i want to have some 2 colours to distinguish the two parts of the
pie chart

i dont need any special code to change the colours or the size or the ratio's i just need some fairly basic code to make a pie chart with the parameters above could anyone help me??

cheers

Charts!!!
ok, im only a newbie at visual basic and only have the learning edition of visual basic.

I need to create a chart that has Price on the vertical axis (Dependant on Value) and Year on the Horizontal Axis (0-25)

The value will be in a label. It pretty much shows inflation.

For example:

Year 1 = 5
Year 2 = 10
Year 3 = 20
Year 4 = 40

This is if inflation is 100%. The value of inflation will be in a text box.

How am i going to code this? If the value is in a label called lblPrice and the text box is called txtInflation?

Ive searched and everyone says to use MSChart Control, but my version does not have this component, can i download it? or will i have 2 buy the full version?

Any help would be greatly appreciated. ANy coding would be a life saver!!

A Little Help With Charts.
I've attatched a .zip file to this thread. This is a peeloff of another thread that I started but a little different topic. The chart that is attatched is working well, but I am having some formatting issues that I am trying to take care off. The x and y axis scale and the labels that I inserted.

The two inputs are in bright orange. Everytime they change the chart changes accordingly.

My first problem is my data labels for the "dashed" lines. They move accordingly with the chart, but I can't get the values to change inside of them. If I take out the text in the labels then they will change, but it kinda defeats the purpose of what I am trying to accomplish.

My next problem that I am facing is the x-axis and y-axis scale. I need to change the maximum value of each depending on how big the chart is.

I have been messing arround with the chart objects in vba but I can't seem to get them to work.

sub example()
With worksheets("Chart Data").Charts("Chart1")

End with
End sub

Charts
Can anyone tell me why the following macro will go ahead and start the creation of a chart with the specified range of data on a sheet called "DCL Calibrator"


Code:
Charts.Add

ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.SetSourceData Source:=Sheets("DCL Calibrator").Range("K7:K11,L7:L11"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="DCL Calibrator"

while the following code produces a Run-time error 1004
Method 'Cells' of Object'_Global' failed



Code:
Charts.Add

Dim GetRow As Integer
Dim GetCol As Integer

GetRow = 7
GetCol = 11

ActiveChart.SetSourceData Source:=Sheets("DCL Calibrator").Range(Cells(GetRow, GetCol), Cells(GetRow + 4, GetCol + 1)), PlotBy:=xlColumns

I would have thought that the ranges in both macros were equivalent

Pie Charts
I make a pie chart on percentages. Two pieces side by side happen to be 0%. This causes them to overlap eachother. Is there any way to stop this from happening without moving them manually each time?

Charts
What is the best ocx, dll, control for line graphs? Does anyone know where I could get a good graph control for free anywhere?

"And the day shall come when the Viper will take his throne"

Charts
Would someone be kind enough to answer my question please? What it concerns is displaying simple bar charts made up of information from a table in Microsoft Access. For example if i have to field yes and no, 10 people say yes and 5 say no. How would i put this information that would be stored ina table into a chart within a visual basic front end.
Thanks
K.

Bar Charts
does anybody know of a source for 3rd party bar charts???

Charts
Help Me.
I want a free chart control other than MS-Chart.

Charts
Would someone be kind enough to answer my question please? What it concerns is displaying simple bar charts made up of information from a table in Microsoft Access. For example if i have to field yes and no, 10 people say yes and 5 say no. How would i put this information that would be stored ina table into a chart within a visual basic front end.
Thanks
K.

XYZ Charts-VB6
how would i go about making a XYZ chat to display 3d images. i would also like to know anything on the subject of of XYZ charts.

Vb 6 And Charts
Hi group,

I have to update an application I build about a year ago.
The app loads a lot of numbers and creates a chart. At this point I use an excel chart in an OLE control.

Is it possible to use SVG or VML in an VB application?

I've seen it in action and it looks very good. Are there any other options?

Regards,
visualsander

Pie Charts
Any know how to make pie charts in VB?

Using Charts
How can I add chart controls to my application and how to connect it to my database ?

If Tutorials are present please add URL

Any help is appreciated

thanx in advance

Charts In VB6
Is it possible to create charts with VB6.
I am a student and would like to know if this is possible.
I have data stored in ACCESS but it can be swaped into EXCEL or Word if that is better.

Thanks for your pateience with a new user.

Gary.

Charts
i want to include a chart into my VB app. the data is retrieved from a database and put into a recordset. the problem is MSChart retrieves data from columns instead of rows.

Example:

i have a recordset which includes following data:

Product Sum Date
food 1000 1/1/2002
drinks 1500 1/2/2002
other 900 2/3/2002

the MSChart returns a chart where there are three bars:
product (value zero), sum(value 3400) and date (value zero)
what i want that it returns three bars food(1000) drinks (1500) ... and so on...
i can retrieve a recordset that doesn't include the date but that doesn't help neither
pls help

XY Charts
I'm having a major case of post holiday brain dead.....

I'm using the MSChart control and want to make a simple XY graph where the x axis is series of dates and the y axis is the corresponding value. I've forgotten how to set the scale for the x axis (dates). While the dates go down to the specific day I want the label on the x-axis just to be mm/yy.

Any help would be appreciated to jump start this old brain.

Thanks

Help With Charts
Hi,

What is the best chart to use for display wise. I've tried MS Chart but find it tough going, I need to create a line graph,1 column and about 300 rows.

Doesn't anybody have any advice or example program?

Charts
Does anyone what all the types of charts are? Does anyone know of a site that will outline how to use MSChart control (basic stuff)?

Thanks

Charts
How can I make charts???

OLE Charts In VB 6.0
Hey guys!

I need an excel chart in my application and I found the Excel Chart within Visual Studio very appealling. You can get it by going to Components->(The insertable objects Tab). I was wondering if anyone here knew how to use it becuase I'm having an awful time trying to find information on it. Can anyone shed a little light on my situation. Any help would be great.

Charts
Hi,

I have got customer sales report top 20 in chart format.

I want the chart to be shorted from highest sales to lowest sales, sothat I get a smooth graph.

can any body please help me.

Regards,
Feroz

Charts
Can anyone kindly tell me whether is there any other chart controls that I can use other than VB6 MSChart Wizard and MSChart? thanx for your help

Charts
Hi,

I need to draw charts. SO what is the best tool to use. Currently I am using ChartDirector, but I think it's not flexible enough.

Any other suggestions?

Charts
Hi,

I want to plot a 3 dimensional chart/graph using visual basic.
I want to know whether we can plot a three dimensional chart/graph,
with x,y,z coordinates plotted along x,y,z axis. It should resemble me
a 3 dimensional cordinate system. any reference or any help would be
appreciated.

Thanking You,
Regards,
Ratnakar Pedagani.

Charts In Vb
this is a content of a .csv file

Date    Open    High    Low    Close    Volume    Adj Close
4/30/07    4081    4148.95    4015    4087.15    62100    4087.15
4/27/07    4095    4170    4011    4141.65    117400    4141.65
4/26/07    4140    4140    4005.65    4096    284300    4096
4/24/07    3895    3990    3714.85    3963.85    92600    3963.85
4/23/07    3870    3945    3855    3910.35    90500    3910.35
4/20/07    3770    3875    3765    3854.55    110200    3854.55
4/19/07    3670.65    3765    3623    3754.4    62500    3754.4
4/18/07    3730    3774    3710    3718.5    30800    3718.5
4/17/07    3742    3780    3684    3728.75    51800    3728.75
4/16/07    3755    3787    3720.8    3737.7    65000    3737.7
4/13/07    3669    3755    3623    3745.4    77600    3745.4


could any one help me in plotting a candle stick chart for above

i want to skip the last column " adj close "

looking forward for a help

also the values would change from file to file



Edited by - rohitb on 5/2/2007 1:44:52 AM

Charts
I've plotted several line charts in Excel using code from VB6.0. I have two questions about changes that I'd like to make to them. Firstly, all of my vertical axes start from zero, which is not the most sensible option most of the time. How can I make the lowest value of the y axis be just below the lowest value being plotted? The second question is how can I draw a line across the graph (in say, red) at a particular value of y, so that it is very clear to a viewer whether the current measurement is above or below the necessary limits.

Charts
I am trying to graph a query without using the wizard. How would i got about this. I know it can get complex. Just the basics.

Charts
Hi

I am looking for a chart control that can be copied and pasted from runtime into another document. I have tried graph32.ocx but the chart gets distorted in the new document.

Thanx

Bar Charts And Pie Charts
How do I import bar charts and pie charts into a VB app?

Deleting Charts
I'm trying to delete a chart from a macro using
activechart.delete

The problem is that it gives me a confirmation window-"are you sure you want to delete this chart"

Is there a way I can either prevent the confirmation from appearing or automatically respond to it?

Thanks

Powerpoint And Charts
Does anyone know how, or know where I can find information to generate a chart in powerpoint from visual basic. Basically I create the entire slide show in VB adding info and bullets. The only thing I can't do is automatically generate the chart.

Database And Charts
I need to create a chart from the data in my Acess database.

Copyright 2005-08 www.BigResource.com, All rights reserved