I need to make charts. I started with MSChart Control and so far I've accomplished almost all I wanted except for one thing which totally eludes me. I need a simple line chart, not columns or a pie. I need to display a row of data like DJIA or similar indices with no additional vertical bars or other embelishments.
The curve comes out nice but a lot of space on the chart is wasted because the curve is being plotted too high on the chart in vertical direction. I have tried to manipulate MSChart.Object.Plot.Axis(VtChAxisIDY,1).ValueScale.Minimum value but it is not responsive at all. I do not know why: perhaps other parameters supercede this one and make the system default to automatic.
In short I began thinking about MSChart.Chart.8 or MSChart.Application.8 controls. I get an error when I try to create an object and place it on a form. It says that the control is not for this container. What container is it for How can I use it Is it a purely Excel bound control
Thanks.

MSGraph.Chart.8 control
Ravi Thapliyal
Sorry, I have to make a correction. I am now thinking about MSGraph, not MSChart. I have been working with MSChart for a couple of days. So, it is MSGraph.Chart.8, and MSGraph.Application.8 that I cannot place on a form. I think now I am not confused, although you never know.
TheNewcomer
Sorry, apparently there was a snafu. When I used this nt:
THISFORM.AddObject ("oGraph","olecontrol","MSGraph.Chart.8")
It seemed to work. It does not give me any errors now but the control is invisible at this point.
Manjeet
I could read it in your graphs.doc file, the one, I downloaded from the site you pointed to.
I cannot understand one thing (hopefully, only one thing:) at this point. Where do you have your oridinal data stored Where is that table VPFGraph.fpt contains general field with a pointer, I understand to your metadata. Right
I must start with a table of real data. It is a vector. It has quite a few values. Each value correspond to the closing on a particular weekend. I may have 120 of such values to a graph in the simplest case scenario. You have only 4 points for your graph as I can see. I am talking about the graph I can see when I run a demo: msGraphDemo.scx. I hope it is yours. Where is this data generated Is it stored in a memory variable or what If you demonstrate a principle with just 4 points then you obviously do not need a table.
Thanks for your answer and please bear with me since I am still confused. I hope it will not last long. I am going to try to recreate the whole thing in my environment today or tomorrow.
minidea
It is fine, it is a very helpful article but it does not answer my question. How come when I use this statement:
THISFORM.AddObject ("oGraph","MSGraph.Chart.8")
I get an error message: this object is invalid for this container
I tried THISFORM.AddObject ("oGraph","MSGraph.Chart"), which you use in your article, with the same result.
Also I have another question. When I tried to examine MSGraph 9.0 object library in object browser I could see classes, interfaces and enums but not properties or methods. I get errors. After the message that the fox was loading them I would get an error: Function argument value, type, or count is invalid.
Thanks.
klotz
Marcia hi,
OK, this is what's going on. I am able to create MSGraph object and manipulate many properties to my liking: axes, labels, dimensions, etc. The only thing I cannot figure out how to do is to attach a data set to it via a recordSource.
In your article you are saying that you drop so called "oleBoundControl" on the form and then somehow magically the MGraph control acquires needed properties and methods.
Thisform.oGraph.ControlSource = '' - it seems this statement in your article introduces oGraph object out of the blue. I could not find out where it is created and how. Is it the oleBound Control or MSGraph control What role does the oleBoundControl play in all this
The methods you are using: MakeGraph(), DoQuery() and others are not recognized by my MSGraph control and they are not listed in the help file: VBRGRP9.CHM. It is a great help file it has a lot of stuff but I could not figure out how to connect the data source to it.
I do not have olebound control anywhere in my VFP toolbox. I checked with the object browser--none. I checked with OLEViewer (it is another MS tool) - could not find it over there either.
I would appreciate your help. This seems to be my last stumbling block in graphics area.
Thanks.
Rayven01
Actually, I preempted you and did it while writing the code the first time around out of hunch or whatsoever. It did not cost me anything. It is still invisible. I feel it may be because there is not much meat to the chart yet, no data, rows and columns are empty, etc. But a lot of properties are defined with default values as I found out, e.g. axes, chart dimensions, etc.
I will try the OLEbound control tonight.
Thanks.
Loranga
Louis Davidson
The OLEBound control is the container for the graph object that lives inside of it.
This is what the white paper said:
The easiest way that I have found to manipulate MSGraph is to store a “template” graph in a General field of a table. Then, whenever I need to create a particular graph, I drop an OleBound Control on a form and set its ControlSource to the General field in a cursor created from that table. This has several benefits:
Avoids contention when several users try to create a graph at the same time since each user has his own cursor
Does not require multiple graphs to be stored. After all, graphs are generally used to depict current trends and, as such, are usually generated ‘on the fly’ so it makes no sense to store them permanently in a table or on disk
Using an OleBound Control gives us direct access to the graph through its properties. This means we can manipulate the graph programmatically while the form is invisible and then display or print the final result.
In my sample code the graph is created by running the query that is stored in the metadata to get a cursor of data that will be used to create the graph. The data in the cursor is put into a memory variable that is formatted in clipboard format (fields separated by tabs and records separated with carriage returns and line feeds). Then, the APPEND GENERAL command is used with the DATA clause to update the graph in the cursor. It is this general field that is the controlSource for the OLEBound control on the form.
The original "seed" graph is loaded into the cursor in the sample form class's init() like so:
*** Set up the cursor for the graph
SELECT
* FROM VfpGraph INTO CURSOR csrGraph READWRITE NOFILTERGO TOP IN
csrGraphsdanil
This does not happen when I use the object browser. Either there is something wrong with your Object Browser program or the is something wrong with the MS Graph type library.
bill777
My apology. That was premature. I unzipped the wrong file. It seems to be what I need.
Thanks.
pattormey
So, it is MSGraph.Chart.8, and MSGraph.Application.8 that I cannot place on a form.
You need to store the graph object in a general field in a cursor and use the general field as the ControlSource for an OLEBound Control that you drop on the form.
Download the white paper and code samples from my conference session entiled "Creating Graphs in VFP" from http://www.tightlinecomputers.com/Downloads.htm. It will give a lot of information about how to use MsChart, MsGraph, Excel Automation or the Office Web Components.
IbanezRox
Marcia hi,
Reading your article on MSGraph I realized that I lack VBAGrp9.chm since I've never install anything beyond the smallest subset of MS Works 2000. Now it is in my C:\WINNT\HELP directory. Thanks.
Aldo Donetti
Paul Chis
THISFORM.AddObject ("oGraph","olecontrol","MSGraph.Chart.8")
This is one way to do it. As the white paper says, I prefer to use an OLEBound Control because it I need to generate the graph on the fly I can do so using the APPEND GENERAL command with the DATA clause. This is the only thing I ever use general fields for.
It seemed to work. It does not give me any errors now but the control is invisible at this point
This is exactly what I would expect to happen. Objects added to forms using the .NewObject() or .AddObject() method are added with their visible property set to false. You need to explicitly set oGraph.Visible = .T. after you add it.