QCustomPlot Discussion and Comments

How to use QCPFinancial to draw K line graph (use your own data )Return to overview

I graduated from the university this year.I want to use QCustomplot to draw day K line graph, I can get histrory-data from sina or Yahoo. ,I can understand the Demo in plot-examples.however in the example.it use timeSeriesToOhlc .I think this static methods just create random data(open ,close,high,low). Now i want to use really data(I get from sina). how to write the code. I tried setdata(). but it doesn't produce correct graph. China's website hava too few information about Qcustomplot.

if anyone have used QCPFinancial to draw K line .plese show me a simple demo.thank you very much!!!有人用过吗?

The question has bothered me for a week。today,I read the qwt demo about stock.I find acually I did not make mistakes。I just forget to set the ChartStyle, maybe jsut because I know little about stock.

same issue.
I can't understand "timeSeriesToOhlc" too.
who and why need input data in this strange format?

QCPDataContainer<QCPFinancialData> datas;
QCPFinancialData ohlc;

for(unsigned int i=startShowDay; i<=endShowDay; i++){
//Get Date:

if(dayData.high>m_KMax) m_KMax=dayData.high;
if(dayData.low<m_KMin) m_KMin=dayData.low;

ohlc.key = i;
ohlc.open = dayData.open;
ohlc.high = dayData.high;
ohlc.low = dayData.low;
ohlc.close = dayData.close;


const QColor BrushPositive(QColor(230, 230, 230));
const QColor PenPositive("#8a0000");
const QColor BrushNegative(QColor(100, 160, 100));
const QColor PenNegative("#008f28");

QCPFinancial *financial = new QCPFinancial(mp_qcpK->xAxis, mp_qcpK->yAxis);


can you print the "dayData".
I think it is a number series without date column, maybe like {12.54, 13.12, 12.54, 12.59, 12.36, 12.71, 12.19, 12.52, 12.49, 12.63, 12.30, 12.58, 12.50, 12.80, 12.43, 12.56 ... }
but I'm not sure this is!


sorry, I can't delete message above. I wrote a wrong data format.

and which type is the "dayData"?

dayData is a structure, just like:

struct DayData{
QDate date;
long long vol;
double open;
double close;
double high;
double low;