Possible to create multiple QStackedBarSeries on a single QChart?



  • I was wondering if it is possible to create two sets of QStackedBarSeries on a single QChart.

    When I try to create two QStackedBarSeries and add them both to the chart in the usual way, I find that for each x, QT bars the two stacked bars over one another i.e.

    // series 1
    	QStackedBarSeries *series = new QStackedBarSeries();
    	series->setName("Orginal Costs");
            int first = 0;
    	int count = _n_meshes ;
    	QVBarModelMapper *mapper = new QVBarModelMapper(this);
    	mapper->setFirstBarSetColumn(0);
    	mapper->setLastBarSetColumn(2);
    	mapper->setFirstRow(first);
    	mapper->setRowCount(count);
    	mapper->setSeries(series);
    	mapper->setModel(original_cost_summary_model);
    
    // series 2
    	QStackedBarSeries *series2 = new QStackedBarSeries();
    	series2->setName("Optimized Costs");
    	//int first = 0;
    	//int count = _n_meshes;
    	QVBarModelMapper *mapper2 = new QVBarModelMapper(this);
    	mapper2->setFirstBarSetColumn(0);
    	mapper2->setLastBarSetColumn(2);
    	mapper2->setFirstRow(first);
    	mapper2->setRowCount(count);
    	mapper2->setSeries(series2);
    	mapper2->setModel(final_cost_summary_model);
    
    	chart->addSeries(series);
    	chart->addSeries(series2);
    

    Am I just missing something simple?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.