Page 1 of 1

Equal axis scales

Posted: Thu Jul 12, 2007 6:32 pm
by 5894628
How do I set equal axis scales so my map displays properly? When the map displays, it gets exanded out to fill the window, distorting the ratio of the x and y scales. I'm using pro version 5 with C++ Builder 6.

Posted: Thu Jul 12, 2007 10:26 pm
by 9047589
Hi, look here: Isometric axis and TeeChart Pro -
http://www.steema.com/support/teechart/ ... %20Pro.htm

Posted: Fri Jul 13, 2007 11:34 pm
by 5894628
Thanks.

Had to modify it a bit by changing the HORZSIZE and VERTSIZE to HORZRES and VERTRES because Screen->Width and Screen->Height are in pixels and the SIZE variables are in millimeters. Below is the C++ code for the method.

Code: Select all

void TInputForm::MakeISOAxis(TCustomChart *AChart)
{
    double tmpX, tmpY, XRange, YRange, Offset, XYScreen;

    if ((AChart->ChartHeight > 0)&&(AChart->ChartWidth > 0))
    {
        XRange = AChart->BottomAxis->Maximum - AChart->BottomAxis->Minimum;
        YRange = AChart->LeftAxis->Maximum - AChart->LeftAxis->Minimum;

        XYScreen = 1.0*(GetDeviceCaps(AChart->Canvas->Handle,HORZRES)/Screen->Width)
            /(GetDeviceCaps(AChart->Canvas->Handle,VERTRES)/Screen->Height);

        tmpX = XRange/AChart->ChartWidth;
        tmpY = (YRange/AChart->ChartHeight)*XYScreen;

        if (tmpX > tmpY)
        {
            if (tmpY != 0.0)
            {
                Offset = ((YRange*tmpX/tmpY)-YRange)/2.0;
                AChart->LeftAxis->SetMinMax(AChart->LeftAxis->Minimum-Offset,
                    AChart->LeftAxis->Maximum+Offset);
            }
        }
        else
        {
            if (tmpX != 0.0)
            {
                Offset = ((XRange*tmpY/tmpX)-XRange)/2.0;
                AChart->BottomAxis->SetMinMax(AChart->BottomAxis->Minimum-Offset,
                    AChart->BottomAxis->Maximum+Offset);
            }
        }
    }
}

Posted: Sat Jul 14, 2007 10:31 pm
by 9047589
Don't you think that
GetDeviceCaps(AChart->Canvas->Handle,HORZRES)==Screen->Width
? :? [/quote]
Using HORZSIZE in this case allows take into account the aspect of a device.

Posted: Thu Dec 18, 2008 2:39 am
by 8574101
Thanks :D