Need sample code to draw Histogram Series in VC++ (MFC)

TeeChart for ActiveX, COM and ASP
Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jan 10, 2008 9:34 am

Hi Abhijit,

No, that's not necessary, TeeChart calculates histogram bar's width automatically so there's no space between bars and they fit the full chart area.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Abhijit
Newbie
Newbie
Posts: 44
Joined: Fri Nov 15, 2002 12:00 am

Post by Abhijit » Thu Jan 10, 2008 11:04 am

Hi ,

Thanks .. Sorry i am taking your lot of time . But again one question..

I am trying to replace AGL ActiveX with TeeChart ActiveX.. In the AGL logic to draw histogram they used to provide 4 points left , right , top , bottom to draw histogram, That code is like this,

m_pIAglCtrl->BeginVertex(AGL_BEGIN_VERTEX_POLYGON);
m_pIAglCtrl->put_Color((OLE_COLOR)fillColor);
m_pIAglCtrl->Vertex(dLeft, dBottom, 0);
m_pIAglCtrl->Vertex(dLeft, dTop, 0);
m_pIAglCtrl->Vertex(dRight, dTop, 0);
m_pIAglCtrl->Vertex(dRight, dBottom, 0);
m_pIAglCtrl->Vertex(dLeft, dBottom, 0);
m_pIAglCtrl->EndVertex();

// fill
m_pIAglCtrl->BeginVertex(AGL_BEGIN_VERTEX_LINE_STRIP);
m_pIAglCtrl->put_Color((OLE_COLOR)lineColor);
m_pIAglCtrl->put_LineSize((short)iLineWeight);
m_pIAglCtrl->Vertex(dLeft, dBottom, 0);
m_pIAglCtrl->Vertex(dLeft, dTop, 0);
m_pIAglCtrl->Vertex(dRight, dTop, 0);
m_pIAglCtrl->Vertex(dRight, dBottom, 0);
m_pIAglCtrl->Vertex(dLeft, dBottom, 0);

m_pIAglCtrl->EndVertex();

In TeeChart Case I need to pass only 2 points i.e X and Y to draw histogram...

Can you please let me know how I will calculate X and Y Co-ordinates using these left , right , top and bottom .. I mean what is that calculation I need to do on left ,right,top , bottom so I can get X , and Y value so I can draw same histogram like AGL using T Chart control..

Please expalin me with example...

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jan 10, 2008 11:56 am

Hi Abhijit,

I'm afraid this histogram concept is not applicable to TeeChart . Using TeeChart, for example, if you want a bar drawn at x value = 5 having a size of 15 then you should do AddXY(5,15). Next bar could be at 10 and having a a value of 20 so it would be AddXY(10,20) and so on.

If you still need to drawn polygons on the chart then, instead of using a histogram series you could use a shape series or directly draw to the chart's canvas as shown in the examples at Tutorial 15 - MS VC++ Applications but using Rectangle method instead of TextOut.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Abhijit
Newbie
Newbie
Posts: 44
Joined: Fri Nov 15, 2002 12:00 am

Post by Abhijit » Thu Jan 31, 2008 8:38 am

Hi,

AddXY function is plotting series also and it set the scale of X and Y axis according to given input also... how can I prevent AddXY teechart method to set scale . I want AddXy should only draw series point . and X and Y axis scale I would set manually ...

One more Issue my X axis is starts scale from (0 ,1) and Y axis scale starts from (-1 , 0) . So when I run this chart first it tries to match X and Y starts scale so that axis is moving in vertical direction . Could you please let me know how I would assign fix scale to X and Y axis . i.e X (0,1) and y(-1 ,1)....



Regards
Abhijit Nimbalkar

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jan 31, 2008 8:53 am

Hi Abhijit,

I recommend you to read Tutorial 4 - Axis Control for examples on how to manually set axes. You'll find the tutorials at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Abhijit
Newbie
Newbie
Posts: 44
Joined: Fri Nov 15, 2002 12:00 am

Post by Abhijit » Thu Jan 31, 2008 10:33 am

Hi ,

Please find above code I am trying to configure X axis and Y axis using this code ...
void CSfxStatisticsView::SetupHistogramXAxis()
{
int axidx = m_pITeeCtrl->Axis->AddCustom(true);
TeeChart::IAxisPtr pAxis;
TeeChart::ISeriesPtr m_hSeriesFinalTime;
m_pITeeCtrl->Axis->get_Custom( axidx, &pAxis );
pAxis->Automatic = false;
pAxis->PositionPercent = 0;
pAxis->StartPosition = 0;
pAxis->EndPosition = 100;
pAxis->Labels->Visible = false;
pAxis->Ticks->Visible = true;
pAxis->GridCentered = true;
pAxis->TickOnLabelsOnly = false;
pAxis->AxisPen->Color = ColorName::Red;
pAxis->AxisPen->Width = 1;
pAxis->Visible = true;
pAxis->TitleSize = 10;
pAxis->Title->Visible = true;

pAxis->Labels->Align = TeeChart::EAxisLabelAlign::alDefault;

int idx = m_pITeeCtrl->AddSeries(TeeChart::ESeriesClass::scHistogram);
m_hSeriesFinalTime = m_pITeeCtrl->Series(idx);
m_hSeriesFinalTime->HorizontalAxisCustom = axidx;

pAxis->GridPen->Visible = false;






}

void CSfxStatisticsView::SetupHistogramYAxis()
{

int axidx = m_pITeeCtrl->Axis->AddCustom(false);
TeeChart::IAxisPtr pAxis;
TeeChart::ISeriesPtr m_hSeriesFinalValue;
m_pITeeCtrl->Axis->get_Custom( axidx, &pAxis );
pAxis->Automatic = false;
pAxis->PositionPercent = 0;
pAxis->StartPosition = 0;
pAxis->EndPosition = 100;
pAxis->Labels->Visible = false;
pAxis->Ticks->Visible = true;
pAxis->TickOnLabelsOnly = false;
pAxis->GridCentered = true;
pAxis->AxisPen->Color = ColorName::Red;
pAxis->AxisPen->Width = 1;
pAxis->Visible = true;
pAxis->TitleSize = 10;
pAxis->Title->Visible = true;

pAxis->Labels->Align = TeeChart::EAxisLabelAlign::alDefault;
int idx = m_pITeeCtrl->AddSeries(TeeChart::ESeriesClass::scHistogram);
m_hSeriesFinalValue = m_pITeeCtrl->Series(idx);
m_hSeriesFinalValue->VerticalAxisCustom = axidx;
pAxis->GridPen->Visible = false;




}

And to draw histogram series I am using above function...
pHistogramValueSeries->AddXY(dX ,dHeight,"",m_pSettings->m_vHIFillColor1);

My problem is X axis is moving vertically .. so even if I am setting values of X axis accurately.. I am not getting accurate accurate results.....


So please check the code and let me know what else I need to configure...

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jan 31, 2008 10:59 am

Hi Abhijit,
My problem is X axis is moving vertically .. so even if I am setting values of X axis accurately.. I am not getting accurate accurate results.....
I'm sorry but I don't understand which is the exact problem you are having. Could you please give us some more details about the issue? It would also be very helpful if you sent us a simple example project we can run "as-is" to reproduce the problem here.

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Abhijit
Newbie
Newbie
Posts: 44
Joined: Fri Nov 15, 2002 12:00 am

Post by Abhijit » Fri Feb 01, 2008 7:05 am

According to your suggestion . I took screen shot and uploaded in your uploaded area.. In that file in second histogram series you can clearly see that first time I can draw histogram with colors after X axis scale start moving so after I am getting only lines with no color .. could you please figure out this problem and let me know...

Thanks in advance..

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Feb 01, 2008 9:07 am

Hi Abhijit,

Thanks for the screenshot but it would be really helpful if you could send us a simple example project we can run "as-is" to reproduce the problem here.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Abhijit
Newbie
Newbie
Posts: 44
Joined: Fri Nov 15, 2002 12:00 am

Post by Abhijit » Fri Feb 01, 2008 9:15 am

Hi ,


Could you please let me know by looking that snapshot whether you are able to figure out anything?

I will try to send you sample program very soon...

My X axis lables are moving in vertical direction because of that I am not able to draw histogram .. Could you please let me know your comments onto that..

Regards
Abhijit Nimbalkar

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Feb 01, 2008 9:21 am

Hi Abhijit,

Thanks, would be great if you could arrange a simple example project we can run "as-is".

Sorry but looking at the screenshot I'm not able to understand which the exact problem is.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Abhijit
Newbie
Newbie
Posts: 44
Joined: Fri Nov 15, 2002 12:00 am

Post by Abhijit » Fri Feb 01, 2008 9:50 am

Hi ,

I have started writing sample application once Its finish I will send to you ... If you have any sample histogram program could you please send it to me .. Apart from that examples....
Could you please let me know how can I draw histogram series without using AddXY method .. Means is there any alternate way or alternate method to draw series .. Whether I can use of AddNULLXY, AddNULL , Add
method to draw histogram series..


Regards
Abhijit

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Feb 01, 2008 10:22 am

Hi Abhijit,

Thanks for working on the example. Yes, you can use other methods for populating series as you can see in Tutorial 6 - Working with Series and example in the features demo. You'll find demo and tutorials at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Abhijit
Newbie
Newbie
Posts: 44
Joined: Fri Nov 15, 2002 12:00 am

Post by Abhijit » Fri Feb 01, 2008 1:15 pm

Hi ,

I have uploaded source code on your site please check.. and compare that GUI with my previous jpg file that I have alrady uploaded..

The Problem with this sample is OnBeforeDrawChart event gets call only one time... I think i am missing something in code .. Could you please check my code . This source code is exactly same as like my current working application code ...


Please get back to me with proper solution it is very important for me...


Problem : -> Series not drawn properly because Grid is scrolling so X and Y scale is also scrolling ....because of that color is not filling in each polygon of histogram series....

Suggestions appriciated ........


Thanks in advance...

Abhijit
Newbie
Newbie
Posts: 44
Joined: Fri Nov 15, 2002 12:00 am

Post by Abhijit » Fri Feb 01, 2008 1:31 pm

Hi ,

Just now I have uploaded new files on your server . After executing that code please move that exe around the window so resize() will get call it will show chart ...

Post Reply