Page 1 of 2

[very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 3:29 am
by 9529132
I have the upper-left and lower-right coordinates of over 100 squares. What kind of series or tools should I use to draw them so that only squares are drawn and no connection lines between any two of the squares? Any sample code would be greatly appreciated.

Thanks in advance!

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 9:35 am
by narcis
Hi David,

I recommend you to use Shape series for that. You'll find examples with source code at "All Features\Welcome!\Chart Styles\Standard\Shape" in the features demo, available at TeeChart's program group.

BTW: If you are interested in priority support service you may be interested in our Pro-Support program.

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 9:55 am
by 9529132
Thanks for the suggestion. If using shape series, do I have to add one series for each of the square? The vertical text align example uses 3 series for three shapes. If so, it will be more than 100 series in my application, will it cause any problem like slow response?

And I would appreciate it if you could provide some samle c++ code about how to use shape series like how to set coordinate, how to set shape style, etc.

Thanks.

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 11:36 am
by narcis
Hi David,
Thanks for the suggestion. If using shape series, do I have to add one series for each of the square?
Yes.
The vertical text align example uses 3 series for three shapes. If so, it will be more than 100 series in my application, will it cause any problem like slow response?
I'm not sure. Most likely this will depend on machine's power. Some general advice on how to optimise TeeChart's performance can be found at the Real-time Charting article here. This is a TeeChart VCL article but most of it also applies to ActiveX version. I recommend you to apply as many hints there as possible.

The alternative to using Shape series would be custom drawing on TeeChart's canvas. You'll find VC++ examples in tutorial 15. Tutorials are available at TeeChart's program group.
And I would appreciate it if you could provide some samle c++ code about how to use shape series like how to set coordinate, how to set shape style, etc.
Sure, here it is:

Code: Select all

	m_Chart1.AddSeries(scShape);
	m_Chart1.Series(0).GetAsShape().SetStyle(chasRectangle);
	m_Chart1.Series(0).GetAsShape().SetX0(100);
	m_Chart1.Series(0).GetAsShape().SetY0(100);
	m_Chart1.Series(0).GetAsShape().SetX1(300);
	m_Chart1.Series(0).GetAsShape().SetY1(200);

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 12:08 pm
by 9529132
Thanks for your quick response. What are x0 y0 x1 y1 for if the shape is circle or oval?

The tutorial 15 is Tutorial 15 - MS VC++ Applications, but there is no introduction about shape series.

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 12:27 pm
by narcis
Hi David,
Thanks for your quick response. What are x0 y0 x1 y1 for if the shape is circle or oval?
They are for the bounding rectangle.
The tutorial 15 is Tutorial 15 - MS VC++ Applications, but there is no introduction about shape series.
Other tutorials and demos are in Visual Basic 6. However, using them, the examples at C:\Program Files\Steema Software\TeeChart Pro v8 ActiveX Control\Examples\Visual C++\Version 6 and with the VC++ syntax summary in tutorial 15 you should be able to create your own VC++ applications.

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 1:50 pm
by 9529132
I am drawing a circle for test, but after assigning x0,y0, x1,y1, it appreas to be an oval, although the x y values are correct. So how to maintain a proper scale so that circles won't appear to be ovals (especially when the dialog with tchart is resizing)? adding some code in OnAfterDraw?

Second question, how to avoid the default solid fill inside the shape? (solved with SetTransparent)

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 2:32 pm
by narcis
Hi David,
I am drawing a circle for test, but after assigning x0,y0, x1,y1, it appreas to be an oval, although the x y values are correct. So how to maintain a proper scale so that circles won't appear to be ovals (especially when the dialog with tchart is resizing)? adding some code in OnAfterDraw?
This can be achieved as shown in the All Features\Welcome!\Axes\Isometric Axis in the features demo.

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 2:56 pm
by 9529132
I followed the example and tested the code below, but still didn't work. Any suggestions?

Code: Select all

void CTestDlg::OnZoomTchart1()
{
	SetIsometricAxis();
}

void CTestDlg::OnUndoZoomTchart1()
{
	SetIsometricAxis();
}

void CTestDlg::SetIsometricAxis()
{
	m_chart1.GetAxis().SetIsometric(aLeftAxis,aBottomAxis);
}
Thanks.

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 2:57 pm
by narcis
Hi David,

You also have to implement the SetIsometricAxis method as in the demo.

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 3:09 pm
by 9529132
I don't know VB, so am I doing right this way?

Code: Select all

void CEncoderEbeamDlg::SetIsometricAxis()
{
	m_chart1.GetAxis().SetIsometric(m_chart1.GetAxis().GetLeft().GetIndex(),m_chart1.GetAxis().GetBottom().GetIndex());
}
If no, please help me with the c++ code. If yes, then I got a funny problem with the code. The chart switch between isometric and non-isometric each time I unzoom it (actually the demo behaves the same). Any advice?

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 3:15 pm
by narcis
Hi David,

I'm sorry if I didn't explain myself correctly but what you have to implement is the MakeIsoAxis method:

Code: Select all

Private Sub MakeIsoAxis()
  With TChart1.Axis
    .Left.Increment = CInt(Text3.Text)
    .Bottom.Increment = CInt(Text2.Text)
    .SetIsometric .Left.Index, .Bottom.Index
  End With
End Sub

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 3:24 pm
by 9529132
I know I have to implement the MakeIsoAxis, actually my SetIsometricAxis is it, only different name. I am just not sure if I have done corectly with C++.

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 3:34 pm
by narcis
Hi David,

It should be implemented like this:

Code: Select all

	m_Chart1.GetAxis().GetLeft().SetIncrement(50);
	m_Chart1.GetAxis().GetBottom().SetIncrement(50);
	m_Chart1.GetAxis().SetIsometric(m_Chart1.GetAxis().GetLeft().GetIndex(),
									m_Chart1.GetAxis().GetBottom().GetIndex());

Re: [very urgent] How to draw many squares?

Posted: Thu Feb 11, 2010 3:54 pm
by 9529132
So here is what I did

Code: Select all

m_chart1.GetAxis().GetLeft().SetMinMax(-maxx,maxx);
m_chart1.GetAxis().GetBottom().SetMinMax(-maxx,maxx);


void CTestDlg::OnZoomTchart1()
{
	SetIsometricAxis();
}

void CTestDlg::OnUndoZoomTchart1()
{
	SetIsometricAxis();
}

void CTestDlg::SetIsometricAxis()
{
	m_chart1.GetAxis().GetLeft().SetIncrement(1);
	m_chart1.GetAxis().GetBottom().SetIncrement(1);
	m_chart1.GetAxis().SetIsometric(m_chart1.GetAxis().GetLeft().GetIndex(),m_chart1.GetAxis().GetBottom().GetIndex());
}
Then, just like what I described just now, I got a funny problem with the code. The chart switch between isometric and non-isometric each time I unzoom it(actually the demo behaves the same). If I zoom it, it just can't become isometric. Would you please have a try of the demo and you will see what I mean. I just found another post complaining the same thing http://www.teechart.net/support/viewtop ... tric#p5675

I want to realize the isometric property no matther you zoom or unzoom it. Please advice how to do it.

Thanks a lot.