no me funciona erase/not delete graphic

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
Renegado
Posts: 88
Joined: Tue Mar 11, 2014 11:59 pm

no me funciona erase/not delete graphic

Post by Renegado »

Saludos, mi pregunta es por que no me borra elementos de una gráfica al imprimir otra. He repasado muchas veces el código ejemplo y no encuentro el error.En mi proyecto lo tengo en una ventana CHILD y pensé que eso era el problema pero al sacar un demo veo que no. Gracias.

Google traducción
---------------------------------------------------------------------------------------------------------------------------------------------
Hello, my question is why not delete me elements of a graphic to print another. I have reviewed many times the example code and can not find the error. In my project so I have a CHILD window and thought that was the problem, but to make a demo, I see that it is not. Thank you.

Code: Select all

#include "hmg.ch"
function main 
    local ser:={ 3,2,1}
	define window m at 0,0;
	       width 590;
	       height 600;
	       title "Previsualizar";
	       main;
	       nomaximize;
	       On Init ShowPie(ser);
	       backcolor { 255,255,255}
	
	
	    define button x
			row 10
			col 10
			Height 50
			caption "&Pastel"
			action showpie(ser)
	    end button
	
	    define button br
			row 10
			col 150
			Height 50
			caption "&Barras"
			action showbar(ser)
	    end button
	
	    define button y
			row 10
			col 430
			Height 50
			caption "&Salir"
			action m.release
	    end button
		
		Define Button Button_1
			Row	10
			Col	290
			Height 50
			Caption	'&Imprimir'
		End Button

	end window
	m.center
	m.activate
return 
Procedure showpie(ser)
        ERASE  WINDOW m
      DRAW GRAPH IN WINDOW m AT 120,120;
        TO 450,450 ;
        TITLE "Reporte de Asistencia" ; 
        TYPE PIE; 
        SERIES ser;  
		DEPTH 25;
		SERIENAMES {"Alum. que nunca faltan","Alum. que a veces faltan","Alum. que faltan con frecuencia"};
		COLORS {{128,0,128},{255,0,0},{0,255,0}}; 
		3DVIEW;
		SHOWXVALUES; 
		SHOWLEGENDS;
		NOBORDER
return

Procedure showBar(ser)
	    ERASE  WINDOW m
	  DRAW GRAPH IN WINDOW m AT 120,120;
		TO 450,480;
		TITLE "Reporte de asistencia";
		TYPE BARS;
		SERIES { {3},{2},{1}};                
		YVALUES {"Bimestre 1"};
		DEPTH 15;
		BARWIDTH 10;
		HVALUES 5;
		SERIENAMES {"uno","dos","tres"};
		COLORS { {128,128,255}, {255,102, 10}, {55,201, 48} };
		3DVIEW;
		SHOWGRID;
		SHOWXVALUES;
		SHOWYVALUES;
		SHOWLEGENDS;
		NOBORDER
		
	
Return 
Attachments
noborra.png
noborra.png (20.29 KiB) Viewed 2519 times
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: no me funciona erase/not delete graphic

Post by gfilatov »

Renegado wrote:Hello, my question is why not delete me elements of a graphic to print another.
...
Hello,

Please be so kind to review the following updated sample.

Code: Select all

#include "hmg.ch"

function main 
    local ser:={ 3,2,1}
   define window m at 0,0;
          width 590;
          height 600;
          title "Previsualizar";
          main;
          nomaximize;
          On Init ShowPie(ser);
          backcolor { 255,255,255}
   
   
       define button x
         row 10
         col 10
         Height 50
         caption "&Pastel"
         action showpie(ser)
       end button
   
       define button br
         row 10
         col 150
         Height 50
         caption "&Barras"
         action showbar(ser)
       end button
   
       define button y
         row 10
         col 430
         Height 50
         caption "&Salir"
         action m.release
       end button
      
      Define Button Button_1
         Row   10
         Col   290
         Height 50
         Caption   '&Imprimir'
      End Button

   end window
   m.center
   m.activate
return 

Procedure showpie(ser)
      EraseBarGraph ( 'm' )
      ERASE WINDOW m

      DRAW GRAPH IN WINDOW m AT 120,120;
        TO 450,450 ;
        TITLE "Reporte de Asistencia" ; 
        TYPE PIE; 
        SERIES ser;  
      DEPTH 25;
      SERIENAMES {"Alum. que nunca faltan","Alum. que a veces faltan","Alum. que faltan con frecuencia"};
      COLORS {{128,0,128},{255,0,0},{0,255,0}}; 
      3DVIEW;
      SHOWXVALUES; 
      SHOWLEGENDS;
      NOBORDER
return

Procedure showBar(ser)
     ErasePieGraph ( 'm' )
     ERASE  WINDOW m

     DRAW GRAPH IN WINDOW m AT 120,120;
      TO 450,480;
      TITLE "Reporte de asistencia";
      TYPE BARS;
      SERIES { {3},{2},{1}};                
      YVALUES {"Bimestre 1"};
      DEPTH 15;
      BARWIDTH 10;
      HVALUES 5;
      SERIENAMES {"uno","dos","tres"};
      COLORS { {128,128,255}, {255,102, 10}, {55,201, 48} };
      3DVIEW;
      SHOWGRID;
      SHOWXVALUES;
      SHOWYVALUES;
      SHOWLEGENDS;
      NOBORDER
Return

Procedure ErasePieGraph ( windowname )
Local i

   if _iscontroldefined("title_of_pie",windowname)
      _releasecontrol("title_of_pie",windowname)
   endif
   for i := 1 to 10
      if _iscontroldefined("pielegend_"+alltrim(str(i,3,0)),windowname)
         _releasecontrol("pielegend_"+alltrim(str(i,3,0)),windowname)
      endif
   next i

Return

Procedure EraseBarGraph ( Parent )
Local i, cName

	If _IsControlDefined ( 'Graph_Title', Parent )
		_ReleaseControl ( 'Graph_Title', Parent )
	EndIf

	For i := 1 To 20
		cName := "Ser_Name_"+ltrim(str(i))
		If _IsControlDefined ( cName, Parent )
			_ReleaseControl ( cName , Parent )
		EndIf
	Next

	For i := 0 To 20
		cName := "xPVal_Name_"+ltrim(str(i))
		If _IsControlDefined ( cName, Parent )
			_ReleaseControl ( cName , Parent )
		EndIf
	Next

	For i := 0 To 20
		cName := "xNVal_Name_"+ltrim(str(i))
		If _IsControlDefined ( cName, Parent )
			_ReleaseControl ( cName , Parent )
		EndIf
	Next

	For i := 1 To 20
		cName := "yVal_Name_"+ltrim(str(i))
		If _IsControlDefined ( cName, Parent )
			_ReleaseControl ( cName , Parent )
		EndIf
	Next

Return
Hope that helps :idea:
Attachments
Screenshot
Screenshot
proper-src.png (7.49 KiB) Viewed 2499 times
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: no me funciona erase/not delete graphic

Post by Javier Tovar »

Thanks for your help Filatov Gregory forever!

regards
User avatar
Renegado
Posts: 88
Joined: Tue Mar 11, 2014 11:59 pm

Re: no me funciona erase/not delete graphic

Post by Renegado »

thank you very much, "Maestro" Grigory Filatov
Post Reply