Sparklines in XBROWSE like Excel 2010

Sparklines in XBROWSE like Excel 2010

Postby Otto » Mon Dec 07, 2009 1:55 am

Today I had a look at the new 2010 EXCEL features.
Now you can have graphs in every row. Complex data can be shown in a more easy form.
Thanks to :bPaintText you can do this with xBrowse too.
For Excel 2010 we’ve implemented sparklines, “intense, simple, word-sized graphics”, as their inventor Edward Tufte describes them in his book Beautiful Evidence. Sparklines help bring meaning and context to numbers being reported and, unlike a chart, are meant to be embedded into what they are describing:

Image

Best regards,
Otto

Image

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: Sparklines in XBROWSE like Excel 2010

Postby nageswaragunupudi » Mon Dec 07, 2009 2:46 am

Mr. Otto

Excellant.
Yes, this little known feature oCol:bPaintText puts lot of power in our hands.
But the way you have used this power is commendable.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Sparklines in XBROWSE like Excel 2010

Postby Otto » Mon Dec 07, 2009 11:01 am

Best regards,
Otto

Code: Select all  Expand view


#include "fivewin.ch"
#include "xbrowse.ch"


function main()

   local oDlg, oBrw
   local oFont
   local aData    := {}

   DEFINE FONT oFont   NAME 'TAHOMA' SIZE 0,-12

   AAdd( aData, {'A',  12, 450, 130, 330, 155,  80, 70,  80, 90, 111, 166, 100,"A" } )
   AAdd( aData, {'B', 130, 230, 155,  80,  12, 500, 70,  80, 90, 111, 166, 200 ,"B"} )
   AAdd( aData, {'C',  80, 270, 280,  90, 411, 166, 12, 500, 130, 330, 155, 50 ,"C"} )
   AAdd( aData, {'D',  50,  90, 111, 130, 330, 355, 80,  12, 500, 70, 166, 300 ,"D"} )
   AAdd( aData, {'E', 330, 330, 155, 180, 412, 470, 70,  80, 90, 111, 166, 300 ,"B"} )
   AAdd( aData, {'F', 430, 330, 155, 280, 212, 500, 70,  80, 90, 111, 166, 300 ,"B"} )
   AAdd( aData, {'G',  30, 330, 155, 380, 200, 480, 70,  80, 90, 111, 166, 300 ,"B"} )
   AAdd( aData, {'H', 430, 330, 155, 480, 312, 250, 70,  80, 90, 111, 166, 300 ,"B"} )
   AAdd( aData, {'I', 330, 330, 155,  86, 212, 400, 70,  80, 90, 111, 166, 300 ,"B"} )
   AAdd( aData, {'J', 230, 330, 155,   8, 112, 300, 70,  80, 90, 111, 166, 300 ,"B"} )


   DEFINE DIALOG oDlg SIZE 1024,440 PIXEL FONT oFont

   @ 10, 10 XBROWSE oBrw ;
      HEADERS  'Name', 'I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII','Graph';
      SIZE 500, 200 PIXEL ;
      OF oDlg ;
      ARRAY aData AUTOCOLS ;
      LINES

   oBrw:nStretchCol := STRETCHCOL_LAST

   WITH OBJECT oBrw:aCols[14]
   :nHeadStrAlign := AL_CENTER
   :nWidth        := 200
   :bPaintText    := { |oCol, hDC, cText, aCoord| DrawText( oCol, hDC, cText, aCoord, oBrw ) }
END

oBrw:nDataLines := 6
oBrw:CreateFromCode()

ACTIVATE DIALOG oDlg CENTERED

RELEASE FONT oFont

return nil

static function DrawText( oCol, hDC, cText, aCoord, oBrw)

   local nTop  := aCoord[ 1 ], nLeft := aCoord[ 2 ]
   local nBottom := aCoord[ 3 ], nRight := aCoord[ 4 ]
   local nRow  := nTop
   local cLine, nFontHt, nAt,oBrush,aRect1:={}

   local rcttop      := nTop
   local rctleft     := nLeft
   local rctbottom   := nBottom
   local rctright    := nRight
   LOCAL I           :=0
   LOCAL nRowheight  := nBottom - nTop
   local nWidth      := 0
*----------------------------------------------------------


// missing:  get the Maxvalue here I use  500

   DEFINE BRUSH oBrush  COLOR RGB(55,255,55)


   FOR I:= 2 to  13
   
     /*
      rcttop   := INT( rctbottom - nRowheight / 500 * oBrw:aCols[I]:value  )
      rctleft  := rctleft + 25
      rctright := rctleft + 20
      aRect1 := { rcttop, rctleft, rctbottom, rctright }
      FillRect( hDC, aRect1, oBrush:hBrush)
     */


      rctleft  := rctleft + 25
      rcttop   := INT( rctbottom - nRowheight / 500 * oBrw:aCols[I]:value  )

      MoveTo( hDC, rctleft, rcttop )
      nWidth:=5

      Ellipse( hDC, rctleft - 3, rcttop, rctleft + nWidth - 1, rcttop + nWidth - 1 )

      if I < 13
         rctright := rctleft + 25
         rcttop   :=     INT( rctbottom - nRowheight / 500 * oBrw:aCols[I+1]:value  )
         LineTo( hDC, rctright, rcttop )
      endif

   next

   oBrush:end()

return nil
*----------------------------------------------------------


 
Last edited by Otto on Tue Dec 08, 2009 10:27 am, edited 2 times in total.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: Sparklines in XBROWSE like Excel 2010

Postby Silvio » Mon Dec 07, 2009 11:18 am

Otto,
It make an error on nzeile . wich is the value of nzeile ?
I think we can insert it on xbrowse class as a new method
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Sparklines in XBROWSE like Excel 2010

Postby Otto » Mon Dec 07, 2009 12:05 pm

Silvio,

nZeile = nRowheight

I changed the code for better understanding and forgot of one item. Now it is ok.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: Sparklines in XBROWSE like Excel 2010

Postby Silvio » Mon Dec 07, 2009 7:35 pm

Otto why not use tgraph class ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Sparklines in XBROWSE like Excel 2010

Postby Otto » Mon Dec 07, 2009 8:23 pm

Silvio,
Why not. I didn’t thought of that.
How would you suggest to address tGraph from inside txbrowse?
Do you think speed would be ok?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: Sparklines in XBROWSE like Excel 2010

Postby nageswaragunupudi » Tue Dec 08, 2009 3:06 am

TGraph is a control.
Mr Otto's approach is the best
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Sparklines in XBROWSE like Excel 2010

Postby Marcelo Via Giglio » Tue Dec 08, 2009 3:35 am

Hello,

first, Otto very good sample about the flexibilities of xBrowse, (Antonio) now about xBrowse in the sample
when we go to the last column (graph) we can see all cell, the cursor (black border) don't appears complete, the right side is missing
I think it is because the use of oBrw:nStretchCol := STRETCHCOL_LAST

I am using fwh9.06 maybe it was solved in newers version ?

Thanks for share your work

Regards

Marcelo
Marcelo Via Giglio
 
Posts: 1050
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Sparklines in XBROWSE like Excel 2010

Postby Antonio Linares » Tue Dec 08, 2009 8:50 pm

Marcelo,

This is how it looks using FWH 9.12 xbrowse (not published yet). Please notice that I use gray color as the background color in my Windows settings:
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sparklines in XBROWSE like Excel 2010

Postby Marcelo Via Giglio » Wed Dec 09, 2009 2:02 am

Antonio,

thanks, I will try to update my version

regards

Marcelo
Marcelo Via Giglio
 
Posts: 1050
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Sparklines in XBROWSE like Excel 2010

Postby Silvio » Wed Dec 09, 2009 8:42 am

Otto ,
yesterday I try to create on this also a draw axes y,x but I hace some problem
can send you the func ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Sparklines in XBROWSE like Excel 2010

Postby Otto » Wed Dec 09, 2009 8:48 am

Best regards,
Otto
Code: Select all  Expand view

      MoveTo( hDC, rctleft, rcttop )
      nWidth:=5
SelectObject( hDC , cPen )
      Ellipse( hDC, rctleft - 3, rcttop, rctleft + nWidth - 1, rcttop + nWidth - 1 )
SelectObject( hDC , cPenRed )
      if I < 13


 


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: Sparklines in XBROWSE like Excel 2010

Postby James Bott » Fri Dec 11, 2009 5:16 pm

Very impressive work, Otto.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests