FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour tgraph and Y series alignment
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
tgraph and Y series alignment
Posted: Mon Feb 12, 2018 09:30 AM
hi,
I'm working with TGRAPH class and have this graph:


I would like get this kind of alignment:


is it possible?

thanks
FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: tgraph and Y series alignment
Posted: Mon Feb 12, 2018 01:00 PM
Did You define a BAR-SEPERATOR :-)

oGraph:nBarSep := nVal // Bar Separator

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: tgraph and Y series alignment
Posted: Mon Feb 12, 2018 01:09 PM

I Uwe
I would like to rotate the text like 2nd picture

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: tgraph and Y series alignment
Posted: Mon Feb 12, 2018 02:08 PM
I think You have to define a extra font

The tested fontstring ( saved to a DBF-field )

cBFont[3] := {"AcmeFont",0,-13,.F.,.F., 900 ,0,,.F.,.F.,.F.,0,3,2,1,,2}

I save the fontstring cBFont[3] to a DBF-field like

ACTION ( aFont := CHOOSEFONT(), ;
oFont0 := BUILDFONT( aFont ) , ;
IIF( aFont[ LF_FACENAME ] <> NIL, ;
( DeleteObject(oBFont[3]), ;
cBFont[3] := FontToText(oFont0) , ;
oBFont[3] := oFont0, ;
oFGet[3]:SetFont(oBFont[3]), ; // control
oGet[5]:Refresh(), ; // control
oFGet[3]:Refresh(), ; // control
DeleteObject(oFont0), ;
oGraph:aFont[3] := oBFont[3], ;
ograph:Refresh() ), NIL ) ) ;

The function BUILDFONT( aFont )

Code (fw): Select all Collapse
STATIC FUNCTION BUILDFONT( aFont ) 

IF EMPTY( aFont[ LF_FACENAME ] ) 
        MsgAlert( "No Font selected !","Break" ) 
        RETURN NIL 
ENDIF 

RETURN TFont():New( aFont[ LF_FACENAME ],; 
,; 
aFont[ LF_HEIGHT ],; 
.f.,; 
!( aFont[ LF_WEIGHT ] == 400 ),; 
aFont[ LF_ESCAPEMENT ],; 
aFont[ LF_ORIENTATION ],; 
aFont[ LF_WEIGHT ],; 
aFont[ LF_ITALIC ],; 
aFont[ LF_UNDERLINE ],; 
aFont[ LF_STRIKEOUT ],; 
aFont[ LF_CHARSET ],; 
aFont[ LF_OUTPRECISION ],; 
aFont[ LF_CLIPPRECISION ],; 
aFont[ LF_QUALITY ],; 
,; 
aFont[ LF_PITCHANDFAMILY ] )


Fonts are defined like

oGraph:aFont[1] := aFont[1] // Title
oGraph:aFont[2] := aFont[2] // xFont
oGraph:aFont[3] := aFont[3] // yFont
oGraph:aFont[4] := aFont[4] // Legends
oGraph:aFont[5] := aFont[5] // Subtitle
oGraph:aFont[6] := aFont[6] // xTitle
oGraph:aFont[7] := aFont[7] // y Title
oGraph:aFont[8] := aFont[8] // Values


Just a quick test !



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: tgraph and Y series alignment
Posted: Tue Feb 13, 2018 08:04 AM
hi Uwe, thank you, I try this:
Code (fw): Select all Collapse
    DEFINE FONT oFont NAME "Tahoma" SIZE 0, -11
    
    DEFINE FONT oFontY NAME "Courier new" SIZE 0, -8 
    
    oFont45 := oFontY:Rotate( 450 )
    mieiFont[3] := oFont45


    DEFINE DIALOG oDlg2 SIZE 1080,600 PIXEL  FONT oFont;
    STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
             WS_MINIMIZEBOX, WS_THICKFRAME ) ;
              TITLE "Periodo di riferimento: "+DtoC(m_get[01])+" - "+dtoc(m_get[02])

    // grafico 1
    @ 10, 1 GRAPH oGraph1;
           SIZE 180, 80 PIXEL ; 
           TYPE GRAPH_TYPE_BAR;
           YVALUES  XGRID XVALUES
           
    oGraph1:aSeries = {{ m_get[21], CLR_CYAN  }}
    oGraph1:aYVals = aResiYval
    oGraph1:aData = {aResiPerc}
    oGraph1:nClrX = CLR_GREEN
    oGraph1:nClrY = CLR_RED
    oGraph1:nMinVal = 0
    oGraph1:lDegrade = .t.
    oGraph1:cTitle := m_get[21]+" %"
    oGraph1:cToolTip = {|oGph,nSerie,nPos,nVal| oGraph1:aYVals[nPos]+": "+cValToChar(Round(nVal,2))}
    oGraph1:SetFonts(mieiFont)

but nothing..

I change metod paint in tgraph.prg
Code (fw): Select all Collapse
METHOD Paint( nTop, nLeft, nBottom, nRight ) CLASS TGraph

 ...
   local oFont45
oFont45 := ::aFont[3]:Rotate( 450 )

  IF lyVal .AND. Len(::aYVals)>0                // Show yLabels
      nI := nLeft + nWide
      FOR nJ := 1 TO ::nMax()
*         ::Say(nBottom+ 5, nI-nDeep, ::aYVals[nJ], ::aFont[3], ::nClrY, ::nTCent)
         ::Say(nBottom+ 5, nI-nDeep, ::aYVals[nJ], oFont45, ::nClrY, ::nTCent)
         nI += nWide
      NEXT
   ENDIF


that works


it seems that
Code (fw): Select all Collapse
oGraph1:SetFonts(mieiFont)
does not work

why?
FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: tgraph and Y series alignment
Posted: Tue Feb 13, 2018 09:42 AM
damianodec ,

Some years ago 2014, I created a graph-designer
I can define anything I want ( visual design ) like fonts, style colors...

There was nothing wrong with the font or class TGraph.
I want to update this tool because of many new possible things during this time
and screen adjustment for modern monitors. :-)
But in the moment I'm jumping around between different topics
that means it will still take some time for the update.



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: tgraph and Y series alignment
Posted: Tue Feb 13, 2018 03:20 PM
damianodec ,

I got it working using the original FWH-sample graph.prg
I noticed there is NO value to define the text-startposition ( yFont ) at the bottom



Code (fw): Select all Collapse
nType       // Graph Type
nDegrade  // Degrade bars color 0, 1, 2

l3D         // Show 3D
lxGrid      // Show Grid
lyGrid      // Show Grid
lDotted     // Grid Dotted
lxVal         // Show xValues
lyVal          // Show yValues
nBarD       // Deep bar
lTitle          // Show Title
lLegends    // Show Legends
cTitle        // Graph Title
cPicture     // Mask values
aSeries     // Series
aData       // Data
aSTemp      // Series
aDTemp      // Data
aYVals      // yValues
aYTemp      // yValues
aFont       // Title, xFont, yFont, Legends
               // Subtitle, xTitle, yTitle, Values
nClrT           // Color titles
nClrX       // Color x labels
nClrY       // Color y labels
nClrL       // Color legends
nClrV       // Color values
nClrST      // Color subtitle
nClrXT      // Color xTitle
nClrYT      // Color yTitle
nPieX       // Pie graph pos
nPieSt      // Start pie (angle)
nPoint      // Point type
nBarSep     // Bar Separator
nXRanges   // n Ranges
nValues     // Pie values (Serie/Period)
lViewVal    // View values
nClr, hPen, hOldPen // Pen handles
nPenWidth    // Graph line pen width
lBorders        // Borders
lcTitle          // Center title
nClrGrid        // Grid color
nClrBack        // Background color
nClrBLeg        // Back legend color
cBitmap        // Background bitmap
cSubTit        // Subtitle
cTitX           // xTitle
cTitY           // yTitle
nMaxVal      // Max Value
nMinVal      // Min Value
lLine           // Yellow line
lPopUp        // PopUp menu
lSelView        // Select view option
lSelBack        // Select back option
lFull              // All Graph Area
nLanguage   // Language (1-English, 2-Spanish, 3-...)
aSTitle INIT {.T.,.T.,.T.,.T.}  // Shadow titles

nTRight     // Right align
nTLeft      // Left  align
nTCent      // Cent  align
oPrn            // Printer object by Galvez
lBordLeg INIT .T.   // Legend border  by dREHER


Add to the sample

Code (fw): Select all Collapse
...
...
ACTIVATE DIALOG oDlg CENTER ON INIT SET_FONTS( oGraph ) // FONTS on INIT !!!

SET RESOURCES TO

RETURN NIL

// ----------------

FUNCTION SET_FONTS( oGraph )

// oGraph:aFont[1] := aFont[1] // Title
// oGraph:aFont[2] := aFont[2] // xFont
// oGraph:aFont[3] := aFont[3] // yFont
// oGraph:aFont[4] := aFont[4] // Legends
// oGraph:aFont[5] := aFont[5] // Subtitle
// oGraph:aFont[6] := aFont[6] // xTitle
// oGraph:aFont[7] := aFont[7] // y Title
// oGraph:aFont[8] := aFont[8] // Values

// METHOD New( 
//  1 cFaceName, 
//  2 nWidth, 
//  3 nHeight, 
//  4 lFromUser,;
//  5 lBold, 
//  6 nEscapement, 
//  7 nOrientation, 
//  8 nWeight,
//  9 lItalic,;
// 10 lUnderline, 
// 11 lStrikeOut, 
// 12 nCharSet, 
// 13 nOutPrecision,;
// 14 nClipPrecision, 
// 15 nQuality, 
// 16 oDevice, 
// 17 nPitchFamily )
//                                                   1      2    3    4    5     6    7  8  9   10   11 12 13  14  15  16  17   
oGraph:aFont[1] := TFont():New( "Arial", 0, -16, .F., .T., 0    , 0,  , .F., .F., .F., 0,  3,   2,   1,     ,34 )
oGraph:aFont[2] := TFont():New( "Arial", 0, -18, .F., .T., 0    , 0,  , .F., .F., .F., 0,  3,   2,   1,     , 2 )
oGraph:aFont[3] := TFont():New( "Arial", 0, -14, .F., .T., 900, 0,  , .F., .F., .F., 0,  3,   2,   1,     ,34 )
oGraph:aFont[4] := TFont():New( "Arial", 0, -16, .F., .T., 0    , 0,  , .F., .F., .F., 0,  3,   2,   1,     , 2 )
oGraph:aFont[5] := TFont():New( "Arial", 0, -16, .F., .F., 0    , 0,  , .F., .F., .F., 0,  3,   2,   1,     , 2 )
oGraph:aFont[6] := TFont():New( "Arial", 0, -12, .F., .F., 0    , 0,  , .F., .F., .F., 0,  3,   2,   1,     , 2 )
oGraph:aFont[7] := TFont():New( "Arial", 0, -18, .F., .T., 0    , 0,  , .F., .F., .F., 0,  3,   2,   1,     ,34 )
oGraph:aFont[8] := TFont():New( "Arial", 0, -20, .F., .T., 0    , 0,  , .F., .F., .F., 0,  3,   2,   1,     ,34 )

oGraph:Refresh()

RETURN NIL


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: tgraph and Y series alignment
Posted: Tue Feb 13, 2018 04:21 PM

hi Uwe
thank you, but I have 3 graph on dialog I would like TFont():New( "Arial", 0, -14, .F., .T., 900, 0, , .F., .F., .F., 0, 3, 2, 1, ,34 ) on the first graph

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tgraph and Y series alignment
Posted: Wed Feb 14, 2018 05:07 AM
A Simple way to do:

Code (fw): Select all Collapse
   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oVert := oGraph:aFont[ 3 ]:Rotate(), ;
                oGraph:SetFonts( { nil, nil, oVert } ), ;
                oVert:End() )

oGraph refers to your first Graph.
Regards



G. N. Rao.

Hyderabad, India
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: tgraph and Y series alignment
Posted: Wed Feb 14, 2018 09:07 AM

thank you Mr. Rao and Mr Uwe

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: tgraph and Y series alignment
Posted: Wed Feb 14, 2018 10:25 AM
You cannot split the text with different fonts for
oGraph:aYVals := { "Jan", "Feb", "Mar", "Apr", "May" }
but You can paint / add extra images ( with possible action ) or text to the graph



disable NOBORDER during design :-) to see the painted areas

Code (fw): Select all Collapse
#include "TTitle.ch"
...
...
ACTIVATE DIALOG oDlg CENTER ;
ON INIT SET_VAL( oGraph, oDlg )

SET RESOURCES TO

RETURN NIL

// ----------------

FUNCTION SET_VAL( oGraph, oDlg )
LOCAL oText1, oTitle1, oTitle2

@ 450, 68 TITLE oTitle1 SIZE  500, 100 OF oDlg TRANSPARENT NOBORDER
@ 57, 75 TITLETEXT oText1 OF oTitle1 TEXT "Test 1" FONT oFont90 COLOR 255
@ 57, 160 TITLETEXT oText1 OF oTitle1 TEXT "Test 2" FONT oFont90 COLOR 16711680
@ 57, 245 TITLETEXT oText1 OF oTitle1 TEXT "Test 3" FONT oFont90 COLOR 32768
@ 57, 330 TITLETEXT oText1 OF oTitle1 TEXT "Test 4" FONT oFont90 COLOR 16711935
@ 57, 415 TITLETEXT oText1 OF oTitle1 TEXT "Test 5" FONT oFont90 COLOR 128

@ 95, 540 TITLE oTitle2 SIZE 200, 200 OF oDlg  TRANSPARENT NOSHADOW  NOBORDER  
oTitle2:aGrdBack := {}
@ 5, 5 TITLEIMG  OF oTitle2 BITMAP "Favorite.bmp" SIZE 60, 60 ;
TRANSPARENT ANIMA ; 
ACTION YOUR_ACTION()
...
...


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion