##// END OF EJS Templates
Handles axes properties
Alexandre Leroux -
r170:aee0cf3098de
parent child
Show More
@@ -9,6 +9,24 Q_LOGGING_CATEGORY(LOG_GraphPlottablesFactory, "GraphPlottablesFactory")
9 9
10 10 namespace {
11 11
12 /// Format for datetimes on a axis
13 const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss");
14
15 /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or
16 /// non-time data
17 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
18 {
19 if (isTimeAxis) {
20 auto dateTicker = QSharedPointer<QCPAxisTickerDateTime>::create();
21 dateTicker->setDateTimeFormat(DATETIME_TICKER_FORMAT);
22
23 return dateTicker;
24 }
25 else {
26 // default ticker
27 return QSharedPointer<QCPAxisTicker>::create();
28 }
29 }
12 30
13 31 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QCustomPlot &plot)
14 32 {
@@ -19,6 +37,20 QCPAbstractPlottable *createScalarSeriesComponent(ScalarSeries &scalarSeries, QC
19 37 component->setData(scalarSeries.xAxisData()->data(), scalarSeries.valuesData()->data(),
20 38 true);
21 39
40 // Axes properties
41 /// @todo : for the moment, no control is performed on the axes: the units and the tickers
42 /// are fixed for the default x-axis and y-axis of the plot, and according to the new graph
43
44 auto setAxisProperties = [](auto axis, const auto &unit) {
45 // label (unit name)
46 axis->setLabel(unit.m_Name);
47
48 // ticker (depending on the type of unit)
49 axis->setTicker(axisTicker(unit.m_TimeUnit));
50 };
51 setAxisProperties(plot.xAxis, scalarSeries.xAxisUnit());
52 setAxisProperties(plot.yAxis, scalarSeries.valuesUnit());
53
22 54 // Display all data
23 55 component->rescaleAxes();
24 56
General Comments 0
You need to be logged in to leave comments. Login now