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

Method numericSpacing

tests/backend/Axis/AxisTest3.cpp:360–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360void AxisTest3::numericSpacing() {
361 QLocale::setDefault(QLocale::C); // use . as decimal separator
362 Project project;
363 auto* ws = new Worksheet(QStringLiteral("worksheet"));
364 QVERIFY(ws != nullptr);
365 project.addChild(ws);
366
367 Spreadsheet* spreadsheetData = new Spreadsheet(QStringLiteral("data"), false);
368 spreadsheetData->setColumnCount(2);
369 spreadsheetData->setRowCount(3);
370 project.addChild(spreadsheetData);
371
372 auto* xCol = spreadsheetData->column(0);
373 xCol->setColumnMode(AbstractColumn::ColumnMode::Double);
374 xCol->replaceValues(-1, QVector<double>({1., 2., 5.}));
375
376 auto* yCol = spreadsheetData->column(1);
377 yCol->replaceValues(-1, QVector<double>({2., 3., 4.}));
378
379 QCOMPARE(spreadsheetData->rowCount(), 3);
380 QCOMPARE(spreadsheetData->columnCount(), 2);
381
382 auto* p = new CartesianPlot(QStringLiteral("plot"));
383 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axes are created
384 p->setNiceExtend(false);
385 QVERIFY(p != nullptr);
386 ws->addChild(p);
387
388 auto* curve = new XYCurve(QStringLiteral("xy-curve"));
389 curve->setXColumn(xCol);
390 curve->setYColumn(yCol);
391 p->addChild(curve);
392
393 auto axes = p->children<Axis>();
394 QCOMPARE(axes.count(), 2);
395 QCOMPARE(axes.at(0)->name(), QStringLiteral("x"));
396 QCOMPARE(axes.at(1)->name(), QStringLiteral("y"));
397
398 auto* xAxis = static_cast<Axis*>(axes.at(0));
399 xAxis->setMajorTicksSpacing(0.5);
400 QCOMPARE(xAxis->range().start(), 1.);
401 QCOMPARE(xAxis->range().end(), 5.);
402 xAxis->setMajorTicksType(Axis::TicksType::Spacing);
403 // QCOMPARE(xAxis->majorTicksNumber(), 3);
404 QCOMPARE(xAxis->labelsTextType(), Axis::LabelsTextType::PositionValues);
405 QCOMPARE(xAxis->majorTicksStartType(), Axis::TicksStartType::Offset);
406 QCOMPARE(xAxis->majorTickStartOffset(), 0.);
407 QCOMPARE(xAxis->majorTickStartValue(), 0.);
408
409 {
410 const auto v = xAxis->tickLabelStrings();
411 QStringList expectedStrings{
412 QStringLiteral("1.0"),
413 QStringLiteral("1.5"),
414 QStringLiteral("2.0"),
415 QStringLiteral("2.5"),
416 QStringLiteral("3.0"),
417 QStringLiteral("3.5"),

Callers

nothing calls this directly

Calls 15

setNiceExtendMethod · 0.80
setYColumnMethod · 0.80
setMajorTicksSpacingMethod · 0.80
rangeMethod · 0.80
setMajorTicksTypeMethod · 0.80
tickLabelStringsMethod · 0.80
addChildMethod · 0.45
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
columnMethod · 0.45
setColumnModeMethod · 0.45
replaceValuesMethod · 0.45

Tested by

no test coverage detected