[very urgent] How to draw many squares?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: [very urgent] How to draw many squares?
Hi David,
In that case the only solution I can think of is implementing MakeIsoAxis as shown here. There are some hints on how to write this code in VC++ here.
Hope this helps!
In that case the only solution I can think of is implementing MakeIsoAxis as shown here. There are some hints on how to write this code in VC++ here.
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |
Re: [very urgent] How to draw many squares?
I didn't notice your reply is on page 2 and I have been waisting so much time waiting...
I think the solution you provided should work and I will give it a try. Thank you so much for your kind help and quick response.

I think the solution you provided should work and I will give it a try. Thank you so much for your kind help and quick response.
Re: [very urgent] How to draw many squares?
I have translated what was done in the post suggested into the code shown below, but unfortunately, the effect is still not there. I don't know if it is because I didn't translate correctly or it is because the algorithm itself.

Code: Select all
double w = m_chart1.GetWidth();
double h = m_chart1.GetHeight();
if(h>0 && w>0)
{
double xmin = m_chart1.GetAxis().GetBottom().GetMinimum();
double xmax = m_chart1.GetAxis().GetBottom().GetMaximum();
double ymin = m_chart1.GetAxis().GetLeft().GetMinimum();
double ymax = m_chart1.GetAxis().GetLeft().GetMaximum();
double cx = GetSystemMetrics(SM_CXSCREEN);
double cy = GetSystemMetrics(SM_CYSCREEN);
CDC dc;
long hDC=m_chart1.GetCanvas().GetHandleDC().lVal;
dc.Attach(HDC(hDC));
double xyscreen = (GetDeviceCaps(dc,HORZSIZE)/cx)/(GetDeviceCaps(dc,VERTSIZE)/cy);
double tmpx = (xmax-xmin)/w;
double tmpy = xyscreen*(ymax-ymin)/h;
if(tmpx>tmpy)
{
if(tmpy != 0.0)
{
double offset = ((ymax-ymin)*tmpx/tmpy - (ymax-ymin))/2.0;
m_chart1.GetAxis().GetLeft().SetMinMax(ymin+offset,ymax -offset);
}
}
else
{
if (tmpx != 0.0)
{
double offset = ((xmax-xmin)*tmpy/tmpx - (xmax-xmin))/2.0;
m_chart1.GetAxis().GetBottom().SetMinMax(xmin+offset,xmax -offset);
}
}
dc.Detach();
}
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: [very urgent] How to draw many squares?
Hi David,
I see an error in your implementation. It's in the offset addition/substraction in SetMinMax. This part:
Should be:
I see an error in your implementation. It's in the offset addition/substraction in SetMinMax. This part:
Code: Select all
if(tmpx>tmpy)
{
if(tmpy != 0.0)
{
double offset = ((ymax-ymin)*tmpx/tmpy - (ymax-ymin))/2.0;
m_chart1.GetAxis().GetLeft().SetMinMax(ymin+offset,ymax -offset);
}
}
else
{
if (tmpx != 0.0)
{
double offset = ((xmax-xmin)*tmpy/tmpx - (xmax-xmin))/2.0;
m_chart1.GetAxis().GetBottom().SetMinMax(xmin+offset,xmax -offset);
}
}
Code: Select all
if(tmpx>tmpy)
{
if(tmpy != 0.0)
{
double offset = ((ymax-ymin)*tmpx/tmpy - (ymax-ymin))/2.0;
m_chart1.GetAxis().GetLeft().SetMinMax(ymin-offset,ymax+offset);
}
}
else
{
if (tmpx != 0.0)
{
double offset = ((xmax-xmin)*tmpy/tmpx - (xmax-xmin))/2.0;
m_chart1.GetAxis().GetBottom().SetMinMax(xmin-offset,xmax+offset);
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |
Re: [very urgent] How to draw many squares?
I can't believe I made such an error...
Now it works well! Thank you so much for your patience and effort!

Re: [very urgent] How to draw many squares?
One more question. The application is MFC dialog based and I initialized the chart in OnInitDialog, but where should I call the SetIsometricAxis so that the display is correct at the beginning, not after you zoom it?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: [very urgent] How to draw many squares?
Hi David,
In the same event you can call InternalRepaint before calling SetIsometricAxis so that chart is internally painted and therefore all objects initialized, for example:
In the same event you can call InternalRepaint before calling SetIsometricAxis so that chart is internally painted and therefore all objects initialized, for example:
Code: Select all
m_Chart1.GetEnvironment().InternalRepaint();
SetIsometricAxis();
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |
Re: [very urgent] How to draw many squares?
Yes, it works! Thanks a lot. BTW, are all these methods documented? I just hope I could find it somewhere in the help files instead of always asking questions in the forum.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: [very urgent] How to draw many squares?
Hi David,
You are welcome! Yes, I think they are documented in the help files, tutorials, demos and mentioned in other forums threads.
You are welcome! Yes, I think they are documented in the help files, tutorials, demos and mentioned in other forums threads.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |