Reputation: 347
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
Reputation: 887
There's no such function in the current documentation. What is your definition for customPlot?
Upvotes: 0