Weimin Chan
Weimin Chan

Reputation: 347

How to plot candlesticks with Qcustomplot

I already have Qvectors of open, close, high, low data.

And I'm going to plot the financial data by using Qt Qcustomplot.

I use ChatGpt to get an example like this:

// Create a QCPFinancial instance
QCPFinancial *candlesticks = new QCPFinancial(customPlot->xAxis, customPlot->yAxis);

// Set the data for the candlesticks
QVector<double> timeData, openData, highData, lowData, closeData;

// Populate the data vectors
// ...

candlesticks->setData(timeData, openData, highData, lowData, closeData);

// Customize the appearance of the candlesticks
candlesticks->setWidth(0.5);
candlesticks->setTwoColored(true);
candlesticks->setBrushPositive(QColor(0, 255, 0));
candlesticks->setBrushNegative(QColor(255, 0, 0));

// Add the candlesticks to the plot
customPlot->addPlottable(candlesticks);

// Set the range of the x and y axes
customPlot->xAxis->setRange(0, timeData.size());
customPlot->yAxis->setRange(lowData.first(), highData.last());

// Call replot to update the plot
customPlot->replot();

But I cannot find the function addPlottable. Does the method still exist?

Which method can I replace it? Thanks!

Upvotes: 0

Views: 215

Answers (1)

mzimmers
mzimmers

Reputation: 887

There's no such function in the current documentation. What is your definition for customPlot?

Upvotes: 0

Related Questions