MCPcopy Create free account
hub / github.com/KDE/labplot / columnLabelValuesMaxValues

Method columnLabelValuesMaxValues

tests/backend/Axis/AxisTest2.cpp:369–423  ·  view source on GitHub ↗

! * \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 */

Source from the content-addressed store, hash-verified

367 * in the axis. This leads to a limited representation of ticks/labels
368 */
369void 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

Callers

nothing calls this directly

Calls 15

setYColumnMethod · 0.80
setMajorTicksTypeMethod · 0.80
setMajorTicksColumnMethod · 0.80
tickLabelStringsMethod · 0.80
addChildMethod · 0.45
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
columnMethod · 0.45
replaceValuesMethod · 0.45
rowCountMethod · 0.45
columnCountMethod · 0.45
addValueLabelMethod · 0.45

Tested by

no test coverage detected