##// END OF EJS Templates
Change sizeHint of vertical axis, caculate width based on each label
Michal Klocek -
r2336:03ff7a7fe0a8
parent child
Show More
@@ -97,7 +97,6 QSizeF ChartDateTimeAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint
97 return sh;
97 return sh;
98 }
98 }
99
99
100
101 switch (which) {
100 switch (which) {
102 case Qt::MinimumSize:{
101 case Qt::MinimumSize:{
103 int count = qMax(ticksList.last().count(),ticksList.first().count());
102 int count = qMax(ticksList.last().count(),ticksList.first().count());
@@ -94,10 +94,18 QSizeF ChartDateTimeAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
94 qreal width = 0;
94 qreal width = 0;
95 qreal height = 0;
95 qreal height = 0;
96
96
97
97 if(ticksList.empty()){
98 if(ticksList.empty()){
98 return sh;
99 return sh;
99 }
100 }
100
101
102 int labelWidth = 0;
103
104 foreach(const QString& s, ticksList)
105 {
106 labelWidth=qMax(fn.width(s),labelWidth);
107 }
108
101 switch (which) {
109 switch (which) {
102 case Qt::MinimumSize: {
110 case Qt::MinimumSize: {
103 width = fn.boundingRect("...").width() + labelPadding();
111 width = fn.boundingRect("...").width() + labelPadding();
@@ -108,8 +116,7 QSizeF ChartDateTimeAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint
108 break;
116 break;
109 }
117 }
110 case Qt::PreferredSize: {
118 case Qt::PreferredSize: {
111 int count = qMax(ticksList.first().count() , ticksList.last().count());
119 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
112 width = count*fn.averageCharWidth() + labelPadding() + 2; //two pixels of tolerance
113 width += base.width();
120 width += base.width();
114 height = fn.height() * ticksList.count();
121 height = fn.height() * ticksList.count();
115 height = qMax(height,base.height());
122 height = qMax(height,base.height());
@@ -95,10 +95,11 QSizeF ChartValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
95 qreal width = 0;
95 qreal width = 0;
96 qreal height = 0;
96 qreal height = 0;
97
97
98 int count = 1;
98 int labelWidth = 0;
99
99
100 if(!ticksList.empty()){
100 foreach(const QString& s, ticksList)
101 count = qMax(ticksList.last().count(),ticksList.first().count());
101 {
102 labelWidth=qMax(fn.width(s),labelWidth);
102 }
103 }
103
104
104 switch (which) {
105 switch (which) {
@@ -112,7 +113,7 QSizeF ChartValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
112 }
113 }
113 case Qt::PreferredSize:
114 case Qt::PreferredSize:
114 {
115 {
115 width = count*fn.averageCharWidth() + labelPadding() + 2; //two pixels of tolerance
116 width = labelWidth + labelPadding() + 2; //two pixels of tolerance
116 width += base.width();
117 width += base.width();
117 height = fn.height() * ticksList.count();
118 height = fn.height() * ticksList.count();
118 height = qMax(height,base.height());
119 height = qMax(height,base.height());
General Comments 0
You need to be logged in to leave comments. Login now