Graph
Previous topic  First topic  Next topic







Define and Properties


Properties
Status
Default
Planned
Started
Ready
Comments
CREATE GRAPH cName | (cVarName) | &(cExpression) 
      [ PARENT cParentName ]
NIL
  
Parent window for this widget
      [ PARENTTYPE n/a ]   
Only for mg_get() function, this property returns the PARENT control type or "" if the parent was not set.
      [ ROW nRow ]
0
  
Row position on container desktop in pixels coordinates
      [ COL nCol ]
0
  
Col position on container desktop in pixels coordinates
      [ WIDTH nWidth ]
?
  
The desired width size of the window in pixels
      [ HEIGHT nHeight ]
?
  
The desired height size of the window in pixels
      [ ROWBOTTOM nRow ]
n/a
  
Bottom Row position on container desktop in pixels coordinates. This property adjust the HEIGHT property according the ROW property.
      [ COLRIGHT nCol ]
n/a
  
Right Col position on container desktop in pixels coordinates. This property adjust the WIDTH property according the COL property.
      [ TOROW nBottom ]
n/a
  
Bottom ROW. Usually used with ROW, COL and TOCOL
      [ TOCOL nRight ]
n/a
  
Right COL. Usually used with ROW, COL and TOROW
      [ COORD { nLeft , nTop , nRight , nBottom } ]
n/a
  
Coordenates to painter area
      [ FROMXY { nLeft , nTop } ]
n/a
  
Coordenates to painter area (Usually used with TOXY property)
      [ TOXY { nRight , nBottom } ]
n/a
  
Coordenates to painter area (Usually used with FROMXY property)
      [ TITLE cTitle ]
""
  
Set graph title
      [ CURSOR ]
Qt_ArrowCursor
  
Change the cursor pointer shape for the DRAW area. Go to to learn more about it.
      [ TOOLTIP cToolTip ]
NIL
  
Text for display into tooltip
      [ VISIBLE .T. | .F. ]
.T.
  
Show or hide DRAW area (like methods SHOW and HIDE)
      [ BACKCOLOR {aBackColor} | aVarBackColor ]
OS.BackColor
  
Set background color
      [ COLORS {aColors} | aVarColors ]
n/a
  
Color array for series. e.g. { {255,0,0} , {0,255,0} , {0,0,255} }
      [ SERIENAMES {aSerieNames} | aVarSerieNames ]
n/a
  
Name for series. e.g. { "serie 1" , "serie 2" , "serie 3" }
      [ SERIEVALUES {aSerieValues} | aVarSerieValues ]
n/a
  
Values for series.
e.g. for "BARS": { {14280,20420,12870} , {8350,10315,15870} , {12345,-8945,10560} }
e.g. for "PIE": {1500,1800,200,500,800}
      [ TYPE cType ]
"BARS"
  
Graph type. Valid types are: "BARS", "LINES", "POINTS" and "PIE"
      [ XVALUES {aXValues} | aVarXValues ]
n/a
  
Labels for 'X' values. e.g. { "Jan" , "Feb" , "Mar" , "Apr" , "May" }
      [ YVALUES nYCantLabels ]
5
  
Cant of 'Y' labels
      [ SHOWXVALUES .T. | .F. ]
.T.
  
Show/Hide 'X' values
      [ SHOWYVALUES .T. | .F. ]
.T.
  
Show/Hide 'Y' values
      [ SHOWGRID .T. | .F. ]
.T.
  
Show/Shide graph grid
      [ SHOWLEGENDS .T. | .F. ]
.T.
  
Show/Hide graph legends
      [ 3DVIEW .T. | .F. ]
.T.
  
Show GRAPH in 3D
      [ DEPTH nDepth ]
15
  
Depth for 3D graph
      [ NOBORDER .T. | .F. ]
.F.
  
Hide/Show graph border
      [ CREATE CONTEXT MENU [ cName ] ]   
CONTEXT MENU for control
            [ ......... ]   
You can see properties for this menu in CONTEXT MENU topic
      [ END MENU ]   
 
END GRAPH 

Jump to Context Menu topic



Methods


Methods
Status
Default
Planned
Started
Ready
Comments
    RELEASE
n/a
  
Release DRAW area
    HIDE
n/a
  
Hide DRAW area.
    SHOW
n/a
  
Show DRAW area.
    REFRESH
n/a
  
This method is used to refresh the control content.
    SAVETOFILE cFileName
n/a
  
This method is used to save GRAPH control to file. The image file type will be chosen from fileName's suffix. Default image type is 'png' and allowed types are: 'bmp', 'jpeg', 'jpg' and 'png'. Warning: by default, the GRAPH control has a transparent BACKCOLOR, some image programs will show 'transparent backcolor' as black.
    UNSETCURSOR
n/a
  
Reset the cursor pointer shape for the DRAW area to default (Qt_ArrowCursor). Go to to learn more about it.



Example:

File: d_graph.prg


#include "marinas-gui.ch"

MEMVAR PRI_nPageGraph

Function main()
   PRIVATE PRI_nPageGraph

   SET APPLSTYLE TO "MarinasLooks"

   CREATE WINDOW d_window
      ROW 0 ; COL 0
      WIDTH 820 ; HEIGHT 480
      CAPTION "Marinas-GUI Sample for Graph Control"
      ICON "../resource/d_test.ico"
      BACKCOLOR {223,242,253}
      MAIN .T.

      d_graph_def()

   END WINDOW

   mg_Do( "d_window" , "center" )

   mg_Do( "d_window" , "activate" )

Return .T.


File: d_graph_def.prg

/*
 * This sample code was borrowed from HMG 4
 * (c) 2010 Roberto Lopez 
 */

#include "marinas-gui.ch"

FUNCTION d_graph_def()

   LOCAL aSeries := { {14280,20420,12870,25347, 7640},;
                      { 8350,10315,15870, 5347,12340},;
                      {12345,-8945,10560,15600,17610} }


   CREATE CHECKBOX graph_checkbox1
      ROW 445
      COL 80
      CAPTION "3D"
      VALUE .T.
      ONCHANGE mg_do( "d_window" , "graph_button1" , "onClick" )
   END CHECKBOX

   CREATE BUTTON graph_button1
      ROW     440
      COL     120
      CAPTION "Bars"
      ONCLICK DrawBarGraph( aSeries )
   END BUTTON

   DrawBarGraph( aSeries )

   CREATE CHECKBOX graph_checkbox2
      ROW 445
      COL 245
      CAPTION "3D"
      VALUE .T.
      ONCHANGE mg_do( "d_window" , "graph_button2" , "onClick" )
   END CHECKBOX

   CREATE BUTTON graph_button2
      ROW     440
      COL     285
      CAPTION "Lines"
      ONCLICK DrawLinesGraph( aSeries )
   END BUTTON

   CREATE CHECKBOX graph_checkbox3
      ROW 445
      COL 400
      CAPTION "3D"
      VALUE .T.
      ONCHANGE mg_do( "d_window" , "graph_button3" , "onClick" )
   END CHECKBOX

   CREATE BUTTON graph_button3
      ROW     440
      COL     440
      CAPTION "Points"
      ONCLICK DrawPointsGraph( aSeries )
   END BUTTON

   CREATE CHECKBOX graph_checkbox4
      ROW 445
      COL 560
      CAPTION "3D"
      VALUE .T.
      ONCHANGE mg_do( "d_window" , "graph_button4" , "onClick" )
   END CHECKBOX

   CREATE BUTTON graph_button4
      ROW     440
      COL     600
      CAPTION "Pie"
      ONCLICK DrawPieGraph()
   END BUTTON

RETURN NIL

/*----------------------------------------------------------------------*/

FUNCTION DrawBarGraph( aSeries )

   IF mg_isControlCreated( "d_window" , "myGraph" )
      mg_do( "d_window" , "myGraph" , "release" )
   ENDIF

   CREATE GRAPH myGraph OF d_window
      WIDTH      610
      HEIGHT     400
      ROW        20
      COL        ( mg_get( "d_window" , "width" ) - mg_get( "d_window" , "myGraph" , "width" ) ) / 2
      TITLE      "Sales and Product"
      TYPE       "BARS"
      SERIEVALUES aSeries
      XVALUES    {"Jan","Feb","Mar","Apr","May"}
      DEPTH      15
      YVALUES    5
      SERIENAMES { "Serie 1","Serie 2","Serie 3" }
      COLORS     { {128,128,255}, {255,102, 10}, {55,201, 48} }
      3DVIEW     mg_get( "d_window" , "graph_checkbox1" , "value" )
      SHOWGRID   .T.
      SHOWXVALUES .T.
      SHOWYVALUES .T.
      SHOWLEGENDS .T.
      NOBORDER   .T.
   END GRAPH

   IF mg_isControlCreated( "d_window" , "maindemo_tab" )
      mg_do( "d_window" , "MainDemo_Tab" , "addControl" , "myGraph" , M->PRI_nPageGraph )
   ENDIF

RETURN NIL

/*----------------------------------------------------------------------*/

FUNCTION DrawLinesGraph( aSeries )

   IF mg_isControlCreated( "d_window" , "myGraph" )
      mg_do( "d_window" , "myGraph" , "release" )
   ENDIF

   CREATE GRAPH myGraph OF d_window
      WIDTH      610
      HEIGHT     400
      ROW        20
      COL        ( mg_get( "d_window" , "width" ) - mg_get( "d_window" , "myGraph" , "width" ) ) / 2
      TITLE      "Sales and Product"
      TYPE       "LINES"
      SERIEVALUES aSeries
      XVALUES    {"Jan","Feb","Mar","Apr","May"}
      DEPTH      15
      BACKCOLOR  {255,255,187}
      YVALUES    5
      SERIENAMES { "Serie 1","Serie 2","Serie 3" }
      COLORS     { {128,128,255}, {255,102, 10}, {55,201, 48} }
      3DVIEW     mg_get( "d_window" , "graph_checkbox2" , "value" )
      SHOWGRID     .T.
      SHOWXVALUES  .T.
      SHOWYVALUES  .T.
      SHOWLEGENDS  .T.
      NOBORDER     .T.
   END GRAPH

   IF mg_isControlCreated( "d_window" , "maindemo_tab" )
      mg_do( "d_window" , "MainDemo_Tab" , "addControl" , "myGraph" , M->PRI_nPageGraph )
   ENDIF

RETURN NIL

/*----------------------------------------------------------------------*/

FUNCTION DrawPointsGraph( aSeries )

   IF mg_isControlCreated( "d_window" , "myGraph" )
      mg_do( "d_window" , "myGraph" , "release" )
   ENDIF

   CREATE GRAPH myGraph OF d_window
      WIDTH      610
      HEIGHT     400
      ROW        20
      COL        ( mg_get( "d_window" , "width" ) - mg_get( "d_window" , "myGraph" , "width" ) ) / 2
      TITLE      "Sales and Product"
      TYPE       "POINTS"
      SERIEVALUES aSeries
      XVALUES    {"Jan","Feb","Mar","Apr","May"}
      DEPTH      15
      YVALUES    5
      SERIENAMES { "Serie 1","Serie 2","Serie 3" }
      COLORS     { {128,128,255}, {255,102, 10}, {55,201, 48} }
      3DVIEW     mg_get( "d_window" , "graph_checkbox3" , "value" )
      SHOWGRID     .T.
      SHOWXVALUES  .T.
      SHOWYVALUES  .T.
      SHOWLEGENDS  .T.
      NOBORDER     .T.
   END GRAPH

   IF mg_isControlCreated( "d_window" , "maindemo_tab" )
      mg_do( "d_window" , "MainDemo_Tab" , "addControl" , "myGraph" , M->PRI_nPageGraph )
   ENDIF

RETURN NIL

/*----------------------------------------------------------------------*/

FUNCTION DrawPieGraph()

   IF mg_isControlCreated( "d_window" , "myGraph" )
      mg_do( "d_window" , "myGraph" , "release" )
   ENDIF

   CREATE GRAPH myGraph OF d_window
      WIDTH      400
      HEIGHT     350
      ROW        20
      COL        ( mg_get( "d_window" , "width" ) - mg_get( "d_window" , "myGraph" , "width" ) ) / 2
      TITLE      "Sales"
      TYPE       "PIE"
      SERIEVALUES {1500,1800,200,500,800}
      DEPTH      25
      SERIENAMES { "Product 1","Product 2","Product 3","Product 4","Product 5" }
      COLORS     { {255,0,0},{0,0,255},{255,255,0},{0,255,0},{255,128,64} }
      3DVIEW     mg_get( "d_window" , "graph_checkbox4" , "value" )
      SHOWXVALUES .T.
      SHOWLEGENDS .T.
      NOBORDER   .T.
   END GRAPH

   IF mg_isControlCreated( "d_window" , "maindemo_tab" )
      mg_do( "d_window" , "MainDemo_Tab" , "addControl" , "myGraph" , M->PRI_nPageGraph )
   ENDIF

RETURN NIL




Marinas-GUI Version 03.06 and
Marinas-IDE Version 05.06 and
LEX Files Version 02.06


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: March 09
2017
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




A Harbour/QT framework to make multiplatform programs

(©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
CarozoDeQuilmes@gmail.com

2009-2017 Beta tester and full English translator: Bruno Luciani
Bruno.Luciani@gmail.com

2014-2015 Final English corrector: David Worboys
DavidWorboys@hotmail.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Jump to Donation Topic


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic