4D v13.4

GRAPH

Home

 
4D v13.4
GRAPH

GRAPH 


 

GRAPH ( graphPicture ; graphNumber ; xLabels {; yElements} {; yElements2 ; ... ; yElementsN} ) 
Parameter Type   Description
graphPicture  Picture variable, Graph variable in Graph area or Picture variable
graphNumber  Longint in Graph type number
xLabels  Array in Labels for the x-axis
yElements  Array in Data to graph (up to eight allowed)

Compatibility note: Beginning with 4D v13, the 4D Chart plug-in is no longer integrated in 4D and must be installed specifically if you want to use it. For compatibility, the GRAPH command can still generate graphs using this plug-in when it is present, but we strongly recommend using the integrated SVG rendering engine instead.

GRAPH draws a graph for a picture variable located in a form on the basis of values coming from arrays. The GRAPH command must be placed in the form method or in an object method belonging to the form, or yet again in a project method called by one of these two methods.

The graphs generated by this command are drawn using the integrated SVG rendering engine. They have interface functions associated with picture variables: a context menu in Application mode (to let you choose, more particularly, the display format), scrollbars, and so on. Specific IDs are assigned automatically to elements present in the graph generated, that you can use to handle them individually (see the following paragraph).

Note: SVG (Scalable Vector Graphics) is a graphics file format (.svg extension). Based on XML, this format is widespread and can be displayed more particularly in Web browsers. For more information, please refer to the following address: http://www.w3.org.Graphics/SVG/. The SVG EXPORT TO PICTURE command can also be used to take advantage of the integrated SVG engine.

In the graphArea parameter, pass the name of the picture variable that displays the graph in the form.

Note: For compatibility, the command also accepts a graph area or a 4D Chart area reference in the graphArea parameter, but we no longer recommend using this syntax.

The graphNum parameter defines the type of graph that will be drawn. It must be a number from 1 to 8. The graph types are described in Example 1. After a graph has been drawn, you can change the type by changing graphNum and executing the GRAPH command again.

The xLabels parameter defines the labels that will be used to label the x-axis (the bottom of the graph). This data can be of string, date, time, or numeric type. There should be the same number of array elements in xLabels as there are subrecords or array elements in each of the yElements.

The data specified by yElements is the data to graph. The data must be numeric. Up to eight data sets can be graphed. Pie charts graph only the first yElements.

Specific IDs are now assigned automatically to elements found in the SVG graph:

IDsDescription
ID_graph_1 to ID_graph_8Columns, lines, areas...
ID_graph_shadow_1 to ID_graph_shadow_8Shadows for columns, lines, areas...
ID_bullet_1 to ID_bullet_8Points (Line and Scatter graphs only)
ID_pie_label_1 to ID_pie_label_8Pie chart labels (Pie chart graphs only)
ID_legend_1 to ID_legend_8Legend titles
ID_legend_borderLegend borders
ID_legend_border_shadowShadows for legend borders
ID_x_valuesValues of X axis
ID_y_valuesValues of Y axis
ID_y0_axisValues of Z axis
ID_backgroundBackground
ID_background_shadowBackground shadow
ID_x_gridGrid on X axis
ID_x_grid_shadowShadow for grid on X axis
ID_y_gridGrid on Y axis
ID_y_grid_shadowShadow for grid on Y axis

Example  

The following example shows the different types of graphs that you can obtain. The code would be inserted in a form method or object method. It is not intended to be realistic, since the data is constant:

 C_PICTURE(vGraph//Variable of graph
 ARRAY STRING(4;X;2//Create an array for the x-axis
 X{1}:="1995" //X Label #1
 X{2}:="1996" //X Label #2
 ARRAY REAL(A;2//Create an array for the y-axis
 A{1}:=30 //Insert some data
 A{2}:=40
 ARRAY REAL(B;2//Create an array for the y-axis
 B{1}:=50 //Insert some data
 B{2}:=80
 vType:=1 //Initialize graph type
 GRAPH(vGraph;vType;X;A;B) //Draw the graph
 GRAPH SETTINGS(vGraph;0;0;0;0;False;False;True;"France";"USA") //Set the legends for the graph

The following figures show the resulting graph.

  • With vType equal to 1, you obtain a Column graph:
  • With vType equal to 2, you obtain a Proportional Column graph:
  • With vType equal to 3, you obtain a Stacked Column graph:
  • With vType equal to 4, you obtain a Line graph:
  • With vType equal to 5, you obtain a Area graph:
  • With vType equal to 6, you obtain a Scatter graph:
  • With vType equal to 7, you obtain a Pie graph:
  • With vType equal to 8, you obtain a Picture graph:

    Note: Pictures are simple rectangles by default.

 
PROPERTIES 

Product: 4D
Theme: Graphs
Number: 169

 
INDEX

Alphabetical list of commands

 
HISTORY 

New
Modified: 4D v11 SQL
Modified: 4D v13

 
SEE ALSO 

GRAPH SETTINGS
GRAPH TABLE
SVG EXPORT TO PICTURE