##// END OF EJS Templates
Adds more axis handling...
Michal Klocek -
r176:6a1519e364a3
parent child
Show More
@@ -0,0 +1,15
1 !include( ../../common.pri ) {
2 error( "Couldn't find the common.pri file!" )
3 }
4
5 !include( ../../integrated.pri ) {
6 error( "Couldn't find the integrated.pri file !")
7 }
8
9 TARGET = axisChart
10 TEMPLATE = app
11 QT += core gui
12 SOURCES += main.cpp
13
14
15
@@ -0,0 +1,56
1 #include <QApplication>
2 #include <QMainWindow>
3 #include <qchartview.h>
4 #include <qlinechartseries.h>
5 #include <qchart.h>
6 #include <qchartaxis.h>
7 #include <cmath>
8
9 QTCOMMERCIALCHART_USE_NAMESPACE
10
11 #define PI 3.14159265358979
12
13 int main(int argc, char *argv[])
14 {
15 QApplication a(argc, argv);
16
17 QMainWindow window;
18
19 QLineChartSeries* series0 = new QLineChartSeries();
20 QPen blue(Qt::blue);
21 blue.setWidth(3);
22 series0->setPen(blue);
23 QLineChartSeries* series1 = new QLineChartSeries();
24 QPen red(Qt::red);
25 red.setWidth(3);
26 series1->setPen(red);
27
28 int numPoints = 100;
29
30 for (int x = 0; x <= numPoints; ++x) {
31 series0->add(x, fabs(sin(PI/50*x)*100));
32 series1->add(x, fabs(cos(PI/50*x)*100));
33 }
34
35 QChartView* chartView = new QChartView(&window);
36
37 chartView->setRenderHint(QPainter::Antialiasing);
38 chartView->setTitle("Basic line chart example");
39 chartView->addSeries(series0);
40 chartView->addSeries(series1);
41 chartView->setChartBackgroundBrush(Qt::white);
42
43 QChartAxis axis = chartView->defaultAxisX();
44 axis.setLabelsOrientation(QChartAxis::LabelsOrientationSlide);
45 axis.setGridPen(Qt::DashLine);
46
47 chartView->setDefaultAxisX(axis);
48 //axis.setShadesBrush(Qt::gray);
49 chartView->setDefaultAxisY(axis);
50
51 window.setCentralWidget(chartView);
52 window.resize(400, 300);
53 window.show();
54
55 return a.exec();
56 }
@@ -7,4 +7,5 SUBDIRS += linechart \
7 percentbarchart \
7 percentbarchart \
8 scatter \
8 scatter \
9 piechart \
9 piechart \
10 dynamiclinechart
10 dynamiclinechart \
11 axischart
@@ -3,18 +3,22
3 #include <QPainter>
3 #include <QPainter>
4 #include <QDebug>
4 #include <QDebug>
5
5
6 #define LABEL_PADDING 5
6 static int label_padding = 5;
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 AxisItem::AxisItem(QChartAxis* axis,AxisType type,QGraphicsItem* parent) :
10 AxisItem::AxisItem(AxisType type,QGraphicsItem* parent) :
11 ChartItem(parent),
11 ChartItem(parent),
12 m_axis(axis),
12 m_ticks(4),
13 m_ticks(4),
13 m_type(type),
14 m_type(type)
14 m_labelsAngle(0),
15 m_shadesEnabled(true),
16 m_grid(this),
17 m_shades(this),
18 m_labels(this)
15 {
19 {
16 //initial initialization
20 //initial initialization
17 handleAxisChanged();
21 createItems();
18 }
22 }
19
23
20 AxisItem::~AxisItem()
24 AxisItem::~AxisItem()
@@ -26,148 +30,257 QRectF AxisItem::boundingRect() const
26 return m_rect;
30 return m_rect;
27 }
31 }
28
32
33 void AxisItem::createItems()
34 {
35 for (int i = 0; i <= m_ticks; ++i) {
36 m_grid.addToGroup(new QGraphicsLineItem(this));
37 m_labels.addToGroup(new QGraphicsSimpleTextItem(this));
38 if(i%2) m_shades.addToGroup(new QGraphicsRectItem(this));
39 }
40 }
41
42 void AxisItem::clear()
43 {
44 foreach(QGraphicsItem* item , m_shades.childItems()) {
45 delete item;
46 }
47
48 foreach(QGraphicsItem* item , m_grid.childItems()) {
49 delete item;
50 }
51
52 foreach(QGraphicsItem* item , m_labels.childItems()) {
53 delete item;
54 }
55
56 }
57
58 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
59 {
29
60
30 /*
61 }
31 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
62
63 void AxisItem::updateDomain()
32 {
64 {
33 if (!m_rect.isValid())
34 return;
35
65
36 if(m_type==X_AXIS) {
66 QList<QGraphicsItem *> lines = m_grid.childItems();
67 QList<QGraphicsItem *> labels = m_labels.childItems();
68 QList<QGraphicsItem *> shades = m_shades.childItems();
37
69
38 const qreal deltaX = m_rect.width() / m_ticks;
70 switch (m_type)
71 {
72 case X_AXIS:
73 {
74 const qreal deltaX = m_rect.width() / m_ticks;
39
75
40 for (int i = 0; i <= m_ticks; ++i) {
76 for (int i = 0; i <= m_ticks; ++i) {
41
77
42 int x = i * deltaX + m_rect.left();
78 int x = i * deltaX + m_rect.left();
43
79
44 if(i==0) x--;
80 qreal label = m_domain.m_minX + (i * m_domain.spanX()/ m_ticks);
45 if(i==m_ticks) x++;
46
81
47 qreal label = m_plotDomain.m_minX + (i * m_plotDomain.spanX()
82 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
48 / m_ticks);
83 lineItem->setLine(x, m_rect.top(), x, m_rect.bottom());
49 painter->drawLine(x, m_rect.top()-1, x, m_rect.bottom()+1);
50 // painter->drawLine(x, m_rect.bottom()-1, x, m_rect.bottom()-1 + 5);
51
84
52 painter->drawText(x - 50, m_rect.bottom() + 5, 100, 20,Qt::AlignHCenter | Qt::AlignTop, QString::number(label));
85 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
53 }
86 labelItem->setText(QString::number(label));
54 }
87 QPointF center = labelItem->boundingRect().center();
88 labelItem->setTransformOriginPoint(center.x(), center.y());
89 labelItem->setPos(x - center.x(), m_rect.bottom() + label_padding);
55
90
56 if(m_type==Y_AXIS) {
91 if(i%2){
92 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
93 rectItem->setRect(x,m_rect.top(),deltaX,m_rect.height());
94 }
95 }
96 }
97 break;
57
98
58 const qreal deltaY = (m_rect.height()) / m_ticks;
99 case Y_AXIS:
100 {
101 const qreal deltaY = m_rect.height()/ m_ticks;
59
102
60 for (int j = 0; j <= m_ticks; ++j) {
103 for (int i = 0; i <= m_ticks; ++i) {
61
104
62 int y = j * -deltaY + m_rect.bottom();
105 int y = i * -deltaY + m_rect.bottom();
63
106
64 if(j==0) y++;
107 qreal label = m_domain.m_minY + (i * m_domain.spanY()/ m_ticks);
65 if(j==m_ticks) y--;
66
108
67 qreal label = m_plotDomain.m_minY + (j * m_plotDomain.spanY()
109 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
68 / m_ticks);
110 lineItem->setLine(m_rect.left() , y, m_rect.right(), y);
69
111
70 painter->drawLine(m_rect.left()-1, y, m_rect.right()+1, y);
112 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
71 //painter->drawLine(m_rect.left() - 5, y, m_rect.left(), y);
113 labelItem->setText(QString::number(label));
72 //TODO : margin = 50 ;
114 QPointF center = labelItem->boundingRect().center();
73 painter->drawText(m_rect.left() - 50, y - 10, 50 - 5, 20,
115 labelItem->setTransformOriginPoint(center.x(), center.y());
74 Qt::AlignRight | Qt::AlignVCenter,
116 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , y-center.y());
75 QString::number(label));
76 }
77 }
78
117
79 //painter->drawRect(m_rect.adjusted(0, 0, -1, -1));
118
119 if(i%2){
120 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
121 rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY);
122 }
123 }
124 }
125 break;
126 default:
127 qDebug()<<"Unknown axis type";
128 break;
129 }
80 }
130 }
81 */
131
82 void AxisItem::createItems()
132 void AxisItem::handleAxisChanged(const QChartAxis& axis)
83 {
133 {
134 if(axis.isGridVisible()) {
135 setGridOpacity(100);
136 }
137 else {
138 setGridOpacity(0);
139 }
84
140
85 if(!m_rect.isValid()) return;
141 if(axis.isLabelsVisible())
142 {
143 setLabelsOpacity(100);
144 }
145 else {
146 setLabelsOpacity(0);
147 }
86
148
87 switch (m_type)
149 if(axis.isShadesVisible()) {
150 setShadesOpacity(100);
151 }
152 else {
153 setShadesOpacity(0);
154 }
155
156 switch(axis.labelsOrientation())
88 {
157 {
89 case X_AXIS:
158 case QChartAxis::LabelsOrientationHorizontal:
90 {
159 setLabelsAngle(0);
91 const qreal deltaX = m_rect.width() / m_ticks;
160 break;
161 case QChartAxis::LabelsOrientationVertical:
162 setLabelsAngle(90);
163 break;
164 case QChartAxis::LabelsOrientationSlide:
165 setLabelsAngle(-45);
166 break;
167 default:
168 break;
169 }
92
170
93 for (int i = 0; i <= m_ticks; ++i) {
171 setLabelsPen(axis.labelsPen());
172 setLabelsBrush(axis.labelsBrush());
173 setLabelsFont(axis.labelFont());
174 setGridPen(axis.gridPen());
175 setShadesPen(axis.shadesPen());
176 setShadesBrush(axis.shadesBrush());
94
177
95 int x = i * deltaX + m_rect.left();
178 }
96
179
97 qreal label = m_domain.m_minX + (i * m_domain.spanX()/ m_ticks);
180 void AxisItem::handleDomainChanged(const Domain& domain)
181 {
182 m_domain = domain;
183 updateDomain();
184 update();
185 }
98
186
99 m_grid<<new QGraphicsLineItem(x, m_rect.top(), x, m_rect.bottom(),this);
187 void AxisItem::handleGeometryChanged(const QRectF& rect)
188 {
189 m_rect = rect;
190 updateDomain();
191 update();
192 }
100
193
101 QGraphicsSimpleTextItem* text = new QGraphicsSimpleTextItem(QString::number(label),this);
194 void AxisItem::setGridOpacity(qreal opacity)
102 QPointF center = text->boundingRect().center();
195 {
103 text->setPos(x - center.x(), m_rect.bottom() + LABEL_PADDING);
196 m_grid.setOpacity(opacity);
104 //text->rotate(-45);
197 }
105 m_labels<<text;
106 }
107 }
108 break;
109
198
110 case Y_AXIS:
111 {
112 const qreal deltaY = m_rect.height()/ m_ticks;
113
199
114 for (int j = 0; j <= m_ticks; ++j) {
200 qreal AxisItem::gridOpacity() const
201 {
202 return m_grid.opacity();
203 }
115
204
116 int y = j * -deltaY + m_rect.bottom();
205 void AxisItem::setLabelsOpacity(qreal opacity)
206 {
207 m_labels.setOpacity(opacity);
208 }
117
209
118 qreal label = m_domain.m_minY + (j * m_domain.spanY()
210 qreal AxisItem::labelsOpacity() const
119 / m_ticks);
211 {
212 return m_labels.opacity();
213 }
120
214
121 m_grid<<new QGraphicsLineItem(m_rect.left() , y, m_rect.right(), y,this);
215 void AxisItem::setShadesOpacity(qreal opacity)
122 QGraphicsSimpleTextItem* text = new QGraphicsSimpleTextItem(QString::number(label),this);
216 {
123 QPointF center = text->boundingRect().center();
217 m_shades.setOpacity(opacity);
124 text->setPos(m_rect.left() - text->boundingRect().width() - LABEL_PADDING , y-center.y());
218 }
125
219
126 m_labels<<text;
220 qreal AxisItem::shadesOpacity() const
221 {
222 return m_shades.opacity();
223 }
127
224
128 }
225 void AxisItem::setLabelsAngle(int angle)
129 }
226 {
130 break;
227 foreach(QGraphicsItem* item , m_labels.childItems()) {
131 default:
228 QPointF center = item->boundingRect().center();
132 qDebug()<<"Unknown axis type";
229 item->setRotation(angle);
133 break;
134 }
230 }
231
232 m_labelsAngle=angle;
135 }
233 }
136
234
137 void AxisItem::clear()
235 void AxisItem::setLabelsPen(const QPen& pen)
138 {
236 {
139 qDeleteAll(m_shades);
237 foreach(QGraphicsItem* item , m_labels.childItems()) {
140 m_shades.clear();
238 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
141 qDeleteAll(m_grid);
239 }
142 m_grid.clear();
143 qDeleteAll(m_labels);
144 m_labels.clear();
145 }
240 }
146
241
147 void AxisItem::updateDomain()
242 void AxisItem::setLabelsBrush(const QBrush& brush)
148 {
243 {
149 clear();
244 foreach(QGraphicsItem* item , m_labels.childItems()) {
150 createItems();
245 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
246 }
151 }
247 }
152
248
153 void AxisItem::handleAxisChanged()
249 void AxisItem::setLabelsFont(const QFont& font)
154 {
250 {
155 //m_axis->
251 foreach(QGraphicsItem* item , m_labels.childItems()) {
252 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
253 }
156 }
254 }
157
255
158 void AxisItem::handleDomainChanged(const Domain& domain)
256 void AxisItem::setShadesBrush(const QBrush& brush)
159 {
257 {
160 m_domain = domain;
258 foreach(QGraphicsItem* item , m_shades.childItems()) {
161 clear();
259 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
162 createItems();
260 }
163 }
261 }
164
262
165 void AxisItem::handleGeometryChanged(const QRectF& rect)
263 void AxisItem::setShadesPen(const QPen& pen)
166 {
264 {
167 Q_ASSERT(rect.isValid());
265 foreach(QGraphicsItem* item , m_shades.childItems()) {
168 m_rect = rect;
266 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
267 }
268 }
269
270 void AxisItem::setGridPen(const QPen& pen)
271 {
272 foreach(QGraphicsItem* item , m_grid.childItems()) {
273 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
274 }
275 }
276
277 void AxisItem::setTicks(int count)
278 {
279 if(count!=m_ticks){
169 clear();
280 clear();
281 m_ticks=count;
170 createItems();
282 createItems();
283 }
171 }
284 }
172
285
173 //TODO "nice numbers algorithm"
286 //TODO "nice numbers algorithm"
@@ -15,46 +15,58 class AxisItem : public QObject, public ChartItem
15 public:
15 public:
16 enum AxisType{X_AXIS,Y_AXIS};
16 enum AxisType{X_AXIS,Y_AXIS};
17
17
18 AxisItem(QChartAxis* axis,AxisType type = X_AXIS,QGraphicsItem* parent = 0);
18 AxisItem(AxisType type = X_AXIS,QGraphicsItem* parent = 0);
19 ~AxisItem();
19 ~AxisItem();
20
20
21 //from QGraphicsItem
21 //from QGraphicsItem
22 QRectF boundingRect() const;
22 QRectF boundingRect() const;
23 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){};
23 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
24
24
25 protected slots:
25 AxisType axisType() const {return m_type;};
26 void handleAxisChanged();
27 void handleDomainChanged(const Domain& domain);
28 void handleGeometryChanged(const QRectF& size);
29
26
30 protected:
27 void setGridOpacity(qreal opacity);
31 void updateDomain();
28 qreal gridOpacity() const;
32
29
33 private:
30 void setLabelsOpacity(qreal opacity);
34 void clear();
31 qreal labelsOpacity() const;
35
32
36 public:
33 void setShadesOpacity(qreal opacity);
37 AxisType axisType() const {return m_type;};
34 qreal shadesOpacity() const;
38
35
39 protected:
36 void setLabelsAngle(int angle);
37 int labelsAngle()const { return m_labelsAngle; }
38
39 void setTicks(int count);
40 int ticks() const { return m_ticks;}
40
41
42 void setShadesBrush(const QBrush& brush);
43 void setShadesPen(const QPen& pen);
41
44
45 void setGridPen(const QPen& pen);
46
47 void setLabelsPen(const QPen& pen);
48 void setLabelsBrush(const QBrush& brush);
49 void setLabelsFont(const QFont& font);
50
51 public slots:
52 void handleAxisChanged(const QChartAxis& axis);
53 void handleDomainChanged(const Domain& domain);
54 void handleGeometryChanged(const QRectF& size);
55 protected:
56 void updateDomain();
42 private:
57 private:
58 void clear();
43 void createItems();
59 void createItems();
44 private:
60 private:
45
46 QChartAxis* m_axis;
47 AxisType m_type;
61 AxisType m_type;
48 int m_ticks;
62 int m_ticks;
49 Domain m_domain;
63 Domain m_domain;
50 QRectF m_rect;
64 QRectF m_rect;
51
65 int m_labelsAngle;
52 QPainterPath m_path;
66 bool m_shadesEnabled;
53
67 QGraphicsItemGroup m_grid;
54
68 QGraphicsItemGroup m_shades;
55 QList<QGraphicsLineItem*> m_grid;
69 QGraphicsItemGroup m_labels;
56 QList<QGraphicsRectItem*> m_shades;
57 QList<QGraphicsSimpleTextItem*> m_labels;
58
70
59 };
71 };
60
72
@@ -26,15 +26,13 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(char
26 m_chart(chart),
26 m_chart(chart),
27 m_dataset(dataset),
27 m_dataset(dataset),
28 m_chartTheme(0),
28 m_chartTheme(0),
29 m_axisXItem(new AxisItem(AxisItem::X_AXIS,m_chart)),
30 m_axisYItem(new AxisItem(AxisItem::Y_AXIS,m_chart)),
29 m_domainIndex(0),
31 m_domainIndex(0),
30 m_marginSize(0),
32 m_marginSize(0),
31 m_axisX(new QChartAxis(this)),
32 m_axisY(new QChartAxis(this)),
33 m_rect(QRectF(QPoint(0,0),m_chart->size()))
33 m_rect(QRectF(QPoint(0,0),m_chart->size()))
34 {
34 {
35 setChartTheme(QChart::ChartThemeDefault);
35 setChartTheme(QChart::ChartThemeDefault);
36 m_axisItems[m_axisX] = new AxisItem(m_axisX,AxisItem::X_AXIS,m_chart);
37 m_axisItems[m_axisY] = new AxisItem(m_axisY,AxisItem::Y_AXIS,m_chart);
38 createConnections();
36 createConnections();
39 }
37 }
40
38
@@ -46,14 +44,10 void ChartPresenter::createConnections()
46 {
44 {
47 QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged()));
45 QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged()));
48 QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*)));
46 QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*)));
49
47 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),m_axisXItem,SLOT(handleGeometryChanged(const QRectF&)));
50 QMapIterator<QChartAxis*,AxisItem*> i(m_axisItems);
48 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),m_axisXItem,SLOT(handleDomainChanged(const Domain&)));
51
49 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),m_axisYItem,SLOT(handleGeometryChanged(const QRectF&)));
52 while (i.hasNext()) {
50 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),m_axisYItem,SLOT(handleDomainChanged(const Domain&)));
53 i.next();
54 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),i.value(),SLOT(handleGeometryChanged(const QRectF&)));
55 QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),i.value(),SLOT(handleDomainChanged(const Domain&)));
56 }
57 }
51 }
58
52
59 void ChartPresenter::handleGeometryChanged()
53 void ChartPresenter::handleGeometryChanged()
@@ -206,58 +200,70 void ChartPresenter::setChartTheme(QChart::ChartTheme theme)
206 i.next();
200 i.next();
207 index++;
201 index++;
208 m_chartTheme->decorate(i.value(),i.key(),index);
202 m_chartTheme->decorate(i.value(),i.key(),index);
209 }
210 }
203 }
211
204
205 m_chartTheme->decorate(m_axisX, m_axisXItem);
206 m_chartTheme->decorate(m_axisY, m_axisYItem);
207
208 }
209
212
210
213 QChart::ChartTheme ChartPresenter::chartTheme()
211 QChart::ChartTheme ChartPresenter::chartTheme()
214 {
212 {
215 return m_chartTheme->id();
213 return m_chartTheme->id();
216 }
214 }
217
215
218 QChartAxis* ChartPresenter::axisX()
216 void ChartPresenter::setDefaultAxisX(const QChartAxis& axis)
219 {
217 {
220 return m_axisX;
218 //if(m_axisX != axis) {
219 m_axisX = axis;
220 m_axisXItem->handleAxisChanged(m_axisX);
221 //}
221 }
222 }
222
223
223 QChartAxis* ChartPresenter::axisY()
224 void ChartPresenter::setDefaultAxisY(const QChartAxis& axis)
224 {
225 {
225 return m_axisY;
226 // if(m_axisY != axis) {
227 m_axisY = axis;
228 m_axisYItem->handleAxisChanged(m_axisY);
229 //}
226 }
230 }
227
231
228 QChartAxis* ChartPresenter::addAxisX()
232 QChartAxis ChartPresenter::defaultAxisX() const
229 {
233 {
230 //only one axis
234 return m_axisX;
231 if(m_axisX==0){
232 m_axisX = new QChartAxis(this);
233 m_axisItems[m_axisX] = new AxisItem(m_axisX,AxisItem::X_AXIS,m_chart);
234 }
235 return m_axisX;
236 }
235 }
237
236
238 QChartAxis* ChartPresenter::addAxisY()
237 QChartAxis ChartPresenter::defaultAxisY() const
239 {
238 {
240 if(m_axisY==0){
239 return m_axisY;
241 m_axisY = new QChartAxis(this);
240 }
242 m_axisItems[m_axisY] = new AxisItem(m_axisY,AxisItem::Y_AXIS,m_chart);
243 return m_axisY;
244 }
245
241
246 QChartAxis* axis = new QChartAxis(this);
242 QChartAxis ChartPresenter::axisY(int id) const
247 m_axisItems[axis] = new AxisItem(axis,AxisItem::Y_AXIS,m_chart);
243 {
248 return axis;
244 return m_axis.value(id);
249 }
245 }
250
246
251 void ChartPresenter::removeAxis(QChartAxis* axis)
247 int ChartPresenter::addAxisY(const QChartAxis& axis)
252 {
248 {
253 AxisItem* item = m_axisItems.take(axis);
249 int key =0 ;
254 if(item){
250
255 delete item;
251 while(m_axis.contains(key)){
256 delete axis;
252 key++;
253 //TODO overflow
257 }
254 }
258 //reset pointers to default ones
255
259 if(axis == m_axisX) m_axisX=0;
256 m_axis.insert(key,axis);
260 else if(axis == m_axisY) m_axisY=0;
257 m_axisItems.insert(key,new AxisItem(AxisItem::Y_AXIS,m_chart));
258
259 return key;
260 }
261
262
263 void ChartPresenter::removeAxisY(int id)
264 {
265 m_axis.remove(id);
266 delete m_axisItems.take(id);
261 }
267 }
262
268
263 #include "moc_chartpresenter_p.cpp"
269 #include "moc_chartpresenter_p.cpp"
@@ -3,6 +3,7
3
3
4 #include "qchartglobal.h"
4 #include "qchartglobal.h"
5 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
5 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
6 #include "qchartaxis.h"
6 #include <QRectF>
7 #include <QRectF>
7
8
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -33,11 +34,13 public:
33 void setChartTheme(QChart::ChartTheme theme);
34 void setChartTheme(QChart::ChartTheme theme);
34 QChart::ChartTheme chartTheme();
35 QChart::ChartTheme chartTheme();
35
36
36 QChartAxis* axisX();
37 void setDefaultAxisX(const QChartAxis& axis);
37 QChartAxis* axisY();
38 void setDefaultAxisY(const QChartAxis& axis);
38 QChartAxis* addAxisX();
39 QChartAxis defaultAxisX() const;
39 QChartAxis* addAxisY();
40 QChartAxis defaultAxisY() const;
40 void removeAxis(QChartAxis* axis);
41 QChartAxis axisY(int id) const;
42 int addAxisY(const QChartAxis& axis);
43 void removeAxisY(int id);
41
44
42 private:
45 private:
43 void createConnections();
46 void createConnections();
@@ -48,19 +51,20 public slots:
48 void handleSeriesChanged(QChartSeries* series);
51 void handleSeriesChanged(QChartSeries* series);
49 //void handleDomainChanged(Domain oldDomain,Domain newDomain);
52 //void handleDomainChanged(Domain oldDomain,Domain newDomain);
50 void handleGeometryChanged();
53 void handleGeometryChanged();
51
52 signals:
54 signals:
53 void geometryChanged(const QRectF& rect);
55 void geometryChanged(const QRectF& rect);
54
55 private:
56 private:
56 QMap<QChartSeries*,ChartItem*> m_chartItems;
57 QMap<QChartSeries*,ChartItem*> m_chartItems;
57 QMap<QChartAxis*,AxisItem*> m_axisItems;
58 QMap<int,AxisItem*> m_axisItems;
59 QMap<int,QChartAxis> m_axis;
58 QChart* m_chart;
60 QChart* m_chart;
59 ChartDataSet* m_dataset;
61 ChartDataSet* m_dataset;
60 QVector<Domain> m_domains;
62 QVector<Domain> m_domains;
61 ChartTheme *m_chartTheme;
63 ChartTheme *m_chartTheme;
62 QChartAxis* m_axisX;
64 QChartAxis m_axisX;
63 QChartAxis* m_axisY;
65 AxisItem* m_axisXItem;
66 QChartAxis m_axisY;
67 AxisItem* m_axisYItem;
64 int m_domainIndex;
68 int m_domainIndex;
65 int m_marginSize;
69 int m_marginSize;
66 QRectF m_rect;
70 QRectF m_rect;
@@ -1,5 +1,6
1 #include "charttheme_p.h"
1 #include "charttheme_p.h"
2 #include "qchart.h"
2 #include "qchart.h"
3 #include "qchartaxis.h"
3
4
4
5
5 //series
6 //series
@@ -207,4 +208,13 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/)
207 }
208 }
208
209
209
210
211 void ChartTheme::decorate(QChartAxis& axis,AxisItem* item)
212 {
213 //TODO: dummy defults for now
214
215 axis.setLabelsBrush(Qt::black);
216 axis.setLabelsPen(Qt::NoPen);
217 item->handleAxisChanged(axis);
218 }
219
210 QTCOMMERCIALCHART_END_NAMESPACE
220 QTCOMMERCIALCHART_END_NAMESPACE
@@ -34,6 +34,7 public:
34 void decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count);
34 void decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count);
35 void decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count);
35 void decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count);
36 void decorate(PiePresenter* item, QPieSeries* series, int count);
36 void decorate(PiePresenter* item, QPieSeries* series, int count);
37 void decorate(QChartAxis& axis,AxisItem* item);
37
38
38 protected:
39 protected:
39 QChart::ChartTheme m_id;
40 QChart::ChartTheme m_id;
@@ -143,29 +143,39 void QChart::zoomReset()
143 m_presenter->zoomReset();
143 m_presenter->zoomReset();
144 }
144 }
145
145
146 QChartAxis* QChart::axisX()
146 void QChart::setDefaultAxisX(const QChartAxis& axis)
147 {
147 {
148 return m_presenter->axisX();
148 m_presenter->setDefaultAxisX(axis);
149 }
149 }
150
150
151 QChartAxis* QChart::axisY()
151 void QChart::setDefaultAxisY(const QChartAxis& axis)
152 {
152 {
153 return m_presenter->axisY();
153 m_presenter->setDefaultAxisY(axis);
154 }
154 }
155
155
156 QChartAxis* QChart::addAxisX()
156 QChartAxis QChart::defaultAxisX() const
157 {
157 {
158 return m_presenter->addAxisX();
158 return m_presenter->defaultAxisX();
159 }
159 }
160
160
161 QChartAxis* QChart::addAxisY()
161 QChartAxis QChart::defaultAxisY() const
162 {
162 {
163 return m_presenter->addAxisY();
163 return m_presenter->defaultAxisY();
164 }
164 }
165
165
166 void QChart::removeAxis(QChartAxis* axis)
166 int QChart::addAxisY(const QChartAxis& axis)
167 {
167 {
168 m_presenter->removeAxis(axis);
168 return m_presenter->addAxisY(axis);
169 }
170
171 QChartAxis QChart::axisY(int id) const
172 {
173 return m_presenter->axisY(id);
174 }
175
176 void QChart::removeAxisY(int id)
177 {
178 m_presenter->removeAxisY(id);
169 }
179 }
170
180
171 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
181 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
@@ -67,11 +67,13 public:
67 void zoomOut();
67 void zoomOut();
68 void zoomReset();
68 void zoomReset();
69
69
70 QChartAxis* axisX();
70 void setDefaultAxisX(const QChartAxis& axis);
71 QChartAxis* axisY();
71 void setDefaultAxisY(const QChartAxis& axis);
72 QChartAxis* addAxisX();
72 QChartAxis defaultAxisX() const;
73 QChartAxis* addAxisY();
73 QChartAxis defaultAxisY() const;
74 void removeAxis(QChartAxis* axis);
74 QChartAxis axisY(int id) const;
75 int addAxisY(const QChartAxis& axis);
76 void removeAxisY(int id);
75
77
76 protected:
78 protected:
77 void resizeEvent(QGraphicsSceneResizeEvent *event);
79 void resizeEvent(QGraphicsSceneResizeEvent *event);
@@ -1,13 +1,12
1
2 #include "qchartaxis.h"
1 #include "qchartaxis.h"
3
2
4 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5
4
6 QChartAxis::QChartAxis(QObject* parent):QObject(parent),
5 QChartAxis::QChartAxis():
7 m_axisVisible(true),
6 m_axisVisible(true),
8 m_girdVisible(true),
7 m_gridVisible(true),
9 m_labelsVisible(true),
8 m_labelsVisible(true),
10 m_rowShadesVisible(true)
9 m_shadesVisible(true)
11 {
10 {
12 // TODO Auto-generated constructor stub
11 // TODO Auto-generated constructor stub
13
12
@@ -20,12 +19,12 QChartAxis::~QChartAxis()
20
19
21 void QChartAxis::setAxisPen(const QPen& pen)
20 void QChartAxis::setAxisPen(const QPen& pen)
22 {
21 {
23 m_axisPen = pen;
22 m_axisPen=pen;
24 }
23 }
25
24
26 void QChartAxis::setAxisBrush(const QBrush& brush)
25 void QChartAxis::setAxisBrush(const QBrush& brush)
27 {
26 {
28 m_axisBrush = brush;
27 m_axisBrush=brush;
29 }
28 }
30
29
31 void QChartAxis::setAxisVisible(bool visible)
30 void QChartAxis::setAxisVisible(bool visible)
@@ -35,7 +34,12 void QChartAxis::setAxisVisible(bool visible)
35
34
36 void QChartAxis::setGridVisible(bool visible)
35 void QChartAxis::setGridVisible(bool visible)
37 {
36 {
38 m_girdVisible=visible;
37 m_gridVisible=visible;
38 }
39
40 void QChartAxis::setGridPen(const QPen& pen)
41 {
42 m_gridPen=pen;
39 }
43 }
40
44
41 void QChartAxis::setLabelsVisible(bool visible)
45 void QChartAxis::setLabelsVisible(bool visible)
@@ -43,11 +47,40 void QChartAxis::setLabelsVisible(bool visible)
43 m_labelsVisible=visible;
47 m_labelsVisible=visible;
44 }
48 }
45
49
46 void QChartAxis::setRowShadesVisible(bool visible)
50 void QChartAxis::setLabelsPen(const QPen& pen)
51 {
52 m_labelsPen=pen;
53 }
54
55 void QChartAxis::setLabelsBrush(const QBrush& brush)
56 {
57 m_labelsBrush=brush;
58 }
59
60 void QChartAxis::setLabelsFont(const QFont& font)
61 {
62 m_labelsFont=font;
63 }
64
65 void QChartAxis::setLabelsOrientation(LabelsOrientation orientation)
66 {
67 m_labelsOrientation=orientation;
68 }
69
70 void QChartAxis::setShadesVisible(bool visible)
71 {
72 m_shadesVisible=visible;
73 }
74
75 void QChartAxis::setShadesPen(const QPen& pen)
76 {
77 m_shadesPen=pen;
78 }
79
80 void QChartAxis::setShadesBrush(const QBrush& brush)
47 {
81 {
48 m_rowShadesVisible=visible;
82 m_shadesBrush=brush;
49 }
83 }
50
84
51 #include "moc_qchartaxis.cpp"
52
85
53 QTCOMMERCIALCHART_END_NAMESPACE
86 QTCOMMERCIALCHART_END_NAMESPACE
@@ -3,62 +3,52
3
3
4 #include <qchartglobal.h>
4 #include <qchartglobal.h>
5 #include <QPen>
5 #include <QPen>
6 #include <QFont>
6
7
7
8
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
10
10 class QChartAxis : public QObject
11 class QChartAxis
11 {
12 {
12 Q_OBJECT
13
14 Q_PROPERTY(bool axisVisible READ isAxisVisible WRITE setAxisVisible NOTIFY axisVisibilityChanged);
15 Q_PROPERTY(QPen axisPen READ axisPen WRITE setAxisPen NOTIFY axisPenChanged);
16 Q_PROPERTY(QBrush axisBrush READ axisBrush WRITE setAxisBrush NOTIFY axisBurshChanged);
17
18 // Q_PROPERTY(bool axisVisible READ isAxisVisible WRITE setAxisVisible NOTIFY axisVisibilityChanged);
19 public:
13 public:
20 enum LabelOrientation{ HORIZONTAL, VERTICAL , SLIDE };
14 enum LabelsOrientation{ LabelsOrientationHorizontal, LabelsOrientationVertical , LabelsOrientationSlide };
21
15
22 QChartAxis(QObject* parent = 0);
16 QChartAxis();
23 virtual ~QChartAxis();
17 virtual ~QChartAxis();
24
18
25 //axis
19 //axis
26 bool isAxisVisible() const { return m_axisVisible;};
20 bool isAxisVisible() const { return m_axisVisible;};
27 void setAxisVisible(bool visible);
21 void setAxisVisible(bool visible);
28 void setAxisPen(const QPen& pen);
22 void setAxisPen(const QPen& pen);
29 const QPen& axisPen() const { return m_axisPen;};
23 QPen axisPen() const { return m_axisPen;};
30 void setAxisBrush(const QBrush& brush);
24 void setAxisBrush(const QBrush& brush);
31 const QBrush& axisBrush() const { return m_axisBrush;};
25 QBrush axisBrush() const { return m_axisBrush;};
32
26
33 //grid
27 //grid
34 bool isGridVisible() const { return m_girdVisible;};
28 bool isGridVisible() const { return m_gridVisible;};
35 void setGridVisible(bool visible);
29 void setGridVisible(bool visible);
30 void setGridPen(const QPen& pen);
31 QPen gridPen() const {return m_gridPen;}
36
32
33 //labels
37 bool isLabelsVisible() const { return m_labelsVisible;};
34 bool isLabelsVisible() const { return m_labelsVisible;};
38 void setLabelsVisible(bool visible);
35 void setLabelsVisible(bool visible);
39
36 void setLabelsPen(const QPen& pen);
40 bool isRowShadesVisible() const { return m_rowShadesVisible;};
37 QPen labelsPen() const { return m_labelsPen;}
41 void setRowShadesVisible(bool visible);
38 void setLabelsBrush(const QBrush& brush);
42
39 QBrush labelsBrush() const { return m_labelsBrush;}
43 /*
40 void setLabelsFont(const QFont& font);
44 void setLabelFont(const QFont& font);
41 QFont labelFont() const { return m_labelsFont;}
45 const QFont& labelFont();
42 void setLabelsOrientation(LabelsOrientation orientation);
46
43 LabelsOrientation labelsOrientation() const { return m_labelsOrientation;};
47 void setLabelPen(const QPen& pen);
44
48 const QPen& labelPen();
45 //shades
49
46 bool isShadesVisible() const { return m_shadesVisible;};
50 void setGridPen(const QPen& pen);
47 void setShadesVisible(bool visible);
51 const QPen& gridPen();
48 void setShadesPen(const QPen& pen);
52
49 QPen shadesPen() const { return m_shadesPen;}
53 void setGridBrush(const QBrush& brush);
50 void setShadesBrush(const QBrush& brush);
54 const QBrush& gridBrush();
51 QBrush shadesBrush() const { return m_shadesBrush;}
55 */
56
57
58 signals:
59 void axisVisibilityChanged();
60 void axisPenChanged();
61 void axisBurshChanged();
62
52
63
53
64 private:
54 private:
@@ -67,9 +57,19 private:
67 QPen m_axisPen;
57 QPen m_axisPen;
68 QBrush m_axisBrush;
58 QBrush m_axisBrush;
69
59
70 bool m_girdVisible;
60 bool m_gridVisible;
61 QPen m_gridPen;
62
71 bool m_labelsVisible;
63 bool m_labelsVisible;
72 bool m_rowShadesVisible;
64 QPen m_labelsPen;
65 QBrush m_labelsBrush;
66 QFont m_labelsFont;
67
68 bool m_shadesVisible;
69 QPen m_shadesPen;
70 QBrush m_shadesBrush;
71
72 LabelsOrientation m_labelsOrientation;
73 };
73 };
74
74
75 QTCOMMERCIALCHART_END_NAMESPACE
75 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,5 +1,6
1 #include "qchartview.h"
1 #include "qchartview.h"
2 #include "qchart.h"
2 #include "qchart.h"
3 #include "qchartaxis.h"
3 #include <QGraphicsView>
4 #include <QGraphicsView>
4 #include <QGraphicsScene>
5 #include <QGraphicsScene>
5 #include <QRubberBand>
6 #include <QRubberBand>
@@ -9,14 +10,14
9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10
11
11 QChartView::QChartView(QWidget *parent) :
12 QChartView::QChartView(QWidget *parent) :
12 QGraphicsView(parent),
13 QGraphicsView(parent),
13 m_scene(new QGraphicsScene()),
14 m_scene(new QGraphicsScene()),
14 m_chart(new QChart()),
15 m_chart(new QChart()),
15 m_rubberBand(0),
16 m_rubberBand(0),
16 m_verticalRubberBand(false),
17 m_verticalRubberBand(false),
17 m_horizonalRubberBand(false)
18 m_horizonalRubberBand(false)
18 {
19 {
19 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
20 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
20 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
21 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
21 setScene(m_scene);
22 setScene(m_scene);
22 m_chart->setMargin(50);
23 m_chart->setMargin(50);
@@ -35,7 +36,6 void QChartView::resizeEvent(QResizeEvent *event)
35 QWidget::resizeEvent(event);
36 QWidget::resizeEvent(event);
36 }
37 }
37
38
38
39 void QChartView::addSeries(QChartSeries* series)
39 void QChartView::addSeries(QChartSeries* series)
40 {
40 {
41 m_chart->addSeries(series);
41 m_chart->addSeries(series);
@@ -74,40 +74,39 void QChartView::setTitle(const QString& title)
74
74
75 void QChartView::setChartBackgroundBrush(const QBrush& brush)
75 void QChartView::setChartBackgroundBrush(const QBrush& brush)
76 {
76 {
77 m_chart->setChartBackgroundBrush(brush);
77 m_chart->setChartBackgroundBrush(brush);
78 }
78 }
79 void QChartView::setChartBackgroundPen(const QPen& pen)
79 void QChartView::setChartBackgroundPen(const QPen& pen)
80 {
80 {
81 m_chart->setChartBackgroundPen(pen);
81 m_chart->setChartBackgroundPen(pen);
82 }
82 }
83
83
84
85 void QChartView::setRubberBandPolicy(const RubberBandPolicy policy)
84 void QChartView::setRubberBandPolicy(const RubberBandPolicy policy)
86 {
85 {
87 switch(policy){
86 switch(policy) {
88 case VerticalRubberBand:
87 case VerticalRubberBand:
89 m_verticalRubberBand = true;
88 m_verticalRubberBand = true;
90 m_horizonalRubberBand = false;
89 m_horizonalRubberBand = false;
91 break;
90 break;
92 case HorizonalRubberBand:
91 case HorizonalRubberBand:
93 m_verticalRubberBand = false;
92 m_verticalRubberBand = false;
94 m_horizonalRubberBand = true;
93 m_horizonalRubberBand = true;
95 break;
94 break;
96 case RectangleRubberBand:
95 case RectangleRubberBand:
97 m_verticalRubberBand = true;
96 m_verticalRubberBand = true;
98 m_horizonalRubberBand = true;
97 m_horizonalRubberBand = true;
99 break;
98 break;
100 case NoRubberBand:
99 case NoRubberBand:
101 default:
100 default:
102 delete m_rubberBand;
101 delete m_rubberBand;
103 m_rubberBand=0;
102 m_rubberBand=0;
104 m_horizonalRubberBand = false;
103 m_horizonalRubberBand = false;
105 m_verticalRubberBand = false;
104 m_verticalRubberBand = false;
106 return;
105 return;
107 }
106 }
108 if(!m_rubberBand){
107 if(!m_rubberBand) {
109 m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
108 m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
110 m_rubberBand->setEnabled(true);
109 m_rubberBand->setEnabled(true);
111 }
110 }
112 }
111 }
113
112
@@ -119,7 +118,6 QChartView::RubberBandPolicy QChartView::rubberBandPolicy() const
119 return NoRubberBand;
118 return NoRubberBand;
120 }
119 }
121
120
122
123 void QChartView::mousePressEvent(QMouseEvent *event)
121 void QChartView::mousePressEvent(QMouseEvent *event)
124 {
122 {
125 if(m_rubberBand && m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
123 if(m_rubberBand && m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
@@ -138,7 +136,7 void QChartView::mousePressEvent(QMouseEvent *event)
138
136
139 void QChartView::mouseMoveEvent(QMouseEvent *event)
137 void QChartView::mouseMoveEvent(QMouseEvent *event)
140 {
138 {
141 if(m_rubberBand && m_rubberBand->isVisible()){
139 if(m_rubberBand && m_rubberBand->isVisible()) {
142 int margin = m_chart->margin();
140 int margin = m_chart->margin();
143 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
141 QRect rect(margin, margin, width() - 2 * margin, height() - 2 * margin);
144 int width = event->pos().x() - m_rubberBandOrigin.x();
142 int width = event->pos().x() - m_rubberBandOrigin.x();
@@ -152,24 +150,26 void QChartView::mouseMoveEvent(QMouseEvent *event)
152 width= rect.width();
150 width= rect.width();
153 }
151 }
154 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin.x(),m_rubberBandOrigin.y(), width,height).normalized());
152 m_rubberBand->setGeometry(QRect(m_rubberBandOrigin.x(),m_rubberBandOrigin.y(), width,height).normalized());
155 } else {
153 }
154 else {
156 QGraphicsView::mouseMoveEvent(event);
155 QGraphicsView::mouseMoveEvent(event);
157 }
156 }
158 }
157 }
159
158
160 void QChartView::mouseReleaseEvent(QMouseEvent *event)
159 void QChartView::mouseReleaseEvent(QMouseEvent *event)
161 {
160 {
162 if(m_rubberBand){
161 if(m_rubberBand) {
163 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
162 if (event->button() == Qt::LeftButton && m_rubberBand->isVisible()) {
164 m_rubberBand->hide();
163 m_rubberBand->hide();
165 QRect rect = m_rubberBand->geometry();
164 QRect rect = m_rubberBand->geometry();
166 m_chart->zoomInToRect(rect);
165 m_chart->zoomInToRect(rect);
167 event->accept();
166 event->accept();
168 }
167 }
169
168
170 if(event->button()==Qt::RightButton)
169 if(event->button()==Qt::RightButton)
171 m_chart->zoomReset();
170 m_chart->zoomReset();
172 }else{
171 }
172 else {
173 QGraphicsView::mouseReleaseEvent(event);
173 QGraphicsView::mouseReleaseEvent(event);
174 }
174 }
175 }
175 }
@@ -177,13 +177,13 void QChartView::mouseReleaseEvent(QMouseEvent *event)
177 void QChartView::keyPressEvent(QKeyEvent *event)
177 void QChartView::keyPressEvent(QKeyEvent *event)
178 {
178 {
179 switch (event->key()) {
179 switch (event->key()) {
180 case Qt::Key_Plus:
180 case Qt::Key_Plus:
181 zoomIn();
181 zoomIn();
182 break;
182 break;
183 case Qt::Key_Minus:
183 case Qt::Key_Minus:
184 zoomOut();
184 zoomOut();
185 break;
185 break;
186 default:
186 default:
187 QGraphicsView::keyPressEvent(event);
187 QGraphicsView::keyPressEvent(event);
188 break;
188 break;
189 }
189 }
@@ -199,29 +199,38 QChart::ChartTheme QChartView::chartTheme() const
199 return m_chart->chartTheme();
199 return m_chart->chartTheme();
200 }
200 }
201
201
202 QChartAxis* QChartView::axisX()
202 void QChartView::setDefaultAxisX(const QChartAxis& axis)
203 {
204 m_chart->setDefaultAxisX(axis);
205 }
206
207 void QChartView::setDefaultAxisY(const QChartAxis& axis)
203 {
208 {
204 return m_chart->axisX();
209 m_chart->setDefaultAxisY(axis);
205 }
210 }
206
211
207 QChartAxis* QChartView::axisY()
212 QChartAxis QChartView::defaultAxisX() const
208 {
213 {
209 return m_chart->axisY();
214 return m_chart->defaultAxisX();
210 }
215 }
211
216
212 QChartAxis* QChartView::addAxisX()
217 QChartAxis QChartView::defaultAxisY() const
213 {
218 {
214 return m_chart->addAxisX();
219 return m_chart->defaultAxisY();
215 }
220 }
216
221
217 QChartAxis* QChartView::addAxisY()
222 int QChartView::addAxisY(const QChartAxis& axis)
218 {
223 {
219 return m_chart->addAxisY();
224 return m_chart->addAxisY(axis);
220 }
225 }
221
226
222 void QChartView::removeAxis(QChartAxis* axis)
227 QChartAxis QChartView::axisY(int id) const
223 {
228 {
224 m_chart->removeAxis(axis);
229 return m_chart->axisY(id);
225 }
230 }
226
231
232 void QChartView::removeAxisY(int id)
233 {
234 m_chart->removeAxisY(id);
235 }
227 QTCOMMERCIALCHART_END_NAMESPACE
236 QTCOMMERCIALCHART_END_NAMESPACE
@@ -45,11 +45,13 public:
45 void setChartTheme(QChart::ChartTheme theme);
45 void setChartTheme(QChart::ChartTheme theme);
46 QChart::ChartTheme chartTheme() const;
46 QChart::ChartTheme chartTheme() const;
47
47
48 QChartAxis* axisX();
48 void setDefaultAxisX(const QChartAxis& axis);
49 QChartAxis* axisY();
49 void setDefaultAxisY(const QChartAxis& axis);
50 QChartAxis* addAxisX();
50 QChartAxis defaultAxisX() const;
51 QChartAxis* addAxisY();
51 QChartAxis defaultAxisY() const;
52 void removeAxis(QChartAxis* axis);
52 QChartAxis axisY(int id) const;
53 int addAxisY(const QChartAxis& axis);
54 void removeAxisY(int id);
53
55
54 protected:
56 protected:
55 void mousePressEvent(QMouseEvent *event);
57 void mousePressEvent(QMouseEvent *event);
General Comments 0
You need to be logged in to leave comments. Login now