STATISTICA







STATISTICA BASIC Program Scales.stb

{ This program generates a simple custom scale to the right of an existing graph. First make the graph, then run this program.

Note that the scale will be placed to the right of the graph, in fixed coordinates.

Program written, modified, or edited at StatSoft, Inc.}


Sub GraphAddCustomScale (graph, ymin, ystep, ynb, fixedmin, fixedmax);
begin
        {-- reserve area on the left for the scale --}
  GraphSetMappingArea (graph, 0, 1000, 1100, 0);

  smin:=fixedmax;
  snb:=ynb+1;
  sstep:=(fixedmax-fixedmin)/ynb;
         {-- allocate polyline array - we will use it for drawing scale line --}
  redim poly (4*snb-1, 2);

         {-- compute points for the scale line --}
  spos:=100;
  for i:=1 to snb do
  begin
    poly(4*i-3,1):=spos;     poly(4*i-3,2):=smin - (i-1) * sstep;
    poly(4*i-2,1):=spos - .5; poly(4*i-2,2):=smin - (i-1) * sstep;
    poly(4*i-1,1):=spos;     poly(4*i-1,2):=smin - (i-1) * sstep;
    if i <> snb then
    begin
      poly(4*i,1):=spos; poly(4*i,2):=smin - i * sstep;
    end;
  end;

         {-- draw text of scale descriptions --}
  for i:=1 to snb do
  begin
    Text$:=Str(ymin+ystep*(snb - i),8,3);
    GraphDrawTextParam (graph, Text$, ?Fontname$, ?Fontsize,
                        BLACK, ?Orientation, ?HorizAlignment,
                        AL_CENTER, ?Border, ?Fill,
                        spos, smin - (i-1) * sstep, FALSE);
  end;

         {-- draw scale line --}
  obj:=GraphDrawPolyline (graph, 4*snb-1, poly, FALSE);
  GraphSetObjectLineStyle (Graph, obj, ON, L_SOLID, ?Size, BLACK);

end Sub; {-- GraphAddCustomScale --}

    {-- begining of the main program --}
redim ScaleDef(5);

    {-- get handle of the top most graph --}
graph:=GetGraph (0);

if not graph then begin
  DisplayMessageBox (MB_OK+MB_ICONSTOP, 'STATISTICA BASIC Example',
	'This program adds a custom defined scale to an existing graph. '+
	'First create a graph and then re-run the program.');
  Exit;
end;

ScaleDef(1) := 0;
ScaleDef(2) := 1;
ScaleDef(3) := 10;
ScaleDef(4) := 10;
ScaleDef(5) := 90;

if not DisplayNumericInputBox ('Select scale parameters',
		'Min:|Step:|Number of Steps:|Fixed range min:|Fixed range max:', ScaleDef)
then
  Exit;

     {-- we have scale position - call subroutine to make a graph --}
GraphAddCustomScale (graph, ScaleDef(1), ScaleDef(2),
                     ScaleDef(3), ScaleDef(4), ScaleDef(5));
Back to List of Programs



[StatSoft]
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217

[StatSoft]e-mail: info@statsoft.com

©Copyright StatSoft, Inc., 1984-2004.
StatSoft, StatSoft logo, STATISTICA, SEWSS, SEDAS, Data Miner, SEPATH and GTrees are trademarks of StatSoft, Inc.