ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  FinanceChart: How to reserve some blank area on the right of xAxis?
Posted by seo on Jan-01-2018 15:54
Attachments:
Some Finance candlestick chart may only  contains a few data (maybe 3 or 5),
But the ChartDirector will always show these candlestick chart fully in QChartViewer, and the candle width will be really huge.

Is there some way to reserve a blank area on the right side of xAxis? thus the candle width will be nice.

The screenshot of other product is very nice? How can FinanceChart get this?
微信截图_20180101154359.png

  Re: FinanceChart: How to reserve some blank area on the right of xAxis?
Posted by Peter Kwan on Jan-02-2018 15:24
Hi seo,

In the "Interactive Financial Chart" sample code, it also does the same thing. If the intraday data are too short (such as if it is at the beginning of a day), the code just extend the timestamp array to add extra positions to the right. Only the timestamp array is exteneded, not the other array (highData, lowData, etc, are not extended). So the right side remains empty.

For your reference, the following is the code we use in our original "Interactive Financial Chart" sample code.

// In some finance chart presentation style, even if the data for the latest day
// is not fully available, the axis for the entire day will still be drawn, where
// no data will appear near the end of the axis.
int extraTrailingPoints = 0;
if (m_resolution <= 86400)
{
    // Add extra points to the axis until it reaches the end of the day. The end
    // of day is assumed to be 16:00 (it depends on the stock exchange).
    double lastTime = m_timeStamps[m_noOfPoints - 1];
    extraTrailingPoints = (int)((16 * 3600 - fmod(lastTime, 86400)) / m_resolution);
    if (extraTrailingPoints > 0)
    {
        double *extendedTimeStamps = new double[m_noOfPoints + extraTrailingPoints];
        memcpy(extendedTimeStamps, m_timeStamps, sizeof(double) * m_noOfPoints);
        for (int i = 0; i < extraTrailingPoints; ++i)
            extendedTimeStamps[m_noOfPoints + i] = lastTime + m_resolution * (i + 1);
        delete[] m_timeStamps;
        m_timeStamps = extendedTimeStamps;
    }
}

Hope this can help.

Regards
Peter Kwan

  Re: FinanceChart: How to reserve some blank area on the right of xAxis?
Posted by seo on Jan-02-2018 16:48

Thanks very much, I will try these code later, but I think it is just what we need!