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

Method columnLabelValues

tests/backend/Axis/AxisTest2.cpp:295–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295void AxisTest2::columnLabelValues() {
296 QLocale::setDefault(QLocale::C); // . as decimal separator
297 Project project;
298 auto* ws = new Worksheet(QStringLiteral("worksheet"));
299 QVERIFY(ws != nullptr);
300 project.addChild(ws);
301
302 Spreadsheet* spreadsheet = new Spreadsheet(QStringLiteral("test"), false);
303 spreadsheet->setColumnCount(2);
304 spreadsheet->setRowCount(3);
305 project.addChild(spreadsheet);
306
307 auto* xCol = spreadsheet->column(0);
308 xCol->replaceValues(0, QVector<double>({1, 2, 3}));
309
310 auto* yCol = spreadsheet->column(1);
311 yCol->replaceValues(0, QVector<double>({2, 3, 4}));
312
313 QCOMPARE(spreadsheet->rowCount(), 3);
314 QCOMPARE(spreadsheet->columnCount(), 2);
315
316 yCol->addValueLabel(2, QStringLiteral("Status 1"));
317 yCol->addValueLabel(3, QStringLiteral("Status 2"));
318 yCol->addValueLabel(4, QStringLiteral("Status 3"));
319
320 auto* p = new CartesianPlot(QStringLiteral("plot"));
321 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
322 QVERIFY(p != nullptr);
323 ws->addChild(p);
324
325 auto* curve = new XYCurve(QStringLiteral("xy-curve"));
326 curve->setXColumn(xCol);
327 curve->setYColumn(yCol);
328 p->addChild(curve);
329
330 auto axes = p->children<Axis>();
331 QCOMPARE(axes.count(), 2);
332 QCOMPARE(axes.at(0)->name(), QStringLiteral("x"));
333 QCOMPARE(axes.at(1)->name(), QStringLiteral("y"));
334 auto* yAxis = static_cast<Axis*>(axes.at(1));
335 // auto* xAxis = static_cast<Axis*>(axes.at(0));
336
337 {
338 QCOMPARE(yAxis->labelsFormat(), Axis::LabelsFormat::Decimal);
339 const auto v = yAxis->tickLabelStrings();
340 QStringList expectedStrings{
341 QStringLiteral("2.0"),
342 QStringLiteral("2.5"),
343 QStringLiteral("3.0"),
344 QStringLiteral("3.5"),
345 QStringLiteral("4.0"),
346 };
347 COMPARE_STRING_VECTORS(yAxis->tickLabelStrings(), expectedStrings);
348 }
349
350 {
351 yAxis->setMajorTicksType(Axis::TicksType::ColumnLabels);
352 yAxis->setMajorTicksColumn(yCol);

Callers

nothing calls this directly

Calls 15

setYColumnMethod · 0.80
tickLabelStringsMethod · 0.80
setMajorTicksTypeMethod · 0.80
setMajorTicksColumnMethod · 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