|
AddZone on FinanceChart |
Posted by dale on Aug-22-2011 13:45 |
|
I have a scrolling FinanceChart with OHLC. I use setData and a timeStamp array for the x-axis which are in charttime format (a double representing seconds). If I use,
x->xAxis()->addZone(timestart[start], timestart[stop],0xffcc66)
I get nothing.
If I use,
x->xAxis()->addZone(10,20,0xffcc66),
then I get a zone starting at the 10th candle and going to the 20th candle, that never changes as I scroll.
Code snippet below:
int noOfPoints = endIndex - startIndex + 1;
// Create the chart object using the selected size
FinanceChart m(m_chartWidth);
// Set the data into the chart object
int extraTrailingPoints = 0; // Will use later, see financedemodlg
int extraPoints = 0;
m.setData(
DoubleArray(&m_timeStamps[startIndex], noOfPoints + extraTrailingPoints),
DoubleArray(&m_highData[startIndex], noOfPoints),
DoubleArray(&m_lowData[startIndex], noOfPoints),
DoubleArray(&m_openData[startIndex], noOfPoints),
DoubleArray(&m_closeData[startIndex], noOfPoints),
DoubleArray(&m_volData[startIndex], noOfPoints),
extraPoints);
CString companyName="TEST";
m.addPlotAreaTitle(Chart::TopLeft, TCHARtoUTF8(companyName));
const char *resolutionText = "";
char buffer[1024];
sprintf(buffer, "<*font=arial.ttf,size=8*>%s - %s chart",
m.formatValue(Chart::chartTime2((int)time(0)), "mmm dd, yyyy"), resolutionText);
m.addPlotAreaTitle(Chart::BottomLeft, buffer);
m.addPlotAreaTitle(Chart::BottomRight,
"<*font=arial.ttf,size=8*>(c) dkdkdkdk");
XYChart *x;
x = m.addMainChart(m_chartHeight);
x->xAxis()->addZone(m_timeStamps[startIndex+10],
m_timeStamps[endIndex-5],
0xffcc66); |
Re: AddZone on FinanceChart |
Posted by Peter Kwan on Aug-23-2011 00:14 |
|
Hi dale,
If you want to set a zone starting from the label m_timeStamps[start] to m_timeStamps[stop], then in your existing code structure, you may use:
x->xAxis()->addZone(start - startIndex, stop - startIndex, 0xffcc66);
It is because the actual array you pass to ChartDirector is m_timeStamps + startIndex, so the array index is (m_timeStamps + startIndex)[start - startIndex].
Hope this can help.
Regards
Peter Kwan |
|