##// END OF EJS Templates
Fixed initial bounding rect issue with bar series
Tero Ahola -
r518:1db754feb986
parent child
Show More
@@ -4,6 +4,8
4 4 #include <qchartview.h>
5 5 #include <qpieseries.h>
6 6 #include <qpieslice.h>
7 #include <qbarseries.h>
8 #include <qbarset.h>
7 9 #include <QGridLayout>
8 10 #include <QFormLayout>
9 11 #include <QComboBox>
@@ -38,7 +40,7 public:
38 40 // generate random data
39 41 int listCount = 3;
40 42 int valueMax = 100;
41 int valueCount = 50;
43 int valueCount = 21;
42 44 for (int i(0); i < listCount; i++) {
43 45 DataList dataList;
44 46 for (int j(0); j < valueCount; j++) {
@@ -85,6 +87,20 public:
85 87 chart->setChartTitle("bar chart");
86 88 chart->setRenderHint(QPainter::Antialiasing);
87 89 baseLayout->addWidget(chart, 1, 1);
90 {
91 QStringList categories;
92 // TODO: categories
93 for (int i(0); i < valueCount; i++)
94 categories << QString::number(i);
95 QBarSeries* series = new QBarSeries(categories, chart);
96 for (int i(0); i < m_dataTable.count(); i++) {
97 QBarSet *set = new QBarSet("Set" + QString::number(i));
98 foreach (Data data, m_dataTable[i])
99 *set << data.first.y();
100 series->addBarSet(set);
101 }
102 chart->addSeries(series);
103 }
88 104 m_charts << chart;
89 105
90 106 // line chart
@@ -6,8 +6,12
6 6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 7
8 8 Bar::Bar(QString category, QGraphicsItem *parent)
9 : QGraphicsObject(parent)
10 ,mCategory(category)
9 : QGraphicsObject(parent),
10 mCategory(category),
11 mXpos(0),
12 mYpos(0),
13 mWidth(0),
14 mHeight(0)
11 15 {
12 16 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
13 17 setAcceptHoverEvents(true);
@@ -12,11 +12,13
12 12
13 13 QTCOMMERCIALCHART_BEGIN_NAMESPACE
14 14
15 BarPresenterBase::BarPresenterBase(QBarSeries *series, QChart *parent)
16 : ChartItem(parent)
17 ,mLayoutSet(false)
18 ,mSeries(series)
19 ,mChart(parent)
15 BarPresenterBase::BarPresenterBase(QBarSeries *series, QChart *parent) :
16 ChartItem(parent),
17 mLayoutSet(false),
18 mSeries(series),
19 mChart(parent),
20 mWidth(0),
21 mHeight(0)
20 22 {
21 23 connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString)));
22 24 connect(series,SIGNAL(enableSeparators(bool)),this,SLOT(enableSeparators(bool)));
@@ -44,7 +46,7 void BarPresenterBase::paint(QPainter *painter, const QStyleOptionGraphicsItem *
44 46
45 47 QRectF BarPresenterBase::boundingRect() const
46 48 {
47 return QRectF(0,0,mWidth,mHeight);
49 return QRectF(0, 0, mWidth, mHeight);
48 50 }
49 51
50 52 void BarPresenterBase::dataChanged()
@@ -5,8 +5,12
5 5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 6
7 7 BarValue::BarValue(QBarSet &set, QGraphicsItem *parent)
8 : QGraphicsObject(parent)
9 ,mBarSet(set)
8 : QGraphicsObject(parent),
9 mBarSet(set),
10 mXpos(0),
11 mYpos(0),
12 mWidth(0),
13 mHeight(0)
10 14 {
11 15 setVisible(false);
12 16 }
General Comments 0
You need to be logged in to leave comments. Login now