##// 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 #include <qchartview.h>
4 #include <qchartview.h>
5 #include <qpieseries.h>
5 #include <qpieseries.h>
6 #include <qpieslice.h>
6 #include <qpieslice.h>
7 #include <qbarseries.h>
8 #include <qbarset.h>
7 #include <QGridLayout>
9 #include <QGridLayout>
8 #include <QFormLayout>
10 #include <QFormLayout>
9 #include <QComboBox>
11 #include <QComboBox>
@@ -38,7 +40,7 public:
38 // generate random data
40 // generate random data
39 int listCount = 3;
41 int listCount = 3;
40 int valueMax = 100;
42 int valueMax = 100;
41 int valueCount = 50;
43 int valueCount = 21;
42 for (int i(0); i < listCount; i++) {
44 for (int i(0); i < listCount; i++) {
43 DataList dataList;
45 DataList dataList;
44 for (int j(0); j < valueCount; j++) {
46 for (int j(0); j < valueCount; j++) {
@@ -85,6 +87,20 public:
85 chart->setChartTitle("bar chart");
87 chart->setChartTitle("bar chart");
86 chart->setRenderHint(QPainter::Antialiasing);
88 chart->setRenderHint(QPainter::Antialiasing);
87 baseLayout->addWidget(chart, 1, 1);
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 m_charts << chart;
104 m_charts << chart;
89
105
90 // line chart
106 // line chart
@@ -6,8 +6,12
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
7
8 Bar::Bar(QString category, QGraphicsItem *parent)
8 Bar::Bar(QString category, QGraphicsItem *parent)
9 : QGraphicsObject(parent)
9 : QGraphicsObject(parent),
10 ,mCategory(category)
10 mCategory(category),
11 mXpos(0),
12 mYpos(0),
13 mWidth(0),
14 mHeight(0)
11 {
15 {
12 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
16 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
13 setAcceptHoverEvents(true);
17 setAcceptHoverEvents(true);
@@ -12,11 +12,13
12
12
13 QTCOMMERCIALCHART_BEGIN_NAMESPACE
13 QTCOMMERCIALCHART_BEGIN_NAMESPACE
14
14
15 BarPresenterBase::BarPresenterBase(QBarSeries *series, QChart *parent)
15 BarPresenterBase::BarPresenterBase(QBarSeries *series, QChart *parent) :
16 : ChartItem(parent)
16 ChartItem(parent),
17 ,mLayoutSet(false)
17 mLayoutSet(false),
18 ,mSeries(series)
18 mSeries(series),
19 ,mChart(parent)
19 mChart(parent),
20 mWidth(0),
21 mHeight(0)
20 {
22 {
21 connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString)));
23 connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString)));
22 connect(series,SIGNAL(enableSeparators(bool)),this,SLOT(enableSeparators(bool)));
24 connect(series,SIGNAL(enableSeparators(bool)),this,SLOT(enableSeparators(bool)));
@@ -5,8 +5,12
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6
6
7 BarValue::BarValue(QBarSet &set, QGraphicsItem *parent)
7 BarValue::BarValue(QBarSet &set, QGraphicsItem *parent)
8 : QGraphicsObject(parent)
8 : QGraphicsObject(parent),
9 ,mBarSet(set)
9 mBarSet(set),
10 mXpos(0),
11 mYpos(0),
12 mWidth(0),
13 mHeight(0)
10 {
14 {
11 setVisible(false);
15 setVisible(false);
12 }
16 }
General Comments 0
You need to be logged in to leave comments. Login now