! * \brief AxisTest2::columnLabelValuesMaxValues * Same as columnLabelValues() with the difference * that more columnLabels are available than the maximum number of ticks allowed * in the axis. This leads to a limited representation of ticks/labels */
| 367 | * in the axis. This leads to a limited representation of ticks/labels |
| 368 | */ |
| 369 | void AxisTest2::columnLabelValuesMaxValues() { |
| 370 | constexpr int valueLabelsCount = 1000; |
| 371 | QLocale::setDefault(QLocale::C); // . as decimal separator |
| 372 | Project project; |
| 373 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 374 | QVERIFY(ws != nullptr); |
| 375 | project.addChild(ws); |
| 376 | |
| 377 | Spreadsheet* spreadsheet = new Spreadsheet(QStringLiteral("test"), false); |
| 378 | spreadsheet->setColumnCount(2); |
| 379 | spreadsheet->setRowCount(3); |
| 380 | project.addChild(spreadsheet); |
| 381 | |
| 382 | auto* xCol = spreadsheet->column(0); |
| 383 | xCol->replaceValues(-1, QVector<double>({1., 100.})); |
| 384 | |
| 385 | auto* yCol = spreadsheet->column(1); |
| 386 | yCol->replaceValues(-1, QVector<double>({1., 1000.})); |
| 387 | |
| 388 | QCOMPARE(spreadsheet->rowCount(), 2); |
| 389 | QCOMPARE(spreadsheet->columnCount(), 2); |
| 390 | |
| 391 | for (int i = 0; i <= valueLabelsCount; i++) { |
| 392 | yCol->addValueLabel(i, QStringLiteral("Status ") + QString::number(i)); |
| 393 | } |
| 394 | |
| 395 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 396 | p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 397 | QVERIFY(p != nullptr); |
| 398 | ws->addChild(p); |
| 399 | |
| 400 | auto* curve = new XYCurve(QStringLiteral("xy-curve")); |
| 401 | curve->setXColumn(xCol); |
| 402 | curve->setYColumn(yCol); |
| 403 | p->addChild(curve); |
| 404 | |
| 405 | auto axes = p->children<Axis>(); |
| 406 | QCOMPARE(axes.count(), 2); |
| 407 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 408 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 409 | auto* yAxis = static_cast<Axis*>(axes.at(1)); |
| 410 | // auto* xAxis = static_cast<Axis*>(axes.at(0)); |
| 411 | |
| 412 | { |
| 413 | yAxis->setMajorTicksType(Axis::TicksType::ColumnLabels); |
| 414 | yAxis->setMajorTicksColumn(yCol); |
| 415 | |
| 416 | const auto v = yAxis->tickLabelStrings(); |
| 417 | QStringList expectedStrings; |
| 418 | for (int i = 0; i <= valueLabelsCount; i += valueLabelsCount / (Axis::maxNumberMajorTicksCustomColumn() - 1)) |
| 419 | expectedStrings.push_back(QStringLiteral("Status ") + QString::number(i)); |
| 420 | |
| 421 | COMPARE_STRING_VECTORS(yAxis->tickLabelStrings(), expectedStrings); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | /*! |
| 426 | * \brief AxisTest2::columnLabelValuesMoreTicksThanLabels |
nothing calls this directly
no test coverage detected