Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Telemetry
KUserFeedback
Commits
74ace635
Commit
74ace635
authored
Feb 11, 2017
by
Volker Krause
Browse files
Port TotalAggregator to the new charts API
parent
f1116bd9
Changes
3
Hide whitespace changes
Inline
Side-by-side
analyzer/analytics/numericaggregator.cpp
View file @
74ace635
...
...
@@ -93,5 +93,7 @@ QtCharts::QChart* NumericAggregator::timelineChart()
l
.
push_back
(
timeAggregationModel
()
->
index
(
i
,
0
).
data
(
TimeAggregationModel
::
DateTimeRole
).
toDateTime
().
toString
(
QStringLiteral
(
"yyyy-MM-dd"
)));
}
xAxis
->
setCategories
(
l
);
yAxis
->
setMinorTickCount
(
4
);
return
m_timelineChart
.
get
();
}
analyzer/analytics/totalaggregator.cpp
View file @
74ace635
...
...
@@ -17,7 +17,20 @@
#include
"totalaggregator.h"
#include
<QtCharts/QAreaSeries>
#include
<QtCharts/QChart>
#include
<QtCharts/QDateTimeAxis>
#include
<QtCharts/QLineSeries>
#include
<QtCharts/QValueAxis>
#include
<QtCharts/QVXYModelMapper>
#include
<QApplication>
#include
<QAbstractItemModel>
#include
<numeric>
using
namespace
UserFeedback
::
Analyzer
;
using
namespace
QtCharts
;
TotalAggregator
::
TotalAggregator
()
=
default
;
TotalAggregator
::~
TotalAggregator
()
=
default
;
...
...
@@ -39,6 +52,37 @@ QAbstractItemModel* TotalAggregator::timeAggregationModel()
QtCharts
::
QChart
*
TotalAggregator
::
timelineChart
()
{
// TODO
return
nullptr
;
if
(
m_timelineChart
)
return
m_timelineChart
.
get
();
QObject
::
connect
(
sourceModel
(),
&
QAbstractItemModel
::
modelReset
,
sourceModel
(),
[
this
]()
{
m_timelineChart
.
reset
();
},
Qt
::
UniqueConnection
);
m_timelineChart
.
reset
(
new
QChart
);
m_timelineChart
->
setTheme
(
qApp
->
palette
().
color
(
QPalette
::
Window
).
lightnessF
()
<
0.25
?
QChart
::
ChartThemeDark
:
QChart
::
ChartThemeLight
);
auto
xAxis
=
new
QDateTimeAxis
(
m_timelineChart
.
get
());
xAxis
->
setFormat
(
QStringLiteral
(
"yyyy-MM-dd"
));
// TODO, follow aggregation mode
auto
yAxis
=
new
QValueAxis
(
m_timelineChart
.
get
());
m_timelineChart
->
addAxis
(
xAxis
,
Qt
::
AlignBottom
);
m_timelineChart
->
addAxis
(
yAxis
,
Qt
::
AlignLeft
);
auto
series
=
new
QLineSeries
(
m_timelineChart
.
get
());
series
->
setName
(
displayName
());
auto
mapper
=
new
QVXYModelMapper
(
series
);
mapper
->
setModel
(
timeAggregationModel
());
mapper
->
setXColumn
(
0
);
mapper
->
setYColumn
(
1
);
mapper
->
setFirstRow
(
0
);
mapper
->
setSeries
(
series
);
m_timelineChart
->
addSeries
(
series
);
series
->
attachAxis
(
xAxis
);
series
->
attachAxis
(
yAxis
);
xAxis
->
setTickCount
(
std
::
min
(
timeAggregationModel
()
->
rowCount
(),
12
));
yAxis
->
setMin
(
0
);
yAxis
->
setMinorTickCount
(
4
);
return
m_timelineChart
.
get
();
}
analyzer/analytics/totalaggregator.h
View file @
74ace635
...
...
@@ -22,6 +22,8 @@
#include
<QCoreApplication>
#include
<memory>
namespace
UserFeedback
{
namespace
Analyzer
{
...
...
@@ -36,6 +38,9 @@ public:
QString
displayName
()
const
override
;
QAbstractItemModel
*
timeAggregationModel
()
override
;
QtCharts
::
QChart
*
timelineChart
()
override
;
private:
std
::
unique_ptr
<
QtCharts
::
QChart
>
m_timelineChart
;
};
}}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment