|
@@
-28,7
+28,8
public:
|
|
28
|
XYGrid* m_grid;
|
|
28
|
XYGrid* m_grid;
|
|
29
|
QRect m_rect;
|
|
29
|
QRect m_rect;
|
|
30
|
QList<const QChartSeries*> m_series;
|
|
30
|
QList<const QChartSeries*> m_series;
|
|
31
|
QList<XYPlotDomain> m_plotDataList;
|
|
31
|
QList<XYPlotDomain> m_plotDomainList;
|
|
|
|
|
32
|
QList<XYLineChartItem*> m_xyLineChartItems;
|
|
32
|
QList<QGraphicsItem*> m_items;
|
|
33
|
QList<QGraphicsItem*> m_items;
|
|
33
|
int m_plotDataIndex;
|
|
34
|
int m_plotDataIndex;
|
|
34
|
int m_marginSize;
|
|
35
|
int m_marginSize;
|
|
@@
-44,21
+45,6
d_ptr(new QChartPrivate(this))
|
|
44
|
// set axis
|
|
45
|
// set axis
|
|
45
|
Q_D(QChart);
|
|
46
|
Q_D(QChart);
|
|
46
|
d->m_axisY->rotate(90);
|
|
47
|
d->m_axisY->rotate(90);
|
|
47
|
|
|
|
|
|
48
|
//TODO hardcoded values , to removed soon
|
|
|
|
|
49
|
XYPlotDomain data;
|
|
|
|
|
50
|
data.m_minX = 0.0;
|
|
|
|
|
51
|
data.m_maxX = 100.0;
|
|
|
|
|
52
|
data.m_minY = 0.0;
|
|
|
|
|
53
|
data.m_maxY = 100.0;
|
|
|
|
|
54
|
data.m_ticksX=4;
|
|
|
|
|
55
|
data.m_ticksY=4;
|
|
|
|
|
56
|
|
|
|
|
|
57
|
d->m_plotDataList.clear();
|
|
|
|
|
58
|
d->m_plotDataList << data;
|
|
|
|
|
59
|
|
|
|
|
|
60
|
d->m_grid->setZValue(10);
|
|
|
|
|
61
|
d->m_grid->setXYPlotData(d->m_plotDataList.at(0));
|
|
|
|
|
62
|
}
|
|
48
|
}
|
|
63
|
|
|
49
|
|
|
64
|
QChart::~QChart(){}
|
|
50
|
QChart::~QChart(){}
|
|
@@
-78,9
+64,28
void QChart::addSeries(QChartSeries* series)
|
|
78
|
switch(series->type())
|
|
64
|
switch(series->type())
|
|
79
|
{
|
|
65
|
{
|
|
80
|
case QChartSeries::SeriesTypeLine: {
|
|
66
|
case QChartSeries::SeriesTypeLine: {
|
|
81
|
XYLineChartItem* item = new XYLineChartItem(static_cast<QXYChartSeries*>(series),this);
|
|
67
|
|
|
82
|
item->updateXYPlotData(d->m_plotDataList.at(0));
|
|
68
|
QXYChartSeries* xyseries = static_cast<QXYChartSeries*>(series);
|
|
83
|
d->m_items<<item;
|
|
69
|
|
|
|
|
|
70
|
XYPlotDomain domain;
|
|
|
|
|
71
|
//TODO "nice numbers algorithm"
|
|
|
|
|
72
|
domain.m_ticksX=4;
|
|
|
|
|
73
|
domain.m_ticksY=4;
|
|
|
|
|
74
|
|
|
|
|
|
75
|
for (int i = 0 ; i < xyseries->count() ; i++)
|
|
|
|
|
76
|
{
|
|
|
|
|
77
|
qreal x = xyseries->x(i);
|
|
|
|
|
78
|
qreal y = xyseries->y(i);
|
|
|
|
|
79
|
domain.m_minX = qMin(domain.m_minX,x);
|
|
|
|
|
80
|
domain.m_minY = qMin(domain.m_minY,y);
|
|
|
|
|
81
|
domain.m_maxX = qMax(domain.m_maxX,x);
|
|
|
|
|
82
|
domain.m_maxY = qMax(domain.m_maxY,y);
|
|
|
|
|
83
|
}
|
|
|
|
|
84
|
|
|
|
|
|
85
|
XYLineChartItem* item = new XYLineChartItem(xyseries,this);
|
|
|
|
|
86
|
item->updateXYPlotDomain(domain);
|
|
|
|
|
87
|
d->m_plotDomainList<<domain;
|
|
|
|
|
88
|
d->m_xyLineChartItems<<item;
|
|
84
|
break;
|
|
89
|
break;
|
|
85
|
}
|
|
90
|
}
|
|
86
|
case QChartSeries::SeriesTypeScatter: {
|
|
91
|
case QChartSeries::SeriesTypeScatter: {
|
|
@@
-114,16
+119,22
QChartSeries* QChart::createSeries(QList<qreal> x, QList<qreal> y, QChartSeries:
|
|
114
|
void QChart::setSize(const QSizeF& size)
|
|
119
|
void QChart::setSize(const QSizeF& size)
|
|
115
|
{
|
|
120
|
{
|
|
116
|
Q_D(QChart);
|
|
121
|
Q_D(QChart);
|
|
117
|
//TODO refactor to setGeometry
|
|
|
|
|
118
|
d->m_rect = QRect(QPoint(0,0),size.toSize());
|
|
122
|
d->m_rect = QRect(QPoint(0,0),size.toSize());
|
|
119
|
d->m_rect.adjust(margin(),margin(),-margin(),-margin());
|
|
123
|
d->m_rect.adjust(margin(),margin(),-margin(),-margin());
|
|
120
|
d->m_grid->setPos(d->m_rect.topLeft());
|
|
124
|
d->m_grid->setPos(d->m_rect.topLeft());
|
|
121
|
d->m_grid->setSize(d->m_rect.size());
|
|
125
|
d->m_grid->setSize(d->m_rect.size());
|
|
122
|
d->m_plotDataList[0].m_viewportRect = d->m_rect;
|
|
|
|
|
123
|
// TODO: line chart items would need to be updated separately as they don't support update
|
|
126
|
// TODO: line chart items would need to be updated separately as they don't support update
|
|
124
|
// via paint method
|
|
127
|
// via paint method
|
|
125
|
foreach(QGraphicsItem* item , d->m_items)
|
|
128
|
for (int i =0; i< d->m_plotDomainList.size();i++)
|
|
126
|
reinterpret_cast<XYLineChartItem*>(item)->updateXYPlotData(d->m_plotDataList.at(0));
|
|
129
|
{
|
|
|
|
|
130
|
d->m_plotDomainList[i].m_viewportRect = d->m_rect;
|
|
|
|
|
131
|
|
|
|
|
|
132
|
}
|
|
|
|
|
133
|
|
|
|
|
|
134
|
foreach(XYLineChartItem* item , d->m_xyLineChartItems)
|
|
|
|
|
135
|
item->updateXYPlotDomain(d->m_plotDomainList.at(d->m_plotDataIndex));
|
|
|
|
|
136
|
|
|
|
|
|
137
|
d->m_grid->setXYPlotData(d->m_plotDomainList.at(d->m_plotDataIndex));
|
|
127
|
update();
|
|
138
|
update();
|
|
128
|
}
|
|
139
|
}
|
|
129
|
|
|
140
|
|