EvalReportWidget.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "EvalReportWidget.h"
  2. #include "view/PlotView.h"
  3. #include "CustomPieChart.h"
  4. #include <QLabel>
  5. #include <QBoxLayout>
  6. EvalReportWidget::EvalReportWidget(QWidget *parent) : QWidget(parent)
  7. {
  8. m_view = new QWidget;
  9. m_layout = new QVBoxLayout(m_view);
  10. addContents();
  11. QScrollArea *scroll = new QScrollArea;
  12. scroll->setAlignment(Qt::AlignLeft);
  13. scroll->setWidget(m_view);
  14. QVBoxLayout *layout = new QVBoxLayout(this);
  15. layout->setMargin(0);
  16. layout->addWidget(scroll);
  17. }
  18. void EvalReportWidget::addContents()
  19. {
  20. QVector<PlotView::Data> v;
  21. QList<int> values = { 26, 96, 28, 45, 67, 89 };
  22. QStringList names;
  23. QList<QColor> colors;
  24. for (int i = 0; i < values.count(); i++) {
  25. PlotView::Data d;
  26. d.name = QString("%1").arg(i);
  27. d.value = values[i] / 100.0;
  28. v.append(d);
  29. names.append(d.name);
  30. colors.append(QColor::fromRgbF(i * 1.0 / values.count(), 0.5, (values.count() - i) * 1.0 / values.count(), 1));
  31. }
  32. QSize s = QSize(500, 500);
  33. PlotView *w1 = new PlotView(PlotView::Line, v, "折线图", this);
  34. w1->setFixedSize(s);
  35. w1->plot();
  36. m_layout->addWidget(w1);
  37. PlotView *w2 = new PlotView(PlotView::HistogramHorizontal, v, "特征值", this);
  38. w2->setFixedSize(s);
  39. w2->plot();
  40. m_layout->addWidget(w2);
  41. PlotView *w3 = new PlotView(PlotView::HistogramVertical, v, "柱状图", this);
  42. w3->setFixedSize(s);
  43. w3->plot();
  44. m_layout->addWidget(w3);
  45. PlotView *w4 = new PlotView(PlotView::Curve, v, "曲线图", this);
  46. w4->setFixedSize(s);
  47. w4->plot();
  48. m_layout->addWidget(w4);
  49. PlotView *w5 = new PlotView(PlotView::Area, v, "面积图", this);
  50. w5->setFixedSize(s);
  51. w5->plot();
  52. m_layout->addWidget(w5);
  53. CustomPieChart *w6 = new CustomPieChart("title", names, values, colors, this);
  54. w6->setFixedSize(s);
  55. m_layout->addWidget(w6);
  56. }