Jump to content
Fivewin Brasil

xBrowse com Gráfico


oribeiro

Recommended Posts

Pessoal, 

Desenvolvi uma função para criar um Browse com gráfico.

*********************************************************************************************
Function xBrwChart(cTitu, aHead, aData) // BROWSE COM GRÁFICO (Oscar 16/08/2019)
*********************************************************************************************
// Exemplo:
// cTitu := "Demonstratico de Compras x Vendas nos últimos 6 meses."
// aHead := {"Descrição", "Jan/19", "Fev/19", "Mar/19", "Abr/19", "Mai/19", "Jun/19"}
// aData := {{"Compras" ,     100 ,     200 ,     300 ,      50 ,     100 ,     400 },;
//           {"Vendas"  ,       0 ,     100 ,     500 ,     150 ,     100 ,     400 }}
// xBrwChart(cTitu, aHead, aData)
   Local oDlg, oBrw, oFont, i, aChart:={}
   Default cTitu := "Título"
   Default aHead := {} // Cabeçalho
   Default aData := {} // Dados
   DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-16
   DEFINE DIALOG oDlg  SIZE 1200,580 PIXEL TRUEPIXEL FONT oFont TITLE cTitu TRANSPARENT STYLE nOr( WS_CAPTION, WS_THICKFRAME, WS_SYSMENU, WS_MAXIMIZEBOX )
   @ 75,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg DATASOURCE aData AUTOCOLS HEADERS aHead CELL LINES FOOTERS NOBORDER FASTEDIT
   For i=2 To Len(aHead)
      AAdd(aChart, aHead[i])                                                                          // Separa os valores para o gráfico a partir da segunda coluna
      oBrw:aCols[ i ]:cEditPicture := '@E 999,999,999.99'                                             // Formata os valores do gráfico com duas casas decimais
   Next
   WITH OBJECT oBrw:AddCol()                                                                          // Adiciona uma coluna com o gráfico
      :cHeader       := "CHART"
      :aChartCols    := aChart
      :nWidth        := 190
   END
   oBrw:bClrStd   := {|| {CLR_BLACK, iif(oBrw:Keyno()%2=0, CLR_WHITE, RGB(236,236,236)) } }           // Cores nas linhas (Par/Impar) ou (oBrw:cAlias)->(RecN())%2=0
   oBrw:nRowHeight := 50
   oBrw:CreateFromCode()
   @ 21, 20 BTNBMP PROMPT { || If( oBrw:Chart:cChartType == "LINE", "&Gráfico de Barras", "&Gráfico de Linhas" ) } ;
            SIZE 130,30 PIXEL OF oDlg FLAT ;
            ACTION ( oBrw:Chart:cChartType := If( oBrw:Chart:cChartType == "LINE", "BAR", "LINE" ), oBrw:Refresh(), oBrw:SetFocus() )
   @ 21,160 BTNBMP PROMPT "&Imprimir" ;
            SIZE 130,30 PIXEL OF oDlg FLAT ;
            WHEN oBrw:oRightCol == nil ACTION oBrw:Report()
   @ 21,300 BTNBMP PROMPT "&Fechar" ;
            SIZE 130,30 PIXEL OF oDlg FLAT ;
            ACTION oDlg:End() Cancel
   oDlg:bResized := {||(oBrw:nHeight:=oDlg:nHeight()-85,oBrw:nWidth:=oDlg:nWidth()-55,oBrw:Resize())} // Redimensiona o Browse conforme o tamanho do Dialog
   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont
Return nil

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...