series必须在add到chart之前,就append数据,如果先add到chart,再append数据到series,则数据不显示
stackedBarSeries->append(phaselist1);
stackedBarSeries->append(phaselist2);
stackedBarSeries->append(phaselist3);
stackedBarSeries->append(phaselist4);
// 必须插入数据后再把序列给到chart,否则数据显示不出来
if(chart!=nullptr){
chart->addSeries(stackedBarSeries);
chart->setTitle("相位选择界面");
std::cout << "stackedBarSeries data done" << std::endl;
}
必须先设置数据,再设置坐标轴(如果坐标轴使用自动推算坐标),否则横坐标不显示数据
// 设置数据
stackedBarSeries->append(phaselist1);
stackedBarSeries->append(phaselist2);
stackedBarSeries->append(phaselist3);
stackedBarSeries->append(phaselist4);
// 必须插入数据后再把序列给到chart,否则数据显示不出来
if(chart!=nullptr){
chart->addSeries(stackedBarSeries);
chart->setTitle("相位选择界面");
std::cout << "stackedBarSeries data done" << std::endl;
}
//...
// 设置坐标轴
QStringList categories;
categories << "相位链1" << "相位链2" << "相位链3" << "相位链4";
axisY = new QBarCategoryAxis();
axisY->append(categories);
chart->addAxis(axisY, Qt::AlignLeft);
stackedBarSeries->attachAxis(axisY);
axisX = new QValueAxis();
chart->addAxis(axisX, Qt::AlignBottom);
stackedBarSeries->attachAxis(axisX);