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

TeeChart for ActiveX, COM and ASP
Abhijit
Newbie
Newbie
Posts: 44
Joined: Fri Nov 15, 2002 12:00 am

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

Also please let me know if any mistakes in code or any property is not configured properly...

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

Post by Abhijit » Mon Feb 04, 2008 8:25 am

have you received uploaded files?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon Feb 04, 2008 10:18 am

Hi Abhijit

Did you send the files to the upload page or to the attachments newsgroup? I can't find them.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon Feb 04, 2008 10:36 am

Hi Abhijit,

Sorry, I was looking at the wrong place. We got your files and we will feedback you asap.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

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

Post by Abhijit » Mon Feb 04, 2008 11:14 am

Hi Yeray,


Please find these 2 functions closely,


void CSfxStatisticsView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
UNREFERENCED_PARAMETER(pSender);
UNREFERENCED_PARAMETER(pHint);
if (m_pITeeCtrl == NULL || m_teeCtrl.GetSafeHwnd() == NULL )
return;

switch (lHint)
{
case hintRefreshDisplay:
m_pITeeCtrl->Repaint();
FitView();
break;
case hintFitView:
FitView();
break;
default:
break;
}
}


void CSfxStatisticsView::DrawHistogramValue(void)
{
double dValStartBin = 0;
double dValEndBin = 0;
double dValBinSize = 0;
long ulNumBins;
long ulNumSamplesInBin = 0;
long ulLeft=0, ulRight=0;
long lNumRecords= 0;


IHistogram* pHIValue = NULL;
m_pIMS->get_ValueHistogram(&pHIValue);

if (pHIValue != NULL)
{
m_pIMS->get_NumRecordsInBuffer(&lNumRecords);
if (lNumRecords)
{
pHIValue->GetParams(&dValStartBin, &dValEndBin, &dValBinSize, &ulNumBins);
pHIValue->GetNumSamplesOutsideBinRange(&ulLeft, &ulRight);



for (int m = 0 ; m < ulNumBins; m++)
{
pHIValue->GetNumSamplesInBin(m, &ulNumSamplesInBin);
pHIValue->GetBinInterval(m, &dValStartBin, &dValEndBin);

// add samples outside binrange to first (ulLeft) and last (ulRight) bin
if (m == 0)
ulNumSamplesInBin += ulLeft;
else if (m == (ulNumBins - 1))
ulNumSamplesInBin += ulRight;

double dHeight = 100.0 * (double) ulNumSamplesInBin / (double) lNumRecords;

if (m_pSettings->m_bHILogarithmicYScale)
{
dHeight = log10(dHeight);
if (!_finite(dHeight))
dHeight = -1.0;

if (m%2)
pHistogramValueSeries->AddXY(dValStartBin,dHeight,"",m_pSettings->m_vHIFillColor1);

else
pHistogramValueSeries->AddXY(dValStartBin,dHeight,"",m_pSettings->m_vHIFillColor2);

}
else if (dHeight > 0.0)
{
if (m%2)
pHistogramValueSeries->AddXY(dValStartBin,dHeight,"",m_pSettings->m_vHIFillColor1);

else
pHistogramValueSeries->AddXY(dValStartBin,dHeight,"",m_pSettings->m_vHIFillColor2);

}
} // for (int m = 0 ; m < ulNumBins; m++)


if (m_pSettings->m_iHIFitType != fitTypeNo)
FitView();
}
}
CString sWindowText;
sWindowText.Format("Histogram Delta Offset [milliseconds] (samples=%u outside left=%u right=%u)",
lNumRecords, ulLeft, ulRight);

if (m_pSettings->m_bHILogarithmicYScale)
sWindowText += " LOGARITHMIC SCALING";

SetWindowText(sWindowText);
}


DrawHistogramValue() tries to draw histogram series using AddXY(dValStartBin,dHeight) parameters .. first time when this function gets call AddXY draw histogram for first 10 interation properly . After that OnUpdate() gets call. so OnUpdate() call to m_pITeeCtrl->Repaint() , so because of this m_pITeeCtrl->Repaint() all the X and Y scale gets reset and grid started moving .. so in the next DrawHistogramValue() call I am not able to draw histogram .. I am getting only straight lines . without colors. You can view this bug in my first loaded jpg on your server..

Could you please let me know other function to rapaint chart , so it will not reset X and Y scales?

Regards
Abhijit Nimbalkar

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

Post by Abhijit » Tue Feb 05, 2008 3:22 am

Hi ,

Have you find anything in the code?

Regards
Abhijit

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

Post by Abhijit » Tue Feb 05, 2008 7:02 am

Hi ,

How do I turn off Auto Scale adjustment for both X and Y scales.....


Regards
Abhijit

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

Post by Abhijit » Tue Feb 05, 2008 11:55 am

Could you please let me know whether you have figure out anything?

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

Post by Narcís » Tue Feb 05, 2008 12:15 pm

Hello Abhijit,

Sorry for the delayed reply but we need some time to investigate the issue. We will get back to you as soon as we have some news.

Thanks for your patience.
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 » Wed Feb 06, 2008 5:00 am

Hi ,

For your referance I have also uploaded my actual project files .. and screen shot files please download that and please let me know that why histogram width changes automatically and why I am getting only lines with out color...

Thanks in advance .. This is very urgent for me .. It will be good for me if you could figure out this problem ASAP..

Upladed file name

2912008-9.rar - source code file..
desktop.rar -- screen shots of my GUI

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

Post by Abhijit » Wed Feb 06, 2008 7:04 am

Please let me know if you need any kind of my help to resolve problem ..

You can reach me on my cell +91 - 9833729073

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

Post by Abhijit » Wed Feb 06, 2008 7:23 am

Could you please let me know how to turn off pagging..

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

Post by Narcís » Wed Feb 06, 2008 8:16 am

Hi Abhijit,

You can disable paging setting points per page to zero:

Code: Select all

    TChart1.Page.MaxPointsPerPage = 0
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 » Wed Feb 06, 2008 8:54 am

I did that but still its not working .... Have you received my code and screen shots ?


Please find some data that I am using to draw histogram series.

CSfxStatisticsView::OnBeforeDrawChart
CSfxStatisticsView::OnBeforeDrawChart
X Axis = 0.000000 , Y Axis= 2.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000
X Axis = 0.100000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000
X Axis = 0.200000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000
X Axis = 0.300000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000
X Axis = 0.400000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000
X Axis = 0.500000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000
X Axis = 0.600000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000
X Axis = 0.700000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000
X Axis = 0.800000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000
X Axis = 0.900000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.000000 , Y Minimum = 0.000000 , Y Maximum = 0.000000

First call of DrawHsitogramValue function... for this first call these above vales are draw proerly histogram.. but after this I value for next value I am getting only lines.. this you can view in attached Destop.rar files which contains screen shots of my application GUI
---------------------------------------------------------------------------------------
CSfxStatisticsView::OnBeforeDrawChart
CSfxStatisticsView::OnBeforeDrawChart
X Axis = 0.000000 , Y Axis= 2.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.100000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.200000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.300000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.400000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.500000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.600000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.700000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.800000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.900000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000


second value...
................................................................................................................

CSfxStatisticsView::OnBeforeDrawChart
CSfxStatisticsView::OnBeforeDrawChart
X Axis = 0.000000 , Y Axis= 2.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.100000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.200000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.300000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.400000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.500000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.600000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.700000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.800000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.900000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
CSfxStatisticsView::OnBeforeDrawChart
CSfxStatisticsView::OnBeforeDrawChart
X Axis = 0.000000 , Y Axis= 2.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.100000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.200000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.300000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.400000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.500000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.600000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.700000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.800000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
X Axis = 0.900000 , Y Axis= -1.000000 , X Minimum = 0.000000 , X Maximum = 0.900000 , Y Minimum = -1.000000 , Y Maximum = 2.000000
CSfxStatisticsView::OnBeforeDrawChart
CSfxStatisticsView::OnBeforeDrawChart

Third value
...........................................................................................................

In this X Axis and Y Axis label contains actual data which I am passing ..
and others are values of X and Y which I am getting using TeeChart functions i.e bottom->GetMaximum() , bottom->GetMinimum,Left->GetMaximum() , Left->GetMinimum


-----------------------------------------------------------------------------

If you look values closely you can find that in the code there is loop for first 10 iteration .. and X axis is increment from 0.0 to 0.9 by 0.1 interval..

When event fired it call to DrawHistogramValue() execute loop for first 10 iteration and again goes out of this function and wait for next event to call this function . I am using OnBeforeDrawChart() event to call histogram.....

When I run the series for first call of DrawHistogramValue() through OnBeforeDrawChart() event . I can able to plot histograms for first 10 iteration ... but in the next DrawHistogramValue() I assume that page moving so X axis scale move vertical direction .... because of that In the next call for DrawHistogramValue() I am not able to get histogram properly .. I can see only lines without colors....

You can view this in Destop.rar files that I have uploaded on your server...

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

Post by Abhijit » Wed Feb 06, 2008 9:03 am

Could you please let me know what you are trying at your end .. or what I can try at my end?

Also please let me know whether you received my uploaded files?

Post Reply