##// END OF EJS Templates
Rename QLineChartSeries to QLineSeries
Michal Klocek -
r349:7594bc4927de
parent child
Show More
@@ -13,8 +13,8 integrated_build:{
13
13
14 CONFIG += ordered
14 CONFIG += ordered
15 QMAKE_CXXFLAGS += -g -Wall
15 QMAKE_CXXFLAGS += -g -Wall
16 unix:QMAKE_DISTCLEAN += -r build bin doc/html
16 unix:QMAKE_DISTCLEAN += -r build bin include lib doc/html
17 win32:QMAKE_DISTCLEAN += /Q /s build bin doc\\html
17 win32:QMAKE_DISTCLEAN += /Q /s build bin include lib doc\\html
18
18
19 # install feature file
19 # install feature file
20 feature.path = $$[QT_INSTALL_DATA]/mkspecs/features
20 feature.path = $$[QT_INSTALL_DATA]/mkspecs/features
@@ -1,7 +1,7
1 #include <QApplication>
1 #include <QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartview.h>
3 #include <qchartview.h>
4 #include <qlinechartseries.h>
4 #include <qlineseries.h>
5 #include <qchart.h>
5 #include <qchart.h>
6 #include <qchartaxis.h>
6 #include <qchartaxis.h>
7 #include <cmath>
7 #include <cmath>
@@ -16,11 +16,11 int main(int argc, char *argv[])
16
16
17 QMainWindow window;
17 QMainWindow window;
18
18
19 QLineChartSeries* series0 = new QLineChartSeries();
19 QLineSeries* series0 = new QLineSeries();
20 QPen blue(Qt::blue);
20 QPen blue(Qt::blue);
21 blue.setWidth(3);
21 blue.setWidth(3);
22 series0->setPen(blue);
22 series0->setPen(blue);
23 QLineChartSeries* series1 = new QLineChartSeries();
23 QLineSeries* series1 = new QLineSeries();
24 QPen red(Qt::red);
24 QPen red(Qt::red);
25 red.setWidth(3);
25 red.setWidth(3);
26 series1->setPen(red);
26 series1->setPen(red);
@@ -2,7 +2,7
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartglobal.h>
3 #include <qchartglobal.h>
4 #include <qchartview.h>
4 #include <qchartview.h>
5 #include <qlinechartseries.h>
5 #include <qlineseries.h>
6 #include <qscatterseries.h>
6 #include <qscatterseries.h>
7 #include <qbarseries.h>
7 #include <qbarseries.h>
8 #include <qbarset.h>
8 #include <qbarset.h>
@@ -21,7 +21,7 int main(int argc, char *argv[])
21 chartView->setRenderHint(QPainter::Antialiasing);
21 chartView->setRenderHint(QPainter::Antialiasing);
22 chartView->setChartTitle("Simple Line Chart");
22 chartView->setChartTitle("Simple Line Chart");
23 // Add series to the chart
23 // Add series to the chart
24 QLineChartSeries *line = new QLineChartSeries();
24 QLineSeries *line = new QLineSeries();
25 line->add(0.0, 0.8);
25 line->add(0.0, 0.8);
26 line->add(1.1, 1.1);
26 line->add(1.1, 1.1);
27 line->add(2.0, 2.5);
27 line->add(2.0, 2.5);
@@ -1,7 +1,7
1 #include <QApplication>
1 #include <QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartview.h>
3 #include <qchartview.h>
4 #include <qlinechartseries.h>
4 #include <qlineseries.h>
5 #include <qchart.h>
5 #include <qchart.h>
6 #include <cmath>
6 #include <cmath>
7
7
@@ -15,11 +15,11 int main(int argc, char *argv[])
15
15
16 QMainWindow window;
16 QMainWindow window;
17
17
18 QLineChartSeries* series0 = new QLineChartSeries();
18 QLineSeries* series0 = new QLineSeries();
19 QPen blue(Qt::blue);
19 QPen blue(Qt::blue);
20 blue.setWidth(3);
20 blue.setWidth(3);
21 series0->setPen(blue);
21 series0->setPen(blue);
22 QLineChartSeries* series1 = new QLineChartSeries();
22 QLineSeries* series1 = new QLineSeries();
23 QPen red(Qt::red);
23 QPen red(Qt::red);
24 red.setWidth(3);
24 red.setWidth(3);
25 series1->setPen(red);
25 series1->setPen(red);
@@ -1,7 +1,7
1 #include <QApplication>
1 #include <QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartview.h>
3 #include <qchartview.h>
4 #include <qlinechartseries.h>
4 #include <qlineseries.h>
5 #include <qchart.h>
5 #include <qchart.h>
6 #include <cmath>
6 #include <cmath>
7 #include "wavegenerator.h"
7 #include "wavegenerator.h"
@@ -13,11 +13,11 int main(int argc, char *argv[])
13
13
14 QMainWindow window;
14 QMainWindow window;
15
15
16 QLineChartSeries* series0 = new QLineChartSeries();
16 QLineSeries* series0 = new QLineSeries();
17 QPen blue(Qt::blue);
17 QPen blue(Qt::blue);
18 blue.setWidth(3);
18 blue.setWidth(3);
19 series0->setPen(blue);
19 series0->setPen(blue);
20 QLineChartSeries* series1 = new QLineChartSeries();
20 QLineSeries* series1 = new QLineSeries();
21 QPen red(Qt::red);
21 QPen red(Qt::red);
22 red.setWidth(3);
22 red.setWidth(3);
23 series1->setPen(red);
23 series1->setPen(red);
@@ -2,7 +2,7
2 #include <QTime>
2 #include <QTime>
3 #include <QObject>
3 #include <QObject>
4 #include <cmath>
4 #include <cmath>
5 #include <qlinechartseries.h>
5 #include <qlineseries.h>
6
6
7 QTCOMMERCIALCHART_USE_NAMESPACE
7 QTCOMMERCIALCHART_USE_NAMESPACE
8
8
@@ -14,7 +14,7 class WaveGenerator: public QObject
14 Q_OBJECT
14 Q_OBJECT
15
15
16 public:
16 public:
17 WaveGenerator(QLineChartSeries* series1, QLineChartSeries* series2) :
17 WaveGenerator(QLineSeries* series1, QLineSeries* series2) :
18 m_series1(series1),
18 m_series1(series1),
19 m_series2(series2),
19 m_series2(series2),
20 m_wave(0),
20 m_wave(0),
@@ -52,8 +52,8 public slots:
52 }
52 }
53
53
54 private:
54 private:
55 QLineChartSeries* m_series1;
55 QLineSeries* m_series1;
56 QLineChartSeries* m_series2;
56 QLineSeries* m_series2;
57 int m_wave;
57 int m_wave;
58 qreal m_step;
58 qreal m_step;
59 QTimer m_timer;
59 QTimer m_timer;
@@ -1,7 +1,7
1 #include <QApplication>
1 #include <QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartview.h>
3 #include <qchartview.h>
4 #include <qlinechartseries.h>
4 #include <qlineseries.h>
5 #include <qchart.h>
5 #include <qchart.h>
6 #include <cmath>
6 #include <cmath>
7
7
@@ -15,12 +15,12 int main(int argc, char *argv[])
15
15
16 //![1]
16 //![1]
17
17
18 QLineChartSeries* series0 = new QLineChartSeries();
18 QLineSeries* series0 = new QLineSeries();
19 QPen blue(Qt::blue);
19 QPen blue(Qt::blue);
20 blue.setWidth(3);
20 blue.setWidth(3);
21 series0->setPen(blue);
21 series0->setPen(blue);
22
22
23 QLineChartSeries* series1 = new QLineChartSeries();
23 QLineSeries* series1 = new QLineSeries();
24 QPen red(Qt::red);
24 QPen red(Qt::red);
25 red.setWidth(3);
25 red.setWidth(3);
26 series1->setPen(red);
26 series1->setPen(red);
@@ -1,5 +1,5
1 #include "chartview.h"
1 #include "chartview.h"
2 #include <qlinechartseries.h>
2 #include <qlineseries.h>
3 #include <QTime>
3 #include <QTime>
4
4
5 ChartView::ChartView(QWidget* parent):QChartView(parent),
5 ChartView::ChartView(QWidget* parent):QChartView(parent),
@@ -11,15 +11,15 m_index(0)
11 QTime now = QTime::currentTime();
11 QTime now = QTime::currentTime();
12 qsrand((uint)now.msec());
12 qsrand((uint)now.msec());
13
13
14 QLineChartSeries* series0 = new QLineChartSeries();
14 QLineSeries* series0 = new QLineSeries();
15 QPen blue(Qt::blue);
15 QPen blue(Qt::blue);
16 blue.setWidth(3);
16 blue.setWidth(3);
17 series0->setPen(blue);
17 series0->setPen(blue);
18 QLineChartSeries* series1 = new QLineChartSeries();
18 QLineSeries* series1 = new QLineSeries();
19 QPen red(Qt::red);
19 QPen red(Qt::red);
20 red.setWidth(3);
20 red.setWidth(3);
21 series1->setPen(red);
21 series1->setPen(red);
22 QLineChartSeries* series2 = new QLineChartSeries();
22 QLineSeries* series2 = new QLineSeries();
23 QPen green(Qt::green);
23 QPen green(Qt::green);
24 green.setWidth(3);
24 green.setWidth(3);
25 series2->setPen(green);
25 series2->setPen(green);
@@ -1,7 +1,7
1 #include "chartwidget.h"
1 #include "chartwidget.h"
2 #include <QApplication>
2 #include <QApplication>
3 #include <QMainWindow>
3 #include <QMainWindow>
4 #include <qlinechartseries.h>
4 #include <qlineseries.h>
5 #include <cmath>
5 #include <cmath>
6
6
7 QTCOMMERCIALCHART_USE_NAMESPACE
7 QTCOMMERCIALCHART_USE_NAMESPACE
@@ -14,11 +14,11 int main(int argc, char *argv[])
14
14
15 QMainWindow window;
15 QMainWindow window;
16
16
17 QLineChartSeries* series0 = new QLineChartSeries();
17 QLineSeries* series0 = new QLineSeries();
18 QPen blue(Qt::blue);
18 QPen blue(Qt::blue);
19 blue.setWidth(3);
19 blue.setWidth(3);
20 series0->setPen(blue);
20 series0->setPen(blue);
21 QLineChartSeries* series1 = new QLineChartSeries();
21 QLineSeries* series1 = new QLineSeries();
22 QPen red(Qt::red);
22 QPen red(Qt::red);
23 red.setWidth(3);
23 red.setWidth(3);
24 series1->setPen(red);
24 series1->setPen(red);
@@ -1,7 +1,7
1 #include "declarativelineseries.h"
1 #include "declarativelineseries.h"
2 #include "declarativechart.h"
2 #include "declarativechart.h"
3 #include "qchart.h"
3 #include "qchart.h"
4 #include "qlinechartseries.h"
4 #include "qlineseries.h"
5
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
7
@@ -23,7 +23,7 void DeclarativeLineSeries::setParentForSeries()
23 qDebug() << "creating line series for chart: " << chart;
23 qDebug() << "creating line series for chart: " << chart;
24 Q_ASSERT(chart);
24 Q_ASSERT(chart);
25
25
26 m_series = new QLineChartSeries();
26 m_series = new QLineSeries();
27 Q_ASSERT(m_series);
27 Q_ASSERT(m_series);
28 for (int i(0); i < m_data.count(); i++) {
28 for (int i(0); i < m_data.count(); i++) {
29 ScatterElement *element = m_data.at(i);
29 ScatterElement *element = m_data.at(i);
@@ -8,7 +8,7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class QChart;
10 class QChart;
11 class QLineChartSeries;
11 class QLineSeries;
12
12
13 class DeclarativeLineSeries : public QDeclarativeItem
13 class DeclarativeLineSeries : public QDeclarativeItem
14 {
14 {
@@ -30,7 +30,7 private slots:
30
30
31 private:
31 private:
32 QChart *m_chart;
32 QChart *m_chart;
33 QLineChartSeries *m_series;
33 QLineSeries *m_series;
34 QList<ScatterElement *> m_data;
34 QList<ScatterElement *> m_data;
35 };
35 };
36
36
@@ -1,7 +1,7
1 #include "chartdataset_p.h"
1 #include "chartdataset_p.h"
2 #include "qchartaxis.h"
2 #include "qchartaxis.h"
3 //series
3 //series
4 #include "qlinechartseries.h"
4 #include "qlineseries.h"
5 #include "qbarseries.h"
5 #include "qbarseries.h"
6 #include "qstackedbarseries.h"
6 #include "qstackedbarseries.h"
7 #include "qpercentbarseries.h"
7 #include "qpercentbarseries.h"
@@ -57,7 +57,7 void ChartDataSet::addSeries(QChartSeries* series, QChartAxis *axisY)
57 {
57 {
58 case QChartSeries::SeriesTypeLine: {
58 case QChartSeries::SeriesTypeLine: {
59
59
60 QLineChartSeries* xyseries = static_cast<QLineChartSeries*>(series);
60 QLineSeries* xyseries = static_cast<QLineSeries*>(series);
61
61
62 for (int i = 0; i < xyseries->count(); i++)
62 for (int i = 0; i < xyseries->count(); i++)
63 {
63 {
@@ -7,7 +7,7
7 #include "qbarseries.h"
7 #include "qbarseries.h"
8 #include "qstackedbarseries.h"
8 #include "qstackedbarseries.h"
9 #include "qpercentbarseries.h"
9 #include "qpercentbarseries.h"
10 #include "qlinechartseries.h"
10 #include "qlineseries.h"
11 #include "qpieseries.h"
11 #include "qpieseries.h"
12 #include "qscatterseries.h"
12 #include "qscatterseries.h"
13 //items
13 //items
@@ -109,7 +109,7 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
109 switch(series->type())
109 switch(series->type())
110 {
110 {
111 case QChartSeries::SeriesTypeLine: {
111 case QChartSeries::SeriesTypeLine: {
112 QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series);
112 QLineSeries* lineSeries = static_cast<QLineSeries*>(series);
113 LineChartItem* item;
113 LineChartItem* item;
114 if(m_options.testFlag(QChart::SeriesAnimations)){
114 if(m_options.testFlag(QChart::SeriesAnimations)){
115 item = new LineChartAnimationItem(this,lineSeries,m_chart);
115 item = new LineChartAnimationItem(this,lineSeries,m_chart);
@@ -8,7 +8,7
8 #include "qbarseries.h"
8 #include "qbarseries.h"
9 #include "qstackedbarseries.h"
9 #include "qstackedbarseries.h"
10 #include "qpercentbarseries.h"
10 #include "qpercentbarseries.h"
11 #include "qlinechartseries.h"
11 #include "qlineseries.h"
12 #include "qscatterseries.h"
12 #include "qscatterseries.h"
13 #include "qpieseries.h"
13 #include "qpieseries.h"
14 #include "qpieslice.h"
14 #include "qpieslice.h"
@@ -85,7 +85,7 void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count)
85 switch(series->type())
85 switch(series->type())
86 {
86 {
87 case QChartSeries::SeriesTypeLine: {
87 case QChartSeries::SeriesTypeLine: {
88 QLineChartSeries* s = static_cast<QLineChartSeries*>(series);
88 QLineSeries* s = static_cast<QLineSeries*>(series);
89 LineChartItem* i = static_cast<LineChartItem*>(item);
89 LineChartItem* i = static_cast<LineChartItem*>(item);
90 decorate(i,s,count);
90 decorate(i,s,count);
91 break;
91 break;
@@ -129,7 +129,7 void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count)
129
129
130 }
130 }
131
131
132 void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int count)
132 void ChartTheme::decorate(LineChartItem* item, QLineSeries* series,int count)
133 {
133 {
134 QPen pen;
134 QPen pen;
135 if(pen != series->pen()){
135 if(pen != series->pen()){
@@ -10,7 +10,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 class ChartItem;
10 class ChartItem;
11 class QChartSeries;
11 class QChartSeries;
12 class LineChartItem;
12 class LineChartItem;
13 class QLineChartSeries;
13 class QLineSeries;
14 class BarPresenter;
14 class BarPresenter;
15 class QBarSeries;
15 class QBarSeries;
16 class StackedBarPresenter;
16 class StackedBarPresenter;
@@ -31,10 +31,10 public:
31 QChart::ChartTheme id() const {return m_id;}
31 QChart::ChartTheme id() const {return m_id;}
32 void decorate(QChart* chart);
32 void decorate(QChart* chart);
33 void decorate(ChartItem* item, QChartSeries* series,int count);
33 void decorate(ChartItem* item, QChartSeries* series,int count);
34 void decorate(LineChartItem* item, QLineChartSeries*, int count);
35 void decorate(BarPresenter* item, QBarSeries* series,int count);
34 void decorate(BarPresenter* item, QBarSeries* series,int count);
36 void decorate(StackedBarPresenter* item, QStackedBarSeries* series,int count);
35 void decorate(StackedBarPresenter* item, QStackedBarSeries* series,int count);
37 void decorate(PercentBarPresenter* item, QPercentBarSeries* series,int count);
36 void decorate(PercentBarPresenter* item, QPercentBarSeries* series,int count);
37 void decorate(LineChartItem* item, QLineSeries*, int count);
38 void decorate(ScatterPresenter* presenter, QScatterSeries* series, int count);
38 void decorate(ScatterPresenter* presenter, QScatterSeries* series, int count);
39 void decorate(PiePresenter* item, QPieSeries* series, int count);
39 void decorate(PiePresenter* item, QPieSeries* series, int count);
40 void decorate(QChartAxis* axis,AxisItem* item);
40 void decorate(QChartAxis* axis,AxisItem* item);
@@ -4,11 +4,11 DEPENDPATH += $$PWD
4 SOURCES += \
4 SOURCES += \
5 $$PWD/linechartanimationitem.cpp \
5 $$PWD/linechartanimationitem.cpp \
6 $$PWD/linechartitem.cpp \
6 $$PWD/linechartitem.cpp \
7 $$PWD/qlinechartseries.cpp
7 $$PWD/qlineseries.cpp
8
8
9 PRIVATE_HEADERS += \
9 PRIVATE_HEADERS += \
10 $$PWD/linechartitem_p.h \
10 $$PWD/linechartitem_p.h \
11 $$PWD/linechartanimationitem_p.h
11 $$PWD/linechartanimationitem_p.h
12
12
13 PUBLIC_HEADERS += \
13 PUBLIC_HEADERS += \
14 $$PWD/qlinechartseries.h No newline at end of file
14 $$PWD/qlineseries.h No newline at end of file
@@ -7,7 +7,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 const static int duration = 500;
7 const static int duration = 500;
8
8
9
9
10 LineChartAnimationItem::LineChartAnimationItem(ChartPresenter* presenter, QLineChartSeries* series,QGraphicsItem *parent):
10 LineChartAnimationItem::LineChartAnimationItem(ChartPresenter* presenter, QLineSeries* series,QGraphicsItem *parent):
11 LineChartItem(presenter,series,parent)
11 LineChartItem(presenter,series,parent)
12 {
12 {
13
13
@@ -14,7 +14,7 class LineChartAnimationItem : public LineChartItem {
14 Q_PROPERTY(int a_addPoints READ ar_addPoints WRITE aw_addPoints);
14 Q_PROPERTY(int a_addPoints READ ar_addPoints WRITE aw_addPoints);
15 // Q_PROPERTY(QPointF a_setPoint READ ar_setPoint WRITE aw_setPoint);
15 // Q_PROPERTY(QPointF a_setPoint READ ar_setPoint WRITE aw_setPoint);
16 public:
16 public:
17 LineChartAnimationItem(ChartPresenter* presenter, QLineChartSeries *series, QGraphicsItem *parent = 0);
17 LineChartAnimationItem(ChartPresenter* presenter, QLineSeries *series, QGraphicsItem *parent = 0);
18 virtual ~LineChartAnimationItem();
18 virtual ~LineChartAnimationItem();
19
19
20 void addPoints(const QVector<QPointF>& points);
20 void addPoints(const QVector<QPointF>& points);
@@ -1,5 +1,5
1 #include "linechartitem_p.h"
1 #include "linechartitem_p.h"
2 #include "qlinechartseries.h"
2 #include "qlineseries.h"
3 #include "chartpresenter_p.h"
3 #include "chartpresenter_p.h"
4 #include <QPainter>
4 #include <QPainter>
5
5
@@ -8,7 +8,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 //TODO: optimazie : remove points which are not visible
9 //TODO: optimazie : remove points which are not visible
10
10
11 LineChartItem::LineChartItem(ChartPresenter* presenter, QLineChartSeries* series,QGraphicsItem *parent):ChartItem(parent),
11 LineChartItem::LineChartItem(ChartPresenter* presenter, QLineSeries* series,QGraphicsItem *parent):ChartItem(parent),
12 m_presenter(presenter),
12 m_presenter(presenter),
13 m_series(series),
13 m_series(series),
14 m_dirtyData(false),
14 m_dirtyData(false),
@@ -111,7 +111,7 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
111 painter->restore();
111 painter->restore();
112 }
112 }
113
113
114 void LineChartItem::calculatePoint(QPointF& point, int index, const QLineChartSeries* series,const QSizeF& size, const Domain& domain) const
114 void LineChartItem::calculatePoint(QPointF& point, int index, const QLineSeries* series,const QSizeF& size, const Domain& domain) const
115 {
115 {
116 const qreal deltaX = size.width()/domain.spanX();
116 const qreal deltaX = size.width()/domain.spanX();
117 const qreal deltaY = size.height()/domain.spanY();
117 const qreal deltaY = size.height()/domain.spanY();
@@ -122,7 +122,7 void LineChartItem::calculatePoint(QPointF& point, int index, const QLineChartSe
122 }
122 }
123
123
124
124
125 void LineChartItem::calculatePoints(QVector<QPointF>& points, QHash<int,int>& hash,const QLineChartSeries* series,const QSizeF& size, const Domain& domain) const
125 void LineChartItem::calculatePoints(QVector<QPointF>& points, QHash<int,int>& hash,const QLineSeries* series,const QSizeF& size, const Domain& domain) const
126 {
126 {
127 const qreal deltaX = size.width()/domain.spanX();
127 const qreal deltaX = size.width()/domain.spanX();
128 const qreal deltaY = size.height()/domain.spanY();
128 const qreal deltaY = size.height()/domain.spanY();
@@ -8,14 +8,14
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 class ChartPresenter;
10 class ChartPresenter;
11 class QLineChartSeries;
11 class QLineSeries;
12 class LineChartAnimationItem;
12 class LineChartAnimationItem;
13
13
14 class LineChartItem : public QObject , public ChartItem
14 class LineChartItem : public QObject , public ChartItem
15 {
15 {
16 Q_OBJECT
16 Q_OBJECT
17 public:
17 public:
18 LineChartItem(ChartPresenter* presenter, QLineChartSeries* series,QGraphicsItem *parent = 0);
18 LineChartItem(ChartPresenter* presenter, QLineSeries* series,QGraphicsItem *parent = 0);
19 ~ LineChartItem(){};
19 ~ LineChartItem(){};
20
20
21 //from QGraphicsItem
21 //from QGraphicsItem
@@ -43,8 +43,8 protected:
43 virtual void updateData();
43 virtual void updateData();
44 virtual void updateDomain();
44 virtual void updateDomain();
45 //refactor
45 //refactor
46 void calculatePoint(QPointF& point, int index, const QLineChartSeries* series,const QSizeF& size, const Domain& domain) const;
46 void calculatePoint(QPointF& point, int index, const QLineSeries* series,const QSizeF& size, const Domain& domain) const;
47 void calculatePoints(QVector<QPointF>& points,QHash<int,int>& hash,const QLineChartSeries* series, const QSizeF& size, const Domain& domain) const;
47 void calculatePoints(QVector<QPointF>& points,QHash<int,int>& hash,const QLineSeries* series, const QSizeF& size, const Domain& domain) const;
48
48
49 protected slots:
49 protected slots:
50 void handleModelChanged(int index);
50 void handleModelChanged(int index);
@@ -61,7 +61,7 private:
61 QList<QGraphicsItem*> m_points;
61 QList<QGraphicsItem*> m_points;
62 QVector<QPointF> m_data;
62 QVector<QPointF> m_data;
63 QHash<int,int> m_hash;
63 QHash<int,int> m_hash;
64 QLineChartSeries* m_series;
64 QLineSeries* m_series;
65 QPen m_pen;
65 QPen m_pen;
66 bool m_dirtyData;
66 bool m_dirtyData;
67 bool m_dirtyGeometry;
67 bool m_dirtyGeometry;
@@ -1,4 +1,4
1 #include "qlinechartseries.h"
1 #include "qlineseries.h"
2
2
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
@@ -55,7 +55,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
55 Constructs empty series object which is a child of \a parent.
55 Constructs empty series object which is a child of \a parent.
56 When series object is added to QChartView or QChart instance ownerships is transfered.
56 When series object is added to QChartView or QChart instance ownerships is transfered.
57 */
57 */
58 QLineChartSeries::QLineChartSeries(QObject* parent):QChartSeries(parent),
58 QLineSeries::QLineSeries(QObject* parent):QChartSeries(parent),
59 m_pointsVisible(false)
59 m_pointsVisible(false)
60 {
60 {
61 }
61 }
@@ -63,14 +63,14 m_pointsVisible(false)
63 Destroys the object. Series added to QChartView or QChart instances are owned by those,
63 Destroys the object. Series added to QChartView or QChart instances are owned by those,
64 and are deleted when mentioned object are destroyed.
64 and are deleted when mentioned object are destroyed.
65 */
65 */
66 QLineChartSeries::~QLineChartSeries()
66 QLineSeries::~QLineSeries()
67 {
67 {
68 }
68 }
69
69
70 /*!
70 /*!
71 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
71 Adds data point \a x \a y to the series. Points are connected with lines on the chart.
72 */
72 */
73 void QLineChartSeries::add(qreal x,qreal y)
73 void QLineSeries::add(qreal x,qreal y)
74 {
74 {
75 m_x<<x;
75 m_x<<x;
76 m_y<<y;
76 m_y<<y;
@@ -80,7 +80,7 void QLineChartSeries::add(qreal x,qreal y)
80 This is an overloaded function.
80 This is an overloaded function.
81 Adds data \a point to the series. Points are connected with lines on the chart.
81 Adds data \a point to the series. Points are connected with lines on the chart.
82 */
82 */
83 void QLineChartSeries::add(const QPointF& point)
83 void QLineSeries::add(const QPointF& point)
84 {
84 {
85 m_x<<point.x();
85 m_x<<point.x();
86 m_y<<point.y();
86 m_y<<point.y();
@@ -89,7 +89,7 void QLineChartSeries::add(const QPointF& point)
89 /*!
89 /*!
90 Modifies \a y value for given \a x a value.
90 Modifies \a y value for given \a x a value.
91 */
91 */
92 void QLineChartSeries::replace(qreal x,qreal y)
92 void QLineSeries::replace(qreal x,qreal y)
93 {
93 {
94 int index = m_x.indexOf(x);
94 int index = m_x.indexOf(x);
95 m_x[index]=x;
95 m_x[index]=x;
@@ -101,7 +101,7 void QLineChartSeries::replace(qreal x,qreal y)
101 This is an overloaded function.
101 This is an overloaded function.
102 Replaces current y value of for given \a point x value with \a point y value.
102 Replaces current y value of for given \a point x value with \a point y value.
103 */
103 */
104 void QLineChartSeries::replace(const QPointF& point)
104 void QLineSeries::replace(const QPointF& point)
105 {
105 {
106 int index = m_x.indexOf(point.x());
106 int index = m_x.indexOf(point.x());
107 m_x[index]=point.x();
107 m_x[index]=point.x();
@@ -112,7 +112,7 void QLineChartSeries::replace(const QPointF& point)
112 /*!
112 /*!
113 Removes current \a x and y value.
113 Removes current \a x and y value.
114 */
114 */
115 void QLineChartSeries::remove(qreal x)
115 void QLineSeries::remove(qreal x)
116 {
116 {
117
117
118 }
118 }
@@ -120,7 +120,7 void QLineChartSeries::remove(qreal x)
120 /*!
120 /*!
121 Removes current \a point x value. Note \point y value is ignored.
121 Removes current \a point x value. Note \point y value is ignored.
122 */
122 */
123 void QLineChartSeries::remove(const QPointF& point)
123 void QLineSeries::remove(const QPointF& point)
124 {
124 {
125
125
126 }
126 }
@@ -128,7 +128,7 void QLineChartSeries::remove(const QPointF& point)
128 /*!
128 /*!
129 Clears all the data.
129 Clears all the data.
130 */
130 */
131 void QLineChartSeries::clear()
131 void QLineSeries::clear()
132 {
132 {
133 m_x.clear();
133 m_x.clear();
134 m_y.clear();
134 m_y.clear();
@@ -137,7 +137,7 void QLineChartSeries::clear()
137 /*!
137 /*!
138 \internal \a pos
138 \internal \a pos
139 */
139 */
140 qreal QLineChartSeries::x(int pos) const
140 qreal QLineSeries::x(int pos) const
141 {
141 {
142 return m_x.at(pos);
142 return m_x.at(pos);
143 }
143 }
@@ -145,7 +145,7 qreal QLineChartSeries::x(int pos) const
145 /*!
145 /*!
146 \internal \a pos
146 \internal \a pos
147 */
147 */
148 qreal QLineChartSeries::y(int pos) const
148 qreal QLineSeries::y(int pos) const
149 {
149 {
150 return m_y.at(pos);
150 return m_y.at(pos);
151 }
151 }
@@ -153,7 +153,7 qreal QLineChartSeries::y(int pos) const
153 /*!
153 /*!
154 Returns number of data points within series.
154 Returns number of data points within series.
155 */
155 */
156 int QLineChartSeries::count() const
156 int QLineSeries::count() const
157 {
157 {
158 Q_ASSERT(m_x.size() == m_y.size());
158 Q_ASSERT(m_x.size() == m_y.size());
159
159
@@ -164,7 +164,7 int QLineChartSeries::count() const
164 /*!
164 /*!
165 Sets \a pen used for drawing given series..
165 Sets \a pen used for drawing given series..
166 */
166 */
167 void QLineChartSeries::setPen(const QPen& pen)
167 void QLineSeries::setPen(const QPen& pen)
168 {
168 {
169 m_pen=pen;
169 m_pen=pen;
170 }
170 }
@@ -172,12 +172,12 void QLineChartSeries::setPen(const QPen& pen)
172 /*!
172 /*!
173 Sets if data points are \a visible and should be drawn on line.
173 Sets if data points are \a visible and should be drawn on line.
174 */
174 */
175 void QLineChartSeries::setPointsVisible(bool visible)
175 void QLineSeries::setPointsVisible(bool visible)
176 {
176 {
177 m_pointsVisible=visible;
177 m_pointsVisible=visible;
178 }
178 }
179
179
180 QDebug operator<< (QDebug debug, const QLineChartSeries series)
180 QDebug operator<< (QDebug debug, const QLineSeries series)
181 {
181 {
182 Q_ASSERT(series.m_x.size() == series.m_y.size());
182 Q_ASSERT(series.m_x.size() == series.m_y.size());
183
183
@@ -190,6 +190,6 QDebug operator<< (QDebug debug, const QLineChartSeries series)
190 }
190 }
191
191
192
192
193 #include "moc_qlinechartseries.cpp"
193 #include "moc_qlineseries.cpp"
194
194
195 QTCOMMERCIALCHART_END_NAMESPACE
195 QTCOMMERCIALCHART_END_NAMESPACE
@@ -9,12 +9,12
9
9
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11
11
12 class QTCOMMERCIALCHART_EXPORT QLineChartSeries : public QChartSeries
12 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QChartSeries
13 {
13 {
14 Q_OBJECT
14 Q_OBJECT
15 public:
15 public:
16 QLineChartSeries(QObject* parent=0);
16 QLineSeries(QObject* parent=0);
17 virtual ~QLineChartSeries();
17 virtual ~QLineSeries();
18
18
19 public: // from QChartSeries
19 public: // from QChartSeries
20 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;}
20 virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeLine;}
@@ -35,7 +35,7 public: // from QChartSeries
35 int count() const;
35 int count() const;
36 qreal x(int pos) const;
36 qreal x(int pos) const;
37 qreal y(int pos) const;
37 qreal y(int pos) const;
38 friend QDebug operator<< (QDebug d, const QLineChartSeries series);
38 friend QDebug operator<< (QDebug d, const QLineSeries series);
39
39
40 signals:
40 signals:
41 void changed(int index);
41 void changed(int index);
@@ -1,7 +1,7
1 #include <QtTest/QtTest>
1 #include <QtTest/QtTest>
2 #include <qchartaxis.h>
2 #include <qchartaxis.h>
3 #include <qchartseries.h>
3 #include <qchartseries.h>
4 #include <qlinechartseries.h>
4 #include <qlineseries.h>
5 #include <private/chartdataset_p.h>
5 #include <private/chartdataset_p.h>
6 #include <private/domain_p.h>
6 #include <private/domain_p.h>
7
7
@@ -10,7 +10,7 QTCOMMERCIALCHART_USE_NAMESPACE
10 Q_DECLARE_METATYPE(Domain)
10 Q_DECLARE_METATYPE(Domain)
11 Q_DECLARE_METATYPE(QChartAxis*)
11 Q_DECLARE_METATYPE(QChartAxis*)
12 Q_DECLARE_METATYPE(QChartSeries*)
12 Q_DECLARE_METATYPE(QChartSeries*)
13 Q_DECLARE_METATYPE(QLineChartSeries*)
13 Q_DECLARE_METATYPE(QLineSeries*)
14
14
15 class tst_ChartDataSet: public QObject {
15 class tst_ChartDataSet: public QObject {
16 Q_OBJECT
16 Q_OBJECT
@@ -99,7 +99,7 void tst_ChartDataSet::addDomain()
99 ChartDataSet dataSet;
99 ChartDataSet dataSet;
100
100
101 Domain domain1(0, 1000, 0, 1000);
101 Domain domain1(0, 1000, 0, 1000);
102 QLineChartSeries series;
102 QLineSeries series;
103 series.add(0, 0);
103 series.add(0, 0);
104 series.add(1000, 1000);
104 series.add(1000, 1000);
105
105
@@ -173,7 +173,7 void tst_ChartDataSet::addSeries()
173
173
174 for (int i = 0; i < seriesCount; i++) {
174 for (int i = 0; i < seriesCount; i++) {
175 QChartAxis* axisY = 0;
175 QChartAxis* axisY = 0;
176 QLineChartSeries* series = new QLineChartSeries();
176 QLineSeries* series = new QLineSeries();
177 if (iterator != axisList.end()) {
177 if (iterator != axisList.end()) {
178 axisY = *iterator;
178 axisY = *iterator;
179 iterator++;
179 iterator++;
@@ -218,10 +218,10 void tst_ChartDataSet::axisY()
218
218
219 QVERIFY2(defaultAxisY, "Missing axisY.");
219 QVERIFY2(defaultAxisY, "Missing axisY.");
220
220
221 QLineChartSeries* series1 = new QLineChartSeries();
221 QLineSeries* series1 = new QLineSeries();
222 dataSet.addSeries(series1);
222 dataSet.addSeries(series1);
223
223
224 QLineChartSeries* series2 = new QLineChartSeries();
224 QLineSeries* series2 = new QLineSeries();
225 dataSet.addSeries(series2, axisY);
225 dataSet.addSeries(series2, axisY);
226
226
227 QVERIFY(dataSet.axisY(series1) == defaultAxisY);
227 QVERIFY(dataSet.axisY(series1) == defaultAxisY);
@@ -244,7 +244,7 void tst_ChartDataSet::clearDomains()
244 QFETCH(int, indexCount);
244 QFETCH(int, indexCount);
245
245
246 Domain domain1(0, 100, 0, 100);
246 Domain domain1(0, 100, 0, 100);
247 QLineChartSeries* series = new QLineChartSeries();
247 QLineSeries* series = new QLineSeries();
248 series->add(0, 0);
248 series->add(0, 0);
249 series->add(100, 100);
249 series->add(100, 100);
250
250
@@ -315,13 +315,13 void tst_ChartDataSet::domain()
315 QFETCH(Domain, domain);
315 QFETCH(Domain, domain);
316
316
317 ChartDataSet dataSet;
317 ChartDataSet dataSet;
318 QLineChartSeries* series1 = new QLineChartSeries();
318 QLineSeries* series1 = new QLineSeries();
319 series1->add(domain1.m_minX, domain1.m_minY);
319 series1->add(domain1.m_minX, domain1.m_minY);
320 series1->add(domain1.m_maxX, domain1.m_maxY);
320 series1->add(domain1.m_maxX, domain1.m_maxY);
321 QLineChartSeries* series2 = new QLineChartSeries();
321 QLineSeries* series2 = new QLineSeries();
322 series2->add(domain2.m_minX, domain2.m_minY);
322 series2->add(domain2.m_minX, domain2.m_minY);
323 series2->add(domain2.m_maxX, domain2.m_maxY);
323 series2->add(domain2.m_maxX, domain2.m_maxY);
324 QLineChartSeries* series3 = new QLineChartSeries();
324 QLineSeries* series3 = new QLineSeries();
325 series3->add(domain3.m_minX, domain3.m_minY);
325 series3->add(domain3.m_minX, domain3.m_minY);
326 series3->add(domain3.m_maxX, domain3.m_maxY);
326 series3->add(domain3.m_maxX, domain3.m_maxY);
327
327
@@ -370,7 +370,7 void tst_ChartDataSet::nextpreviousDomain()
370 ChartDataSet dataSet;
370 ChartDataSet dataSet;
371
371
372 Domain domain1(0, 1000, 0, 1000);
372 Domain domain1(0, 1000, 0, 1000);
373 QLineChartSeries* series = new QLineChartSeries();
373 QLineSeries* series = new QLineSeries();
374 series->add(0, 0);
374 series->add(0, 0);
375 series->add(1000, 1000);
375 series->add(1000, 1000);
376
376
@@ -487,7 +487,7 void tst_ChartDataSet::removeSeries()
487
487
488 for (int i = 0; i < seriesCount; i++) {
488 for (int i = 0; i < seriesCount; i++) {
489 QChartAxis* axisY = 0;
489 QChartAxis* axisY = 0;
490 QLineChartSeries* series = new QLineChartSeries();
490 QLineSeries* series = new QLineSeries();
491 if (iterator != axisList.end()) {
491 if (iterator != axisList.end()) {
492 axisY = *iterator;
492 axisY = *iterator;
493 iterator++;
493 iterator++;
@@ -559,7 +559,7 void tst_ChartDataSet::removeAllSeries()
559
559
560 for (int i = 0; i < seriesCount; i++) {
560 for (int i = 0; i < seriesCount; i++) {
561 QChartAxis* axisY = 0;
561 QChartAxis* axisY = 0;
562 QLineChartSeries* series = new QLineChartSeries();
562 QLineSeries* series = new QLineSeries();
563 if (iterator != axisList.end()) {
563 if (iterator != axisList.end()) {
564 axisY = *iterator;
564 axisY = *iterator;
565 iterator++;
565 iterator++;
@@ -3,7 +3,7
3 #include "qchartseries.h"
3 #include "qchartseries.h"
4 #include "qpieseries.h"
4 #include "qpieseries.h"
5 #include "qscatterseries.h"
5 #include "qscatterseries.h"
6 #include <qlinechartseries.h>
6 #include <qlineseries.h>
7 #include <qbarset.h>
7 #include <qbarset.h>
8 #include <qbarcategory.h>
8 #include <qbarcategory.h>
9 #include <qbarseries.h>
9 #include <qbarseries.h>
@@ -219,7 +219,7 void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS
219 if (seriesName.contains("line", Qt::CaseInsensitive)) {
219 if (seriesName.contains("line", Qt::CaseInsensitive)) {
220 for (int j(0); j < data.count(); j ++) {
220 for (int j(0); j < data.count(); j ++) {
221 QList<qreal> column = data.at(j);
221 QList<qreal> column = data.at(j);
222 QLineChartSeries *series = new QLineChartSeries();
222 QLineSeries *series = new QLineSeries();
223 for (int i(0); i < column.count(); i++) {
223 for (int i(0); i < column.count(); i++) {
224 series->add(i, column.at(i));
224 series->add(i, column.at(i));
225 }
225 }
General Comments 0
You need to be logged in to leave comments. Login now