ChartDirector Support Forum Home   Search
How to get the index value of dataset when tracking a finance chart
Posted by James on Feb-09-2021 10:09
Hi,
I'm confused with the index value of Drawing and Tracking.

In function drawchart:
//-----------------------------------
// After determining the extra points, we can obtain the data
int startIndex = (int)floor(viewer->getValueAtViewPort("x", viewer->getViewPortLeft()));
int endIndex = (int)ceil(viewer->getValueAtViewPort("x", viewer->getViewPortLeft() + viewer->getViewPortWidth()));

// Add the extra points (adjust the extra points if there are insufficient data)
extraPoints = min(extraPoints, startIndex);
startIndex -= extraPoints;
int duration = endIndex - startIndex + 1;
TRACE("start index = %d , end index = %d for plot arean", startIndex,endIndex);
//--------------------------------------
the debug information is :
start index = 143 , end index = 221 for plot area
that means there are 79 data point to draw

But in the tracking function trackFinance, I add a debugger code:
//---------------------------------------
TRACE("index X =%d, and value =%fn", xIndex,value);
//-----------------------------------------

Then I found that index=0 at the left of chart, and index = 48 at the right of chart.
Why the max index !=(79-1) ？ What's the index value in dataset at this moment?
How to get the index value of dataset when tracking a chart?

Thanks

Regards

James

Re: How to get the index value of dataset when tracking a finance chart
Posted by James on Feb-09-2021 14:08
Hi，
I noticed that code in drawChart:
//-----------------------------------------
startIndex -= extraPoints;
//-----------------------------------------

That menas the startIndex has negtive offset refer to plot data point.
So the actual index in dataset is:
startIndex + extraPoints + index of tracking = 143 +30 + 48 = 221, at right of plot area and the right of dataset.

Regards