FoxPro for Graph Object Full contact (2)

Source: Internet
Author: User
Tags cdata chr constant

Where does the data sequence occur?

Data series is based on a very critical issue, which refers to a set of related data points that are plotted in a chart. Each data series in a chart has a specific color or pattern and is described in the legend of the chart. (You can draw one or more data series in a chart, but there can be only one data series in a pie chart.) )

In terms of the previous example data source table, we can specify "quarter" as the basis for the data sequence ("quarter" as the legend, the horizontal axis is "year"), you can also make "year" as the basis for data series ("year" as the legend, the horizontal axis is "quarter") But how to implement different data series?

My experience is that in Visual FoxPro the data series must be generated on the line of the Graph data source string. In the example above, "quarter" is specified as the basis on which the data series is produced (the "quarter" is the legend, and the horizontal axis is "year").

According to the theory that the data series in Visual FoxPro must be generated on the line of the Graph data source string, the graph data source character must be regenerated if the preceding example specifies "year" as the basis for the data series ("year" as The legend, and the horizontal axis is "quarter")- Put the year on the line. The code is as follows:

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

SELECT boe_table

M.cdata= "" +tab+ "first quarter" +tab+ "second quarter" +tab+ "third quarter" +tab+ "quarter Four" +crlf
For i=2 to Fcount ("boe_table")
M.cdata=m.cdata+field (I) +tab
SCAN
M.cdata=m.cdata+alltr (TRANSFORM (EVAL FIELD (I))) +tab
ENDscan
M.cdata=m.cdata+crlf
ENDfor

Use MessageBox () to display the CDATA generated above, as follows:

Bind graph Data source character to graph control

The following code is used to add "Graph data source characters" to a generic field and specify the field with "MSGraph." CHART class, and finally the field as the data source for the unbound ActiveX control.

CREATE CURSOR GRAPH (olegraph G)

APPEND BLANK
APPEND General olegraph DATA m.cdata CLASS "MSGraph. CHART "
* CDATA is "Graph data source character"
Thisform.graph.controlsource= "Graph. Olegraph && assumes that the Graph control is "unbound stereotypes ActiveX control"

Data refresh

If the control is already bound to a field, but we want to refresh the data data source for Graph, you can use the following code:

SELECT GRAPH
Thisform.graph.controlsource= ""
APPEND General olegraph DATA m.cdata CLASS "MSGraph. CHART "
* Replace the contents of the common field for the new Cdada
Thisform.graph.controlsource= "Graph. Olegraph "

As simple as that, we already know how to produce a graph data source string for different data series, and you specify a data source for the graph control.

Format Graph Control

So far, we have established a chart. The following figure is a chart that does not have any decorations, which is based on the previous example in the "quarter" series of data. How can it be used without beauty?

Chart type

The

Graph object provides us with a variety of chart styles, each with its own economic significance. Of course, what kind of case in which style of chart is not the problem discussed in this article. In the case of the previous example, we can choose the following chart style (you can also choose a different style):

Chart type Constant Constant value
Clustered Column Chart Xlcolumnclustered 51
Stacked Column Chart Xlcolumnstacked 52
Three-dimensional stacked column chart Xl3dcolumnstacked 55
Clustered cylindrical cone-shaped graphs Xlconecolclustered 99

We can complete the chart type setup by following code:

#DEFINE xlcolumnclustered 51
#DEFINE xlcolumnstacked 52
#DEFINE xl3dcolumnstacked 55
#DEFINE xlconecolclustered 99

Thisform.graph.charttype=xlconecolclustered

Chart title

Refer to the following code:

ThisForm.graph.HasTitle =. T.
With ThisForm.graph.ChartTitle
. CAPTION = "Sales Performance"
. FONT. Name = "Official script"
. FONT. FontStyle = "Bold"
. FONT. Size = 16
. FONT. ColorIndex = 3
. Shadow =. T.
. Interior.ColorIndex = 19
Endwith

X axis and Y axis

Refer to the following code:

ThisForm.graph.Axes (1). HasTitle =. T.
With ThisForm.graph.Axes (1)
. axistitle.caption= "Year"
With. Axistitle.font
. Name = "Official script"
. FontStyle = "Bold"
. Size = 10
. colorindex=25
Endwith
With. Ticklabels.font
. Name = "Song Body"
. FontStyle = "Bold"
. Size = 10
Endwith
Endwith

&& above to format x axis

ThisForm.graph.Axes (2). HasTitle =. T.
With ThisForm.graph.Axes (2)
. axistitle.caption= "Sales"
. Axistitle.orientation =-4166
With. Axistitle.font
. Name = "Official script"
. FontStyle = "Bold"
. Size = 10
. colorindex=25
Endwith
With. Ticklabels.font
. Name = "Song Body"
. FontStyle = "Bold"
. Size = 10
Endwith
Endwith

&& above to format Y axis

Legend

Refer to the following code:

With ThisForm.graph.Legend
With. FONT
. Name = "Song Body"
. FontStyle = "Bold"
. Size = 10
Endwith

With. Border
. linestyle=-4142
Endwith
Endwith

The format of the Graph control is a rich topic, we mention some of the most basic settings, but bucket!

Print chart

You often see this online question: How do you print a chart in Visual FoxPro? People tend to put ideas on the "print form", because VB, Delphi for form encapsulation PrintForm method, unfortunately, Visual FoxPro did not, the most exasperating is: their own API to write and too troublesome ...

To solve this problem may wish to change a way of thinking. We know that the Visual FoxPro report supports the display of the graph control, and that the settings for graph at run time are recorded in the generic field that is bound to graph. So all we have to do is just do it:

Create a new report, insert a bound ActiveX control in the page header band, and set its properties as follows:

Notice that in the field we fill in the generic field in the example above.

 

More information from where to

There are two help files that you must look at, in the Office 2000 directory (my machine is D:\Program Files\Microsoft Office\office\2052\) Graph9.chm and Vbagrp9.chm. The former is about the economic significance of graph, the latter is the graph object discussed in this article. Because the language is explained in VBA code, there are many constants (such as: Xl3dline), Visual FoxPro 6.0 and the following version do not support this external definition constants, you must explicitly tell Visual FoxPro what these constants are just!

In order to facilitate the Netizen, the author specially produced the GRAPH9 header file (defines all about Graph 9 constant), for everybody to download.

How to: When you edit a form, select the "Include File ..." Item under the "Form" menu, and add the Msgraph9.h to the download.

You can use the constants found from the Vbagrp9.chm in the future:

* #DEFINE xlconecolclustered 99 because it already contains the header file, this sentence can be saved
Thisform.graph.charttype=xlconecolclustered

Note: The Intellisense for Visual FoxPro 7 automatically provides a constant-and constant-value correspondence, which is convenient at that time.

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.