FoxPro for Graph Object Full contact (1)

Source: Internet
Author: User
Tags cdata chr

Objective

Many friends may have the understanding that Visual FoxPro has limited support for Graph objects-it's hard to use it to make rich, beautiful icons; there are some problems that seem insurmountable: print charts--visual FoxPro does not provide a way to print a form, graph Does not provide a way to print or Save as a picture ...

I have this idea, but with the gradual establishment of "object-oriented" programming concepts and the deepening of the understanding of COM, I have changed the original point of view.

Excel has been praised for its ability to chart, as you know: Microsoft has never provided a single graphics engine, and Excel's chart features are entirely provided by the Gpaph object. In other words: Excel can do it in Visual FoxPro-they use the same diagram engine.

Before we begin, I have the following suggestions:

    1. Note Some basic questions about using Graph in Visual FoxPro, such as data sources, data refreshes ...

    2. Graph is a content, very rich object, we cannot tell too many methods and attributes (which is not interesting), more knowledge can refer to the Graph object's help file.

How Visual FoxPro supports Graph objects

Composition of Graph objects

As you can see from the diagram, there are two important child objects--chart, datasheet, below the Application object at the top level. The datasheet object controls the data generated by the graph, theoretically changing its content to get the data refresh function of the chart, and the Chart object controls various forms of the graph, that is, the control of the format.

Visible: With good Graph you have to (as long as) use these two objects on it. In terms of functional requirements, Graph is the control of data source control and format.

How Visual FoxPro supports Graph objects

However, it is not so simple that when you add a Graph object to Visual FoxPro, we build an instance of the graph object, not an instance of the Application object mentioned above. We can observe the Application object at Graph top by using the following statement:

? Thisform.graph.application.name
* Back: Microsoft Visual FoxPro

In this way, we cannot get the datasheet object to control the data source through the Appliction object. More specifically: we can only control the format through the Graph object instance to not be able to complete the control of the data. The same is true in Excel, except that the upper Application object is replaced with Excel. )

Don't worry, Visual FoxPro has its own way of solving it. The Visual FoxPro control of Graph's data source is achieved by "let Graph control bind to a common field", and we can easily control the data source of the chart by constantly changing the contents of the common field.

Light has no data, the control of the format we can use the graph object's properties to control, write some code your chart on the "beautiful Lun Huan." The point here is that control of the chart format is also written to the generic field. Someone asks: Can you write the format together when you write data to a common field? I think: This is OK, but who has done so, who put the easy to use method and roamed?

Graph data source and Data update

Specify Graph Data Source string

For example, the structure and data of the data table are as follows, which indicates the sales in the quarter of 1996-1998. (Data table is

Quarter

year1996

year1997

year1998

First quarter

730.1

929

1693.97

Second quarter

782.2

1361.1

2042.98

Third quarter

908

1485.2

2462.44

Quarter Four

736.3

1254.7

2800

We first use the tab notation to convert the datasheet to a string that matches the Graph requirement. This code is as follows: (data is from boe_table.) DBF)

#DEFINE TAB CHR (9)
#DEFINE CRLF CHR +CHR (10)
Local CDATA
M.cdata= ""

Select boe_table && Select data source table

M.cdata= "" "+tab+" 1996 "+tab+" 1997 "+tab+" 1998 "+crlf
SCAN All
M.cdata=m.cdata+quarter+tab+alltr (STR (year1996,7,2));
+tab+alltr (str (year1997,7,2)) +tab+alltr (str (year1998,7,2)) +crlf
ENDscan

If this string is displayed, you will find that it forms like a table. as follows, use Messagebox () to display the CDATA generated above. For ease of explanation, we call this string: Graph data source string.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.