##// END OF EJS Templates
added example for stacked bar chart.
sauimone -
r95:9f20814aa978
parent child
Show More
@@ -2,4 +2,5 TEMPLATE = subdirs
2 SUBDIRS += linechart \
2 SUBDIRS += linechart \
3 zoomlinechart \
3 zoomlinechart \
4 colorlinechart \
4 colorlinechart \
5 barchart
5 barchart \
6 stackedbarchart
@@ -2,7 +2,6
2 #define BARCHARTSERIES_H
2 #define BARCHARTSERIES_H
3
3
4 #include <QList>
4 #include <QList>
5 //#include <QRectF>
6 #include <QAbstractItemModel>
5 #include <QAbstractItemModel>
7 #include "qchartseries.h"
6 #include "qchartseries.h"
8 #include "qchartglobal.h"
7 #include "qchartglobal.h"
@@ -35,9 +34,6 public:
35
34
36 public Q_SLOTS:
35 public Q_SLOTS:
37
36
38 // TODO: wrong place for this... series don't know anything about layout
39 // void chartSizeChanged(QRectF rect);
40
41 private:
37 private:
42
38
43 QAbstractItemModel* mModel;
39 QAbstractItemModel* mModel;
@@ -7,6 +7,8
7 #include "qchartaxis.h"
7 #include "qchartaxis.h"
8 #include "barchartseries.h"
8 #include "barchartseries.h"
9 #include "bargroup.h"
9 #include "bargroup.h"
10 #include "stackedbarchartseries.h"
11 #include "stackedbargroup.h"
10
12
11 #include "xylinechartitem_p.h"
13 #include "xylinechartitem_p.h"
12 #include "plotdomain_p.h"
14 #include "plotdomain_p.h"
@@ -96,6 +98,23 void QChart::addSeries(QChartSeries* series)
96 childItems().append(barGroup);
98 childItems().append(barGroup);
97 break;
99 break;
98 }
100 }
101 case QChartSeries::SeriesTypeStackedBar: {
102
103 qDebug() << "barSeries added";
104 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
105 StackedBarGroup* stackedBarGroup = new StackedBarGroup(*stackedBarSeries,this);
106
107 // Add some fugly colors for 5 fist series...
108 stackedBarGroup->addColor(QColor(255,0,0,128));
109 stackedBarGroup->addColor(QColor(255,255,0,128));
110 stackedBarGroup->addColor(QColor(0,255,0,128));
111 stackedBarGroup->addColor(QColor(0,0,255,128));
112 stackedBarGroup->addColor(QColor(255,128,0,128));
113
114 m_chartItems<<stackedBarGroup;
115 childItems().append(stackedBarGroup);
116 break;
117 }
99 case QChartSeries::SeriesTypeScatter: {
118 case QChartSeries::SeriesTypeScatter: {
100 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
119 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
101 scatterSeries->d->setParentItem(this);
120 scatterSeries->d->setParentItem(this);
@@ -141,6 +160,10 QChartSeries* QChart::createSeries(QChartSeries::QChartSeriesType type)
141 series = new BarChartSeries(this);
160 series = new BarChartSeries(this);
142 break;
161 break;
143 }
162 }
163 case QChartSeries::SeriesTypeStackedBar: {
164 series = new StackedBarChartSeries(this);
165 break;
166 }
144 case QChartSeries::SeriesTypeScatter: {
167 case QChartSeries::SeriesTypeScatter: {
145 series = new QScatterSeries(this);
168 series = new QScatterSeries(this);
146 break;
169 break;
@@ -15,6 +15,8 SOURCES += \
15 barchart/barchartseries.cpp \
15 barchart/barchartseries.cpp \
16 barchart/bargroup.cpp \
16 barchart/bargroup.cpp \
17 barchart/bar.cpp \
17 barchart/bar.cpp \
18 barchart/stackedbarchartseries.cpp \
19 barchart/stackedbargroup.cpp \
18 xylinechart/qxychartseries.cpp \
20 xylinechart/qxychartseries.cpp \
19 xylinechart/xylinechartitem.cpp \
21 xylinechart/xylinechartitem.cpp \
20 plotdomain.cpp \
22 plotdomain.cpp \
@@ -26,9 +28,7 SOURCES += \
26 pieslice.cpp \
28 pieslice.cpp \
27 qchartview.cpp \
29 qchartview.cpp \
28 qchartseries.cpp \
30 qchartseries.cpp \
29 qchartaxis.cpp \
31 qchartaxis.cpp
30 barchart/stackedbarchartseries.cpp \
31 barchart/stackedbargroup.cpp
32
32
33 PRIVATE_HEADERS += \
33 PRIVATE_HEADERS += \
34 xylinechart/xylinechartitem_p.h \
34 xylinechart/xylinechartitem_p.h \
@@ -48,12 +48,12 PUBLIC_HEADERS += \
48 xylinechart/qxychartseries.h \
48 xylinechart/qxychartseries.h \
49 barchart/barchartseries.h \
49 barchart/barchartseries.h \
50 barchart/bargroup.h \
50 barchart/bargroup.h \
51 barchart/stackedbarchartseries.h \
52 barchart/stackedbargroup.h \
51 qchartview.h \
53 qchartview.h \
52 qchartaxis.h
54 qchartaxis.h
53
55
54 HEADERS += $$PUBLIC_HEADERS \
56 HEADERS += $$PUBLIC_HEADERS
55 barchart/stackedbarchartseries.h \
56 barchart/stackedbargroup.h
57 HEADERS += $$PRIVATE_HEADERS
57 HEADERS += $$PRIVATE_HEADERS
58
58
59 INCLUDEPATH += xylinechart \
59 INCLUDEPATH += xylinechart \
General Comments 0
You need to be logged in to leave comments. Login now