Problem with prototype KPI - Dashboard Created in HMG

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines
Been thanked: 2 times

Problem with prototype KPI - Dashboard Created in HMG

Post by dhaine_adp » Tue May 11, 2010 9:45 pm

Hello Friends,

I have attached a test file for which I am having a problem with flickering display of graph that seems to be a side effect of scrolling label (a.k.a. marquee). This prototype is suppose to be displayed on a 46 inches Sony HD/LCD attached to a workstation.

The program runs on tray icon when minimized. It will be run by another program via execute command.

I am quite aware that HMG is not optimized for graphic display but is there a work around with the flickering?

The KPI-Dashboard can be easily produced in MS Excel but the display would look dull and dry if there are no moving text. For that reason I added a label that moves with HMG, of course. I was planning to put another label which scrolls a bit faster than the other one but because I can't eliminate the flickering of the graph, the other label is not added.

I would appreciate it very much if you can suggest a way to eliminate the flickering of graph.

Another problem that I encountered is when the window is initially displayed, the graph does not appear. However when you click maximize and then restore or minimize, the graph is shown? Why? I don't know either....

The attached program is compiled with HMG 3.0.33.


TIA and regards,

Danny
Attachments
TestKPI-Dashboard.zip
Test KPI-Dashboard
(3.15 KiB) Downloaded 181 times
Regards,

Danny
Manila, Philippines

User avatar
esgici
Posts: 4513
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Post by esgici » Tue May 11, 2010 10:49 pm

Hi Danny

undefined reference to `HB_FUN_MULTIMESSAGE'

( A new competitor to MsgMulti() ? )

Regards

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines
Been thanked: 2 times

Post by dhaine_adp » Wed May 12, 2010 4:09 am

Hi Danny

undefined reference to `HB_FUN_MULTIMESSAGE'

( A new competitor to MsgMulti() ? )
No it's not a competitor, I just renamed it.

Anyway I repost the source code without that call and replace it with msginfo().

Code: Select all

#include "minigui.ch"

#define PRODUCTID "KPI"
#define PRODUCTNM "Dashboard"
#define CLIENT    ""
#define VERSIONID 1.0
#define HOMEPAGE  ""
#define SERVERADD ""
#DEFINE FILLER    SPACE(3)

#define FALSE .F.
#define TRUE  .T.

REQUEST DBFCDX, DBFFPT


***************
function Main()

Local aSer:={ {14280,20420,12870,25347, 7640},;
           { 8350,10315,15870, 5347,12340},;
           {12345, -8945,10560,15600,17610} }
           
   *--> control flag to monitor windows minimize and restore events
   PRIVATE lWndMin   := FALSE
   
   *--> control flag to monitor windows maximize and restore events
   PRIVATE lWndSize   := FALSE   
   
   ANNOUNCE RDDSYS
   SET FIXED ON 
   SET DECIMALS TO 2
   SET MULTIPLE OFF WARNING
   SET DATE AMERICAN
   SET CENTURY ON
   SET EPOCH TO 1950
   SET WRAP ON
   SET SCOREBOARD OFF
   SET DELETED ON
   SET CONFIRM ON
   SET BELL ON
   SET FONT TO "Verdana" , 9
   SET NAVIGATION EXTENDED
   SET BROWSESYNC ON
   SET TOOLTIPSTYLE BALLOON
   SET TOOLTIPBACKCOLOR { 255 , 255 , 255 }
   SET TOOLTIPFORECOLOR { 0 , 0 , 0 }
   RDDSETDEFAULT("DBFCDX")
   
   DEFINE WINDOW MainForm ;
      AT 0,0 ;
      WIDTH 640 HEIGHT 480 ;
      TITLE PRODUCTNM + " Version " + ALLTRIM( STR( VERSIONID ) ) ;
      MAIN ;
      ICON "graph.ico" ;
      NOTIFYICON "graph.ico" ;
      NOTIFYTOOLTIP PRODUCTNM ;
      ON INIT ( ShowDashboard(), DrawBarGraph( aser ) ) ;
      ON MINIMIZE ShowDashboard() ;
      ON MAXIMIZE Resize( TRUE ) ;
      ON SIZE Resize( FALSE ) ;
      ON NOTIFYCLICK ShowDashboard() ;
      ON INTERACTIVECLOSE ForceClose()
   
      DEFINE NOTIFY MENU 
         ITEM "About..."   ACTION MSGINFO("Dashboard", "About")
         SEPARATOR
         ITEM 'Exit Dashboard' ACTION MainForm.Release
      END MENU
      
      @ GetDesktopHeight() - 110, 0 LABEL Dummy OF MainForm VALUE "" HEIGHT 40 WIDTH GetDesktopWidth();
         FONT "ARIAL" SIZE 10 BACKCOLOR RED FONTCOLOR YELLOW      
      
      @ GetDesktopHeight() - 100, 0 LABEL lblCritical OF MainForm VALUE "Critical" HEIGHT 20 WIDTH GetDesktopWidth();
         FONT "ARIAL" SIZE 10 BACKCOLOR RED FONTCOLOR YELLOW
      
   END WINDOW
   
   
   MainForm.Center()
   MainForm.Activate()
   RELEASE ALL
   RETURN NIL   



Procedure DrawBarGraph ( aSer )

	ERASE WINDOW MainForm

	DRAW GRAPH							;
		IN WINDOW MainForm					;
		AT 20,20						;
		TO 400,610						;
		TITLE "Sales and Product"				;
		TYPE BARS						;
		SERIES aSer						;
		YVALUES {"Mon","Tue","Wed","Thu","Friday"}			;
		DEPTH 15						;
		BARWIDTH 15						;
		HVALUES 5						;
		SERIENAMES {"PRODUCT A","SHAMPOO B","PRODUCT K"}		;
		COLORS { {128,128,255}, {255,102, 10}, {55,201, 48} }	;
		3DVIEW    						;
		SHOWGRID                        			;
		SHOWXVALUES                     			;
		SHOWYVALUES                     			;
		SHOWLEGENDS 						;
		NOBORDER
		
   Return



****************************
static function ForceClose()

   LOCAL lRetVal := FALSE

   lRetVal := MSGYESNO( "Exit Dashboard?", "Please confirm" )
   IF lRetVal
      MainForm.Release()
      DestroyWindow()
   ENDIF
   RETURN lRetval





*******************************
static function DestroyWindow()

   DBCLOSEALL()
   RELEASE WINDOW ALL
   RETURN



*************************************
static function Resize( lMaxMinSize )

   LOCAL nDeskTopWidth  := GETDESKTOPWIDTH()
   LOCAL nDeskTopHeight := GETDESKTOPHEIGHT()
   
   IF lMaxMinSize
      **--> Windows Maximize event

   ELSE
      **--> Windows Minimize event
         
   ENDIF
   RETURN NIL   





*********************************
static function ShowDashboard()

   STATIC nRunOnce := 0

   IF lWndMin
      lWndMin := FALSE
      MainForm.Restore()
      ScrollLabel(FALSE)
   ELSE
      lWndMin := TRUE
      MainForm.Hide()
      ScrollLabel(TRUE)
   ENDIF
   
   RETURN NIL



**************************************
static function ScrollLabel(lExit)


   LOCAL nRow := GetDesktopHeight() - 100
   LOCAL nCol := GetDesktopWidth()
   LOCAL ii := nCol
   LOCAL cText := "PRODUCT A (10/200) -- SHAMPOO B (3/100) -- PRODUCT K (13/20)"
   LOCAL cShowThis := ""

   LOCAL nCharCount := 0
   LOCAL nCharPos   := 1
   
   LOCAL nWidth := 0

   nCharCount := len( cText )

   WHILE TRUE
      if lExit
         EXIT
      endif
      
      if ii < 0
      
         if len( MainForm.lblCritical.Value ) = 1
            MainForm.lblCritical.Value := ""
            MainForm.lblCritical.Width := 0
            nCharPos  := 1
            cShowThis := ""
            ii        := nCol
         else
            MainForm.lblCritical.Hide
            cShowThis := alltrim( substr( MainForm.lblCritical.Value, 2 ) )
            nWidth    := GetTextWidth( nil, cShowThis, "Arial" )
            MainForm.lblCritical.Width := nWidth
            MainForm.lblCritical.Value := cShowThis
            MainForm.lblCritical.Show
            Delay( 700000 )
         endif      
      
      else
         cShowThis += substr( cText, ( nCharPos++ ), 1 )
         nWidth    := GetTextWidth( nil, cShowThis, "Arial" )
         ** MainForm.lblCritical.Hide
         MainForm.lblCritical.Col   := ii
         MainForm.lblCritical.Width := nWidth
         MainForm.lblCritical.Value := cShowThis
         ** MainForm.lblCritical.Show
         ii--
         Delay()
      endif
      do events
   
   END
   RETURN


   
*****************************
static function Delay(nDelay)

   LOCAL nIterate := 0
   
   IF VALTYPE( nDelay ) == "U"; nDelay := 190000; endif
   WHILE nIterate++ < nDelay; END; nIterate := 0
   RETURN nil


-Danny
Regards,

Danny
Manila, Philippines

User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines
Been thanked: 2 times

Post by dhaine_adp » Wed May 12, 2010 4:28 am

Hi Friends,

Another thing concerning with this problem, the red band at the bottom displays the current inventory level as it happened. And all those text that would appear supposed to be is the inventory items which is below SKU (safe keeping unit). So I might say that the production planner/scheduler and or purchaser could make a more informed decision for adjustment or whatever he should supposed to do.

If you apply the same principles to a hospital, visually you can find your inventory items, available rooms, A/R, F/S by selecting a proper dashboard display on notify menu.

That's my humble idea regarding that Dashboard prototype. Posibilities of application is numerous (or endless if we can call it that way).

I think even for meteorological data in tandem with Campbell Weather instrument, a good Dashboard can be made.

Well I am hoping that I can found solution to it because I really like to accomplish it by HMG code.


Regards,



Danny
Regards,

Danny
Manila, Philippines

User avatar
esgici
Posts: 4513
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Post by esgici » Wed May 12, 2010 11:26 am

dhaine_adp wrote: ...
No it's not a competitor, I just renamed it.
...
It was only a joke :)

I can't found any problem in your program.

IMHO source of problem is from DRAW GRAPH. When replaced it with another control (fe an image) flickering go away. Happen same thing when extracting Restore / Hide MainForm lines (or changing Restore to Show )from ShowDashboard(). But in this second case label doesn't scroll.

Also, I can't any explanation for second (why graph doesn't appears at init?) problem.

Anyway your program is very nice and your method for scrolling label is impressive.

Please notify us when you will found the solution.

Regards

--

Esgici
Last edited by esgici on Wed May 12, 2010 9:30 pm, edited 1 time in total.
Viva INTERNATIONAL HMG :D

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Wed May 12, 2010 12:28 pm

Hi,

To see the graph while init, add this as line number 63 too. :)

on gotfocus DrawBarGraph( aser );

Giving a draw command before window paint procedure starts won't actually draw them because how can you draw a picture where there is no wall?. Once the window is activated or painted or shown in the screen, if you give draw command, that will be painted immediately.

When you call on gotfocus, the window is already painted. So, when we call draw command, the graph is drawn. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Wed May 12, 2010 1:01 pm

Regarding the flickering effect, if we can draw the graph in a separate window that will not be repainted when the text is scrolled.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Wed May 12, 2010 1:16 pm

Kindly try this code...
TestKPI-Dashboard.zip
(3.15 KiB) Downloaded 188 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
esgici
Posts: 4513
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Post by esgici » Wed May 12, 2010 1:42 pm

Hi Rathi

Nothing changed :(

Regards

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Wed May 12, 2010 1:59 pm

Very sorry. :( I had uploaded the same file.

Now please try this.
TestDashboard.zip
(2.21 KiB) Downloaded 193 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply