Algo muy sencillo con la clase TGraph, primero debes obtener los valores a graficar (Producto y cantidad vendida)
los metes en dos arreglos, en mi caso son acPro (Productos) y anVez (Cantidad vendida),
llamas a la función Grafica() y el resto es coser y cantar.
#Include "tgraph.ch"
...
...
...
...
STATIC FUNCTION Grafica()
LOCAL oGraph
LOCAL oIcono
DEFINE ICON oIcono RESOURCE "AppLogo"
DEFINE WINDOW oWnd FROM 15, 60 TO 45, 180 TITLE "Consumo por producto";
ICON oIcono
oGraph:=TGraph():New(0,0,oWnd,oWnd:nWidth()-15,oWnd:nHeight()-40)
WITH Object oGraph
:aFont[1] := TFont():New( "Arial", 0, -16, .F., .T., 0 , 0, , .F., .F., .F., 0, 3, 2, 1, ,34 ) // Título de la gráfica
:aFont[2] := TFont():New( "Arial", 0, -18, .F., .T., 0 , 0, , .F., .F., .F., 0, 3, 2, 1, , 2 ) // Eje de las X
:aFont[3] := TFont():New( "Arial", 0, -08, .F., .T., 0, 0, , .F., .F., .F., 0, 3, 2, 1, ,34 ) // Eje de las Y
:aFont[4] := TFont():New( "Arial", 0, -16, .F., .T., 0 , 0, , .F., .F., .F., 0, 3, 2, 1, , 2 ) // Leyendas
:aFont[5] := TFont():New( "Arial", 0, -16, .F., .F., 0 , 0, , .F., .F., .F., 0, 3, 2, 1, , 2 ) // Sub titulo
:aFont[6] := TFont():New( "Arial", 0, -18, .F., .T., 900, 0, , .F., .F., .F., 0, 3, 2, 1, , 2 ) // Texto de las X
:aFont[7] := TFont():New( "Arial", 0, -14, .F., .T., 0 , 0, , .F., .F., .F., 0, 3, 2, 1, ,34 ) // Texto de las Y
:aFont[8] := TFont():New( "Arial", 0, -20, .F., .T., 0 , 0, , .F., .F., .F., 0, 3, 2, 1, ,34 ) // Valores
:nType := GRAPH_TYPE_BAR // GRAPH_TYPE_BAR,GRAPH_TYPE_LINE,GRAPH_TYPE_POINT,GRAPH_TYPE_PIE
:cTitle := "Consumo por producto"
:cSubTit := "Del " + Date2Txt(oVar:INI) + " al " + Date2Txt(oVar:FIN)
:lCTitle := (.T.)
:cPicture := "999,999" // Picture para el eje X (Línea vertical)
:cXPicture := "999" // Picture para el eje X (Línea vertical)
:SetYVals(acPro) // Valores del eje Y (Línea horizontal)
:cTitX := "Cantidad" // Título del eje X (Línea vertical)
:cTitY := "Productos" // Título del eje Y (Línea horizontal)
:lXVal := (.T.) // Muestra los valores en el eje X (la línea horizontal)
:lYVal := (.T.) // Muestra los valores en el eje Y (la línea horizontal)
:lTitle := (.T.) // Muestra el título y sub titulo de la gráfica
:lLegends := (.F.) // Para que muestre que significan las barras
:lPopUp := (.T.)
:lDegrade := (.T.)
:l3D := (.T.)
// :lLine := (.T.) // Pinta una línea amarilla sobre todas la barras
:AddSerie(anVez,"Consumo por producto",CLR_HBLUE) // Leyenda y color de las barras
:Refresh()
END
ACTIVATE WINDOW oWnd CENTERED;
ON PAINT (oGraph:nWidth := oWnd:nWidth() - 15, ;
oGraph:nHeight := oWnd:nHeight - 40, ;
oGraph:Refresh(.F.))
oIcono:END()
RETURN(.T.)