QChart legend labels don't reflect the sequence of QPieSeries labels.
-
Here is a minimal working example:
int main(int argc, char *argv[]) { QApplication a(argc, argv); QPieSeries *series = new QPieSeries; series = new QPieSeries; series->append("Label 1", 10); series->append("Label 2", 20); series->append("Label 3", 30); series->append("Label 4", 40); QChart *chart = new QChart; chart->addSeries(series); chart->setAnimationOptions(QChart::AllAnimations); QChartView *chartView = new QChartView(chart); chartView->setRenderHint(QPainter::Antialiasing); series->insert(3, new QPieSlice("New Label", 200)); chartView->show(); return a.exec(); }
As you can see, after the instruction
series->insert(3, new QPieSlice("New Label", 200));
the new slice is insterted in the correct index (index 3), but in the legend of the chart the label is appended at the end.Is it possible to update ("manually") the sequence of the legend labels correctly after the insertion of a slice?
UPDATE:
I found that this problem was reported and it was fixed in version 5.11.1. See this for more info.
I am developing a charting software for my object oriented programming class and unfortunately, due to the constraints imposed, I am forced to use Qt version 5.9.5.
If you are aware of any solution/work around to this problem for version 5.9.5 I would really love to hear it!
Thanks in advance!