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

Method axisFormat

tests/cartesianplot/CartesianPlotTest.cpp:361–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361void CartesianPlotTest::axisFormat() {
362 // testing #74
363
364 QString savePath;
365 {
366 Project project;
367
368 Spreadsheet* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false);
369 project.addChild(sheet);
370
371 sheet->setColumnCount(2);
372 sheet->setRowCount(3);
373
374 sheet->column(0)->setColumnMode(AbstractColumn::ColumnMode::DateTime);
375 sheet->column(1)->setColumnMode(AbstractColumn::ColumnMode::Integer);
376
377 sheet->column(0)->setDateTimeAt(0, QDateTime::fromString(QStringLiteral("2022-02-03 12:23:00"), Qt::ISODate));
378 sheet->column(0)->setDateTimeAt(1, QDateTime::fromString(QStringLiteral("2022-02-04 12:23:00"), Qt::ISODate));
379 sheet->column(0)->setDateTimeAt(2, QDateTime::fromString(QStringLiteral("2022-02-05 12:23:00"), Qt::ISODate));
380
381 QCOMPARE(sheet->column(0)->dateTimeAt(0), QDateTime::fromString(QStringLiteral("2022-02-03 12:23:00"), Qt::ISODate));
382
383 sheet->column(1)->setValueAt(0, 0);
384 sheet->column(1)->setValueAt(1, 1);
385 sheet->column(1)->setValueAt(2, 2);
386
387 auto* worksheet = new Worksheet(QStringLiteral("Worksheet"));
388 project.addChild(worksheet);
389
390 auto* plot = new CartesianPlot(QStringLiteral("plot"));
391 worksheet->addChild(plot);
392 plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
393
394 auto* curve = new XYCurve(QStringLiteral("curve"));
395 plot->addChild(curve);
396
397 curve->setXColumn(sheet->column(0));
398 curve->setYColumn(sheet->column(1));
399
400 auto* xAxis = static_cast<Axis*>(plot->child<Axis>(0));
401 QVERIFY(xAxis);
402 QCOMPARE(xAxis->name(), QStringLiteral("x"));
403
404 const auto original = xAxis->labelsDateTimeFormat();
405 const auto newFormat = QStringLiteral("yyyy-MM-dd hh:mm");
406 QVERIFY(original != newFormat);
407 xAxis->setLabelsDateTimeFormat(newFormat);
408
409 SAVE_PROJECT("TestAxisDateTimeFormat.lml");
410 }
411
412 {
413 Project project;
414 project.load(savePath);
415
416 /* check the project tree for the imported project */
417 /* Spreadsheet */
418 auto* aspect = project.child<AbstractAspect>(0);

Callers

nothing calls this directly

Calls 15

setYColumnMethod · 0.80
addChildMethod · 0.45
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
setColumnModeMethod · 0.45
columnMethod · 0.45
setDateTimeAtMethod · 0.45
dateTimeAtMethod · 0.45
setValueAtMethod · 0.45
setTypeMethod · 0.45
setXColumnMethod · 0.45

Tested by

no test coverage detected