Antonio,
great! ![]()
EMG
Antonio,
great! ![]()
EMG
Antonio,
I made the modifies on tgraph and I tried it run but then after sone tooltip showed make an error
Time from start: 0 hours 0 mins 47 secs
Error occurred at: 26-12-2014, 16:54:03
Error description: Error BASE/1132 Limiti superati: accesso all'array
Args:
[ 1] = A { ... } length: 1
[ 2] = N 2
Called from: Lib\tgraph\tgraph.prg => (b)TGRAPH:MOUSEMOVE( 1883 )
Called from: Lib\tgraph\tgraph.prg => TGRAPH:MOUSEMOVE( 1883 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\CONTROL.PRG => TGRAPH:HANDLEEVENT( 1733 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3345 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1050 )
Called from: source\Main.prg => TAPPLICATION:ACTIVATE( 394 )
Called from: source\Main.prg => MAIN( 55 )
I found an error on new addserie method
Time from start: 0 hours 0 mins 9 secs
Error occurred at: 26-12-2014, 17:05:15
Error description: Error BASE/1123 Parametro errato: AADD
Args:
[ 1] = U
[ 2] = C 0
Called from: => AADD( 0 )
Called from: Lib\tgraph\tgraph.prg => TGRAPH:ADDSERIE( 460 )
Silvio,
Could you please provide a small example to reproduce the error ? many thanks
#include "FiveWin.ch"
#include "constant.ch"
Function Grafico()
local oBar, oCol, oCont,oOptions
local aBrowse
local i,oLogoBmp,oCursor
LOCAL oBrush := TBrush():New("NULL",,,)
Local aMes:={ "Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Oct","Nov","Dic" }
Local aEntrate :={}
Local aUscite :={}
Local nBottom := 45
Local nRight := 120
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
Local cClrEntrate := 7031871
Local cClrUscite := 204
Local nMaxValGraph := 2000
Local aCanE :={ { "Gen", 0 }, { "Feb", 0 }, { "Mar", 0 }, { "Apr", 0 }, ;
{ "Mag", 0 }, { "Giu", 0 }, { "Lug", 0 }, { "Ago", 0 }, ;
{ "Set", 0 }, { "Oct", 0 }, { "Nov", 0 }, { "Dic", 0 } }
Local aCanU :={ { "Gen", 0 }, { "Feb", 0 }, { "Mar", 0 }, { "Apr", 0 }, ;
{ "Mag", 0 }, { "Giu", 0 }, { "Lug", 0 }, { "Ago", 0 }, ;
{ "Set", 0 }, { "Oct", 0 }, { "Nov", 0 }, { "Dic", 0 } }
USE MOVIMENTI ALIAS MV
SELECT MV
MV->(DbGoTop())
MV->( DBEVAL( { || IF(Month( FIELD->APFECHA ) >0, aCanE[ Month( FIELD->APFECHA ) ][ 2 ]+= IIF( FIELD->APTIPO="E", MV->APIMPTOTAL,0), ) }) )
MV->( DBEVAL( { || IF(Month( FIELD->APFECHA ) >0, aCanU[ Month( FIELD->APFECHA ) ][ 2 ]+= IIF( FIELD->APTIPO="U", MV->APIMPTOTAL,0), ) }) )
For n=1 to len( aCanE)
AADD( aEntrate,aCanE[n][2])
next n
For n=1 to len( aCanU)
AADD( aUscite,aCanU[n][2])
next n
DEFINE DIALOG oDlg ;
TITLE "Test New Graph" ;
SIZE nWidth, nHeight TRANSPARENT PIXEL
oGraph:=TGraph():New(0,0,oDlg,oDlg:nBottom/2,oDlg:nWidth/4)
oGraph:cPicture:="99,999.99"
oGraph:SetYVals(aMes)
oGraph:nType :=1
oGraph:cTitX :="Importo Totale"
oGraph:cTitY :="Mesi"
oGraph:lYVal :=.T.
oGraph:lLegends:=.T.
oGraph:lPopUp :=.F.
oGraph:nBarD :=15
oGraph:nXRanges:=20
oGraph:l3D :=.f.
oGraph:nBarSep:=5
oGraph:lxGrid :=.T.
oGraph:lYGrid :=.f.
oGraph:cTitle:="Visualizzazione annuale dei movimenti di entrata ed uscita"
oGraph:AddSerie(aEntrate,"Entrate",cClrEntrate)
oGraph:AddSerie(aUscite,"Uscite",cClrUscite)
oGraph:cToolTip = { | nAt | Str( nAt ) }
ACTIVATE DIALOG oDlg
return nilSilvio,
Your example is working fine here.
Maybe you did a wrong modification of class TGraph ?
// Add
DATA lToolTip // Default = FALSE
//-------------------------------
// To display tooltip
oGraph:lToolTip := TRUE
oGraph:cToolTip = { | nAt, nRow, nCol | oGraph:ToolTip( nAt, nRow, nCol) }
//--------------------------------------------------
METHOD ToolTip(nAt, nRow, nCol) CLASS TGRAPH
// Display Tootip for one or two value series
if nAt/2 - int(nAt/2) = 0
// Even (Series 2)
nI := nAt/2
::ShowToolTip( nRow, nCol, ::aYVals[nI] + CRLF+ ::cLabelSerie2 + " = $"+ ::aSeries2[nI] )
else
// Odd (Series 1)
nI := int(nAt/2)+1
::ShowToolTip( nRow, nCol, ::aYVals[nI] + CRLF+ ::cLabelSerie1 + " = " + ::aSeries1[nI] )
endif
//------------------------------------------------------------------------
METHOD MouseMove( nRow, nCol, nFlags ) CLASS TGraph
LOCAL nAt := 0
if ::lToolTip = .T.
if ! Empty( ::aBarCoors )
nAt = AScan( ::aBarCoors,;
{ | aCoors | nRow <= aCoors[ 2 ] .and. ;
nRow >= aCoors[ 2 ] - aCoors[ 3 ] .and. ;
nCol >= aCoors[ 1 ] .and. ;
nCol <= aCoors[ 1 ] + aCoors[ 4 ] } )
if nAt != 0
DEFAULT ::cToolTip := { | nAt | AllTrim( Transform( ::aData[ 1 ][ nAt ],;
"999,999,999.99" ) ) }
//::ShowToolTip( nRow, nCol, Eval( ::cToolTip, nAt ) )
::ShowToolTip( nRow, nCol, Eval( ::cToolTip, nAt, nRow, nCol ) )
else
::DestroyTooltip()
endif
endif
endif
return nil
return (.T.)George,
Many thanks
But what will happen if the Graph is only showing one serie only ?
oGraph:cToolTip = { | nAt, nSerie | nSerie := If( nAt % ;
Len( oGraph:aSeries ) == 0, Len( oGraph:aSeries ),;
Int( nAt % Len( oGraph:aSeries ) ) ),;
"Series: " + Alltrim( Str( nSerie ) ) + CRLF + ;
"Bar: " + AllTrim( Str( Int( nAt / Len( oGraph:aSeries ) ) + 1 + ;
If( nAt % Len( oGraph:aSeries ) == 0, -1, 0 ) ) ) }METHOD AddSerie( aDat, cLegend, nColor, nType, l3D ) CLASS TGraph
LOCAL nI
DEFAULT nType := NIL, ;
l3D := NIL
AAdd( ::aSeries, { cLegend, nColor, nType, l3D } )
AAdd( ::aData , aDat )
AAdd( ::aSTemp , { cLegend, nColor, nType, l3D } )
AAdd( ::aDTemp, aDat )
// Coded added
IF len( ::aSeries ) = 1
// Series 1
FOR nX := 1 TO LEN(aDat)
aadd(::aSeries1, transform(int(aDat[nX]), "@B 999,999" ) )
NEXT
::cLabelSerie1 := ::aSeries[len( ::aSeries )] [1]
ELSE
// Series 2
FOR nX := 1 TO LEN(aDat)
aadd(::aSeries2, transform(int(aDat[nX]*100), "@B 999,999,999" ))
NEXT
::cLabelSerie2 := ::aSeries[len( ::aSeries )] [1]
ENDIF
RETURN Len( ::aSeries )George,
if you test the code that I have posted then you will see that you can already display tooltips for "n" series values
without having to modify that Class TGraph method.
Antonio,
can have on my email the new tgraph with last George ( and Linares) modifies please ?
Perhaps I made error to insert modifies
//---------------------------------------------------------------------------
// To use Tooltips in TGRAPH Class (only tested with one and two series!)
//---------------------------------------------------------------------------
// In your program
oGraph:lToolTip := TRUE
oGraph:cToolTip = { | nAt, nSerie, nRow, nCol | nSerie := If( nAt % ;
Len( oGraph:aSeries ) == 0, Len( oGraph:aSeries ),;
Int( nAt % Len( oGraph:aSeries ) ) ),;
oGraph:ToolTip( nAt, nRow, nCol, nSerie) }
//--------------------------------------------------------
// Data to be added to TGRAPH Class
//-----------------------------------------------------
DATA aBarCoors
DATA lToolTip INIT .F.
//------------------------------------------------------------------------
// Methods to add in TGRAPH Class
//------------------------------------------------------------------------
METHOD MouseMove( nRow, nCol, nFlags ) CLASS TGraph
LOCAL nAt := 0
if ::lToolTip = .T.
if ! Empty( ::aBarCoors )
nAt = AScan( ::aBarCoors,;
{ | aCoors | nRow <= aCoors[ 2 ] .and. ;
nRow >= aCoors[ 2 ] - aCoors[ 3 ] .and. ;
nCol >= aCoors[ 1 ] .and. ;
nCol <= aCoors[ 1 ] + aCoors[ 4 ] } )
if nAt != 0
::ShowToolTip( nRow, nCol, Eval( ::cToolTip, nAt, nRow, nCol ) )
else
::DestroyTooltip()
endif
endif
endif
return nil
//-------------------------------------------------------------------------
METHOD ToolTip(nAt, nRow, nCol, nSerie) CLASS TGRAPH
LOCAL nSeries := len(::aSeries), nI
if nSeries = 1
::ShowToolTip( nRow, nCol, ::aYVals[nAt] + CRLF+ ::aSeries[1][1] + " = " + alltrim(str(::aData[1][nAT])))
elseif nAt/2 - int(nAt/2) = 0
// Even
nI := int(nAt/nSeries)
::ShowToolTip( nRow, nCol, ::aYVals[nI] + CRLF+ ::aSeries[nSerie][1] + " = " + alltrim(str(::aData[nSerie][nI])) )
else
// Odd
nI := int(nAt/nSeries) + 1
::ShowToolTip( nRow, nCol, ::aYVals[nI] + CRLF+ ::aSeries[nSerie][1] + " = " + alltrim(str(::aData[nSerie][nI])) )
endif
return nilSilvio,
Please try the above code and let me know if this work for you.
Regards,
George
Now it seem run here
I made :
DATA aBarCoors AS ARRAY INIT {} // Array with Bars coords. added by Antonio Linares
DATA aSeries1 AS ARRAY INIT {} // Array containing Series 1 Value
DATA aSeries2 AS ARRAY INIT {} // Array containing Series 2 Value
DATA cLabelSerie1 // Serie 1 Label
DATA cLabelSerie2 // Serie 2 Label
DATA lToolTip AS LOGIC INIT .F. // Default = FALSE
then I wish asl a question for the tooltip
oGraph:cToolTip = { | nAt, nSerie | nSerie := If( nAt % ;
Len( oGraph:aSeries ) == 0, Len( oGraph:aSeries ),;
Int( nAt % Len( oGraph:aSeries ) ) ),;
"Series: " + Alltrim( Str( nSerie ) ) + CRLF + ;
"Bar: " + AllTrim( Str( Int( nAt / Len( oGraph:aSeries ) ) + 1 + ;
If( nAt % Len( oGraph:aSeries ) == 0, -1, 0 ) ) ) }
I have :
oGraph:AddSerie(aEntrate,"Entrate",cClrEntrate)
oGraph:AddSerie(aUscite,"Uscite",cClrUscite)
If I want show the cLegend of each series and the his value how I can insert into ctooltip ? thanks