1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #include "EvalReportWidget.h"
- #include "view/PlotView.h"
- #include "CustomPieChart.h"
- #include <QLabel>
- #include <QBoxLayout>
- EvalReportWidget::EvalReportWidget(QWidget *parent) : QWidget(parent)
- {
- m_view = new QWidget;
- m_layout = new QVBoxLayout(m_view);
- addContents();
- QScrollArea *scroll = new QScrollArea;
- scroll->setAlignment(Qt::AlignLeft);
- scroll->setWidget(m_view);
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->setMargin(0);
- layout->addWidget(scroll);
- }
- void EvalReportWidget::addContents()
- {
- QVector<PlotView::Data> v;
- QList<int> values = { 26, 96, 28, 45, 67, 89 };
- QStringList names;
- QList<QColor> colors;
- for (int i = 0; i < values.count(); i++) {
- PlotView::Data d;
- d.name = QString("%1").arg(i);
- d.value = values[i] / 100.0;
- v.append(d);
- names.append(d.name);
- colors.append(QColor::fromRgbF(i * 1.0 / values.count(), 0.5, (values.count() - i) * 1.0 / values.count(), 1));
- }
- QSize s = QSize(500, 500);
- PlotView *w1 = new PlotView(PlotView::Line, v, "折线图", this);
- w1->setFixedSize(s);
- w1->plot();
- m_layout->addWidget(w1);
- PlotView *w2 = new PlotView(PlotView::HistogramHorizontal, v, "特征值", this);
- w2->setFixedSize(s);
- w2->plot();
- m_layout->addWidget(w2);
- PlotView *w3 = new PlotView(PlotView::HistogramVertical, v, "柱状图", this);
- w3->setFixedSize(s);
- w3->plot();
- m_layout->addWidget(w3);
- PlotView *w4 = new PlotView(PlotView::Curve, v, "曲线图", this);
- w4->setFixedSize(s);
- w4->plot();
- m_layout->addWidget(w4);
- PlotView *w5 = new PlotView(PlotView::Area, v, "面积图", this);
- w5->setFixedSize(s);
- w5->plot();
- m_layout->addWidget(w5);
- CustomPieChart *w6 = new CustomPieChart("title", names, values, colors, this);
- w6->setFixedSize(s);
- m_layout->addWidget(w6);
- }
|