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
6a94f6af
Commit
6a94f6af
authored
Feb 12, 2017
by
Volker Krause
Browse files
Port category timeline chart to new chart API
parent
74ace635
Changes
3
Hide whitespace changes
Inline
Side-by-side
analyzer/analytics/categoryaggregator.cpp
View file @
6a94f6af
...
...
@@ -19,7 +19,17 @@
#include
<model/categoryaggregationmodel.h>
#include
<QtCharts/QAreaSeries>
#include
<QtCharts/QChart>
#include
<QtCharts/QDateTimeAxis>
#include
<QtCharts/QLineSeries>
#include
<QtCharts/QValueAxis>
#include
<QtCharts/QVXYModelMapper>
#include
<QApplication>
using
namespace
UserFeedback
::
Analyzer
;
using
namespace
QtCharts
;
CategoryAggregator
::
CategoryAggregator
()
=
default
;
CategoryAggregator
::~
CategoryAggregator
()
=
default
;
...
...
@@ -45,12 +55,51 @@ QAbstractItemModel* CategoryAggregator::timeAggregationModel()
m_model
->
setSourceModel
(
sourceModel
());
const
auto
e
=
aggregation
().
elements
().
at
(
0
);
m_model
->
setAggregationValue
(
e
.
schemaEntry
().
name
()
+
QLatin1Char
(
'.'
)
+
e
.
schemaEntryElement
().
name
());
QObject
::
connect
(
m_model
.
get
(),
&
QAbstractItemModel
::
modelReset
,
[
this
]()
{
m_timelineChart
.
reset
();
});
}
return
m_model
.
get
();
}
QtCharts
::
QChart
*
CategoryAggregator
::
timelineChart
()
{
// TODO
return
nullptr
;
if
(
m_timelineChart
)
return
m_timelineChart
.
get
();
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
);
QLineSeries
*
prevSeries
=
nullptr
;
for
(
int
i
=
1
;
i
<
timeAggregationModel
()
->
columnCount
();
++
i
)
{
auto
series
=
new
QLineSeries
;
auto
mapper
=
new
QVXYModelMapper
(
series
);
mapper
->
setModel
(
timeAggregationModel
());
mapper
->
setXColumn
(
0
);
mapper
->
setYColumn
(
i
);
mapper
->
setFirstRow
(
0
);
mapper
->
setSeries
(
series
);
auto
areaSeries
=
new
QAreaSeries
(
series
,
prevSeries
);
series
->
setParent
(
areaSeries
);
// otherwise series isn't deleted by removeAllSeries!
areaSeries
->
setName
(
timeAggregationModel
()
->
headerData
(
i
,
Qt
::
Horizontal
).
toString
().
toHtmlEscaped
());
m_timelineChart
->
addSeries
(
areaSeries
);
areaSeries
->
attachAxis
(
xAxis
);
areaSeries
->
attachAxis
(
yAxis
);
prevSeries
=
series
;
}
xAxis
->
setTickCount
(
std
::
min
(
timeAggregationModel
()
->
rowCount
(),
12
));
yAxis
->
setMin
(
0
);
yAxis
->
setMinorTickCount
(
4
);
return
m_timelineChart
.
get
();
}
analyzer/analytics/categoryaggregator.h
View file @
6a94f6af
...
...
@@ -40,6 +40,7 @@ public:
private:
std
::
unique_ptr
<
CategoryAggregationModel
>
m_model
;
std
::
unique_ptr
<
QtCharts
::
QChart
>
m_timelineChart
;
};
}}
...
...
analyzer/analytics/totalaggregator.cpp
View file @
6a94f6af
...
...
@@ -17,7 +17,6 @@
#include
"totalaggregator.h"
#include
<QtCharts/QAreaSeries>
#include
<QtCharts/QChart>
#include
<QtCharts/QDateTimeAxis>
#include
<QtCharts/QLineSeries>
...
...
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