Hi, now i have the problem that when i zoom and drag the finace chart the shown dots count are not fixed, it will be less or more, cause my datas are not a serial times. for example: start with 20 datas in 2016-7-2 and next 95 datas in 2016-7-4.
how can i zoom and drag with fixed dot no mater what the data is.
The problem is because in a standard financial chart, the x-axis represents trading sessions, not date/time. The date/time labels on the x-axis are just names for human reading and have no positional meaning. For example, the candlesticks always equally spaced, even though the date/time are irregular and somewhat random.
If you use date/time as the x-coordinates, then when you scroll the chart, the x-axis will contain the same duration in date/time, which is not related to the number of candlesticks.
Instead, you may simply use the array index as the x-coordinates. In this case, the full x-range of the chart are just the full range of the array index:
// start and end indexes
int startIndex = (int)floor(viewer->getValueAtViewPort("x", viewer->getViewPortLeft()));
int endIndex = (int)ceil(viewer->getValueAtViewPort("x", viewer->getViewPortLeft() + viewer->getViewPortWidth());
// adjust for extra points
int extraPoints = std::min(10, startIndex);
staartIndex -= extraPoints;
int noOfPoints = endIndex - startIndex + 1;
// get the data
DoubleArray timeStamps = DoubleArray(m_timeStamps.data + startIndex, noOfPoints);
DoubleArray volData = DoubleArray(m_values.data + startIndex, noOfPoints);