yh=di.TextYsize("T",TinyFont); /* Draw x-axis scale and text */
mark_inc= maxg-yaxis.map_2_to_1((5*yh));
if (mark_inc < =1)
{
  mark_inc=1;
  semi_inc=0;
}
else
if (mark_inc < =5)
{
  mark_inc=5;
  semi_inc=1;
}
else
if (mark_inc < =10)
{
  mark_inc=10;
  semi_inc=2;
}
else
{
  mark_inc=25;
  semi_inc=5;
}

start_pos=((((maxg+ming)/2)/mark_inc)*mark_inc);
/* Move from start position to beginning of drawable area */
while (start_pos > ming) start_pos-=mark_inc;
/* Draw large ticks and text labels*/
for (i=start_pos; i < maxg; i+=mark_inc)
{
  int y=yaxis.map_1_to_2(i);
  if ((y < GYSIZE) && (y>0))
  {
    di.Line(0,y,0+BIGTICK,y,4);
    di.Line(0+BIGTICK,y,GXSIZE-1,y,5);
  }
  if ((y < GYSIZE-yh) && (y>yh))
  {
    sprintf(buffer,"%d",i);
    di.Text(buffer,0+BIGTICK,y-(yh/2),TinyFont,4);
  }
}
if (semi_inc)		/* Draw small ticks */
{
  for (i=start_pos; i < maxg; i+=semi_inc)
  {
    int y=yaxis.map_1_to_2(i);
    if ((y < GYSIZE) && (y>0))di.Line(0,y,0+SMTICK,y,4);
  }
}
Listing 8This code draws the tick marks and numbers on the x-axis. It adjusts the spacing of the numbers to fit on the displayed scale.