@@ -33,8 +33,8 int BarChartModel::countItemsInSeries() | |||||
33 | { |
|
33 | { | |
34 | int count(0); |
|
34 | int count(0); | |
35 | for (int i=0; i<mSeries.count(); i++){ |
|
35 | for (int i=0; i<mSeries.count(); i++){ | |
36 |
// TODO: can we assume that all series have same number of |
|
36 | // TODO: can we assume that all series have same number of values? If not. then which values are empty? | |
37 |
int temp = mSeries.at(i)->count |
|
37 | int temp = mSeries.at(i)->countValues(); | |
38 | if (temp > count) { |
|
38 | if (temp > count) { | |
39 | count = temp; |
|
39 | count = temp; | |
40 | } |
|
40 | } | |
@@ -86,7 +86,7 qreal BarChartModel::valueAt(int series, int item) | |||||
86 | if ((series < 0) || (series >= mSeries.count())) { |
|
86 | if ((series < 0) || (series >= mSeries.count())) { | |
87 | // No series, no value. |
|
87 | // No series, no value. | |
88 | return 0; |
|
88 | return 0; | |
89 |
} else if ((item < 0) || (item >= mSeries.at(series)->count |
|
89 | } else if ((item < 0) || (item >= mSeries.at(series)->countValues())) { | |
90 | // No item, no value. |
|
90 | // No item, no value. | |
91 | return 0; |
|
91 | return 0; | |
92 | } |
|
92 | } |
@@ -141,7 +141,7 qreal BarChartSeriesBase::max() | |||||
141 | return max; |
|
141 | return max; | |
142 | } |
|
142 | } | |
143 |
|
143 | |||
144 |
int BarChartSeriesBase::count |
|
144 | int BarChartSeriesBase::countValues() | |
145 | { |
|
145 | { | |
146 | Q_ASSERT(mData != 0); |
|
146 | Q_ASSERT(mData != 0); | |
147 | return mData->count(); |
|
147 | return mData->count(); |
@@ -39,7 +39,7 public: | |||||
39 |
|
39 | |||
40 | qreal min(); |
|
40 | qreal min(); | |
41 | qreal max(); |
|
41 | qreal max(); | |
42 |
int count |
|
42 | int countValues(); | |
43 | qreal valueAt(int item); |
|
43 | qreal valueAt(int item); | |
44 |
|
44 | |||
45 | public Q_SLOTS: |
|
45 | public Q_SLOTS: |
@@ -54,33 +54,38 void ChartDataSet::addSeries(QChartSeries* series) | |||||
54 | case QChartSeries::SeriesTypeBar: { |
|
54 | case QChartSeries::SeriesTypeBar: { | |
55 |
|
55 | |||
56 | BarChartSeries* barSeries = static_cast<BarChartSeries*>(series); |
|
56 | BarChartSeries* barSeries = static_cast<BarChartSeries*>(series); | |
57 |
qreal x = barSeries->count |
|
57 | qreal x = barSeries->countValues(); | |
58 | qreal y = barSeries->max(); |
|
58 | qreal y = barSeries->max(); | |
59 | domain.m_minX = qMin(domain.m_minX,x); |
|
59 | domain.m_minX = qMin(domain.m_minX,x); | |
60 | domain.m_minY = qMin(domain.m_minY,y); |
|
60 | domain.m_minY = qMin(domain.m_minY,y); | |
61 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
61 | domain.m_maxX = qMax(domain.m_maxX,x); | |
62 | domain.m_maxY = qMax(domain.m_maxY,y); |
|
62 | domain.m_maxY = qMax(domain.m_maxY,y); | |
|
63 | ||||
63 | } |
|
64 | } | |
64 | break; |
|
65 | break; | |
65 | case QChartSeries::SeriesTypeStackedBar: { |
|
66 | case QChartSeries::SeriesTypeStackedBar: { | |
66 |
|
67 | |||
67 | StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series); |
|
68 | StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series); | |
|
69 | /* | |||
68 | qreal x = stackedBarSeries->countColumns(); |
|
70 | qreal x = stackedBarSeries->countColumns(); | |
69 | qreal y = stackedBarSeries->maxColumnSum(); |
|
71 | qreal y = stackedBarSeries->maxColumnSum(); | |
70 | domain.m_minX = qMin(domain.m_minX,x); |
|
72 | domain.m_minX = qMin(domain.m_minX,x); | |
71 | domain.m_minY = qMin(domain.m_minY,y); |
|
73 | domain.m_minY = qMin(domain.m_minY,y); | |
72 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
74 | domain.m_maxX = qMax(domain.m_maxX,x); | |
73 | domain.m_maxY = qMax(domain.m_maxY,y); |
|
75 | domain.m_maxY = qMax(domain.m_maxY,y); | |
|
76 | */ | |||
74 | } |
|
77 | } | |
75 | break; |
|
78 | break; | |
76 | case QChartSeries::SeriesTypePercentBar: { |
|
79 | case QChartSeries::SeriesTypePercentBar: { | |
77 |
|
80 | |||
78 | PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series); |
|
81 | PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series); | |
|
82 | /* | |||
79 | qreal x = percentBarSeries->countColumns(); |
|
83 | qreal x = percentBarSeries->countColumns(); | |
80 | domain.m_minX = qMin(domain.m_minX,x); |
|
84 | domain.m_minX = qMin(domain.m_minX,x); | |
81 | domain.m_minY = 0; |
|
85 | domain.m_minY = 0; | |
82 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
86 | domain.m_maxX = qMax(domain.m_maxX,x); | |
83 | domain.m_maxY = 100; |
|
87 | domain.m_maxY = 100; | |
|
88 | */ | |||
84 | } |
|
89 | } | |
85 | break; |
|
90 | break; | |
86 |
|
91 |
General Comments 0
You need to be logged in to leave comments.
Login now