| 571 | } |
| 572 | |
| 573 | void CartesianPlotTest::rangeFormatYDataChanged() { |
| 574 | Project project; |
| 575 | |
| 576 | Spreadsheet* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false); |
| 577 | project.addChild(sheet); |
| 578 | |
| 579 | sheet->setColumnCount(2); |
| 580 | sheet->setRowCount(3); |
| 581 | |
| 582 | sheet->column(0)->setColumnMode(AbstractColumn::ColumnMode::DateTime); |
| 583 | sheet->column(1)->setColumnMode(AbstractColumn::ColumnMode::Integer); |
| 584 | |
| 585 | sheet->column(0)->setDateTimeAt(0, QDateTime::fromString(QStringLiteral("2022-02-03 12:23:00"), Qt::ISODate)); |
| 586 | sheet->column(0)->setDateTimeAt(1, QDateTime::fromString(QStringLiteral("2022-02-04 12:23:00"), Qt::ISODate)); |
| 587 | sheet->column(0)->setDateTimeAt(2, QDateTime::fromString(QStringLiteral("2022-02-05 12:23:00"), Qt::ISODate)); |
| 588 | |
| 589 | QCOMPARE(sheet->column(0)->dateTimeAt(0), QDateTime::fromString(QStringLiteral("2022-02-03 12:23:00"), Qt::ISODate)); |
| 590 | |
| 591 | sheet->column(1)->setValueAt(0, 0); |
| 592 | sheet->column(1)->setValueAt(1, 1); |
| 593 | sheet->column(1)->setValueAt(2, 2); |
| 594 | |
| 595 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 596 | project.addChild(worksheet); |
| 597 | |
| 598 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 599 | worksheet->addChild(plot); |
| 600 | plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 601 | |
| 602 | auto* curve = new XYCurve(QStringLiteral("curve")); |
| 603 | plot->addChild(curve); |
| 604 | |
| 605 | curve->setXColumn(sheet->column(0)); |
| 606 | curve->setYColumn(sheet->column(1)); |
| 607 | |
| 608 | QCOMPARE(plot->rangeFormat(Dimension::X, 0), RangeT::Format::DateTime); |
| 609 | QCOMPARE(plot->rangeFormat(Dimension::Y, 0), RangeT::Format::Numeric); |
| 610 | |
| 611 | // simulate data change |
| 612 | plot->dataChanged(curve, Dimension::Y); |
| 613 | |
| 614 | QCOMPARE(plot->rangeFormat(Dimension::X, 0), RangeT::Format::DateTime); |
| 615 | QCOMPARE(plot->rangeFormat(Dimension::Y, 0), RangeT::Format::Numeric); |
| 616 | } |
| 617 | |
| 618 | void CartesianPlotTest::rangeFormatXDataChanged() { |
| 619 | Project project; |
nothing calls this directly
no test coverage detected