##// END OF EJS Templates
Bar series to use theme base colors. Pie brush minor fix....
Tero Ahola -
r661:4756f59398b8
parent child
Show More
@@ -4,7 +4,9
4 4 #include <qchartview.h>
5 5 #include <qpieseries.h>
6 6 #include <qpieslice.h>
7 #include <qbarseries.h>
7 8 #include <qpercentbarseries.h>
9 #include <qstackedbarseries.h>
8 10 #include <qbarset.h>
9 11 #include <QGridLayout>
10 12 #include <QFormLayout>
@@ -106,7 +108,9 public:
106 108 // TODO: categories
107 109 for (int i(0); i < valueCount; i++)
108 110 categories << QString::number(i);
109 QPercentBarSeries* series = new QPercentBarSeries(categories, chart);
111 // QBarSeries* series = new QBarSeries(categories, chart);
112 // QPercentBarSeries* series = new QPercentBarSeries(categories, chart);
113 QStackedBarSeries* series = new QStackedBarSeries(categories, chart);
110 114 for (int i(0); i < m_dataTable.count(); i++) {
111 115 QBarSet *set = new QBarSet("Set" + QString::number(i));
112 116 foreach (Data data, m_dataTable[i])
@@ -48,6 +48,7 void BarPresenter::layoutChanged()
48 48
49 49 // TODO: width settable per bar?
50 50 bar->resize(mBarWidth, barHeight);
51 bar->setPen(mSeries->barsetAt(set)->pen());
51 52 bar->setBrush(mSeries->barsetAt(set)->brush());
52 53 bar->setPos(xPos, yPos-barHeight);
53 54 itemIndex++;
@@ -56,6 +56,7 void StackedBarPresenter::layoutChanged()
56 56 Bar* bar = mBars.at(itemIndex);
57 57
58 58 bar->resize(mBarWidth, barHeight);
59 bar->setPen(mSeries->barsetAt(set)->pen());
59 60 bar->setBrush(mSeries->barsetAt(set)->brush());
60 61 bar->setPos(xPos, yPos-barHeight);
61 62 itemIndex++;
@@ -150,19 +150,32 void ChartTheme::decorate(QBarSeries* series, int index, bool force)
150 150 QPen pen;
151 151 QList<QBarSet*> sets = series->barSets();
152 152
153 for (int i(0); i < sets.count(); i++) {
154 qreal pos = 0.5;
155 if (sets.count() > 1)
156 pos = (qreal) i / (qreal) (sets.count() - 1);
153 qreal takeAtPos = 0.5;
154 qreal step = 0.2;
155 if (sets.count() > 1 ) {
156 step = 1.0 / (qreal) sets.count();
157 if (sets.count() % m_seriesGradients.count())
158 step *= m_seriesGradients.count();
159 else
160 step *= (m_seriesGradients.count() - 1);
161 }
157 162
158 if (brush == sets.at(i)->brush() || force ) {
159 QColor c = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
160 sets.at(i)->setBrush(QBrush(c));
163 for (int i(0); i < sets.count(); i++) {
164 int colorIndex = (index + i) % m_seriesGradients.count();
165 if (i > 0 && i % m_seriesGradients.count() == 0) {
166 // There is no dedicated base color for each sets, generate more colors
167 takeAtPos += step;
168 if (takeAtPos == 1.0)
169 takeAtPos += step;
170 takeAtPos -= (int) takeAtPos;
161 171 }
172 qDebug() << "pos:" << takeAtPos;
173 if (brush == sets.at(i)->brush() || force )
174 sets.at(i)->setBrush(colorAt(m_seriesGradients.at(colorIndex), takeAtPos));
162 175
163 176 // Pick label color from the opposite end of the gradient.
164 177 // 0.3 as a boundary seems to work well.
165 if (pos < 0.3)
178 if (takeAtPos < 0.3)
166 179 sets.at(i)->setFloatingValuePen(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 1));
167 180 else
168 181 sets.at(i)->setFloatingValuePen(colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), 0));
@@ -203,7 +216,7 void ChartTheme::decorate(QPieSeries* series, int index, bool force)
203 216 }
204 217
205 218 // Get color for a slice from a gradient linearly, beginning from the start of the gradient
206 qreal pos = (qreal) i / (qreal) series->count();
219 qreal pos = (qreal) (i + 1) / (qreal) series->count();
207 220 if (brush == series->slices().at(i)->sliceBrush() || force) {
208 221 QColor brushColor = colorAt(m_seriesGradients.at(index % m_seriesGradients.size()), pos);
209 222 series->slices().at(i)->setSliceBrush(brushColor);
@@ -67,7 +67,9 QGroupBox *DataSerieDialog::columnCountSelector()
67 67 layout->addWidget(radio);
68 68 layout->addWidget(new QRadioButton("2"));
69 69 layout->addWidget(new QRadioButton("3"));
70 layout->addWidget(new QRadioButton("4"));
70 71 layout->addWidget(new QRadioButton("5"));
72 layout->addWidget(new QRadioButton("8"));
71 73 layout->addWidget(new QRadioButton("10"));
72 74 layout->addWidget(new QRadioButton("100"));
73 75
@@ -89,6 +91,7 QGroupBox *DataSerieDialog::rowCountSelector()
89 91 layout->addWidget(new QRadioButton("50"));
90 92 layout->addWidget(new QRadioButton("100"));
91 93 layout->addWidget(new QRadioButton("10000"));
94 layout->addWidget(new QRadioButton("100000"));
92 95 layout->addWidget(new QRadioButton("1000000"));
93 96
94 97 QGroupBox *groupBox = new QGroupBox("Row count");
General Comments 0
You need to be logged in to leave comments. Login now