Announcement

Collapse
No announcement yet.

Graphic commands to create Bar Charts with PowerBASIC

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Graphic commands to create Bar Charts with PowerBASIC

    Hello,

    Until now I was using RMChart to create bar charts inside my PowerBASIC programs; now, I would like to use the new graphic commands to create bar charts directly with PowerBASIC commands.

    I'm looking for sample codes how to start creating Bar Charts with the new graphic commands ?

    Thanks
    Jean-Pierre
    Jean-Pierre LEROY

  • #2
    Code:
    'PBCC5 program
    #COMPILE EXE
    #BREAK ON
    
    FUNCTION PBMAIN () AS LONG
    
    DIM results&&(32)
    FOR r& = 0 TO 32
        'fill the results array with some data to plot
        results&&(r&)=RND(1,1000)
    NEXT
    
    
    CONSOLE SET SCREEN 40,80
    CONSOLE SET LOC 20,20
    
    GRAPHIC WINDOW "Simple bar chart", 400,100,400,200 TO gwin???
    GRAPHIC ATTACH gwin???,0 ,REDRAW
                 
    FONT NEW "MyFont", 8,0,0,1,900 TO hFont&
    GRAPHIC SET FONT hFont&
           
    'find maximum value to scale the graph
    FOR r&=0 TO 32
        m&&=MAX(m&&,results&&(r&))
    NEXT
    GRAPHIC COLOR 1,2
    GRAPHIC CLEAR
             
    'plot the data
    FOR r&=0 TO 32
        GRAPHIC BOX (r&*10,200) - (r&*10+10,200-(200*results&&(r&)/m&&)) ,0,%RED,%GREEN,0
        GRAPHIC SET POS (r&*10-1,200)
        GRAPHIC COLOR %BLACK,-2
        GRAPHIC PRINT RIGHT$("  "+TRIM$(STR$(r&)),2)
        
        PRINT r&,results&&(r&)
    
    NEXT
    
    'force the window to update
    GRAPHIC REDRAW
    
    'wait for a key to be pressed to end program
    GRAPHIC SET FOCUS
    GRAPHIC WAITKEY$
    GRAPHIC DETACH
    
    END FUNCTION

    Comment


    • #3
      See PB/CC Print and Graphics Examples at http://www.powerbasic.com/support/downloads/demos.htm. There is a 3D bar chart demo, which can easily be rewritten for PBWin.
      Sincerely,

      Steve Rossell
      PowerBASIC Staff

      Comment


      • #4
        Paul and Steve,

        Thank you for the sample codes.

        It works as expected.
        Jean-Pierre LEROY

        Comment

        Working...
        X