| 382 | |
| 383 | #ifdef QT_CHARTS_LIB |
| 384 | QChartView *createChart(const QString &statsFile, const QString &tool) |
| 385 | { |
| 386 | auto *chart = new QChart; |
| 387 | chart->addSeries(numberOfReports(statsFile, tool + "-error")); |
| 388 | chart->addSeries(numberOfReports(statsFile, tool + "-warning")); |
| 389 | chart->addSeries(numberOfReports(statsFile, tool + "-style")); |
| 390 | chart->addSeries(numberOfReports(statsFile, tool + "-performance")); |
| 391 | chart->addSeries(numberOfReports(statsFile, tool + "-portability")); |
| 392 | |
| 393 | auto *axisX = new QDateTimeAxis; |
| 394 | axisX->setTitleText("Date"); |
| 395 | chart->addAxis(axisX, Qt::AlignBottom); |
| 396 | |
| 397 | for (QAbstractSeries *s : chart->series()) { |
| 398 | s->attachAxis(axisX); |
| 399 | } |
| 400 | |
| 401 | auto *axisY = new QValueAxis; |
| 402 | axisY->setLabelFormat("%i"); |
| 403 | axisY->setTitleText("Count"); |
| 404 | chart->addAxis(axisY, Qt::AlignLeft); |
| 405 | |
| 406 | qreal maxY = 0; |
| 407 | for (QAbstractSeries *s : chart->series()) { |
| 408 | s->attachAxis(axisY); |
| 409 | if (const auto *ls = dynamic_cast<const QLineSeries*>(s)) { |
| 410 | for (QPointF p : ls->points()) { |
| 411 | // cppcheck-suppress useStlAlgorithm - this would reduce the readability of the code |
| 412 | maxY = std::max(p.y(), maxY); |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | axisY->setMax(maxY); |
| 417 | |
| 418 | //chart->createDefaultAxes(); |
| 419 | chart->setTitle(tool); |
| 420 | |
| 421 | auto *chartView = new QChartView(chart); |
| 422 | chartView->setRenderHint(QPainter::Antialiasing); |
| 423 | return chartView; |
| 424 | } |
| 425 | |
| 426 | QLineSeries *numberOfReports(const QString &fileName, const QString &severity) |
| 427 | { |
no test coverage detected