Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QChart legend labels don't reflect the sequence of QPieSeries labels.
Forum Updated to NodeBB v4.3 + New Features

QChart legend labels don't reflect the sequence of QPieSeries labels.

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 202 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    user13
    wrote on last edited by user13
    #1

    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();			
    }
    

    PieChart.png

    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!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved