Add ( x,y) to change location in chart

hi all
this code from linked below

https://www.amibroker.com/guide/afl/gfxdrawtext.html

how to add ( x,y) to change location in chart ?

	
// formatted text output sample via low-level gfx functions


CellHeight = 20;
CellWidth = 100;
GfxSelectFont( "Tahoma", CellHeight/2 );

function PrintInCell( string, row, Col )
{
GfxDrawText( string, Col * CellWidth, row * CellHeight, (Col + 1 ) * CellWidth, (row + 1 ) * CellHeight, 0 );
}

PrintInCell( "Open", 0, 0 );
PrintInCell( "High", 0, 1 );
PrintInCell( "Low", 0, 2 );
PrintInCell( "Close", 0, 3 );
PrintInCell( "Volume", 0, 4 );

GfxSelectPen( colorBlue );
for( i = 1; i < 10 && i < BarCount; i++ )
{
PrintInCell( StrFormat("%g", O[ i ] ), i, 0 );
PrintInCell( StrFormat("%g", H[ i ] ), i, 1 );
PrintInCell( StrFormat("%g", L[ i ] ), i, 2 );
PrintInCell( StrFormat("%g", C[ i ] ), i, 3 );
PrintInCell( StrFormat("%g", V[ i ] ), i, 4 );
GfxMoveTo( 0, i * CellHeight );
GfxLineTo( 5 * CellWidth, i * CellHeight );
}
GfxMoveTo( 0, i * CellHeight );
GfxLineTo( 5 * CellWidth, i * CellHeight );

for( Col = 1; Col < 6; Col++ )
{
GfxMoveTo( Col * CellWidth, 0);
GfxLineTo( Col * CellWidth, 10 * CellHeight );
}

thank you

Hi.
This is the example code how to move the X-axis.
I'll let you finish the code the Y-axis as it is easy :grinning:

// formatted text output sample via low-level gfx functions

x= Param("X-axis",0,0,500,1);

CellHeight = 20;
CellWidth = 100;
GfxSelectFont( "Tahoma", CellHeight/2 );

function PrintInCell( string, row, Col )
{ //  Draw / Print Text
GfxDrawText( string, x+Col * CellWidth, row * CellHeight, (x+Col + 1 ) * CellWidth, (row + 1 ) * CellHeight, 0 );
}

PrintInCell( "Open", 0, 0 );
PrintInCell( "High", 0, 1 );
PrintInCell( "Low", 0, 2 );
PrintInCell( "Close", 0, 3 );
PrintInCell( "Volume", 0, 4 );

GfxSelectPen( colorBlue );
for( i = 1; i < 10 && i < BarCount; i++ )
{
PrintInCell( StrFormat("%g", O[ i ] ), i, 0 );
PrintInCell( StrFormat("%g", H[ i ] ), i, 1 );
PrintInCell( StrFormat("%g", L[ i ] ), i, 2 );
PrintInCell( StrFormat("%g", C[ i ] ), i, 3 );
PrintInCell( StrFormat("%g", V[ i ] ), i, 4 );
// horizontal lines
GfxMoveTo( x+0, i * CellHeight );
GfxLineTo( x+5 * CellWidth, i * CellHeight );
}

// Bottom Line
GfxMoveTo( x+0, i * CellHeight );
GfxLineTo( x+5 * CellWidth, i * CellHeight );

for( Col = 1; Col < 6; Col++ )
{  // columns
GfxMoveTo( x+Col * CellWidth, 0);
GfxLineTo( x+Col * CellWidth, 10 * CellHeight );
}

GfxMove

3 Likes

thank you for your reply

1 Like

Hi again @needhelp

after reading (that duplicate post) you just created, Modify drawing table .
I understand that you are probably having a little trouble. So for this reason, I add in the afl code 4 different parameters in order to fully cover your question.

  • Parameters added to understand how to control the X,Y axis and the size of the Cells
// formatted text output sample via low-level gfx functions

// Parameters added to understand how to control the X,Y axis and the size of the Cells 
x= Param("X-axis",0,0,500,1);
Y= Param("Y-axis",0,0,500,1);
CellHeight= Param("CellHeight",20,20,500,1);
CellWidth= Param("CellWidth",100,100,500,1);

//CellHeight = 20;
//CellWidth = 100;

GfxSelectFont( "Tahoma", CellHeight/2 );

function PrintInCell( string, row, Col )
{ //  Draw / Print Text
	GfxDrawText( string, x+Col * CellWidth,  Y+row * CellHeight, (x+Col + 1 ) * CellWidth, ( Y+row + 1 ) * CellHeight, 0 );
}

PrintInCell( "Open", 0, 0 );
PrintInCell( "High", 0, 1 );
PrintInCell( "Low", 0, 2 );
PrintInCell( "Close", 0, 3 );
PrintInCell( "Volume", 0, 4 );

GfxSelectPen( colorBlue );
for( i = 1; i < 10 && i < BarCount; i++ )
{
PrintInCell( StrFormat("%g", O[ i ] ), i, 0 );
PrintInCell( StrFormat("%g", H[ i ] ), i, 1 );
PrintInCell( StrFormat("%g", L[ i ] ), i, 2 );
PrintInCell( StrFormat("%g", C[ i ] ), i, 3 );
PrintInCell( StrFormat("%g", V[ i ] ), i, 4 );
// horizontal lines
GfxMoveTo( x+0, y+i * CellHeight );
GfxLineTo( x+5 * CellWidth, y+i * CellHeight );
}

// Bottom Line
GfxMoveTo( x+0, y+i * CellHeight );
GfxLineTo( x+5 * CellWidth, y+i * CellHeight );


for( Col = 1; Col < 6; Col++ )
{  // columns
GfxMoveTo( x+Col * CellWidth, y+0);
GfxLineTo( x+Col * CellWidth, y+10 * CellHeight );
}



1 Like

Yes unfortunately @needhelp has done this before, even know he knows it's against forum rules!

What he doesn't appear to understand is that forum members will just ignore his posts if he continues to deliberately breaks forum rules (and his duplicate post will likely be removed anyway!).

1 Like

thank you i add the y as you told me as x

but the up line not show and the left not show .

333

the last one is your latest code.

please i am trying to get my idea to you

but I appreciate what you did.

what i want get
as below photo

4444

I appreciate what you did.

thank you

You need to stop yours SMS style of communication. Your posts aren't clear enough and do not provide all necessary details to give you an answer. Please follow this advice: How to ask a good question

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.