##// END OF EJS Templates
fixed bug in category implementation. model now owns the category and sets
sauimone -
r173:5bd6f6e4373b
parent child
Show More
@@ -13,29 +13,29 int main(int argc, char *argv[])
13 13 QApplication a(argc, argv);
14 14 QMainWindow window;
15 15
16 QBarCategory category;
17 category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
16 QBarCategory *category = new QBarCategory;
17 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
18 18
19 19 BarChartSeries* series0 = new BarChartSeries(category);
20 20
21 QBarSet barSet0;
22 QBarSet barSet1;
23 QBarSet barSet2;
24 QBarSet barSet3;
25 QBarSet barSet4;
21 QBarSet *set0 = new QBarSet;
22 QBarSet *set1 = new QBarSet;
23 QBarSet *set2 = new QBarSet;
24 QBarSet *set3 = new QBarSet;
25 QBarSet *set4 = new QBarSet;
26 26
27 27 // Create some test data to chart
28 barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
33
34 series0->addBarSet(barSet0);
35 series0->addBarSet(barSet1);
36 series0->addBarSet(barSet2);
37 series0->addBarSet(barSet3);
38 series0->addBarSet(barSet4);
28 *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 *set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 *set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
33
34 series0->addBarSet(set0);
35 series0->addBarSet(set1);
36 series0->addBarSet(set2);
37 series0->addBarSet(set3);
38 series0->addBarSet(set4);
39 39
40 40 ChartWidget* chartWidget = new ChartWidget(&window);
41 41 chartWidget->addSeries(series0);
@@ -13,29 +13,29 int main(int argc, char *argv[])
13 13 QApplication a(argc, argv);
14 14 QMainWindow window;
15 15
16 QBarCategory category;
17 category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
16 QBarCategory *category = new QBarCategory;
17 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
18 18
19 19 PercentBarChartSeries* series0 = new PercentBarChartSeries(category);
20 20
21 QBarSet barSet0;
22 QBarSet barSet1;
23 QBarSet barSet2;
24 QBarSet barSet3;
25 QBarSet barSet4;
21 QBarSet *set0 = new QBarSet;
22 QBarSet *set1 = new QBarSet;
23 QBarSet *set2 = new QBarSet;
24 QBarSet *set3 = new QBarSet;
25 QBarSet *set4 = new QBarSet;
26 26
27 27 // Create some test data to chart
28 barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
33
34 series0->addBarSet(barSet0);
35 series0->addBarSet(barSet1);
36 series0->addBarSet(barSet2);
37 series0->addBarSet(barSet3);
38 series0->addBarSet(barSet4);
28 *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 *set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 *set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
33
34 series0->addBarSet(set0);
35 series0->addBarSet(set1);
36 series0->addBarSet(set2);
37 series0->addBarSet(set3);
38 series0->addBarSet(set4);
39 39
40 40 ChartWidget* chartWidget = new ChartWidget(&window);
41 41 chartWidget->addSeries(series0);
@@ -13,29 +13,29 int main(int argc, char *argv[])
13 13 QApplication a(argc, argv);
14 14 QMainWindow window;
15 15
16 QBarCategory category;
17 category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
16 QBarCategory *category = new QBarCategory;
17 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
18 18
19 19 StackedBarChartSeries* series0 = new StackedBarChartSeries(category);
20 20
21 QBarSet barSet0;
22 QBarSet barSet1;
23 QBarSet barSet2;
24 QBarSet barSet3;
25 QBarSet barSet4;
21 QBarSet *set0 = new QBarSet;
22 QBarSet *set1 = new QBarSet;
23 QBarSet *set2 = new QBarSet;
24 QBarSet *set3 = new QBarSet;
25 QBarSet *set4 = new QBarSet;
26 26
27 27 // Create some test data to chart
28 barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
33
34 series0->addBarSet(barSet0);
35 series0->addBarSet(barSet1);
36 series0->addBarSet(barSet2);
37 series0->addBarSet(barSet3);
38 series0->addBarSet(barSet4);
28 *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
29 *set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
30 *set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
31 *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
32 *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
33
34 series0->addBarSet(set0);
35 series0->addBarSet(set1);
36 series0->addBarSet(set2);
37 series0->addBarSet(set3);
38 series0->addBarSet(set4);
39 39
40 40 ChartWidget* chartWidget = new ChartWidget(&window);
41 41 chartWidget->addSeries(series0);
@@ -7,27 +7,35
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 BarChartModel::BarChartModel(QBarCategory &category, QObject *parent) :
10 BarChartModel::BarChartModel(QBarCategory *category, QObject *parent) :
11 11 QObject(parent)
12 12 ,mCategory(category)
13 13 {
14 14 }
15 15
16 QBarCategory& BarChartModel::category()
16 BarChartModel::~BarChartModel()
17 17 {
18 return mCategory;
18 delete mCategory;
19 19 }
20 20
21 void BarChartModel::addBarSet(QBarSet &set)
21
22 QBarCategory& BarChartModel::category()
22 23 {
23 mDataModel.append(&set);
24 return *mCategory;
24 25 }
25 26
26 void BarChartModel::removeBarSet(QBarSet &set)
27 void BarChartModel::addBarSet(QBarSet *set)
27 28 {
28 mDataModel.removeOne(&set);
29 mDataModel.append(set);
29 30 }
30 31
32 void BarChartModel::removeBarSet(QBarSet *set)
33 {
34 if (mDataModel.contains(set)) {
35 mDataModel.removeOne(set);
36 delete set;
37 }
38 }
31 39
32 40 int BarChartModel::countSets()
33 41 {
@@ -135,7 +143,7 qreal BarChartModel::maxCategorySum()
135 143
136 144 QString BarChartModel::label(int category)
137 145 {
138 return mCategory.label(category);
146 return mCategory->label(category);
139 147 }
140 148
141 149 #include "moc_barchartmodel_p.cpp"
@@ -16,11 +16,12 class BarChartModel : public QObject //, public QAbstractItemModel
16 16 {
17 17 Q_OBJECT
18 18 public:
19 explicit BarChartModel(QBarCategory &category, QObject *parent = 0);
19 explicit BarChartModel(QBarCategory *category, QObject *parent = 0);
20 ~BarChartModel();
20 21
21 22 QBarCategory& category();
22 void addBarSet(QBarSet &set);
23 void removeBarSet(QBarSet &set);
23 void addBarSet(QBarSet *set);
24 void removeBarSet(QBarSet *set);
24 25
25 26 int countSets(); // Number of sets in model
26 27 int countCategories(); // Number of categories
@@ -43,7 +44,7 public slots:
43 44 private:
44 45
45 46 QList<QBarSet*> mDataModel;
46 QBarCategory& mCategory;
47 QBarCategory* mCategory; // Owned
47 48
48 49 };
49 50
@@ -7,18 +7,18
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 BarChartSeries::BarChartSeries(QBarCategory &category, QObject *parent)
10 BarChartSeries::BarChartSeries(QBarCategory *category, QObject *parent)
11 11 : QChartSeries(parent)
12 12 ,mModel(new BarChartModel(category, this))
13 13 {
14 14 }
15 15
16 void BarChartSeries::addBarSet(QBarSet &set)
16 void BarChartSeries::addBarSet(QBarSet *set)
17 17 {
18 18 mModel->addBarSet(set);
19 19 }
20 20
21 void BarChartSeries::removeBarSet(QBarSet &set)
21 void BarChartSeries::removeBarSet(QBarSet *set)
22 22 {
23 23 mModel->removeBarSet(set);
24 24 }
@@ -17,14 +17,18 class QTCOMMERCIALCHART_EXPORT BarChartSeries : public QChartSeries
17 17 {
18 18 Q_OBJECT
19 19 public:
20 BarChartSeries(QBarCategory &category, QObject* parent=0);
20 BarChartSeries(QBarCategory *category, QObject* parent=0);
21 21
22 // from BarChartSeriesBase
23 22 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeBar; }
24 23
25 void addBarSet(QBarSet &set);
26 void removeBarSet(QBarSet &set);
24 void addBarSet(QBarSet *set); // Takes ownership
25 void removeBarSet(QBarSet *set); // Also deletes the set, if set is owned.
27 26
27 //TODO:
28 //QList<QString> legend(); // Returns legend of series (ie. names of all sets in series)
29
30 // TODO: Functions below this are not part of api and will be moved
31 // to private implementation, when we start using it (not part of api)
28 32 int countCategories();
29 33 qreal min();
30 34 qreal max();
@@ -8,7 +8,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 8 BarGroup::BarGroup(BarChartModel& model, QGraphicsItem *parent) :
9 9 BarGroupBase(model,parent)
10 10 {
11 mBarDefaultWidth = 10;
11 mBarDefaultWidth = 5;
12 12 }
13 13
14 14 void BarGroup::layoutChanged()
@@ -17,6 +17,7 void BarGroup::layoutChanged()
17 17 // Scale bars to new layout
18 18 // Layout for bars:
19 19 if (mModel.countSets() <= 0) {
20 qDebug() << "No sets in model!";
20 21 return;
21 22 }
22 23
@@ -13,7 +13,6 BarGroupBase::BarGroupBase(BarChartModel& model, QGraphicsItem *parent)
13 13 ,mLayoutDirty(true)
14 14 ,mSeparatorsVisible(true)
15 15 ,mModel(model)
16 // ,mSeries(series)
17 16 {
18 17 dataChanged();
19 18 }
@@ -72,20 +71,20 void BarGroupBase::dataChanged()
72 71 }
73 72
74 73 // Create new graphic items for bars
75 int totalItems = mModel.countTotalItems(); // mSeries.countTotalItems();
74 int totalItems = mModel.countTotalItems();
76 75 for (int i=0; i<totalItems; i++) {
77 76 Bar *bar = new Bar(this);
78 77 childItems().append(bar);
79 78 }
80 79
81 int count = mModel.countCategories(); // mSeries.countColumns();
80 int count = mModel.countCategories();
82 81 for (int i=0; i<count; i++) {
83 82 BarLabel* label = new BarLabel(this);
84 83 label->set(mModel.label(i));
85 84 childItems().append(label);
86 85 }
87 86
88 count = mModel.countCategories() - 1; // mSeries.countColumns() - 1; // There is one less separator than columns
87 count = mModel.countCategories() - 1; // There is one less separator than columns
89 88 for (int i=0; i<count; i++) {
90 89 Separator* sep = new Separator(this);
91 90 sep->setColor(QColor(255,0,0,255)); // TODO: color for separations from theme
@@ -100,14 +99,13 void BarGroupBase::dataChanged()
100 99
101 100 void BarGroupBase::handleModelChanged(int index)
102 101 {
103 qDebug() << "BarGroupBase::handleModelChanged" << index;
102 // qDebug() << "BarGroupBase::handleModelChanged" << index;
104 103 dataChanged();
105 104 }
106 105
107 106 void BarGroupBase::handleDomainChanged(const Domain& domain)
108 107 {
109 108 // qDebug() << "BarGroupBase::handleDomainChanged";
110
111 109 // TODO: Figure out the use case for this.
112 110 // Affects the size of visible item, so layout is changed.
113 111 // layoutChanged();
@@ -115,7 +113,6 void BarGroupBase::handleDomainChanged(const Domain& domain)
115 113
116 114 void BarGroupBase::handleGeometryChanged(const QRectF& rect)
117 115 {
118 // qDebug() << "BarGroupBase::handleGeometryChanged";
119 116 mWidth = rect.width();
120 117 mHeight = rect.height();
121 118 layoutChanged();
@@ -9,18 +9,18
9 9
10 10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11 11
12 PercentBarChartSeries::PercentBarChartSeries(QBarCategory &category, QObject *parent)
12 PercentBarChartSeries::PercentBarChartSeries(QBarCategory *category, QObject *parent)
13 13 : QChartSeries(parent)
14 14 ,mModel(new BarChartModel(category, this))
15 15 {
16 16 }
17 17
18 void PercentBarChartSeries::addBarSet(QBarSet &set)
18 void PercentBarChartSeries::addBarSet(QBarSet *set)
19 19 {
20 20 mModel->addBarSet(set);
21 21 }
22 22
23 void PercentBarChartSeries::removeBarSet(QBarSet &set)
23 void PercentBarChartSeries::removeBarSet(QBarSet *set)
24 24 {
25 25 mModel->removeBarSet(set);
26 26 }
@@ -16,14 +16,19 class QTCOMMERCIALCHART_EXPORT PercentBarChartSeries : public QChartSeries
16 16 {
17 17 Q_OBJECT
18 18 public:
19 PercentBarChartSeries(QBarCategory &category, QObject* parent=0);
19 PercentBarChartSeries(QBarCategory *category, QObject* parent=0);
20 20
21 21 // from BarChartSeriesBase
22 22 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypePercentBar; }
23 23
24 void addBarSet(QBarSet &set);
25 void removeBarSet(QBarSet &set);
24 void addBarSet(QBarSet *set); // Takes ownership
25 void removeBarSet(QBarSet *set); // Also deletes the set, if set is owned.
26 26
27 //TODO:
28 //QList<QString> legend(); // Returns legend of series (ie. names of all sets in series)
29
30 // TODO: Functions below this are not part of api and will be moved
31 // to private implementation, when we start using it (not part of api)
27 32 int countCategories();
28 33 qreal min();
29 34 qreal max();
@@ -14,9 +14,11 PercentBarGroup::PercentBarGroup(BarChartModel& model, QGraphicsItem *parent) :
14 14
15 15 void PercentBarGroup::layoutChanged()
16 16 {
17 // qDebug() << "PercentBarGroup::layoutChanged";
17 18 // Scale bars to new layout
18 19 // Layout for bars:
19 20 if (mModel.countSets() <= 0) {
21 qDebug() << "No sets in model!";
20 22 // Nothing to do.
21 23 return;
22 24 }
@@ -22,5 +22,6 QString QBarCategory::label(int category)
22 22 return mList.at(category);
23 23 }
24 24
25
25 // TODO?:
26 //#include "moc_qbarcategory.cpp"
26 27 QTCOMMERCIALCHART_END_NAMESPACE
@@ -5,8 +5,9
5 5
6 6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 7
8 class QTCOMMERCIALCHART_EXPORT QBarCategory // TODO? : pubclic QObject
8 class QTCOMMERCIALCHART_EXPORT QBarCategory // TODO?: : public QObject
9 9 {
10 // Q_OBJECT;
10 11 public:
11 12 QBarCategory();
12 13
@@ -31,5 +31,6 qreal QBarSet::valueAt(int index)
31 31 return mValues.at(index);
32 32 }
33 33
34
34 //TODO?:
35 //#include "moc_qbarset.cpp"
35 36 QTCOMMERCIALCHART_END_NAMESPACE
@@ -5,8 +5,9
5 5
6 6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 7
8 class QTCOMMERCIALCHART_EXPORT QBarSet // : pubclic QObject // TODO: Need for this?
8 class QTCOMMERCIALCHART_EXPORT QBarSet // TODO? : public QObject
9 9 {
10 //Q_OBJECT;
10 11 public:
11 12 QBarSet();
12 13
@@ -7,18 +7,18
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 StackedBarChartSeries::StackedBarChartSeries(QBarCategory &category, QObject *parent)
10 StackedBarChartSeries::StackedBarChartSeries(QBarCategory *category, QObject *parent)
11 11 : QChartSeries(parent)
12 12 ,mModel(new BarChartModel(category, this))
13 13 {
14 14 }
15 15
16 void StackedBarChartSeries::addBarSet(QBarSet &set)
16 void StackedBarChartSeries::addBarSet(QBarSet *set)
17 17 {
18 18 mModel->addBarSet(set);
19 19 }
20 20
21 void StackedBarChartSeries::removeBarSet(QBarSet &set)
21 void StackedBarChartSeries::removeBarSet(QBarSet *set)
22 22 {
23 23 mModel->removeBarSet(set);
24 24 }
@@ -16,14 +16,19 class QTCOMMERCIALCHART_EXPORT StackedBarChartSeries : public QChartSeries
16 16 {
17 17 Q_OBJECT
18 18 public:
19 StackedBarChartSeries(QBarCategory &category, QObject* parent=0);
19 StackedBarChartSeries(QBarCategory *category, QObject* parent=0);
20 20
21 21 // from QChartSeries
22 22 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeStackedBar; }
23 23
24 void addBarSet(QBarSet &set);
25 void removeBarSet(QBarSet &set);
24 void addBarSet(QBarSet *set); // Takes ownership
25 void removeBarSet(QBarSet *set); // Also deletes the set, if set is owned.
26 26
27 //TODO:
28 //QList<QString> legend(); // Returns legend of series (ie. names of all sets in series)
29
30 // TODO: Functions below this are not part of api and will be moved
31 // to private implementation, when we start using it (not part of api)
27 32 int countCategories();
28 33 qreal min();
29 34 qreal max();
@@ -17,11 +17,13 void StackedBarGroup::layoutChanged()
17 17 // Scale bars to new layout
18 18 // Layout for bars:
19 19 if (mModel.countSets() <= 0) {
20 qDebug() << "No sets in model!";
20 21 // Nothing to do.
21 22 return;
22 23 }
23 24
24 25 if (mModel.countCategories() == 0) {
26 qDebug() << "No categories in model!";
25 27 // Nothing to do
26 28 return;
27 29 }
@@ -65,7 +67,6 void StackedBarGroup::layoutChanged()
65 67 xPos += xStep;
66 68 }
67 69
68
69 70 // Position separators
70 71 int separatorIndex = labelIndex; // Separators are after labels in childItems(). TODO: better way to store these?
71 72 xPos = xStep + xStep/2; // Initial position is between first and second group. ie one and half steps from left.
@@ -52,7 +52,7 void ChartDataSet::addSeries(QChartSeries* series)
52 52 break;
53 53 }
54 54 case QChartSeries::SeriesTypeBar: {
55
55 qDebug() << "QChartSeries::SeriesTypeBar";
56 56 BarChartSeries* barSeries = static_cast<BarChartSeries*>(series);
57 57 qreal x = barSeries->countCategories();
58 58 qreal y = barSeries->max();
@@ -63,6 +63,7 void ChartDataSet::addSeries(QChartSeries* series)
63 63 break;
64 64 }
65 65 case QChartSeries::SeriesTypeStackedBar: {
66 qDebug() << "QChartSeries::SeriesTypeStackedBar";
66 67
67 68 StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series);
68 69 qreal x = stackedBarSeries->countCategories();
@@ -74,6 +75,7 void ChartDataSet::addSeries(QChartSeries* series)
74 75 break;
75 76 }
76 77 case QChartSeries::SeriesTypePercentBar: {
78 qDebug() << "QChartSeries::SeriesTypePercentBar";
77 79
78 80 PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series);
79 81 qreal x = percentBarSeries->countCategories();
@@ -76,6 +76,7 void ChartPresenter::setMargin(int margin)
76 76
77 77 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
78 78 {
79 qDebug() << " ChartPresenter::handleSeriesAdded";
79 80 switch(series->type())
80 81 {
81 82 case QChartSeries::SeriesTypeLine: {
@@ -180,11 +180,11 void MainWidget::addSeries(QString series, QString data)
180 180 QList<qreal> x;
181 181 QList<qreal> y;
182 182
183 QBarSet set0;
184 QBarSet set1;
185 QBarSet set2;
186 QBarSet set3;
187 QBarSet set4;
183 QBarSet *set0 = new QBarSet;
184 QBarSet *set1 = new QBarSet;
185 QBarSet *set2 = new QBarSet;
186 QBarSet *set3 = new QBarSet;
187 QBarSet *set4 = new QBarSet;
188 188
189 189 if (data == "linear") {
190 190 for (int i = 0; i < 20; i++) {
@@ -213,11 +213,11 void MainWidget::addSeries(QString series, QString data)
213 213 }
214 214 } else if (data == "Table, 5 series"){
215 215 // Create some test data to chart
216 set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
217 set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
218 set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
219 set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
220 set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
216 *set0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12;
217 *set1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2;
218 *set2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5;
219 *set3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7;
220 *set4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6;
221 221 } else {
222 222 // TODO: check if data has a valid file name
223 223 Q_ASSERT(false);
@@ -248,8 +248,8 void MainWidget::addSeries(QString series, QString data)
248 248 } else if (series == "Bar") {
249 249 qDebug() << "Bar chart series";
250 250
251 QBarCategory category;
252 category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
251 QBarCategory *category = new QBarCategory;
252 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
253 253
254 254 BarChartSeries* series0 = new BarChartSeries(category, this);
255 255
@@ -264,8 +264,8 void MainWidget::addSeries(QString series, QString data)
264 264 } else if (series == "StackedBar") {
265 265 qDebug() << "Stacked bar chart series";
266 266
267 QBarCategory category;
268 category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
267 QBarCategory *category = new QBarCategory;
268 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
269 269
270 270 StackedBarChartSeries* series0 = new StackedBarChartSeries(category, this);
271 271
@@ -280,8 +280,8 void MainWidget::addSeries(QString series, QString data)
280 280 } else if (series == "PercentBar") {
281 281 qDebug() << "Percent bar chart series";
282 282
283 QBarCategory category;
284 category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
283 QBarCategory *category = new QBarCategory;
284 *category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
285 285
286 286 PercentBarChartSeries* series0 = new PercentBarChartSeries(category, this);
287 287
General Comments 0
You need to be logged in to leave comments. Login now