@@ -1,44 +1,42 | |||||
1 | integrated_build:{ |
|
1 | integrated_build:{ | |
2 | message('Internal build within charts core source tree') |
|
2 | message('Internal build within charts core source tree') | |
3 | INCLUDEPATH += $$CHART_BUILD_HEADER_DIR |
|
3 | INCLUDEPATH += $$CHART_BUILD_HEADER_DIR | |
4 | LIBS += -L $$CHART_BUILD_LIB_DIR -Wl,-rpath,$$CHART_BUILD_LIB_DIR |
|
4 | LIBS += -L $$CHART_BUILD_LIB_DIR -Wl,-rpath,$$CHART_BUILD_LIB_DIR | |
5 | DESTDIR = $$CHART_BUILD_BIN_DIR |
|
5 | DESTDIR = $$CHART_BUILD_BIN_DIR | |
6 | CONFIG(debug, debug|release) { |
|
6 | CONFIG(debug, debug|release) { | |
7 | LIBS += -lQtCommercialChartd |
|
7 | LIBS += -lQtCommercialChartd | |
8 |
|
8 | #this is ugly hack to work around missing rpath, it simply copies lib | ||
9 | #this is ugly hack to work around missing rpath, it simply copies lib |
|
9 | win32:{ | |
10 | win32:{ |
|
10 | copylib.target = $$CHART_BUILD_BIN_DIR/QtCommercialChartd.dll | |
11 | copylib.target = $$CHART_BUILD_BIN_DIR/QtCommercialChartd.dll |
|
11 | copylib.commands = $$QMAKE_COPY $$CHART_BUILD_LIB_DIR\\QtCommercialChartd.dll $$CHART_BUILD_BIN_DIR | |
12 |
copylib. |
|
12 | copylib.depends = $$CHART_BUILD_LIB_DIR/QtCommercialChartd.dll | |
13 |
|
|
13 | PRE_TARGETDEPS += $$CHART_BUILD_BIN_DIR/QtCommercialChartd.dll | |
14 | PRE_TARGETDEPS += $$CHART_BUILD_BIN_DIR/QtCommercialChartd.dll |
|
14 | QMAKE_EXTRA_TARGETS +=copylib | |
15 | QMAKE_EXTRA_TARGETS +=copylib |
|
15 | } | |
16 | } |
|
|||
17 |
|
||||
18 | } else { |
|
16 | } else { | |
19 | LIBS += -lQtCommercialChart |
|
17 | LIBS += -lQtCommercialChart | |
20 |
|
18 | |||
21 | #this is ugly hack to work around missing rpath, it simply copies lib |
|
19 | #this is ugly hack to work around missing rpath, it simply copies lib | |
22 | win32: { |
|
20 | win32: { | |
23 | copylib.target = $$CHART_BUILD_BIN_DIR/QtCommercialChart |
|
21 | copylib.target = $$CHART_BUILD_BIN_DIR/QtCommercialChart | |
24 | copylib.commands = $$QMAKE_COPY $$CHART_BUILD_LIB_DIR\\QtCommercialChart.dll $$CHART_BUILD_BIN_DIR |
|
22 | copylib.commands = $$QMAKE_COPY $$CHART_BUILD_LIB_DIR\\QtCommercialChart.dll $$CHART_BUILD_BIN_DIR | |
25 | copylib.depends = $$CHART_BUILD_LIB_DIR/QtCommercialChart.dll |
|
23 | copylib.depends = $$CHART_BUILD_LIB_DIR/QtCommercialChart.dll | |
26 | PRE_TARGETDEPS += $$CHART_BUILD_BIN_DIR/QtCommercialChart |
|
24 | PRE_TARGETDEPS += $$CHART_BUILD_BIN_DIR/QtCommercialChart | |
27 | QMAKE_EXTRA_TARGETS +=copylib |
|
25 | QMAKE_EXTRA_TARGETS +=copylib | |
28 | } |
|
26 | } | |
29 | } |
|
27 | } | |
30 |
|
28 | |||
31 | mac: { |
|
29 | mac: { | |
32 | # This is a hack to make binaries to use the internal version of the QtCommercial Charts library on OSX |
|
30 | # This is a hack to make binaries to use the internal version of the QtCommercial Charts library on OSX | |
33 | QMAKE_POST_LINK += install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/chartwidgettest.app/Contents/MacOS/chartwidgettest |
|
31 | QMAKE_POST_LINK += install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/chartwidgettest.app/Contents/MacOS/chartwidgettest | |
34 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/barchart.app/Contents/MacOS/barchart |
|
32 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/barchart.app/Contents/MacOS/barchart | |
35 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/colorlineChart.app/Contents/MacOS/colorlineChart |
|
33 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/colorlineChart.app/Contents/MacOS/colorlineChart | |
36 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/lineChart.app/Contents/MacOS/lineChart |
|
34 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/lineChart.app/Contents/MacOS/lineChart | |
37 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/percentbarchart.app/Contents/MacOS/percentbarchart |
|
35 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/percentbarchart.app/Contents/MacOS/percentbarchart | |
38 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/stackedbarchart.app/Contents/MacOS/stackedbarchart |
|
36 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/stackedbarchart.app/Contents/MacOS/stackedbarchart | |
39 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/zoomLineChart.app/Contents/MacOS/zoomLineChart |
|
37 | QMAKE_POST_LINK += && install_name_tool -change "libQtCommercialChartd.1.dylib" "@rpath/libQtCommercialChartd.dylib" $$CHART_BUILD_BIN_DIR/zoomLineChart.app/Contents/MacOS/zoomLineChart | |
40 | } |
|
38 | } | |
41 |
|
39 | |||
42 | } else { |
|
40 | } else { | |
43 | CONFIG+=qtcommercialchart |
|
41 | CONFIG+=qtcommercialchart | |
44 | } |
|
42 | } |
@@ -1,84 +1,84 | |||||
1 | #ifndef CHARTTHEME_H |
|
1 | #ifndef CHARTTHEME_H | |
2 | #define CHARTTHEME_H |
|
2 | #define CHARTTHEME_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include <QObject> |
|
5 | #include <QObject> | |
6 | #include <QSharedData> |
|
6 | #include <QSharedData> | |
7 | #include <QColor> |
|
7 | #include <QColor> | |
8 | #include <QLinearGradient> |
|
8 | #include <QLinearGradient> | |
9 | #include <QPen> |
|
9 | #include <QPen> | |
10 |
|
10 | |||
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
12 |
|
12 | |||
13 | class ChartTheme; |
|
13 | class ChartTheme; | |
14 |
|
14 | |||
15 | class ChartThemeObserver |
|
15 | class ChartThemeObserver | |
16 | { |
|
16 | { | |
17 | public: |
|
17 | public: | |
18 | virtual void themeChanged(ChartTheme *theme) = 0; |
|
18 | virtual void themeChanged(ChartTheme *theme) = 0; | |
19 | }; |
|
19 | }; | |
20 |
|
20 | |||
21 | /*! |
|
21 | /*! | |
22 | * The theme specific settings for the appearance of a series. TODO: These can be overridden by setting |
|
22 | * The theme specific settings for the appearance of a series. TODO: These can be overridden by setting | |
23 | * custom settings to a QChartSeries object. |
|
23 | * custom settings to a QChartSeries object. | |
24 | */ |
|
24 | */ | |
25 | struct SeriesTheme { |
|
25 | struct SeriesTheme { | |
26 | public: |
|
26 | public: | |
27 | SeriesTheme() : |
|
27 | SeriesTheme() : | |
28 | linePen(QPen()), |
|
28 | linePen(QPen()), | |
29 | markerPen(QPen()) {} |
|
29 | markerPen(QPen()) {} | |
30 | SeriesTheme(QColor lineColor, qreal lineWidth/*, QPen marker*/) : |
|
30 | SeriesTheme(QColor lineColor, qreal lineWidth/*, QPen marker*/) : | |
31 | linePen(QPen(QBrush(lineColor), lineWidth)), |
|
31 | linePen(QPen(QBrush(lineColor), lineWidth)), | |
32 | markerPen(linePen) {} |
|
32 | markerPen(linePen) {} | |
33 |
|
33 | |||
34 | //const QBrush & brush, qreal width, Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap, Qt::PenJoinStyle join = Qt::BevelJo |
|
34 | //const QBrush & brush, qreal width, Qt::PenStyle style = Qt::SolidLine, Qt::PenCapStyle cap = Qt::SquareCap, Qt::PenJoinStyle join = Qt::BevelJo | |
35 | // TODO: |
|
35 | // TODO: | |
36 | //QColor lineColor; |
|
36 | //QColor lineColor; | |
37 | QPen linePen; |
|
37 | QPen linePen; | |
38 | //QBrush lineBrush; |
|
38 | //QBrush lineBrush; | |
39 | QPen markerPen; |
|
39 | QPen markerPen; | |
40 | //QBrush markerBrush; |
|
40 | //QBrush markerBrush; | |
41 | }; |
|
41 | }; | |
42 |
|
42 | |||
43 | /*! |
|
43 | /*! | |
44 | * Explicitly shared data class for the themes. |
|
44 | * Explicitly shared data class for the themes. | |
45 | */ |
|
45 | */ | |
46 | class ChartThemeData : public QSharedData |
|
46 | class ChartThemeData : public QSharedData | |
47 | { |
|
47 | { | |
48 | public: |
|
48 | public: | |
49 | ChartThemeData() : m_currentTheme(0) {} |
|
49 | ChartThemeData() : m_currentTheme(0) {} | |
50 | ~ChartThemeData() {} |
|
50 | ~ChartThemeData() {} | |
51 |
|
51 | |||
52 | public: |
|
52 | public: | |
53 | void setTheme(int theme); |
|
53 | void setTheme(int theme); | |
54 |
|
54 | |||
55 | public: |
|
55 | public: | |
56 | int m_currentTheme; |
|
56 | int m_currentTheme; | |
57 | QList<ChartThemeObserver *> m_observers; |
|
57 | QList<ChartThemeObserver *> m_observers; | |
58 | QColor m_gradientStartColor; |
|
58 | QColor m_gradientStartColor; | |
59 | QColor m_gradientEndColor; |
|
59 | QColor m_gradientEndColor; | |
60 | QList<SeriesTheme> m_seriesThemes; |
|
60 | QList<SeriesTheme> m_seriesThemes; | |
61 | int m_seriesIndex; |
|
61 | int m_seriesIndex; | |
62 | }; |
|
62 | }; | |
63 |
|
63 | |||
64 | class ChartTheme : public QObject |
|
64 | class ChartTheme : public QObject | |
65 | { |
|
65 | { | |
66 | Q_OBJECT |
|
66 | Q_OBJECT | |
67 | public: |
|
67 | public: | |
68 | explicit ChartTheme(QObject *parent = 0); |
|
68 | explicit ChartTheme(QObject *parent = 0); | |
69 | explicit ChartTheme(const ChartTheme &other) : d(other.d) {} |
|
69 | explicit ChartTheme(const ChartTheme &other, QObject *parent = 0) : QObject(parent), d(other.d) {} | |
70 | void operator =(const ChartTheme &other) { d = other.d; } |
|
70 | void operator =(const ChartTheme &other) { d = other.d; } | |
71 |
|
71 | |||
72 | void setTheme(int theme); |
|
72 | void setTheme(int theme); | |
73 | SeriesTheme themeForSeries(); |
|
73 | SeriesTheme themeForSeries(); | |
74 | void addObserver(ChartThemeObserver *o) { d->m_observers << o; } |
|
74 | void addObserver(ChartThemeObserver *o) { d->m_observers << o; } | |
75 |
|
75 | |||
76 | public: |
|
76 | public: | |
77 | // All the graphical elements of a QChart share the same theme settings |
|
77 | // All the graphical elements of a QChart share the same theme settings | |
78 | // so let's use explicitly shared data |
|
78 | // so let's use explicitly shared data | |
79 | QExplicitlySharedDataPointer<ChartThemeData> d; |
|
79 | QExplicitlySharedDataPointer<ChartThemeData> d; | |
80 | }; |
|
80 | }; | |
81 |
|
81 | |||
82 | QTCOMMERCIALCHART_END_NAMESPACE |
|
82 | QTCOMMERCIALCHART_END_NAMESPACE | |
83 |
|
83 | |||
84 | #endif // CHARTTHEME_H |
|
84 | #endif // CHARTTHEME_H |
@@ -1,74 +1,74 | |||||
1 | #include "pieslice.h" |
|
1 | #include "pieslice.h" | |
2 | #include <QPainter> |
|
2 | #include <QPainter> | |
3 | #include <QDebug> |
|
3 | #include <QDebug> | |
4 |
|
4 | |||
5 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
5 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
6 |
|
6 | |||
7 | PieSlice::PieSlice(const QColor& color, qreal startAngle, qreal span, QRectF rect) |
|
7 | PieSlice::PieSlice(const QColor& color, qreal startAngle, qreal span, QRectF rect) | |
8 | : m_color(color), |
|
8 | : m_color(color), | |
9 | m_startAngle(startAngle), |
|
9 | m_startAngle(startAngle), | |
10 | m_span(span), |
|
10 | m_span(span), | |
11 | m_rect(rect) |
|
11 | m_rect(rect) | |
12 | { |
|
12 | { | |
13 | setAcceptHoverEvents(true); |
|
13 | setAcceptHoverEvents(true); | |
14 | } |
|
14 | } | |
15 |
|
15 | |||
16 | PieSlice::~PieSlice() |
|
16 | PieSlice::~PieSlice() | |
17 | { |
|
17 | { | |
18 | } |
|
18 | } | |
19 |
|
19 | |||
20 | QRectF PieSlice::boundingRect() const |
|
20 | QRectF PieSlice::boundingRect() const | |
21 | { |
|
21 | { | |
22 | return m_rect; |
|
22 | return m_rect; | |
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 | QPainterPath PieSlice::shape() const |
|
25 | QPainterPath PieSlice::shape() const | |
26 | { |
|
26 | { | |
27 | qreal angle = (-m_startAngle) + (90); |
|
27 | qreal angle = (-m_startAngle) + (90); | |
28 | qreal span = -m_span; |
|
28 | qreal span = -m_span; | |
29 |
|
29 | |||
30 | QPainterPath path; |
|
30 | QPainterPath path; | |
31 | path.moveTo(boundingRect().center()); |
|
31 | path.moveTo(boundingRect().center()); | |
32 | path.arcTo(boundingRect(), angle, span); |
|
32 | path.arcTo(boundingRect(), angle, span); | |
33 |
|
33 | |||
34 | // TODO: draw the shape so that it might have a hole in the center |
|
34 | // TODO: draw the shape so that it might have a hole in the center | |
35 | // - Sin & Cos will be needed to find inner/outer arc endpoints |
|
35 | // - Sin & Cos will be needed to find inner/outer arc endpoints | |
36 |
|
36 | |||
37 | // dx, dy are offsets from the center |
|
37 | // dx, dy are offsets from the center | |
38 | //qreal l = boundingRect().height(); |
|
38 | //qreal l = boundingRect().height(); | |
39 | //qreal dx = qSin(angle*(M_PI/180)) * l; |
|
39 | //qreal dx = qSin(angle*(M_PI/180)) * l; | |
40 | //qreal dy = qCos(angle*(M_PI/180)) * l; |
|
40 | //qreal dy = qCos(angle*(M_PI/180)) * l; | |
41 |
|
41 | |||
42 | // TODO: exploded slice? |
|
42 | // TODO: exploded slice? | |
43 |
|
43 | |||
44 | return path; |
|
44 | return path; | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
47 | void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) | |
48 | { |
|
48 | { | |
49 | painter->setRenderHint(QPainter::Antialiasing); |
|
49 | painter->setRenderHint(QPainter::Antialiasing); | |
50 | // TODO: how to map theme settings to a pie slice? Now we |
|
50 | // TODO: how to map theme settings to a pie slice? Now we | |
51 | //painter->setPen(m_theme.linePen); |
|
51 | //painter->setPen(m_theme.linePen); | |
52 | // TODO: |
|
52 | // TODO: | |
53 | painter->setBrush(m_theme.linePen.color()); |
|
53 | painter->setBrush(m_theme.linePen.color()); | |
54 |
|
54 | |||
55 | // From Qt docs: |
|
55 | // From Qt docs: | |
56 | // The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). |
|
56 | // The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). | |
57 | // Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. |
|
57 | // Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. | |
58 | // Zero degrees is at the 3 o'clock position. |
|
58 | // Zero degrees is at the 3 o'clock position. | |
59 | // |
|
59 | // | |
60 | // For sake of simplicity convert this so that zero degrees is at 12 o'clock and full circle is 360. |
|
60 | // For sake of simplicity convert this so that zero degrees is at 12 o'clock and full circle is 360. | |
61 | //qreal angle = (-m_startAngle*16) + (90*16); |
|
61 | //qreal angle = (-m_startAngle*16) + (90*16); | |
62 | //qreal span = -m_span*16; |
|
62 | //qreal span = -m_span*16; | |
63 | //painter->drawPie(boundingRect(), angle, span); |
|
63 | //painter->drawPie(boundingRect(), angle, span); | |
64 |
|
64 | |||
65 | painter->drawPath(shape()); |
|
65 | painter->drawPath(shape()); | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | void PieSlice::hoverEnterEvent(QGraphicsSceneHoverEvent * event) |
|
68 | void PieSlice::hoverEnterEvent(QGraphicsSceneHoverEvent * event) | |
69 | { |
|
69 | { | |
70 | QGraphicsItem::hoverEnterEvent(event); |
|
70 | QGraphicsItem::hoverEnterEvent(event); | |
71 | qDebug() << "hover" << m_color << m_startAngle << m_span; |
|
71 | qDebug() << "hover" << m_color << m_startAngle << m_span; | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | QTCOMMERCIALCHART_END_NAMESPACE |
|
74 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,412 +1,412 | |||||
1 | #include "qchart.h" |
|
1 | #include "qchart.h" | |
2 | #include "qchartseries.h" |
|
2 | #include "qchartseries.h" | |
3 | #include "qscatterseries.h" |
|
3 | #include "qscatterseries.h" | |
4 | #include "qscatterseries_p.h" |
|
4 | #include "qscatterseries_p.h" | |
5 | #include "qpieseries.h" |
|
5 | #include "qpieseries.h" | |
6 | #include "qpieseries_p.h" |
|
6 | #include "qpieseries_p.h" | |
7 | #include "qxychartseries.h" |
|
7 | #include "qxychartseries.h" | |
8 | #include "qchartaxis.h" |
|
8 | #include "qchartaxis.h" | |
9 | #include "barchartseries.h" |
|
9 | #include "barchartseries.h" | |
10 | #include "bargroup.h" |
|
10 | #include "bargroup.h" | |
11 | #include "stackedbarchartseries.h" |
|
11 | #include "stackedbarchartseries.h" | |
12 | #include "stackedbargroup.h" |
|
12 | #include "stackedbargroup.h" | |
13 | #include "percentbarchartseries.h" |
|
13 | #include "percentbarchartseries.h" | |
14 | #include "percentbargroup.h" |
|
14 | #include "percentbargroup.h" | |
15 | #include "charttheme_p.h" |
|
15 | #include "charttheme_p.h" | |
16 | #include "chartitem_p.h" |
|
16 | #include "chartitem_p.h" | |
17 |
|
17 | |||
18 | #include "xylinechartitem_p.h" |
|
18 | #include "xylinechartitem_p.h" | |
19 | #include "plotdomain_p.h" |
|
19 | #include "plotdomain_p.h" | |
20 | #include "axisitem_p.h" |
|
20 | #include "axisitem_p.h" | |
21 | #include <QGraphicsScene> |
|
21 | #include <QGraphicsScene> | |
22 | #include <QDebug> |
|
22 | #include <QDebug> | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | QChart::QChart(QGraphicsObject* parent) : QGraphicsObject(parent), |
|
26 | QChart::QChart(QGraphicsObject* parent) : QGraphicsObject(parent), | |
27 | m_backgroundItem(0), |
|
27 | m_backgroundItem(0), | |
28 | m_titleItem(0), |
|
28 | m_titleItem(0), | |
29 | m_axisXItem(new AxisItem(AxisItem::X_AXIS,this)), |
|
29 | m_axisXItem(new AxisItem(AxisItem::X_AXIS, this)), | |
30 | m_plotDataIndex(0), |
|
30 | m_plotDataIndex(0), | |
31 | m_marginSize(0), |
|
31 | m_marginSize(0), | |
32 | m_chartTheme(new ChartTheme()) |
|
32 | m_chartTheme(new ChartTheme(this)) | |
33 | { |
|
33 | { | |
34 | // TODO: the default theme? |
|
34 | // TODO: the default theme? | |
35 | setTheme(QChart::ChartThemeDefault); |
|
35 | setTheme(QChart::ChartThemeDefault); | |
36 |
|
36 | |||
37 | PlotDomain domain; |
|
37 | PlotDomain domain; | |
38 | m_plotDomainList << domain; |
|
38 | m_plotDomainList << domain; | |
39 | m_axisYItem << new AxisItem(AxisItem::Y_AXIS,this); |
|
39 | m_axisYItem << new AxisItem(AxisItem::Y_AXIS,this); | |
40 | m_chartItems << m_axisXItem; |
|
40 | m_chartItems << m_axisXItem; | |
41 | m_chartItems << m_axisYItem.at(0); |
|
41 | m_chartItems << m_axisYItem.at(0); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | QChart::~QChart(){} |
|
44 | QChart::~QChart(){} | |
45 |
|
45 | |||
46 | QRectF QChart::boundingRect() const |
|
46 | QRectF QChart::boundingRect() const | |
47 | { |
|
47 | { | |
48 | return m_rect; |
|
48 | return m_rect; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | void QChart::addSeries(QChartSeries* series) |
|
51 | void QChart::addSeries(QChartSeries* series) | |
52 | { |
|
52 | { | |
53 | // TODO: we should check the series not already added |
|
53 | // TODO: we should check the series not already added | |
54 |
|
54 | |||
55 | m_chartSeries << series; |
|
55 | m_chartSeries << series; | |
56 |
|
56 | |||
57 | switch(series->type()) |
|
57 | switch(series->type()) | |
58 | { |
|
58 | { | |
59 | case QChartSeries::SeriesTypeLine: { |
|
59 | case QChartSeries::SeriesTypeLine: { | |
60 |
|
60 | |||
61 | QXYChartSeries* xyseries = static_cast<QXYChartSeries*>(series); |
|
61 | QXYChartSeries* xyseries = static_cast<QXYChartSeries*>(series); | |
62 | m_plotDataIndex = 0 ; |
|
62 | m_plotDataIndex = 0 ; | |
63 | m_plotDomainList.resize(1); |
|
63 | m_plotDomainList.resize(1); | |
64 |
|
64 | |||
65 | PlotDomain& domain = m_plotDomainList[m_plotDataIndex]; |
|
65 | PlotDomain& domain = m_plotDomainList[m_plotDataIndex]; | |
66 |
|
66 | |||
67 | for (int i = 0 ; i < xyseries->count() ; i++) { |
|
67 | for (int i = 0 ; i < xyseries->count() ; i++) { | |
68 | qreal x = xyseries->x(i); |
|
68 | qreal x = xyseries->x(i); | |
69 | qreal y = xyseries->y(i); |
|
69 | qreal y = xyseries->y(i); | |
70 | domain.m_minX = qMin(domain.m_minX,x); |
|
70 | domain.m_minX = qMin(domain.m_minX,x); | |
71 | domain.m_minY = qMin(domain.m_minY,y); |
|
71 | domain.m_minY = qMin(domain.m_minY,y); | |
72 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
72 | domain.m_maxX = qMax(domain.m_maxX,x); | |
73 | domain.m_maxY = qMax(domain.m_maxY,y); |
|
73 | domain.m_maxY = qMax(domain.m_maxY,y); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | XYLineChartItem* item = new XYLineChartItem(xyseries,this); |
|
76 | XYLineChartItem* item = new XYLineChartItem(xyseries,this); | |
77 |
|
77 | |||
78 | m_chartItems << item; |
|
78 | m_chartItems << item; | |
79 | // TODO: |
|
79 | // TODO: | |
80 | //m_chartTheme->addObserver(xyseries); |
|
80 | //m_chartTheme->addObserver(xyseries); | |
81 |
|
81 | |||
82 | break; |
|
82 | break; | |
83 | } |
|
83 | } | |
84 | case QChartSeries::SeriesTypeBar: { |
|
84 | case QChartSeries::SeriesTypeBar: { | |
85 |
|
85 | |||
86 | qDebug() << "barSeries added"; |
|
86 | qDebug() << "barSeries added"; | |
87 | BarChartSeries* barSeries = static_cast<BarChartSeries*>(series); |
|
87 | BarChartSeries* barSeries = static_cast<BarChartSeries*>(series); | |
88 | BarGroup* barGroup = new BarGroup(*barSeries,this); |
|
88 | BarGroup* barGroup = new BarGroup(*barSeries,this); | |
89 |
|
89 | |||
90 | // Add some fugly colors for 5 fist series... |
|
90 | // Add some fugly colors for 5 fist series... | |
91 | barGroup->addColor(QColor(255,0,0,128)); |
|
91 | barGroup->addColor(QColor(255,0,0,128)); | |
92 | barGroup->addColor(QColor(255,255,0,128)); |
|
92 | barGroup->addColor(QColor(255,255,0,128)); | |
93 | barGroup->addColor(QColor(0,255,0,128)); |
|
93 | barGroup->addColor(QColor(0,255,0,128)); | |
94 | barGroup->addColor(QColor(0,0,255,128)); |
|
94 | barGroup->addColor(QColor(0,0,255,128)); | |
95 | barGroup->addColor(QColor(255,128,0,128)); |
|
95 | barGroup->addColor(QColor(255,128,0,128)); | |
96 |
|
96 | |||
97 | m_chartItems << barGroup; |
|
97 | m_chartItems << barGroup; | |
98 | childItems().append(barGroup); |
|
98 | childItems().append(barGroup); | |
99 |
|
99 | |||
100 | // TODO: setting of domain should this be somewhere else. |
|
100 | // TODO: setting of domain should this be somewhere else. | |
101 | m_plotDataIndex = 0 ; |
|
101 | m_plotDataIndex = 0 ; | |
102 | m_plotDomainList.resize(1); |
|
102 | m_plotDomainList.resize(1); | |
103 |
|
103 | |||
104 | qreal x = barSeries->countColumns(); |
|
104 | qreal x = barSeries->countColumns(); | |
105 | qreal y = barSeries->max(); |
|
105 | qreal y = barSeries->max(); | |
106 |
|
106 | |||
107 | PlotDomain& domain = m_plotDomainList[m_plotDataIndex]; |
|
107 | PlotDomain& domain = m_plotDomainList[m_plotDataIndex]; | |
108 |
|
108 | |||
109 | domain.m_minX = qMin(domain.m_minX,x); |
|
109 | domain.m_minX = qMin(domain.m_minX,x); | |
110 | domain.m_minY = qMin(domain.m_minY,y); |
|
110 | domain.m_minY = qMin(domain.m_minY,y); | |
111 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
111 | domain.m_maxX = qMax(domain.m_maxX,x); | |
112 | domain.m_maxY = qMax(domain.m_maxY,y); |
|
112 | domain.m_maxY = qMax(domain.m_maxY,y); | |
113 | break; |
|
113 | break; | |
114 | } |
|
114 | } | |
115 | case QChartSeries::SeriesTypeStackedBar: { |
|
115 | case QChartSeries::SeriesTypeStackedBar: { | |
116 |
|
116 | |||
117 | qDebug() << "barSeries added"; |
|
117 | qDebug() << "barSeries added"; | |
118 | StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series); |
|
118 | StackedBarChartSeries* stackedBarSeries = static_cast<StackedBarChartSeries*>(series); | |
119 | StackedBarGroup* stackedBarGroup = new StackedBarGroup(*stackedBarSeries,this); |
|
119 | StackedBarGroup* stackedBarGroup = new StackedBarGroup(*stackedBarSeries,this); | |
120 |
|
120 | |||
121 | // Add some fugly colors for 5 fist series... |
|
121 | // Add some fugly colors for 5 fist series... | |
122 | stackedBarGroup->addColor(QColor(255,0,0,128)); |
|
122 | stackedBarGroup->addColor(QColor(255,0,0,128)); | |
123 | stackedBarGroup->addColor(QColor(255,255,0,128)); |
|
123 | stackedBarGroup->addColor(QColor(255,255,0,128)); | |
124 | stackedBarGroup->addColor(QColor(0,255,0,128)); |
|
124 | stackedBarGroup->addColor(QColor(0,255,0,128)); | |
125 | stackedBarGroup->addColor(QColor(0,0,255,128)); |
|
125 | stackedBarGroup->addColor(QColor(0,0,255,128)); | |
126 | stackedBarGroup->addColor(QColor(255,128,0,128)); |
|
126 | stackedBarGroup->addColor(QColor(255,128,0,128)); | |
127 |
|
127 | |||
128 | m_chartItems << stackedBarGroup; |
|
128 | m_chartItems << stackedBarGroup; | |
129 | childItems().append(stackedBarGroup); |
|
129 | childItems().append(stackedBarGroup); | |
130 |
|
130 | |||
131 | // TODO: setting of domain should this be somewhere else. |
|
131 | // TODO: setting of domain should this be somewhere else. | |
132 | m_plotDataIndex = 0 ; |
|
132 | m_plotDataIndex = 0 ; | |
133 | m_plotDomainList.resize(1); |
|
133 | m_plotDomainList.resize(1); | |
134 |
|
134 | |||
135 | qreal x = stackedBarSeries->countColumns(); |
|
135 | qreal x = stackedBarSeries->countColumns(); | |
136 | qreal y = stackedBarSeries->maxColumnSum(); |
|
136 | qreal y = stackedBarSeries->maxColumnSum(); | |
137 |
|
137 | |||
138 | PlotDomain& domain = m_plotDomainList[m_plotDataIndex]; |
|
138 | PlotDomain& domain = m_plotDomainList[m_plotDataIndex]; | |
139 |
|
139 | |||
140 | domain.m_minX = qMin(domain.m_minX,x); |
|
140 | domain.m_minX = qMin(domain.m_minX,x); | |
141 | domain.m_minY = qMin(domain.m_minY,y); |
|
141 | domain.m_minY = qMin(domain.m_minY,y); | |
142 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
142 | domain.m_maxX = qMax(domain.m_maxX,x); | |
143 | domain.m_maxY = qMax(domain.m_maxY,y); |
|
143 | domain.m_maxY = qMax(domain.m_maxY,y); | |
144 | break; |
|
144 | break; | |
145 | } |
|
145 | } | |
146 | case QChartSeries::SeriesTypePercentBar: { |
|
146 | case QChartSeries::SeriesTypePercentBar: { | |
147 |
|
147 | |||
148 | qDebug() << "barSeries added"; |
|
148 | qDebug() << "barSeries added"; | |
149 | PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series); |
|
149 | PercentBarChartSeries* percentBarSeries = static_cast<PercentBarChartSeries*>(series); | |
150 | PercentBarGroup* percentBarGroup = new PercentBarGroup(*percentBarSeries,this); |
|
150 | PercentBarGroup* percentBarGroup = new PercentBarGroup(*percentBarSeries,this); | |
151 |
|
151 | |||
152 | // Add some fugly colors for 5 fist series... |
|
152 | // Add some fugly colors for 5 fist series... | |
153 | percentBarGroup->addColor(QColor(255,0,0,128)); |
|
153 | percentBarGroup->addColor(QColor(255,0,0,128)); | |
154 | percentBarGroup->addColor(QColor(255,255,0,128)); |
|
154 | percentBarGroup->addColor(QColor(255,255,0,128)); | |
155 | percentBarGroup->addColor(QColor(0,255,0,128)); |
|
155 | percentBarGroup->addColor(QColor(0,255,0,128)); | |
156 | percentBarGroup->addColor(QColor(0,0,255,128)); |
|
156 | percentBarGroup->addColor(QColor(0,0,255,128)); | |
157 | percentBarGroup->addColor(QColor(255,128,0,128)); |
|
157 | percentBarGroup->addColor(QColor(255,128,0,128)); | |
158 |
|
158 | |||
159 | m_chartItems << percentBarGroup; |
|
159 | m_chartItems << percentBarGroup; | |
160 | childItems().append(percentBarGroup); |
|
160 | childItems().append(percentBarGroup); | |
161 |
|
161 | |||
162 | // TODO: setting of domain should this be somewhere else. |
|
162 | // TODO: setting of domain should this be somewhere else. | |
163 | m_plotDataIndex = 0 ; |
|
163 | m_plotDataIndex = 0 ; | |
164 | m_plotDomainList.resize(1); |
|
164 | m_plotDomainList.resize(1); | |
165 |
|
165 | |||
166 | qreal x = percentBarSeries->countColumns(); |
|
166 | qreal x = percentBarSeries->countColumns(); | |
167 |
|
167 | |||
168 | PlotDomain& domain = m_plotDomainList[m_plotDataIndex]; |
|
168 | PlotDomain& domain = m_plotDomainList[m_plotDataIndex]; | |
169 |
|
169 | |||
170 | domain.m_minX = qMin(domain.m_minX,x); |
|
170 | domain.m_minX = qMin(domain.m_minX,x); | |
171 | domain.m_minY = 0; |
|
171 | domain.m_minY = 0; | |
172 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
172 | domain.m_maxX = qMax(domain.m_maxX,x); | |
173 | domain.m_maxY = 100; |
|
173 | domain.m_maxY = 100; | |
174 | break; |
|
174 | break; | |
175 | } |
|
175 | } | |
176 | case QChartSeries::SeriesTypeScatter: { |
|
176 | case QChartSeries::SeriesTypeScatter: { | |
177 | QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series); |
|
177 | QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series); | |
178 | scatterSeries->d->m_theme = m_chartTheme->themeForSeries(); |
|
178 | scatterSeries->d->m_theme = m_chartTheme->themeForSeries(); | |
179 | scatterSeries->d->setParentItem(this); |
|
179 | scatterSeries->d->setParentItem(this); | |
180 | m_chartItems << scatterSeries->d; |
|
180 | m_chartItems << scatterSeries->d; | |
181 | m_chartTheme->addObserver(scatterSeries->d); |
|
181 | m_chartTheme->addObserver(scatterSeries->d); | |
182 | break; |
|
182 | break; | |
183 | } |
|
183 | } | |
184 | case QChartSeries::SeriesTypePie: { |
|
184 | case QChartSeries::SeriesTypePie: { | |
185 | QPieSeries *pieSeries = qobject_cast<QPieSeries *>(series); |
|
185 | QPieSeries *pieSeries = qobject_cast<QPieSeries *>(series); | |
186 | pieSeries->d->setParentItem(this); |
|
186 | pieSeries->d->setParentItem(this); | |
187 | m_chartItems << pieSeries->d; |
|
187 | m_chartItems << pieSeries->d; | |
188 | pieSeries->d->m_chartTheme = m_chartTheme; |
|
188 | pieSeries->d->m_chartTheme = m_chartTheme; | |
189 | m_chartTheme->addObserver(pieSeries->d); |
|
189 | m_chartTheme->addObserver(pieSeries->d); | |
190 | break; |
|
190 | break; | |
191 | } |
|
191 | } | |
192 | } |
|
192 | } | |
193 |
|
193 | |||
194 | // Update all the items to match the new visible area of the chart |
|
194 | // Update all the items to match the new visible area of the chart | |
195 | foreach(ChartItem* i, m_chartItems) |
|
195 | foreach(ChartItem* i, m_chartItems) | |
196 | i->setPlotDomain(m_plotDomainList.at(m_plotDataIndex)); |
|
196 | i->setPlotDomain(m_plotDomainList.at(m_plotDataIndex)); | |
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | QChartSeries* QChart::createSeries(QChartSeries::QChartSeriesType type) |
|
199 | QChartSeries* QChart::createSeries(QChartSeries::QChartSeriesType type) | |
200 | { |
|
200 | { | |
201 | // TODO: support also other types; not only scatter and pie |
|
201 | // TODO: support also other types; not only scatter and pie | |
202 |
|
202 | |||
203 | QChartSeries *series(0); |
|
203 | QChartSeries *series(0); | |
204 |
|
204 | |||
205 | switch (type) { |
|
205 | switch (type) { | |
206 | case QChartSeries::SeriesTypeLine: { |
|
206 | case QChartSeries::SeriesTypeLine: { | |
207 | series = QXYChartSeries::create(); |
|
207 | series = QXYChartSeries::create(); | |
208 | break; |
|
208 | break; | |
209 | } |
|
209 | } | |
210 | case QChartSeries::SeriesTypeBar: { |
|
210 | case QChartSeries::SeriesTypeBar: { | |
211 | series = new BarChartSeries(this); |
|
211 | series = new BarChartSeries(this); | |
212 | break; |
|
212 | break; | |
213 | } |
|
213 | } | |
214 | case QChartSeries::SeriesTypeStackedBar: { |
|
214 | case QChartSeries::SeriesTypeStackedBar: { | |
215 | series = new StackedBarChartSeries(this); |
|
215 | series = new StackedBarChartSeries(this); | |
216 | break; |
|
216 | break; | |
217 | } |
|
217 | } | |
218 | case QChartSeries::SeriesTypePercentBar: { |
|
218 | case QChartSeries::SeriesTypePercentBar: { | |
219 | series = new PercentBarChartSeries(this); |
|
219 | series = new PercentBarChartSeries(this); | |
220 | break; |
|
220 | break; | |
221 | } |
|
221 | } | |
222 | case QChartSeries::SeriesTypeScatter: { |
|
222 | case QChartSeries::SeriesTypeScatter: { | |
223 | series = new QScatterSeries(this); |
|
223 | series = new QScatterSeries(this); | |
224 | break; |
|
224 | break; | |
225 | } |
|
225 | } | |
226 | case QChartSeries::SeriesTypePie: { |
|
226 | case QChartSeries::SeriesTypePie: { | |
227 | series = new QPieSeries(this); |
|
227 | series = new QPieSeries(this); | |
228 | break; |
|
228 | break; | |
229 | } |
|
229 | } | |
230 | default: |
|
230 | default: | |
231 | Q_ASSERT(false); |
|
231 | Q_ASSERT(false); | |
232 | break; |
|
232 | break; | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | addSeries(series); |
|
235 | addSeries(series); | |
236 | return series; |
|
236 | return series; | |
237 | } |
|
237 | } | |
238 |
|
238 | |||
239 | void QChart::setSize(const QSize& size) |
|
239 | void QChart::setSize(const QSize& size) | |
240 | { |
|
240 | { | |
241 | m_rect = QRect(QPoint(0,0),size); |
|
241 | m_rect = QRect(QPoint(0,0),size); | |
242 | QRect rect = m_rect.adjusted(margin(),margin(), -margin(), -margin()); |
|
242 | QRect rect = m_rect.adjusted(margin(),margin(), -margin(), -margin()); | |
243 |
|
243 | |||
244 | // recalculate title position |
|
244 | // recalculate title position | |
245 | if (m_titleItem) { |
|
245 | if (m_titleItem) { | |
246 | QPointF center = m_rect.center() -m_titleItem->boundingRect().center(); |
|
246 | QPointF center = m_rect.center() -m_titleItem->boundingRect().center(); | |
247 | m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2); |
|
247 | m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2); | |
248 | } |
|
248 | } | |
249 |
|
249 | |||
250 | //recalculate background gradient |
|
250 | //recalculate background gradient | |
251 | if (m_backgroundItem) { |
|
251 | if (m_backgroundItem) { | |
252 | m_backgroundItem->setRect(rect); |
|
252 | m_backgroundItem->setRect(rect); | |
253 | if (m_bacgroundOrinetation == HorizonatlGradientOrientation) |
|
253 | if (m_bacgroundOrinetation == HorizonatlGradientOrientation) | |
254 | m_backgroundGradient.setFinalStop(m_backgroundItem->rect().width(), 0); |
|
254 | m_backgroundGradient.setFinalStop(m_backgroundItem->rect().width(), 0); | |
255 | else |
|
255 | else | |
256 | m_backgroundGradient.setFinalStop(0, m_backgroundItem->rect().height()); |
|
256 | m_backgroundGradient.setFinalStop(0, m_backgroundItem->rect().height()); | |
257 | m_backgroundItem->setBrush(m_backgroundGradient); |
|
257 | m_backgroundItem->setBrush(m_backgroundGradient); | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | // resize and reposition childs |
|
260 | // resize and reposition childs | |
261 | foreach (ChartItem *item, m_chartItems) { |
|
261 | foreach (ChartItem *item, m_chartItems) { | |
262 | item->setPos(rect.topLeft()); |
|
262 | item->setPos(rect.topLeft()); | |
263 | item->setSize(rect.size()); |
|
263 | item->setSize(rect.size()); | |
264 | } |
|
264 | } | |
265 |
|
265 | |||
266 | update(); |
|
266 | update(); | |
267 | } |
|
267 | } | |
268 |
|
268 | |||
269 | void QChart::setBackground(const QColor& startColor, const QColor& endColor, GradientOrientation orientation) |
|
269 | void QChart::setBackground(const QColor& startColor, const QColor& endColor, GradientOrientation orientation) | |
270 | { |
|
270 | { | |
271 |
|
271 | |||
272 | if(!m_backgroundItem){ |
|
272 | if(!m_backgroundItem){ | |
273 | m_backgroundItem = new QGraphicsRectItem(this); |
|
273 | m_backgroundItem = new QGraphicsRectItem(this); | |
274 | m_backgroundItem->setZValue(-1); |
|
274 | m_backgroundItem->setZValue(-1); | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 | m_bacgroundOrinetation = orientation; |
|
277 | m_bacgroundOrinetation = orientation; | |
278 | m_backgroundGradient.setColorAt(0.0, startColor); |
|
278 | m_backgroundGradient.setColorAt(0.0, startColor); | |
279 | m_backgroundGradient.setColorAt(1.0, endColor); |
|
279 | m_backgroundGradient.setColorAt(1.0, endColor); | |
280 | m_backgroundGradient.setStart(0,0); |
|
280 | m_backgroundGradient.setStart(0,0); | |
281 |
|
281 | |||
282 | if(orientation == VerticalGradientOrientation){ |
|
282 | if(orientation == VerticalGradientOrientation){ | |
283 | m_backgroundGradient.setFinalStop(0,m_rect.height()); |
|
283 | m_backgroundGradient.setFinalStop(0,m_rect.height()); | |
284 | }else{ |
|
284 | }else{ | |
285 | m_backgroundGradient.setFinalStop(m_rect.width(),0); |
|
285 | m_backgroundGradient.setFinalStop(m_rect.width(),0); | |
286 | } |
|
286 | } | |
287 |
|
287 | |||
288 | m_backgroundItem->setBrush(m_backgroundGradient); |
|
288 | m_backgroundItem->setBrush(m_backgroundGradient); | |
289 | m_backgroundItem->setPen(Qt::NoPen); |
|
289 | m_backgroundItem->setPen(Qt::NoPen); | |
290 | m_backgroundItem->update(); |
|
290 | m_backgroundItem->update(); | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | void QChart::setTitle(const QString& title,const QFont& font) |
|
293 | void QChart::setTitle(const QString& title,const QFont& font) | |
294 | { |
|
294 | { | |
295 | if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this); |
|
295 | if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this); | |
296 | m_titleItem->setPlainText(title); |
|
296 | m_titleItem->setPlainText(title); | |
297 | m_titleItem->setFont(font); |
|
297 | m_titleItem->setFont(font); | |
298 | } |
|
298 | } | |
299 |
|
299 | |||
300 | int QChart::margin() const |
|
300 | int QChart::margin() const | |
301 | { |
|
301 | { | |
302 | return m_marginSize; |
|
302 | return m_marginSize; | |
303 | } |
|
303 | } | |
304 |
|
304 | |||
305 | void QChart::setMargin(int margin) |
|
305 | void QChart::setMargin(int margin) | |
306 | { |
|
306 | { | |
307 | m_marginSize = margin; |
|
307 | m_marginSize = margin; | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | void QChart::setTheme(QChart::ChartThemeId theme) |
|
310 | void QChart::setTheme(QChart::ChartThemeId theme) | |
311 | { |
|
311 | { | |
312 | m_chartTheme->setTheme(theme); |
|
312 | m_chartTheme->setTheme(theme); | |
313 | setBackground(m_chartTheme->d->m_gradientStartColor, |
|
313 | setBackground(m_chartTheme->d->m_gradientStartColor, | |
314 | m_chartTheme->d->m_gradientEndColor, |
|
314 | m_chartTheme->d->m_gradientEndColor, | |
315 | m_bacgroundOrinetation); |
|
315 | m_bacgroundOrinetation); | |
316 |
|
316 | |||
317 | // TODO: Move the controlling of the series presentations into private implementation of the |
|
317 | // TODO: Move the controlling of the series presentations into private implementation of the | |
318 | // series instead of QChart controlling themes for each |
|
318 | // series instead of QChart controlling themes for each | |
319 | // In other words, the following should be used when creating xy series: |
|
319 | // In other words, the following should be used when creating xy series: | |
320 | // m_chartTheme->addObserver(xyseries) |
|
320 | // m_chartTheme->addObserver(xyseries) | |
321 | foreach (QChartSeries *series, m_chartSeries) { |
|
321 | foreach (QChartSeries *series, m_chartSeries) { | |
322 | if (series->type() == QChartSeries::SeriesTypeLine) { |
|
322 | if (series->type() == QChartSeries::SeriesTypeLine) { | |
323 | QXYChartSeries *xyseries = static_cast<QXYChartSeries *>(series); |
|
323 | QXYChartSeries *xyseries = static_cast<QXYChartSeries *>(series); | |
324 | SeriesTheme seriesTheme = m_chartTheme->themeForSeries(); |
|
324 | SeriesTheme seriesTheme = m_chartTheme->themeForSeries(); | |
325 | xyseries->setPen(seriesTheme.linePen); |
|
325 | xyseries->setPen(seriesTheme.linePen); | |
326 | } |
|
326 | } | |
327 | } |
|
327 | } | |
328 |
|
328 | |||
329 | update(); |
|
329 | update(); | |
330 | } |
|
330 | } | |
331 |
|
331 | |||
332 | void QChart::zoomInToRect(const QRect& rectangle) |
|
332 | void QChart::zoomInToRect(const QRect& rectangle) | |
333 | { |
|
333 | { | |
334 |
|
334 | |||
335 | if(!rectangle.isValid()) return; |
|
335 | if(!rectangle.isValid()) return; | |
336 |
|
336 | |||
337 | qreal margin = this->margin(); |
|
337 | qreal margin = this->margin(); | |
338 |
|
338 | |||
339 | QRect rect = rectangle.normalized(); |
|
339 | QRect rect = rectangle.normalized(); | |
340 | rect.translate(-margin, -margin); |
|
340 | rect.translate(-margin, -margin); | |
341 |
|
341 | |||
342 | PlotDomain& oldDomain = m_plotDomainList[m_plotDataIndex]; |
|
342 | PlotDomain& oldDomain = m_plotDomainList[m_plotDataIndex]; | |
343 |
|
343 | |||
344 | PlotDomain domain = oldDomain.subDomain(rect,m_rect.width() - 2 * margin,m_rect.height() - 2 * margin); |
|
344 | PlotDomain domain = oldDomain.subDomain(rect,m_rect.width() - 2 * margin,m_rect.height() - 2 * margin); | |
345 |
|
345 | |||
346 | m_plotDomainList.resize(m_plotDataIndex + 1); |
|
346 | m_plotDomainList.resize(m_plotDataIndex + 1); | |
347 | m_plotDomainList<<domain; |
|
347 | m_plotDomainList<<domain; | |
348 | m_plotDataIndex++; |
|
348 | m_plotDataIndex++; | |
349 |
|
349 | |||
350 | foreach (ChartItem* item, m_chartItems) |
|
350 | foreach (ChartItem* item, m_chartItems) | |
351 | item->setPlotDomain(m_plotDomainList[m_plotDataIndex]); |
|
351 | item->setPlotDomain(m_plotDomainList[m_plotDataIndex]); | |
352 | update(); |
|
352 | update(); | |
353 | } |
|
353 | } | |
354 |
|
354 | |||
355 | void QChart::zoomIn() |
|
355 | void QChart::zoomIn() | |
356 | { |
|
356 | { | |
357 | if (m_plotDataIndex < m_plotDomainList.count() - 1) { |
|
357 | if (m_plotDataIndex < m_plotDomainList.count() - 1) { | |
358 | m_plotDataIndex++; |
|
358 | m_plotDataIndex++; | |
359 | foreach (ChartItem* item, m_chartItems) |
|
359 | foreach (ChartItem* item, m_chartItems) | |
360 | item->setPlotDomain(m_plotDomainList[m_plotDataIndex]); |
|
360 | item->setPlotDomain(m_plotDomainList[m_plotDataIndex]); | |
361 | update(); |
|
361 | update(); | |
362 | } else { |
|
362 | } else { | |
363 | QRect rect = m_rect.adjusted(margin(),margin(), -margin(), -margin()); |
|
363 | QRect rect = m_rect.adjusted(margin(),margin(), -margin(), -margin()); | |
364 | rect.setWidth(rect.width()/2); |
|
364 | rect.setWidth(rect.width()/2); | |
365 | rect.setHeight(rect.height()/2); |
|
365 | rect.setHeight(rect.height()/2); | |
366 | rect.moveCenter(m_rect.center()); |
|
366 | rect.moveCenter(m_rect.center()); | |
367 | zoomInToRect(rect); |
|
367 | zoomInToRect(rect); | |
368 | } |
|
368 | } | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | void QChart::zoomOut() |
|
371 | void QChart::zoomOut() | |
372 | { |
|
372 | { | |
373 | if (m_plotDataIndex > 0) { |
|
373 | if (m_plotDataIndex > 0) { | |
374 | m_plotDataIndex--; |
|
374 | m_plotDataIndex--; | |
375 | foreach (ChartItem* item, m_chartItems) |
|
375 | foreach (ChartItem* item, m_chartItems) | |
376 | item->setPlotDomain(m_plotDomainList[m_plotDataIndex]); |
|
376 | item->setPlotDomain(m_plotDomainList[m_plotDataIndex]); | |
377 | update(); |
|
377 | update(); | |
378 | } |
|
378 | } | |
379 | } |
|
379 | } | |
380 |
|
380 | |||
381 | void QChart::zoomReset() |
|
381 | void QChart::zoomReset() | |
382 | { |
|
382 | { | |
383 | if (m_plotDataIndex > 0) { |
|
383 | if (m_plotDataIndex > 0) { | |
384 | m_plotDataIndex = 0; |
|
384 | m_plotDataIndex = 0; | |
385 | foreach (ChartItem* item, m_chartItems) |
|
385 | foreach (ChartItem* item, m_chartItems) | |
386 | item->setPlotDomain(m_plotDomainList[m_plotDataIndex]); |
|
386 | item->setPlotDomain(m_plotDomainList[m_plotDataIndex]); | |
387 | update(); |
|
387 | update(); | |
388 | } |
|
388 | } | |
389 | } |
|
389 | } | |
390 |
|
390 | |||
391 | void QChart::setAxisX(const QChartAxis& axis) |
|
391 | void QChart::setAxisX(const QChartAxis& axis) | |
392 | { |
|
392 | { | |
393 | setAxis(m_axisXItem,axis); |
|
393 | setAxis(m_axisXItem,axis); | |
394 | } |
|
394 | } | |
395 | void QChart::setAxisY(const QChartAxis& axis) |
|
395 | void QChart::setAxisY(const QChartAxis& axis) | |
396 | { |
|
396 | { | |
397 | setAxis(m_axisYItem.at(0),axis); |
|
397 | setAxis(m_axisYItem.at(0),axis); | |
398 | } |
|
398 | } | |
399 |
|
399 | |||
400 | void QChart::setAxisY(const QList<QChartAxis>& axis) |
|
400 | void QChart::setAxisY(const QList<QChartAxis>& axis) | |
401 | { |
|
401 | { | |
402 | //TODO not implemented |
|
402 | //TODO not implemented | |
403 | } |
|
403 | } | |
404 |
|
404 | |||
405 | void QChart::setAxis(AxisItem *item, const QChartAxis& axis) |
|
405 | void QChart::setAxis(AxisItem *item, const QChartAxis& axis) | |
406 | { |
|
406 | { | |
407 | item->setVisible(axis.isAxisVisible()); |
|
407 | item->setVisible(axis.isAxisVisible()); | |
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 | #include "moc_qchart.cpp" |
|
410 | #include "moc_qchart.cpp" | |
411 |
|
411 | |||
412 | QTCOMMERCIALCHART_END_NAMESPACE |
|
412 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,99 +1,99 | |||||
1 | #ifndef CHART_H |
|
1 | #ifndef CHART_H | |
2 | #define CHART_H |
|
2 | #define CHART_H | |
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <qchartseries.h> |
|
5 | #include <qchartseries.h> | |
6 | #include <QGraphicsObject> |
|
6 | #include <QGraphicsObject> | |
7 | #include <QLinearGradient> |
|
7 | #include <QLinearGradient> | |
8 | #include <QFont> |
|
8 | #include <QFont> | |
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 | class AxisItem; |
|
12 | class AxisItem; | |
13 | class QChartSeries; |
|
13 | class QChartSeries; | |
14 | class PlotDomain; |
|
14 | class PlotDomain; | |
15 | class BarGroup; |
|
15 | class BarGroup; | |
16 | class QChartAxis; |
|
16 | class QChartAxis; | |
17 | class ChartTheme; |
|
17 | class ChartTheme; | |
18 | class ChartItem; |
|
18 | class ChartItem; | |
19 |
|
19 | |||
20 | // TODO: We don't need to have QChart tied to QGraphicsItem: |
|
20 | // TODO: We don't need to have QChart tied to QGraphicsItem: | |
21 | //class QTCOMMERCIALCHART_EXPORT QChart |
|
21 | //class QTCOMMERCIALCHART_EXPORT QChart | |
22 | //class QTCOMMERCIALCHART_EXPORT QChartGraphicsItem : public QGraphicsItem { |
|
22 | //class QTCOMMERCIALCHART_EXPORT QChartGraphicsItem : public QGraphicsItem { | |
23 | // public: QChartGraphicsItem(QChart &chart); |
|
23 | // public: QChartGraphicsItem(QChart &chart); | |
24 |
|
24 | |||
25 | /*! |
|
25 | /*! | |
26 | * TODO: define the responsibilities |
|
26 | * TODO: define the responsibilities | |
27 | */ |
|
27 | */ | |
28 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsObject |
|
28 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsObject | |
29 | { |
|
29 | { | |
30 | Q_OBJECT |
|
30 | Q_OBJECT | |
31 | public: |
|
31 | public: | |
32 | enum GradientOrientation { |
|
32 | enum GradientOrientation { | |
33 | HorizonatlGradientOrientation, |
|
33 | HorizonatlGradientOrientation, | |
34 | VerticalGradientOrientation |
|
34 | VerticalGradientOrientation | |
35 | }; |
|
35 | }; | |
36 | enum ChartThemeId { |
|
36 | enum ChartThemeId { | |
37 | ChartThemeInvalid = -1, |
|
37 | ChartThemeInvalid = -1, | |
38 | /*! The default theme follows the GUI style of the Operating System */ |
|
38 | /*! The default theme follows the GUI style of the Operating System */ | |
39 | ChartThemeDefault, |
|
39 | ChartThemeDefault, | |
40 | ChartThemeVanilla, |
|
40 | ChartThemeVanilla, | |
41 | ChartThemeIcy, |
|
41 | ChartThemeIcy, | |
42 | ChartThemeGrayscale, |
|
42 | ChartThemeGrayscale, | |
43 | //ChartThemeScientific, |
|
43 | //ChartThemeScientific, | |
44 | ChartThemeUnnamed1 |
|
44 | ChartThemeUnnamed1 | |
45 | }; |
|
45 | }; | |
46 |
|
46 | |||
47 | public: |
|
47 | public: | |
48 | QChart(QGraphicsObject* parent = 0); |
|
48 | QChart(QGraphicsObject* parent = 0); | |
49 | ~QChart(); |
|
49 | ~QChart(); | |
50 |
|
50 | |||
51 | //from QGraphicsItem |
|
51 | //from QGraphicsItem | |
52 | QRectF boundingRect() const; |
|
52 | QRectF boundingRect() const; | |
53 |
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){} |
|
53 | void paint(QPainter */*painter*/, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) {} | |
54 |
|
54 | |||
55 | void addSeries(QChartSeries* series); |
|
55 | void addSeries(QChartSeries* series); | |
56 | //TODO: QChartSeries* createSeries(QSeriesData *data, QChartSeries::QChartSeriesType type); |
|
56 | //TODO: QChartSeries* createSeries(QSeriesData *data, QChartSeries::QChartSeriesType type); | |
57 | // TODO: who owns the series now? maybe owned by chart and returned a reference instead... |
|
57 | // TODO: who owns the series now? maybe owned by chart and returned a reference instead... | |
58 | QChartSeries* createSeries(QChartSeries::QChartSeriesType type); |
|
58 | QChartSeries* createSeries(QChartSeries::QChartSeriesType type); | |
59 |
|
59 | |||
60 | void setSize(const QSize& size); |
|
60 | void setSize(const QSize& size); | |
61 | void setMargin(int margin); |
|
61 | void setMargin(int margin); | |
62 | int margin() const; |
|
62 | int margin() const; | |
63 | void setTheme(QChart::ChartThemeId theme); |
|
63 | void setTheme(QChart::ChartThemeId theme); | |
64 |
|
64 | |||
65 | void setTitle(const QString& title,const QFont& font = QFont()); |
|
65 | void setTitle(const QString& title,const QFont& font = QFont()); | |
66 | void setBackground(const QColor& startColor, const QColor& endColor = Qt::white, GradientOrientation orientation = VerticalGradientOrientation); |
|
66 | void setBackground(const QColor& startColor, const QColor& endColor = Qt::white, GradientOrientation orientation = VerticalGradientOrientation); | |
67 |
|
67 | |||
68 | void zoomInToRect(const QRect& rectangle); |
|
68 | void zoomInToRect(const QRect& rectangle); | |
69 | void zoomIn(); |
|
69 | void zoomIn(); | |
70 | void zoomOut(); |
|
70 | void zoomOut(); | |
71 | void zoomReset(); |
|
71 | void zoomReset(); | |
72 |
|
72 | |||
73 | void setAxisX(const QChartAxis& axis); |
|
73 | void setAxisX(const QChartAxis& axis); | |
74 | void setAxisY(const QChartAxis& axis); |
|
74 | void setAxisY(const QChartAxis& axis); | |
75 | void setAxisY(const QList<QChartAxis>& axis); |
|
75 | void setAxisY(const QList<QChartAxis>& axis); | |
76 |
|
76 | |||
77 | private: |
|
77 | private: | |
78 | void setAxis(AxisItem *item, const QChartAxis& axis); |
|
78 | void setAxis(AxisItem *item, const QChartAxis& axis); | |
79 |
|
79 | |||
80 | private: |
|
80 | private: | |
81 | Q_DISABLE_COPY(QChart) |
|
81 | Q_DISABLE_COPY(QChart) | |
82 | QGraphicsRectItem* m_backgroundItem; |
|
82 | QGraphicsRectItem* m_backgroundItem; | |
83 | QLinearGradient m_backgroundGradient; |
|
83 | QLinearGradient m_backgroundGradient; | |
84 | GradientOrientation m_bacgroundOrinetation; |
|
84 | GradientOrientation m_bacgroundOrinetation; | |
85 | QGraphicsTextItem* m_titleItem; |
|
85 | QGraphicsTextItem* m_titleItem; | |
86 | AxisItem* m_axisXItem; |
|
86 | AxisItem* m_axisXItem; | |
87 | QList<AxisItem*> m_axisYItem; |
|
87 | QList<AxisItem*> m_axisYItem; | |
88 | QRect m_rect; |
|
88 | QRect m_rect; | |
89 | QList<QChartSeries *> m_chartSeries; |
|
89 | QList<QChartSeries *> m_chartSeries; | |
90 | QList<ChartItem *> m_chartItems; |
|
90 | QList<ChartItem *> m_chartItems; | |
91 | QVector<PlotDomain> m_plotDomainList; |
|
91 | QVector<PlotDomain> m_plotDomainList; | |
92 | int m_plotDataIndex; |
|
92 | int m_plotDataIndex; | |
93 | int m_marginSize; |
|
93 | int m_marginSize; | |
94 | ChartTheme *m_chartTheme; |
|
94 | ChartTheme *m_chartTheme; | |
95 | }; |
|
95 | }; | |
96 |
|
96 | |||
97 | QTCOMMERCIALCHART_END_NAMESPACE |
|
97 | QTCOMMERCIALCHART_END_NAMESPACE | |
98 |
|
98 | |||
99 | #endif |
|
99 | #endif |
@@ -1,49 +1,49 | |||||
1 | #ifndef QCHARTSERIES_H |
|
1 | #ifndef QCHARTSERIES_H | |
2 | #define QCHARTSERIES_H |
|
2 | #define QCHARTSERIES_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include <QObject> |
|
5 | #include <QObject> | |
6 | #include <QAbstractItemModel> |
|
6 | #include <QAbstractItemModel> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QTCOMMERCIALCHART_EXPORT QChartSeries : public QObject |
|
10 | class QTCOMMERCIALCHART_EXPORT QChartSeries : public QObject | |
11 | { |
|
11 | { | |
12 | Q_OBJECT |
|
12 | Q_OBJECT | |
13 | public: |
|
13 | public: | |
14 | enum QChartSeriesType { |
|
14 | enum QChartSeriesType { | |
15 | SeriesTypeLine = 0, |
|
15 | SeriesTypeLine = 0, | |
16 | // SeriesTypeArea, |
|
16 | // SeriesTypeArea, | |
17 | SeriesTypeBar, |
|
17 | SeriesTypeBar, | |
18 | SeriesTypeStackedBar, |
|
18 | SeriesTypeStackedBar, | |
19 | SeriesTypePercentBar, |
|
19 | SeriesTypePercentBar, | |
20 | SeriesTypePie, |
|
20 | SeriesTypePie, | |
21 | SeriesTypeScatter |
|
21 | SeriesTypeScatter | |
22 | // SeriesTypeSpline |
|
22 | // SeriesTypeSpline | |
23 | }; |
|
23 | }; | |
24 |
|
24 | |||
25 | protected: |
|
25 | protected: | |
26 | QChartSeries(QObject *parent = 0):QObject(parent){}; |
|
26 | QChartSeries(QObject *parent = 0):QObject(parent){}; | |
27 |
|
27 | |||
28 | public: |
|
28 | public: | |
29 | virtual ~QChartSeries(){}; |
|
29 | virtual ~QChartSeries(){}; | |
30 |
|
30 | |||
31 | // Factory method |
|
31 | // Factory method | |
32 | static QChartSeries* create(QChartSeriesType type, QObject* parent = 0 ); |
|
32 | static QChartSeries* create(QChartSeriesType type, QObject* parent = 0 ); | |
33 |
|
33 | |||
34 | // Pure virtual |
|
34 | // Pure virtual | |
35 | virtual QChartSeriesType type() const = 0; |
|
35 | virtual QChartSeriesType type() const = 0; | |
36 |
|
36 | |||
37 | virtual bool setData(QList<int> data) { return false; } |
|
37 | virtual bool setData(QList<int> /*data*/) { return false; } | |
38 | virtual bool setData(QList<qreal> data) { return false; } |
|
38 | virtual bool setData(QList<qreal> /*data*/) { return false; } | |
39 | virtual bool setData(QList<qreal> x, QList<qreal> y){ return false; } |
|
39 | virtual bool setData(QList<qreal> /*x*/, QList<qreal> /*y*/){ return false; } | |
40 |
|
40 | |||
41 | // Prototype for data model. TODO: remove the other setData methods and use something like this for now? |
|
41 | // Prototype for data model. TODO: remove the other setData methods and use something like this for now? | |
42 | virtual bool setData(QAbstractItemModel* model) { return false; } |
|
42 | virtual bool setData(QAbstractItemModel* /*model*/) { return false; } | |
43 |
|
43 | |||
44 | }; |
|
44 | }; | |
45 |
|
45 | |||
46 | QTCOMMERCIALCHART_END_NAMESPACE |
|
46 | QTCOMMERCIALCHART_END_NAMESPACE | |
47 |
|
47 | |||
48 | #endif |
|
48 | #endif | |
49 |
|
49 |
@@ -1,125 +1,125 | |||||
1 | #include "qscatterseries.h" |
|
1 | #include "qscatterseries.h" | |
2 | #include "qscatterseries_p.h" |
|
2 | #include "qscatterseries_p.h" | |
3 | #include "qchart.h" |
|
3 | #include "qchart.h" | |
4 | #include <QPainter> |
|
4 | #include <QPainter> | |
5 | #include <QGraphicsScene> |
|
5 | #include <QGraphicsScene> | |
6 | #include <QDebug> |
|
6 | #include <QDebug> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | //#define QSeriesData QList<qreal> |
|
10 | //#define QSeriesData QList<qreal> | |
11 |
|
11 | |||
12 | QScatterSeriesPrivate::QScatterSeriesPrivate(QGraphicsItem *parent) : |
|
12 | QScatterSeriesPrivate::QScatterSeriesPrivate(QGraphicsItem *parent) : | |
13 | ChartItem(parent), |
|
13 | ChartItem(parent), | |
14 | m_markerColor(QColor()), |
|
14 | m_markerColor(QColor()), | |
15 | m_visibleChartArea() |
|
15 | m_visibleChartArea() | |
16 | { |
|
16 | { | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 | void QScatterSeriesPrivate::resize(QRectF rect) |
|
19 | void QScatterSeriesPrivate::resize(QRectF rect) | |
20 | { |
|
20 | { | |
21 | qreal scalex = rect.width() / m_visibleChartArea.spanX(); |
|
21 | qreal scalex = rect.width() / m_visibleChartArea.spanX(); | |
22 | qreal scaley = rect.height() / m_visibleChartArea.spanY(); |
|
22 | qreal scaley = rect.height() / m_visibleChartArea.spanY(); | |
23 |
|
23 | |||
24 | m_scenex.clear(); |
|
24 | m_scenex.clear(); | |
25 | m_sceney.clear(); |
|
25 | m_sceney.clear(); | |
26 |
|
26 | |||
27 | // Convert relative coordinates to absolute pixel coordinates that can be used for drawing |
|
27 | // Convert relative coordinates to absolute pixel coordinates that can be used for drawing | |
28 | foreach(qreal x, m_x) |
|
28 | foreach(qreal x, m_x) | |
29 | m_scenex.append(rect.left() + x * scalex - m_visibleChartArea.m_minX * scalex); |
|
29 | m_scenex.append(rect.left() + x * scalex - m_visibleChartArea.m_minX * scalex); | |
30 |
|
30 | |||
31 | foreach(qreal y, m_y) |
|
31 | foreach(qreal y, m_y) | |
32 | m_sceney.append(rect.bottom() - y * scaley - m_visibleChartArea.m_minY * scaley); |
|
32 | m_sceney.append(rect.bottom() - y * scaley - m_visibleChartArea.m_minY * scaley); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | void QScatterSeriesPrivate::setSize(const QSize &size) |
|
35 | void QScatterSeriesPrivate::setSize(const QSize &size) | |
36 | { |
|
36 | { | |
37 | QGraphicsItem *parent = this->parentItem(); |
|
37 | QGraphicsItem *parent = this->parentItem(); | |
38 | if (parent) |
|
38 | if (parent) | |
39 | resize(QRectF(parent->pos(), size)); |
|
39 | resize(QRectF(parent->pos(), size)); | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | void QScatterSeriesPrivate::themeChanged(ChartTheme *theme) |
|
42 | void QScatterSeriesPrivate::themeChanged(ChartTheme *theme) | |
43 | { |
|
43 | { | |
44 | m_theme = theme->themeForSeries(); |
|
44 | m_theme = theme->themeForSeries(); | |
45 | } |
|
45 | } | |
46 |
|
46 | |||
47 | void QScatterSeriesPrivate::setPlotDomain(const PlotDomain& plotDomain) |
|
47 | void QScatterSeriesPrivate::setPlotDomain(const PlotDomain& plotDomain) | |
48 | { |
|
48 | { | |
49 | m_visibleChartArea = plotDomain; |
|
49 | m_visibleChartArea = plotDomain; | |
50 | resize(parentItem()->boundingRect()); |
|
50 | resize(parentItem()->boundingRect()); | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | QRectF QScatterSeriesPrivate::boundingRect() const |
|
53 | QRectF QScatterSeriesPrivate::boundingRect() const | |
54 | { |
|
54 | { | |
55 | return QRectF(0, 0, 55, 100); |
|
55 | return QRectF(0, 0, 55, 100); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | void QScatterSeriesPrivate::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
58 | void QScatterSeriesPrivate::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) | |
59 | { |
|
59 | { | |
60 | // TODO: The opacity should be user definable? |
|
60 | // TODO: The opacity should be user definable? | |
61 | //brush.setColor(QColor(255, 82, 0, 100)); |
|
61 | //brush.setColor(QColor(255, 82, 0, 100)); | |
62 | if (m_markerColor.isValid()) { |
|
62 | if (m_markerColor.isValid()) { | |
63 | QPen pen = painter->pen(); |
|
63 | QPen pen = painter->pen(); | |
64 | QBrush brush = pen.brush(); |
|
64 | QBrush brush = pen.brush(); | |
65 | brush.setColor(m_markerColor); |
|
65 | brush.setColor(m_markerColor); | |
66 | pen.setBrush(brush); |
|
66 | pen.setBrush(brush); | |
67 | pen.setWidth(4); |
|
67 | pen.setWidth(4); | |
68 | painter->setPen(pen); |
|
68 | painter->setPen(pen); | |
69 | } |
|
69 | } | |
70 | else |
|
70 | else | |
71 | painter->setPen(m_theme.markerPen); |
|
71 | painter->setPen(m_theme.markerPen); | |
72 | // brush.setColor(m_theme..lineColor); |
|
72 | // brush.setColor(m_theme..lineColor); | |
73 |
|
73 | |||
74 | // TODO: m_scenex and m_sceny are left empty during construction -> we would need a resize |
|
74 | // TODO: m_scenex and m_sceny are left empty during construction -> we would need a resize | |
75 | // event right after construction or maybe given a size during initialization |
|
75 | // event right after construction or maybe given a size during initialization | |
76 | for (int i(0); i < m_scenex.count() && i < m_sceney.count(); i++) { |
|
76 | for (int i(0); i < m_scenex.count() && i < m_sceney.count(); i++) { | |
77 | if (scene()->width() > m_scenex.at(i) && scene()->height() > m_sceney.at(i)) |
|
77 | if (scene()->width() > m_scenex.at(i) && scene()->height() > m_sceney.at(i)) | |
78 | //painter->drawArc(m_scenex.at(i), m_sceney.at(i), 2, 2, 0, 5760); |
|
78 | //painter->drawArc(m_scenex.at(i), m_sceney.at(i), 2, 2, 0, 5760); | |
79 | painter->drawPoint(m_scenex.at(i), m_sceney.at(i)); |
|
79 | painter->drawPoint(m_scenex.at(i), m_sceney.at(i)); | |
80 | } |
|
80 | } | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | QScatterSeries::QScatterSeries(QObject *parent) : |
|
83 | QScatterSeries::QScatterSeries(QObject *parent) : | |
84 | QChartSeries(parent), |
|
84 | QChartSeries(parent), | |
85 | d(new QScatterSeriesPrivate(qobject_cast<QGraphicsItem *> (parent))) |
|
85 | d(new QScatterSeriesPrivate(qobject_cast<QGraphicsItem *> (parent))) | |
86 | { |
|
86 | { | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | bool QScatterSeries::setData(QList<qreal> x, QList<qreal> y) |
|
89 | bool QScatterSeries::setData(QList<qreal> x, QList<qreal> y) | |
90 | { |
|
90 | { | |
91 | // TODO: validate data |
|
91 | // TODO: validate data | |
92 | d->m_x = x; |
|
92 | d->m_x = x; | |
93 | d->m_y = y; |
|
93 | d->m_y = y; | |
94 | QGraphicsItem *parentItem = qobject_cast<QGraphicsItem *>(parent()); |
|
94 | QGraphicsItem *parentItem = qobject_cast<QGraphicsItem *>(parent()); | |
95 | Q_ASSERT(parentItem); |
|
95 | Q_ASSERT(parentItem); | |
96 | // d->setPos(parentItem->pos()); |
|
96 | // d->setPos(parentItem->pos()); | |
97 | // d->setSize(parentItem->boundingRect().size().toSize()); |
|
97 | // d->setSize(parentItem->boundingRect().size().toSize()); | |
98 | d->resize(parentItem->boundingRect()); |
|
98 | d->resize(parentItem->boundingRect()); | |
99 | return true; |
|
99 | return true; | |
100 | } |
|
100 | } | |
101 |
|
101 | |||
102 | void QScatterSeries::setMarkerColor(QColor color) |
|
102 | void QScatterSeries::setMarkerColor(QColor color) | |
103 | { |
|
103 | { | |
104 | d->m_markerColor = color; |
|
104 | d->m_markerColor = color; | |
105 | } |
|
105 | } | |
106 |
|
106 | |||
107 | QColor QScatterSeries::markerColor() |
|
107 | QColor QScatterSeries::markerColor() | |
108 | { |
|
108 | { | |
109 | return d->m_markerColor; |
|
109 | return d->m_markerColor; | |
110 | } |
|
110 | } | |
111 |
|
111 | |||
112 | // TODO: |
|
112 | // TODO: | |
113 | //void QScatterSeries::chartScaleChanged(qreal xscale, qreal yscale) |
|
113 | //void QScatterSeries::chartScaleChanged(qreal xscale, qreal yscale) | |
114 | //{ |
|
114 | //{ | |
115 | // d->rescale(xscale, yscale); |
|
115 | // d->rescale(xscale, yscale); | |
116 | //} |
|
116 | //} | |
117 |
|
117 | |||
118 | QScatterSeries::~QScatterSeries() |
|
118 | QScatterSeries::~QScatterSeries() | |
119 | { |
|
119 | { | |
120 | delete d; |
|
120 | delete d; | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | #include "moc_qscatterseries.cpp" |
|
123 | #include "moc_qscatterseries.cpp" | |
124 |
|
124 | |||
125 | QTCOMMERCIALCHART_END_NAMESPACE |
|
125 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,366 +1,377 | |||||
1 | #include "mainwidget.h" |
|
1 | #include "mainwidget.h" | |
2 | #include "dataseriedialog.h" |
|
2 | #include "dataseriedialog.h" | |
3 | #include "qchartseries.h" |
|
3 | #include "qchartseries.h" | |
4 | #include "qpieseries.h" |
|
4 | #include "qpieseries.h" | |
5 | #include <qxychartseries.h> |
|
5 | #include <qxychartseries.h> | |
6 | #include <barchartseries.h> |
|
6 | #include <barchartseries.h> | |
7 | #include <QPushButton> |
|
7 | #include <QPushButton> | |
8 | #include <QComboBox> |
|
8 | #include <QComboBox> | |
9 | #include <QSpinBox> |
|
9 | #include <QSpinBox> | |
10 | #include <QCheckBox> |
|
10 | #include <QCheckBox> | |
11 | #include <QGridLayout> |
|
11 | #include <QGridLayout> | |
12 | #include <QHBoxLayout> |
|
12 | #include <QHBoxLayout> | |
13 | #include <QLabel> |
|
13 | #include <QLabel> | |
14 | #include <QSpacerItem> |
|
14 | #include <QSpacerItem> | |
15 | #include <QMessageBox> |
|
15 | #include <QMessageBox> | |
16 | #include <cmath> |
|
16 | #include <cmath> | |
17 | #include <QDebug> |
|
17 | #include <QDebug> | |
18 | #include <QStandardItemModel> |
|
18 | #include <QStandardItemModel> | |
19 |
|
19 | |||
20 |
|
20 | |||
21 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
21 | QTCOMMERCIALCHART_USE_NAMESPACE | |
22 |
|
22 | |||
23 | MainWidget::MainWidget(QWidget *parent) : |
|
23 | MainWidget::MainWidget(QWidget *parent) : | |
24 | QWidget(parent) |
|
24 | QWidget(parent) | |
25 | { |
|
25 | { | |
26 | m_chartWidget = new QChartWidget(this); |
|
26 | m_chartWidget = new QChartWidget(this); | |
27 |
|
27 | |||
|
28 | // GridLayout for the controls for configuring the chart widget | |||
|
29 | QGridLayout *grid = new QGridLayout(); | |||
|
30 | QGridLayout *mainLayout = new QGridLayout(); | |||
28 | QPushButton *addSeriesButton = new QPushButton("Add series"); |
|
31 | QPushButton *addSeriesButton = new QPushButton("Add series"); | |
29 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); |
|
32 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); | |
|
33 | grid->addWidget(addSeriesButton, 0, 1); | |||
|
34 | initBackroundCombo(grid); | |||
|
35 | initScaleControls(grid); | |||
|
36 | initThemeCombo(grid); | |||
|
37 | QCheckBox *zoomCheckBox = new QCheckBox("Zoom enabled"); | |||
|
38 | connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartWidget, SLOT(setZoomEnabled(bool))); | |||
|
39 | zoomCheckBox->setChecked(true); | |||
|
40 | grid->addWidget(zoomCheckBox, grid->rowCount(), 0); | |||
|
41 | // add row with empty label to make all the other rows static | |||
|
42 | grid->addWidget(new QLabel(""), grid->rowCount(), 0); | |||
|
43 | grid->setRowStretch(grid->rowCount() - 1, 1); | |||
|
44 | mainLayout->addLayout(grid, 0, 0); | |||
|
45 | ||||
|
46 | // Init series type specific controls | |||
|
47 | initPieControls(); | |||
|
48 | mainLayout->addLayout(m_pieLayout, 2, 0); | |||
|
49 | // Scatter series specific settings | |||
|
50 | // m_scatterLayout = new QGridLayout(); | |||
|
51 | // m_scatterLayout->addWidget(new QLabel("scatter"), 0, 0); | |||
|
52 | // m_scatterLayout->setEnabled(false); | |||
|
53 | // mainLayout->addLayout(m_scatterLayout, 1, 0); | |||
|
54 | ||||
|
55 | // Add layouts and the chart widget to the main layout | |||
|
56 | mainLayout->addWidget(m_chartWidget, 0, 1, 3, 1); | |||
|
57 | setLayout(mainLayout); | |||
|
58 | ||||
|
59 | // force an update to test data | |||
|
60 | testDataChanged(0); | |||
|
61 | } | |||
30 |
|
62 | |||
31 | // Chart background |
|
63 | // Combo box for selecting the chart's background | |
|
64 | void MainWidget::initBackroundCombo(QGridLayout *grid) | |||
|
65 | { | |||
32 | QComboBox *backgroundCombo = new QComboBox(this); |
|
66 | QComboBox *backgroundCombo = new QComboBox(this); | |
33 | backgroundCombo->addItem("Color"); |
|
67 | backgroundCombo->addItem("Color"); | |
34 | backgroundCombo->addItem("Gradient"); |
|
68 | backgroundCombo->addItem("Gradient"); | |
35 | backgroundCombo->addItem("Image"); |
|
69 | backgroundCombo->addItem("Image"); | |
36 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), |
|
70 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), | |
37 | this, SLOT(backgroundChanged(int))); |
|
71 | this, SLOT(backgroundChanged(int))); | |
38 |
|
72 | |||
39 | // Axis |
|
73 | grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0); | |
40 | // TODO: multiple axes? |
|
74 | grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1); | |
|
75 | } | |||
|
76 | ||||
|
77 | // Scale related controls (auto-scale vs. manual min-max values) | |||
|
78 | void MainWidget::initScaleControls(QGridLayout *grid) | |||
|
79 | { | |||
41 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); |
|
80 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); | |
42 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); |
|
81 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); | |
43 | // Allow setting also non-sense values (like -2147483648 and 2147483647) |
|
82 | // Allow setting also non-sense values (like -2147483648 and 2147483647) | |
44 | m_xMinSpin = new QSpinBox(); |
|
83 | m_xMinSpin = new QSpinBox(); | |
45 | m_xMinSpin->setMinimum(INT_MIN); |
|
84 | m_xMinSpin->setMinimum(INT_MIN); | |
46 | m_xMinSpin->setMaximum(INT_MAX); |
|
85 | m_xMinSpin->setMaximum(INT_MAX); | |
47 | m_xMinSpin->setValue(0); |
|
86 | m_xMinSpin->setValue(0); | |
48 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); |
|
87 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); | |
49 | m_xMaxSpin = new QSpinBox(); |
|
88 | m_xMaxSpin = new QSpinBox(); | |
50 | m_xMaxSpin->setMinimum(INT_MIN); |
|
89 | m_xMaxSpin->setMinimum(INT_MIN); | |
51 | m_xMaxSpin->setMaximum(INT_MAX); |
|
90 | m_xMaxSpin->setMaximum(INT_MAX); | |
52 | m_xMaxSpin->setValue(10); |
|
91 | m_xMaxSpin->setValue(10); | |
53 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); |
|
92 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); | |
54 | m_yMinSpin = new QSpinBox(); |
|
93 | m_yMinSpin = new QSpinBox(); | |
55 | m_yMinSpin->setMinimum(INT_MIN); |
|
94 | m_yMinSpin->setMinimum(INT_MIN); | |
56 | m_yMinSpin->setMaximum(INT_MAX); |
|
95 | m_yMinSpin->setMaximum(INT_MAX); | |
57 | m_yMinSpin->setValue(0); |
|
96 | m_yMinSpin->setValue(0); | |
58 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); |
|
97 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); | |
59 | m_yMaxSpin = new QSpinBox(); |
|
98 | m_yMaxSpin = new QSpinBox(); | |
60 | m_yMaxSpin->setMinimum(INT_MIN); |
|
99 | m_yMaxSpin->setMinimum(INT_MIN); | |
61 | m_yMaxSpin->setMaximum(INT_MAX); |
|
100 | m_yMaxSpin->setMaximum(INT_MAX); | |
62 | m_yMaxSpin->setValue(10); |
|
101 | m_yMaxSpin->setValue(10); | |
63 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); |
|
102 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); | |
64 |
|
103 | |||
|
104 | grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0); | |||
|
105 | grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0); | |||
|
106 | grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1); | |||
|
107 | grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0); | |||
|
108 | grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1); | |||
|
109 | grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0); | |||
|
110 | grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1); | |||
|
111 | grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0); | |||
|
112 | grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1); | |||
|
113 | ||||
|
114 | m_autoScaleCheck->setChecked(true); | |||
|
115 | } | |||
|
116 | ||||
|
117 | // Combo box for selecting theme | |||
|
118 | void MainWidget::initThemeCombo(QGridLayout *grid) | |||
|
119 | { | |||
65 | QComboBox *chartTheme = new QComboBox(); |
|
120 | QComboBox *chartTheme = new QComboBox(); | |
66 | chartTheme->addItem("Default"); |
|
121 | chartTheme->addItem("Default"); | |
67 | chartTheme->addItem("Vanilla"); |
|
122 | chartTheme->addItem("Vanilla"); | |
68 | chartTheme->addItem("Icy"); |
|
123 | chartTheme->addItem("Icy"); | |
69 | chartTheme->addItem("Grayscale"); |
|
124 | chartTheme->addItem("Grayscale"); | |
70 | chartTheme->addItem("Unnamed1"); |
|
125 | chartTheme->addItem("Unnamed1"); | |
71 | connect(chartTheme, SIGNAL(currentIndexChanged(int)), |
|
126 | connect(chartTheme, SIGNAL(currentIndexChanged(int)), | |
72 | this, SLOT(changeChartTheme(int))); |
|
127 | this, SLOT(changeChartTheme(int))); | |
73 | // connect(chartTheme, SIGNAL(currentIndexChanged(int)), |
|
|||
74 | // m_signalMapper, SLOT(map())); |
|
|||
75 | // m_signalMapper->setMapping(chartTheme, (QChart::ChartThemeId)chartTheme->currentIndex()); |
|
|||
76 | // connect(m_signalMapper, SIGNAL(mapped(QChart::ChartThemeId)), |
|
|||
77 | // m_chartWidget, SLOT(setTheme(QChart::ChartThemeId))); |
|
|||
78 |
|
||||
79 | QCheckBox *zoomCheckBox = new QCheckBox("Zoom enabled"); |
|
|||
80 | connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartWidget, SLOT(setZoomEnabled(bool))); |
|
|||
81 | zoomCheckBox->setChecked(true); |
|
|||
82 |
|
||||
83 | QGridLayout *grid = new QGridLayout(); |
|
|||
84 | QGridLayout *mainLayout = new QGridLayout(); |
|
|||
85 | grid->addWidget(addSeriesButton, 0, 1); |
|
|||
86 | grid->addWidget(new QLabel("Background:"), 2, 0); |
|
|||
87 | grid->addWidget(backgroundCombo, 2, 1); |
|
|||
88 | grid->addWidget(m_autoScaleCheck, 3, 0); |
|
|||
89 | grid->addWidget(new QLabel("x min:"), 4, 0); |
|
|||
90 | grid->addWidget(m_xMinSpin, 4, 1); |
|
|||
91 | grid->addWidget(new QLabel("x max:"), 5, 0); |
|
|||
92 | grid->addWidget(m_xMaxSpin, 5, 1); |
|
|||
93 | grid->addWidget(new QLabel("y min:"), 6, 0); |
|
|||
94 | grid->addWidget(m_yMinSpin, 6, 1); |
|
|||
95 | grid->addWidget(new QLabel("y max:"), 7, 0); |
|
|||
96 | grid->addWidget(m_yMaxSpin, 7, 1); |
|
|||
97 | grid->addWidget(new QLabel("Chart theme:"), 8, 0); |
|
128 | grid->addWidget(new QLabel("Chart theme:"), 8, 0); | |
98 | grid->addWidget(chartTheme, 8, 1); |
|
129 | grid->addWidget(chartTheme, 8, 1); | |
99 | grid->addWidget(zoomCheckBox, 9, 0); |
|
130 | } | |
100 | // add row with empty label to make all the other rows static |
|
|||
101 | grid->addWidget(new QLabel(""), 10, 0); |
|
|||
102 | grid->setRowStretch(10, 1); |
|
|||
103 |
|
||||
104 | mainLayout->addLayout(grid, 0, 0); |
|
|||
105 |
|
||||
106 | // Scatter specific settings |
|
|||
107 | m_scatterLayout = new QGridLayout(); |
|
|||
108 | m_scatterLayout->addWidget(new QLabel("scatter"), 0, 0); |
|
|||
109 | m_scatterLayout->setEnabled(false); |
|
|||
110 |
|
131 | |||
111 | // Pie specific settings |
|
132 | void MainWidget::initPieControls() | |
|
133 | { | |||
|
134 | // Pie series specific settings | |||
112 | // Pie size factory |
|
135 | // Pie size factory | |
113 | QDoubleSpinBox *pieSizeSpin = new QDoubleSpinBox(); |
|
136 | QDoubleSpinBox *pieSizeSpin = new QDoubleSpinBox(); | |
114 | pieSizeSpin->setMinimum(LONG_MIN); |
|
137 | pieSizeSpin->setMinimum(LONG_MIN); | |
115 | pieSizeSpin->setMaximum(LONG_MAX); |
|
138 | pieSizeSpin->setMaximum(LONG_MAX); | |
116 | pieSizeSpin->setValue(1.0); |
|
139 | pieSizeSpin->setValue(1.0); | |
117 | pieSizeSpin->setSingleStep(0.1); |
|
140 | pieSizeSpin->setSingleStep(0.1); | |
118 | connect(pieSizeSpin, SIGNAL(valueChanged(double)), this, SLOT(setPieSizeFactor(double))); |
|
141 | connect(pieSizeSpin, SIGNAL(valueChanged(double)), this, SLOT(setPieSizeFactor(double))); | |
119 | // Pie position |
|
142 | // Pie position | |
120 | QComboBox *piePosCombo = new QComboBox(this); |
|
143 | QComboBox *piePosCombo = new QComboBox(this); | |
121 | piePosCombo->addItem("Maximized"); |
|
144 | piePosCombo->addItem("Maximized"); | |
122 | piePosCombo->addItem("Top left"); |
|
145 | piePosCombo->addItem("Top left"); | |
123 | piePosCombo->addItem("Top right"); |
|
146 | piePosCombo->addItem("Top right"); | |
124 | piePosCombo->addItem("Bottom left"); |
|
147 | piePosCombo->addItem("Bottom left"); | |
125 | piePosCombo->addItem("Bottom right"); |
|
148 | piePosCombo->addItem("Bottom right"); | |
126 | connect(piePosCombo, SIGNAL(currentIndexChanged(int)), |
|
149 | connect(piePosCombo, SIGNAL(currentIndexChanged(int)), | |
127 | this, SLOT(setPiePosition(int))); |
|
150 | this, SLOT(setPiePosition(int))); | |
128 | m_pieLayout = new QGridLayout(); |
|
151 | m_pieLayout = new QGridLayout(); | |
129 | m_pieLayout->setEnabled(false); |
|
152 | m_pieLayout->setEnabled(false); | |
130 | m_pieLayout->addWidget(new QLabel("Pie size factor"), 0, 0); |
|
153 | m_pieLayout->addWidget(new QLabel("Pie size factor"), 0, 0); | |
131 | m_pieLayout->addWidget(pieSizeSpin, 0, 1); |
|
154 | m_pieLayout->addWidget(pieSizeSpin, 0, 1); | |
132 | m_pieLayout->addWidget(new QLabel("Pie position"), 1, 0); |
|
155 | m_pieLayout->addWidget(new QLabel("Pie position"), 1, 0); | |
133 | m_pieLayout->addWidget(piePosCombo, 1, 1); |
|
156 | m_pieLayout->addWidget(piePosCombo, 1, 1); | |
134 |
|
||||
135 | mainLayout->addLayout(m_scatterLayout, 1, 0); |
|
|||
136 | mainLayout->addLayout(m_pieLayout, 2, 0); |
|
|||
137 |
|
||||
138 | //m_chartWidget->setColor(Qt::red); |
|
|||
139 | mainLayout->addWidget(m_chartWidget, 0, 1, 3, 1); |
|
|||
140 | // hbox->setStretch(1, 1); |
|
|||
141 |
|
||||
142 | setLayout(mainLayout); |
|
|||
143 |
|
||||
144 | m_autoScaleCheck->setChecked(true); |
|
|||
145 | testDataChanged(0); |
|
|||
146 | } |
|
157 | } | |
147 |
|
158 | |||
148 | void MainWidget::addSeries() |
|
159 | void MainWidget::addSeries() | |
149 | { |
|
160 | { | |
150 | DataSerieDialog dialog(m_defaultSeriesName, this); |
|
161 | DataSerieDialog dialog(m_defaultSeriesName, this); | |
151 | connect(&dialog, SIGNAL(accepted(QString, QString)), this, SLOT(addSeries(QString, QString))); |
|
162 | connect(&dialog, SIGNAL(accepted(QString, QString)), this, SLOT(addSeries(QString, QString))); | |
152 | dialog.exec(); |
|
163 | dialog.exec(); | |
153 | } |
|
164 | } | |
154 |
|
165 | |||
155 | void MainWidget::addSeries(QString series, QString data) |
|
166 | void MainWidget::addSeries(QString series, QString data) | |
156 | { |
|
167 | { | |
157 | qDebug() << "addSeries: " << series << " data: " << data; |
|
168 | qDebug() << "addSeries: " << series << " data: " << data; | |
158 | m_defaultSeriesName = series; |
|
169 | m_defaultSeriesName = series; | |
159 |
|
170 | |||
160 | // TODO: a dedicated data class for storing x and y values |
|
171 | // TODO: a dedicated data class for storing x and y values | |
161 | QList<qreal> x; |
|
172 | QList<qreal> x; | |
162 | QList<qreal> y; |
|
173 | QList<qreal> y; | |
163 |
|
174 | |||
164 | if (data == "linear") { |
|
175 | if (data == "linear") { | |
165 | for (int i = 0; i < 20; i++) { |
|
176 | for (int i = 0; i < 20; i++) { | |
166 | x.append(i); |
|
177 | x.append(i); | |
167 | y.append(i); |
|
178 | y.append(i); | |
168 | } |
|
179 | } | |
169 | } else if (data == "linear, 1M") { |
|
180 | } else if (data == "linear, 1M") { | |
170 | // 1 million data points from 0.0001 to 100 |
|
181 | // 1 million data points from 0.0001 to 100 | |
171 | // TODO: What is the requirement? Should we be able to show this kind of data with |
|
182 | // TODO: What is the requirement? Should we be able to show this kind of data with | |
172 | // reasonable performance, or can we expect the application developer to do "data mining" |
|
183 | // reasonable performance, or can we expect the application developer to do "data mining" | |
173 | // for us, so that the count of data points given to QtCommercial Chart is always |
|
184 | // for us, so that the count of data points given to QtCommercial Chart is always | |
174 | // reasonable? |
|
185 | // reasonable? | |
175 | for (qreal i = 0; i < 100; i += 0.0001) { |
|
186 | for (qreal i = 0; i < 100; i += 0.0001) { | |
176 | x.append(i); |
|
187 | x.append(i); | |
177 | y.append(20); |
|
188 | y.append(20); | |
178 | } |
|
189 | } | |
179 | } else if (data == "SIN") { |
|
190 | } else if (data == "SIN") { | |
180 | for (int i = 0; i < 100; i++) { |
|
191 | for (int i = 0; i < 100; i++) { | |
181 | x.append(i); |
|
192 | x.append(i); | |
182 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100)); |
|
193 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100)); | |
183 | } |
|
194 | } | |
184 | } else if (data == "SIN + random") { |
|
195 | } else if (data == "SIN + random") { | |
185 | for (qreal i = 0; i < 100; i += 0.1) { |
|
196 | for (qreal i = 0; i < 100; i += 0.1) { | |
186 | x.append(i + (rand() % 5)); |
|
197 | x.append(i + (rand() % 5)); | |
187 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); |
|
198 | y.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); | |
188 | } |
|
199 | } | |
189 | } else { |
|
200 | } else { | |
190 | // TODO: check if data has a valid file name |
|
201 | // TODO: check if data has a valid file name | |
191 | Q_ASSERT(false); |
|
202 | Q_ASSERT(false); | |
192 | } |
|
203 | } | |
193 |
|
204 | |||
194 | // TODO: color of the series |
|
205 | // TODO: color of the series | |
195 | QChartSeries *newSeries = 0; |
|
206 | QChartSeries *newSeries = 0; | |
196 | if (series == "Scatter") { |
|
207 | if (series == "Scatter") { | |
197 | newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypeScatter); |
|
208 | newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypeScatter); | |
198 | Q_ASSERT(newSeries->setData(x, y)); |
|
209 | Q_ASSERT(newSeries->setData(x, y)); | |
199 | } else if (series == "Pie") { |
|
210 | } else if (series == "Pie") { | |
200 | newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypePie); |
|
211 | newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypePie); | |
201 | Q_ASSERT(newSeries->setData(y)); |
|
212 | Q_ASSERT(newSeries->setData(y)); | |
202 | } else if (series == "Line") { |
|
213 | } else if (series == "Line") { | |
203 | // TODO: adding data to an existing line series does not give any visuals for some reason |
|
214 | // TODO: adding data to an existing line series does not give any visuals for some reason | |
204 | // newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypeLine); |
|
215 | // newSeries = m_chartWidget->createSeries(QChartSeries::SeriesTypeLine); | |
205 | // QXYChartSeries *lineSeries = static_cast<QXYChartSeries *>(newSeries); |
|
216 | // QXYChartSeries *lineSeries = static_cast<QXYChartSeries *>(newSeries); | |
206 | // lineSeries->setColor(Qt::blue); |
|
217 | // lineSeries->setColor(Qt::blue); | |
207 | // for (int i(0); i < x.count() && i < y.count(); i++) { |
|
218 | // for (int i(0); i < x.count() && i < y.count(); i++) { | |
208 | // lineSeries->add(x.at(i), y.at(i)); |
|
219 | // lineSeries->add(x.at(i), y.at(i)); | |
209 | // } |
|
220 | // } | |
210 | //Q_ASSERT(newSeries->setData(x, y)); |
|
221 | //Q_ASSERT(newSeries->setData(x, y)); | |
211 | QXYChartSeries* series0 = QXYChartSeries::create(); |
|
222 | QXYChartSeries* series0 = QXYChartSeries::create(); | |
212 | for (int i(0); i < x.count() && i < y.count(); i++) |
|
223 | for (int i(0); i < x.count() && i < y.count(); i++) | |
213 | series0->add(x.at(i), y.at(i)); |
|
224 | series0->add(x.at(i), y.at(i)); | |
214 | m_chartWidget->addSeries(series0); |
|
225 | m_chartWidget->addSeries(series0); | |
215 | newSeries = series0; |
|
226 | newSeries = series0; | |
216 | } else { |
|
227 | } else { | |
217 | // TODO |
|
228 | // TODO | |
218 | } |
|
229 | } | |
219 |
|
230 | |||
220 | // BarChart |
|
231 | // BarChart | |
221 | if (series == "Bar") { |
|
232 | if (series == "Bar") { | |
222 | // This is the another way of creating series. Should we create test cases for both ways, if we support them? |
|
233 | // This is the another way of creating series. Should we create test cases for both ways, if we support them? | |
223 | qDebug() << "Bar chart series"; |
|
234 | qDebug() << "Bar chart series"; | |
224 | newSeries = QChartSeries::create(QChartSeries::SeriesTypeBar, this); |
|
235 | newSeries = QChartSeries::create(QChartSeries::SeriesTypeBar, this); | |
225 |
|
236 | |||
226 | // Create some test data to chart |
|
237 | // Create some test data to chart | |
227 | QStandardItemModel dataModel(2,10,this); |
|
238 | QStandardItemModel dataModel(2,10,this); | |
228 | QModelIndex index; |
|
239 | QModelIndex index; | |
229 | index = dataModel.index(0,0); |
|
240 | index = dataModel.index(0,0); | |
230 | // Series 1, items 6 to 9 missing. |
|
241 | // Series 1, items 6 to 9 missing. | |
231 | dataModel.setData(dataModel.index(0,0),1); |
|
242 | dataModel.setData(dataModel.index(0,0),1); | |
232 | dataModel.setData(dataModel.index(0,1),12); |
|
243 | dataModel.setData(dataModel.index(0,1),12); | |
233 | dataModel.setData(dataModel.index(0,2),5); |
|
244 | dataModel.setData(dataModel.index(0,2),5); | |
234 | dataModel.setData(dataModel.index(0,3),8); |
|
245 | dataModel.setData(dataModel.index(0,3),8); | |
235 | dataModel.setData(dataModel.index(0,4),17); |
|
246 | dataModel.setData(dataModel.index(0,4),17); | |
236 | dataModel.setData(dataModel.index(0,5),9); |
|
247 | dataModel.setData(dataModel.index(0,5),9); | |
237 |
|
248 | |||
238 | // Series 2, some other items missing |
|
249 | // Series 2, some other items missing | |
239 | dataModel.setData(dataModel.index(1,0),5); |
|
250 | dataModel.setData(dataModel.index(1,0),5); | |
240 | dataModel.setData(dataModel.index(1,3),4); |
|
251 | dataModel.setData(dataModel.index(1,3),4); | |
241 | dataModel.setData(dataModel.index(1,5),7); |
|
252 | dataModel.setData(dataModel.index(1,5),7); | |
242 | dataModel.setData(dataModel.index(1,6),8); |
|
253 | dataModel.setData(dataModel.index(1,6),8); | |
243 | dataModel.setData(dataModel.index(1,8),9); |
|
254 | dataModel.setData(dataModel.index(1,8),9); | |
244 | dataModel.setData(dataModel.index(1,9),9); |
|
255 | dataModel.setData(dataModel.index(1,9),9); | |
245 |
|
256 | |||
246 | newSeries->setData(&dataModel); |
|
257 | newSeries->setData(&dataModel); | |
247 |
|
258 | |||
248 | m_chartWidget->addSeries(newSeries); |
|
259 | m_chartWidget->addSeries(newSeries); | |
249 | } |
|
260 | } | |
250 |
|
261 | |||
251 | setCurrentSeries(newSeries); |
|
262 | setCurrentSeries(newSeries); | |
252 | } |
|
263 | } | |
253 |
|
264 | |||
254 | void MainWidget::setCurrentSeries(QChartSeries *series) |
|
265 | void MainWidget::setCurrentSeries(QChartSeries *series) | |
255 | { |
|
266 | { | |
256 | m_currentSeries = series; |
|
267 | m_currentSeries = series; | |
257 | switch (m_currentSeries->type()) { |
|
268 | switch (m_currentSeries->type()) { | |
258 | case QChartSeries::SeriesTypeLine: |
|
269 | case QChartSeries::SeriesTypeLine: | |
259 | break; |
|
270 | break; | |
260 | case QChartSeries::SeriesTypeScatter: |
|
271 | case QChartSeries::SeriesTypeScatter: | |
261 | break; |
|
272 | break; | |
262 | case QChartSeries::SeriesTypePie: |
|
273 | case QChartSeries::SeriesTypePie: | |
263 | break; |
|
274 | break; | |
264 | case QChartSeries::SeriesTypeBar: |
|
275 | case QChartSeries::SeriesTypeBar: | |
265 | qDebug() << "setCurrentSeries (bar)"; |
|
276 | qDebug() << "setCurrentSeries (bar)"; | |
266 | break; |
|
277 | break; | |
267 | default: |
|
278 | default: | |
268 | Q_ASSERT(false); |
|
279 | Q_ASSERT(false); | |
269 | break; |
|
280 | break; | |
270 | } |
|
281 | } | |
271 | } |
|
282 | } | |
272 |
|
283 | |||
273 | void MainWidget::testDataChanged(int itemIndex) |
|
284 | void MainWidget::testDataChanged(int itemIndex) | |
274 | { |
|
285 | { | |
275 | qDebug() << "testDataChanged: " << itemIndex; |
|
286 | qDebug() << "testDataChanged: " << itemIndex; | |
276 |
|
287 | |||
277 | // switch (itemIndex) { |
|
288 | // switch (itemIndex) { | |
278 | // case 0: { |
|
289 | // case 0: { | |
279 | // QList<QChartDataPoint> data; |
|
290 | // QList<QChartDataPoint> data; | |
280 | // for (int x = 0; x < 20; x++) { |
|
291 | // for (int x = 0; x < 20; x++) { | |
281 | // data.append(QChartDataPoint() << x << x / 2); |
|
292 | // data.append(QChartDataPoint() << x << x / 2); | |
282 | // } |
|
293 | // } | |
283 | // m_chartWidget->setData(data); |
|
294 | // m_chartWidget->setData(data); | |
284 | // break; |
|
295 | // break; | |
285 | // } |
|
296 | // } | |
286 | // case 1: { |
|
297 | // case 1: { | |
287 | // QList<QChartDataPoint> data; |
|
298 | // QList<QChartDataPoint> data; | |
288 | // for (int x = 0; x < 100; x++) { |
|
299 | // for (int x = 0; x < 100; x++) { | |
289 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); |
|
300 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); | |
290 | // } |
|
301 | // } | |
291 | // m_chartWidget->setData(data); |
|
302 | // m_chartWidget->setData(data); | |
292 | // break; |
|
303 | // break; | |
293 | // } |
|
304 | // } | |
294 | // case 2: { |
|
305 | // case 2: { | |
295 | // QList<QChartDataPoint> data; |
|
306 | // QList<QChartDataPoint> data; | |
296 | // for (int x = 0; x < 1000; x++) { |
|
307 | // for (int x = 0; x < 1000; x++) { | |
297 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
308 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
298 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
309 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
299 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
310 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
300 | // } |
|
311 | // } | |
301 | // m_chartWidget->setData(data); |
|
312 | // m_chartWidget->setData(data); | |
302 | // break; |
|
313 | // break; | |
303 | // } |
|
314 | // } | |
304 | // default: |
|
315 | // default: | |
305 | // break; |
|
316 | // break; | |
306 | // } |
|
317 | // } | |
307 | } |
|
318 | } | |
308 |
|
319 | |||
309 | void MainWidget::backgroundChanged(int itemIndex) |
|
320 | void MainWidget::backgroundChanged(int itemIndex) | |
310 | { |
|
321 | { | |
311 | qDebug() << "backgroundChanged: " << itemIndex; |
|
322 | qDebug() << "backgroundChanged: " << itemIndex; | |
312 | } |
|
323 | } | |
313 |
|
324 | |||
314 | void MainWidget::autoScaleChanged(int value) |
|
325 | void MainWidget::autoScaleChanged(int value) | |
315 | { |
|
326 | { | |
316 | if (value) { |
|
327 | if (value) { | |
317 | // TODO: enable auto scaling |
|
328 | // TODO: enable auto scaling | |
318 | } else { |
|
329 | } else { | |
319 | // TODO: set scaling manually (and disable auto scaling) |
|
330 | // TODO: set scaling manually (and disable auto scaling) | |
320 | } |
|
331 | } | |
321 |
|
332 | |||
322 | m_xMinSpin->setEnabled(!value); |
|
333 | m_xMinSpin->setEnabled(!value); | |
323 | m_xMaxSpin->setEnabled(!value); |
|
334 | m_xMaxSpin->setEnabled(!value); | |
324 | m_yMinSpin->setEnabled(!value); |
|
335 | m_yMinSpin->setEnabled(!value); | |
325 | m_yMaxSpin->setEnabled(!value); |
|
336 | m_yMaxSpin->setEnabled(!value); | |
326 | } |
|
337 | } | |
327 |
|
338 | |||
328 | void MainWidget::xMinChanged(int value) |
|
339 | void MainWidget::xMinChanged(int value) | |
329 | { |
|
340 | { | |
330 | qDebug() << "xMinChanged: " << value; |
|
341 | qDebug() << "xMinChanged: " << value; | |
331 | } |
|
342 | } | |
332 |
|
343 | |||
333 | void MainWidget::xMaxChanged(int value) |
|
344 | void MainWidget::xMaxChanged(int value) | |
334 | { |
|
345 | { | |
335 | qDebug() << "xMaxChanged: " << value; |
|
346 | qDebug() << "xMaxChanged: " << value; | |
336 | } |
|
347 | } | |
337 |
|
348 | |||
338 | void MainWidget::yMinChanged(int value) |
|
349 | void MainWidget::yMinChanged(int value) | |
339 | { |
|
350 | { | |
340 | qDebug() << "yMinChanged: " << value; |
|
351 | qDebug() << "yMinChanged: " << value; | |
341 | } |
|
352 | } | |
342 |
|
353 | |||
343 | void MainWidget::yMaxChanged(int value) |
|
354 | void MainWidget::yMaxChanged(int value) | |
344 | { |
|
355 | { | |
345 | qDebug() << "yMaxChanged: " << value; |
|
356 | qDebug() << "yMaxChanged: " << value; | |
346 | } |
|
357 | } | |
347 |
|
358 | |||
348 | void MainWidget::changeChartTheme(int themeIndex) |
|
359 | void MainWidget::changeChartTheme(int themeIndex) | |
349 | { |
|
360 | { | |
350 | qDebug() << "changeChartTheme: " << themeIndex; |
|
361 | qDebug() << "changeChartTheme: " << themeIndex; | |
351 | m_chartWidget->setTheme((QChart::ChartThemeId) themeIndex); |
|
362 | m_chartWidget->setTheme((QChart::ChartThemeId) themeIndex); | |
352 | } |
|
363 | } | |
353 |
|
364 | |||
354 | void MainWidget::setPieSizeFactor(double size) |
|
365 | void MainWidget::setPieSizeFactor(double size) | |
355 | { |
|
366 | { | |
356 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); |
|
367 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); | |
357 | if (pie) |
|
368 | if (pie) | |
358 | pie->setSizeFactor(qreal(size)); |
|
369 | pie->setSizeFactor(qreal(size)); | |
359 | } |
|
370 | } | |
360 |
|
371 | |||
361 | void MainWidget::setPiePosition(int position) |
|
372 | void MainWidget::setPiePosition(int position) | |
362 | { |
|
373 | { | |
363 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); |
|
374 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); | |
364 | if (pie) |
|
375 | if (pie) | |
365 | pie->setPosition((QPieSeries::PiePosition) position); |
|
376 | pie->setPosition((QPieSeries::PiePosition) position); | |
366 | } |
|
377 | } |
@@ -1,50 +1,56 | |||||
1 | #ifndef MAINWIDGET_H |
|
1 | #ifndef MAINWIDGET_H | |
2 | #define MAINWIDGET_H |
|
2 | #define MAINWIDGET_H | |
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <qchartwidget.h> |
|
5 | #include <qchartwidget.h> | |
6 | #include <QWidget> |
|
6 | #include <QWidget> | |
7 |
|
7 | |||
8 | class QSpinBox; |
|
8 | class QSpinBox; | |
9 | class QCheckBox; |
|
9 | class QCheckBox; | |
10 | class QGridLayout; |
|
10 | class QGridLayout; | |
11 |
|
11 | |||
12 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
12 | QTCOMMERCIALCHART_USE_NAMESPACE | |
13 |
|
13 | |||
14 | class MainWidget : public QWidget |
|
14 | class MainWidget : public QWidget | |
15 | { |
|
15 | { | |
16 | Q_OBJECT |
|
16 | Q_OBJECT | |
17 | public: |
|
17 | public: | |
18 | explicit MainWidget(QWidget *parent = 0); |
|
18 | explicit MainWidget(QWidget *parent = 0); | |
19 |
|
19 | |||
20 | signals: |
|
20 | signals: | |
21 |
|
21 | |||
|
22 | private: | |||
|
23 | void initBackroundCombo(QGridLayout *grid); | |||
|
24 | void initScaleControls(QGridLayout *grid); | |||
|
25 | void initThemeCombo(QGridLayout *grid); | |||
|
26 | void initPieControls(); | |||
|
27 | ||||
22 | private slots: |
|
28 | private slots: | |
23 | void addSeries(); |
|
29 | void addSeries(); | |
24 | void addSeries(QString series, QString data); |
|
30 | void addSeries(QString series, QString data); | |
25 | void testDataChanged(int itemIndex); |
|
31 | void testDataChanged(int itemIndex); | |
26 | void backgroundChanged(int itemIndex); |
|
32 | void backgroundChanged(int itemIndex); | |
27 | void autoScaleChanged(int value); |
|
33 | void autoScaleChanged(int value); | |
28 | void xMinChanged(int value); |
|
34 | void xMinChanged(int value); | |
29 | void xMaxChanged(int value); |
|
35 | void xMaxChanged(int value); | |
30 | void yMinChanged(int value); |
|
36 | void yMinChanged(int value); | |
31 | void yMaxChanged(int value); |
|
37 | void yMaxChanged(int value); | |
32 | void setCurrentSeries(QChartSeries *series); |
|
38 | void setCurrentSeries(QChartSeries *series); | |
33 | void changeChartTheme(int themeIndex); |
|
39 | void changeChartTheme(int themeIndex); | |
34 | void setPieSizeFactor(double margin); |
|
40 | void setPieSizeFactor(double margin); | |
35 | void setPiePosition(int position); |
|
41 | void setPiePosition(int position); | |
36 |
|
42 | |||
37 | private: |
|
43 | private: | |
38 | QChartWidget *m_chartWidget; |
|
44 | QChartWidget *m_chartWidget; | |
39 | QCheckBox *m_autoScaleCheck; |
|
45 | QCheckBox *m_autoScaleCheck; | |
40 | QSpinBox *m_xMinSpin; |
|
46 | QSpinBox *m_xMinSpin; | |
41 | QSpinBox *m_xMaxSpin; |
|
47 | QSpinBox *m_xMaxSpin; | |
42 | QSpinBox *m_yMinSpin; |
|
48 | QSpinBox *m_yMinSpin; | |
43 | QSpinBox *m_yMaxSpin; |
|
49 | QSpinBox *m_yMaxSpin; | |
44 | QString m_defaultSeriesName; |
|
50 | QString m_defaultSeriesName; | |
45 | QChartSeries *m_currentSeries; |
|
51 | QChartSeries *m_currentSeries; | |
46 | QGridLayout *m_scatterLayout; |
|
52 | QGridLayout *m_scatterLayout; | |
47 | QGridLayout *m_pieLayout; |
|
53 | QGridLayout *m_pieLayout; | |
48 | }; |
|
54 | }; | |
49 |
|
55 | |||
50 | #endif // MAINWIDGET_H |
|
56 | #endif // MAINWIDGET_H |
General Comments 0
You need to be logged in to leave comments.
Login now