##// END OF EJS Templates
Documentation and fix for box specific pen color...
Mika Salmela -
r2531:baa389f1ece6
parent child
Show More
@@ -55,7 +55,7 int main(int argc, char *argv[])
55 //![3]
55 //![3]
56 QChart *chart = new QChart();
56 QChart *chart = new QChart();
57 chart->addSeries(series);
57 chart->addSeries(series);
58 chart->setTitle("Cargotec's share deviation 2012")
58 chart->setTitle("Cargotec's share deviation in 2012");
59 chart->setAnimationOptions(QChart::SeriesAnimations);
59 chart->setAnimationOptions(QChart::SeriesAnimations);
60 //![3]
60 //![3]
61
61
@@ -25,6 +25,12 BoxSet {
25 id: myNewBox
25 id: myNewBox
26 label: "Foo"
26 label: "Foo"
27 values: [5, 6, 7, 8, 9]
27 values: [5, 6, 7, 8, 9]
28 onPenChanged: {
29 console.log("onPenChanged")
30 }
31 onColorChanged: {
32 console.log("onColorChanged")
33 }
28 Component.onCompleted: {
34 Component.onCompleted: {
29 console.log("BoxSet completed")
35 console.log("BoxSet completed")
30 }
36 }
@@ -38,8 +38,17 ChartView {
38 BoxSet { values: [3, 4, 4.4, 6, 7] }
38 BoxSet { values: [3, 4, 4.4, 6, 7] }
39 BoxSet { label: "Tok"; values: [5, 6, 7.5, 8, 12] }
39 BoxSet { label: "Tok"; values: [5, 6, 7.5, 8, 12] }
40 BoxSet { label: "Kol"; values: [2, 5, 5.7, 8, 9] }
40 BoxSet { label: "Kol"; values: [2, 5, 5.7, 8, 9] }
41 BoxSet { label: "Nel"; values: [5, 6, 6.8, 7, 8] }
41 BoxSet { id: nelBox
42 BoxSet { label: "Vii"; values: [4, 5, 5.2, 6, 7] }
42 label: "Nel"
43 values: [5, 6, 6.8, 7, 8];
44 onColorChanged: {
45 console.log("onColorChanged")
46 }
47 }
48 BoxSet { label: "Vii"; values: [4, 5, 5.2, 6, 7]; color: "#aa0000" }
49 //onClicked: console.log("series onClicked " + boxset.median)
50 //onHovered: console.log("series onHovered " + status + "median = " + boxset.median)
51 onCountChanged: console.log("onCountChanged")
43 }
52 }
44 //![2]
53 //![2]
45
54
@@ -51,6 +60,7 ChartView {
51 MouseArea {
60 MouseArea {
52 anchors.fill: parent
61 anchors.fill: parent
53 onClicked: {
62 onClicked: {
63 nelBox.color = "#0000aa"
54 var com = Qt.createComponent("box.qml")
64 var com = Qt.createComponent("box.qml")
55 if (com.status == Component.Ready) {
65 if (com.status == Component.Ready) {
56 var obj = com.createObject(moreButton)
66 var obj = com.createObject(moreButton)
@@ -67,9 +77,12 ChartView {
67 obj.label = "mik"
77 obj.label = "mik"
68 console.log("label = " + obj.label)
78 console.log("label = " + obj.label)
69 plotSeries.append(obj)
79 plotSeries.append(obj)
80 obj.color = "#aa0000"
81 console.log("color = " + obj.color)
82 obj.borderColor = "#00aa00"
70 } else {
83 } else {
71 console.log(com.errorString())
84 console.log(com.errorString())
72 }
85 }
73 }
86 }
74 }
87 }
75 }
88 }
@@ -55,7 +55,7 void DeclarativeBoxSet::setValues(QVariantList values)
55 }
55 }
56 }
56 }
57
57
58 // Declarative box&whiskers series =====================================================
58 // =====================================================
59
59
60 DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QDeclarativeItem *parent) :
60 DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QDeclarativeItem *parent) :
61 QBoxPlotSeries(parent),
61 QBoxPlotSeries(parent),
@@ -65,6 +65,8 DeclarativeBoxPlotSeries::DeclarativeBoxPlotSeries(QDeclarativeItem *parent) :
65 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
65 connect(m_axes, SIGNAL(axisYChanged(QAbstractAxis*)), this, SIGNAL(axisYChanged(QAbstractAxis*)));
66 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
66 connect(m_axes, SIGNAL(axisXTopChanged(QAbstractAxis*)), this, SIGNAL(axisXTopChanged(QAbstractAxis*)));
67 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
67 connect(m_axes, SIGNAL(axisYRightChanged(QAbstractAxis*)), this, SIGNAL(axisYRightChanged(QAbstractAxis*)));
68 connect(this, SIGNAL(hovered(bool, QBoxSet*)), this, SLOT(onHovered(bool, QBoxSet*)));
69 connect(this, SIGNAL(clicked(QBoxSet*)), this, SLOT(onClicked(QBoxSet*)));
68 }
70 }
69
71
70 void DeclarativeBoxPlotSeries::classBegin()
72 void DeclarativeBoxPlotSeries::classBegin()
@@ -100,7 +102,6 void DeclarativeBoxPlotSeries::appendSeriesChildren(QDeclarativeListProperty<QOb
100
102
101 DeclarativeBoxSet *DeclarativeBoxPlotSeries::at(int index)
103 DeclarativeBoxSet *DeclarativeBoxPlotSeries::at(int index)
102 {
104 {
103 qDebug() << "DeclarativeBoxPlotSeries::at";
104 QList<QBoxSet *> setList = boxSets();
105 QList<QBoxSet *> setList = boxSets();
105 if (index >= 0 && index < setList.count())
106 if (index >= 0 && index < setList.count())
106 return qobject_cast<DeclarativeBoxSet *>(setList[index]);
107 return qobject_cast<DeclarativeBoxSet *>(setList[index]);
@@ -118,6 +119,15 DeclarativeBoxSet *DeclarativeBoxPlotSeries::insert(int index, const QString lab
118 return 0;
119 return 0;
119 }
120 }
120
121
122 void DeclarativeBoxPlotSeries::onHovered(bool status, QBoxSet *boxset)
123 {
124 emit hovered(status, qobject_cast<DeclarativeBoxSet *>(boxset));
125 }
126
127 void DeclarativeBoxPlotSeries::onClicked(QBoxSet *boxset)
128 {
129 emit clicked(qobject_cast<DeclarativeBoxSet *>(boxset));
130 }
121
131
122 #include "moc_declarativeboxplotseries.cpp"
132 #include "moc_declarativeboxplotseries.cpp"
123
133
@@ -98,9 +98,13 Q_SIGNALS:
98 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
98 Q_REVISION(1) void axisYChanged(QAbstractAxis *axis);
99 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
99 Q_REVISION(2) void axisXTopChanged(QAbstractAxis *axis);
100 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
100 Q_REVISION(2) void axisYRightChanged(QAbstractAxis *axis);
101 void clicked(DeclarativeBoxSet *boxset);
102 void hovered(bool status, DeclarativeBoxSet *boxset);
101
103
102 public Q_SLOTS:
104 public Q_SLOTS:
103 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
105 static void appendSeriesChildren(QDeclarativeListProperty<QObject> *list, QObject *element);
106 void onHovered(bool status, QBoxSet *boxset);
107 void onClicked(QBoxSet *boxset);
104
108
105 public:
109 public:
106 DeclarativeAxes *m_axes;
110 DeclarativeAxes *m_axes;
@@ -112,8 +112,6 void BoxPlotChartItem::handleDataStructureChanged()
112
112
113 void BoxPlotChartItem::handleUpdatedBars()
113 void BoxPlotChartItem::handleUpdatedBars()
114 {
114 {
115 qDebug() << "BoxPlotChartItem::handleUpdatedBars()";
116
117 foreach (BoxWhiskers *item, m_boxTable.values()) {
115 foreach (BoxWhiskers *item, m_boxTable.values()) {
118 item->setBrush(m_series->brush());
116 item->setBrush(m_series->brush());
119 item->setPen(m_series->pen());
117 item->setPen(m_series->pen());
@@ -42,8 +42,8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
42 \mainclass
42 \mainclass
43
43
44 QBoxPlotSeries represents a series of data shown as box-and-whisker bars. The purpose of this class is to act as
44 QBoxPlotSeries represents a series of data shown as box-and-whisker bars. The purpose of this class is to act as
45 a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple QBoxPlotSeries
45 a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple instances of
46 items with the same index are drawn to same slot.
46 QBoxPlotSeries then box-and-whiskers items with the same index are drawn to same slot.
47
47
48 See the \l {Box and Whiskers Example} {box-and-whiskers chart example} to learn how to create a box-and-whiskers chart.
48 See the \l {Box and Whiskers Example} {box-and-whiskers chart example} to learn how to create a box-and-whiskers chart.
49 \image examples_boxplotchart.png
49 \image examples_boxplotchart.png
@@ -53,12 +53,16 QTCOMMERCIALCHART_BEGIN_NAMESPACE
53
53
54 /*!
54 /*!
55 \qmlclass BoxPlotSeries QBoxPlotSeries
55 \qmlclass BoxPlotSeries QBoxPlotSeries
56 \inherits AbstractBarSeries
56 \inherits QAbstractSeries
57
58 BoxPlotSeries represents a series of data shown as box-and-whisker bars. The purpose of this class is to act as
59 a container for single box-and-whisker items. Each item is drawn to own slot. If chart includes multiple instances of
60 BoxPlotSeries then box-and-whiskers items with the same index are drawn to same slot.
57
61
58 The following QML shows how to create a simple box-and-whiskers chart:
62 The following QML shows how to create a simple box-and-whiskers chart:
59 \snippet ../examples/qmlboxplot/qml/qmlboxplot/main.qml 1
63 \snippet ../examples/qmlboxplot/qml/qmlboxplot/main.qml 1
60 \beginfloatleft
64 \beginfloatleft
61 \image demos_qmlchart7.png
65 \image TODO_CREATE_IMAGE.png
62 \endfloat
66 \endfloat
63 \clearfloat
67 \clearfloat
64 */
68 */
@@ -87,6 +91,45 QTCOMMERCIALCHART_BEGIN_NAMESPACE
87 \fn QBoxPlotSeries::countChanged()
91 \fn QBoxPlotSeries::countChanged()
88 \brief Signal is emitted when there is change in count of box-and-whiskers items in the series.
92 \brief Signal is emitted when there is change in count of box-and-whiskers items in the series.
89 */
93 */
94 /*!
95 \qmlmethod BoxPlotSeries::append(const QString label, QVariantList values)
96 Appends a new box-and-whiskers set with \a label and \a values to the series.
97 */
98 /*!
99 \qmlmethod BoxPlotSeries::append(BoxSet *box)
100 Appends the \a box to the series.
101 */
102 /*!
103 \qmlmethod BoxPlotSeries::insert(int index, const QString label, QVariantList values)
104 Inserts a new box-and-whiskers set with \a label and \a values at the \a index position.
105 */
106 /*!
107 \qmlmethod BoxPlotSeries::remove(QBoxSet *boxset)
108 Removes the \a boxset from the series.
109 */
110 /*!
111 \qmlmethod BoxPlotSeries::clear()
112 Removes all boxsets from the series. Deletes removed sets.
113 */
114
115 /*!
116 \qmlsignal BoxPlotSeries::onClicked(BoxSet boxset);
117 Signal is emitted when the user clicks the \a boxset on the chart.
118 */
119 /*!
120 \qmlsignal BoxPlotSeries::onHovered(bool status, BoxSet boxset);
121 Signal is emitted when there is change in hover \a status over \a boxset.
122 */
123 /*!
124 \qmlsignal BoxPlotSeries::onCountChanged();
125 Signal is emitted when there is change in count of box-and-whiskers items in the series.
126 */
127 /*
128 void boxsetsAdded(QList<QBoxSet *> sets);
129 */
130 /*
131 void boxsetsRemoved(QList<QBoxSet *> sets);
132 */
90
133
91 /*!
134 /*!
92 Constructs empty QBoxPlotSeries.
135 Constructs empty QBoxPlotSeries.
@@ -32,9 +32,9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 QBoxSet represents one box-and-whiskers item. It takes fives values to create a graphical representation
33 QBoxSet represents one box-and-whiskers item. It takes fives values to create a graphical representation
34 of range and three medians. There's two type of methods to give the values. The first one is with constructor
34 of range and three medians. There's two type of methods to give the values. The first one is with constructor
35 or append type of methods (append and operator <<). In these the values have to be given in order lower extreme,
35 or append type of methods (append and operator <<). The values have to be given in order lower extreme,
36 lower quartile, median, upper quartile and upper extre. Second method is to create an empty QBoxSet instance and
36 lower quartile, median, upper quartile and upper extre. Second method is to create an empty QBoxSet instance and
37 give the values using own methods.
37 give the values using value specific methods.
38
38
39 \mainclass
39 \mainclass
40
40
@@ -45,11 +45,19 QTCOMMERCIALCHART_BEGIN_NAMESPACE
45
45
46 BoxSet represents one box-and-whiskers item. It takes fives values to create a graphical representation
46 BoxSet represents one box-and-whiskers item. It takes fives values to create a graphical representation
47 of range and three medians. There's two type of methods to give the values. The first one is with constructor
47 of range and three medians. There's two type of methods to give the values. The first one is with constructor
48 or append type of methods (append and operator <<). In these the values have to be given in order lower extreme,
48 or with append method. In these the values have to be given in order lower extreme, lower quartile, median,
49 lower quartile, median, upper quartile and upper extre. Second method is to create an empty BoxSet instance and
49 upper quartile and upper extre. Second method is to create an empty QBoxSet instance and
50 give the values using own methods.
50 give the values using value specific methods.
51 \sa BoxPlotSeries
51 \sa BoxPlotSeries
52 */
52 */
53 /*!
54 \qmlproperty string BoxSet::label
55 Defines the label of the boxSet.
56 */
57 /*!
58 \qmlproperty int BoxSet::count
59 The count of values on the box-and-whiskers set
60 */
53
61
54 /*!
62 /*!
55 \property QBoxSet::pen
63 \property QBoxSet::pen
@@ -65,16 +73,52 QTCOMMERCIALCHART_BEGIN_NAMESPACE
65 \property QBoxSet::color
73 \property QBoxSet::color
66 The fill (brush) color of the box-and-whiskers set.
74 The fill (brush) color of the box-and-whiskers set.
67 */
75 */
68
76 /*!
77 \qmlproperty color BoxSet::color
78 Defines the fill (brush) color of the box-and-whiskers set.
79 */
69 /*!
80 /*!
70 \property QBoxSet::borderColor
81 \property QBoxSet::borderColor
71 The line (pen) color of the box-and-whiskers set.
82 The line (pen) color of the box-and-whiskers set.
72 */
83 */
84 /*!
85 \qmlproperty color BoxSet::borderColor
86 Defines the outline color of the box-and-whiskers set.
87 */
88
89 /*!
90 \qmlproperty qreal BoxSet::lowerExtreme
91 The lower extreme value of the box-and-whiskers set
92 */
93
94 /*!
95 \qmlproperty qreal BoxSet::lowerQuartile
96 The lower quartile value of the box-and-whiskers set
97 */
98
99 /*!
100 \qmlproperty qreal BoxSet::median
101 The median value of the box-and-whiskers set
102 */
103
104 /*!
105 \qmlproperty qreal BoxSet::upperQuartile
106 The upper quartile value of the box-and-whiskers set
107 */
108
109 /*!
110 \qmlproperty qreal BoxSet::upperExtreme
111 The upper extreme value of the box-and-whiskers set
112 */
73
113
74 /*!
114 /*!
75 \fn void QBoxSet::clicked()
115 \fn void QBoxSet::clicked()
76 The signal is emitted if the user clicks with a mouse on top of box-and-whisker item.
116 The signal is emitted if the user clicks with a mouse on top of box-and-whisker item.
77 */
117 */
118 /*!
119 \qmlsignal BoxSet::onClicked()
120 This signal is emitted when the user clicks with a mouse on top of box-and-whisker item.
121 */
78
122
79 /*!
123 /*!
80 \fn void QBoxSet::hovered(bool status)
124 \fn void QBoxSet::hovered(bool status)
@@ -82,23 +126,40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
82 The signal is emitted if mouse is hovered on top of box-and-whisker item.
126 The signal is emitted if mouse is hovered on top of box-and-whisker item.
83 Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item.
127 Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item.
84 */
128 */
129 /*!
130 \qmlsignal BoxSet::onHovered(bool status)
131
132 The signal is emitted if mouse is hovered on top of box-and-whisker item.
133 Parameter \a status is true, if mouse entered on top of item, false if mouse left from top of item.
134 */
85
135
86 /*!
136 /*!
87 \fn void QBoxSet::penChanged()
137 \fn void QBoxSet::penChanged()
88 This signal is emitted when the pen of the box-and-whisker item has changed.
138 This signal is emitted when the pen of the box-and-whisker item has changed.
89 \sa pen
139 \sa pen
90 */
140 */
91
141 /*!
142 \qmlsignal BoxSet::onPenChanged()
143 This signal is emitted when the pen of the box-and-whisker item has changed.
144 */
92 /*!
145 /*!
93 \fn void QBoxSet::brushChanged()
146 \fn void QBoxSet::brushChanged()
94 This signal is emitted when the brush of the box-and-whisker item has changed.
147 This signal is emitted when the brush of the box-and-whisker item has changed.
95 \sa brush
148 \sa brush
96 */
149 */
150 /*!
151 \qmlsignal BoxSet::onBrushChanged()
152 This signal is emitted when the brush of the box-and-whisker item has changed.
153 */
97
154
98 /*!
155 /*!
99 \fn void QBoxSet::colorChanged(QColor)
156 \fn void QBoxSet::colorChanged(QColor)
100 This signal is emitted when the fill (brush) color of the box-and-whisker item has changed to \a color.
157 This signal is emitted when the fill (brush) color of the box-and-whisker item has changed to \a color.
101 */
158 */
159 /*!
160 \qmlsignal BoxSet::onColorChanged(QColor color)
161 This signal is emitted when the fill (brush) color of the box-and-whisker item has changed to \a color.
162 */
102
163
103 /*!
164 /*!
104 \fn void QBoxSet::valuesAdded(int index, int count)
165 \fn void QBoxSet::valuesAdded(int index, int count)
@@ -107,6 +168,12 QTCOMMERCIALCHART_BEGIN_NAMESPACE
107 Parameter \a count is the number of inserted values.
168 Parameter \a count is the number of inserted values.
108 \sa append(), insert()
169 \sa append(), insert()
109 */
170 */
171 /*!
172 \qmlsignal BoxSet::onValuesAdded(int index, int count)
173 This signal is emitted when new values have been added to the box-and-whisker item.
174 Parameter \a index indicates the position of the first inserted value.
175 Parameter \a count is the number of inserted values.
176 */
110
177
111 /*!
178 /*!
112 \fn void QBoxSet::valueChanged(int index)
179 \fn void QBoxSet::valueChanged(int index)
@@ -114,11 +181,19 QTCOMMERCIALCHART_BEGIN_NAMESPACE
114 Parameter \a index indicates the position of the modified value.
181 Parameter \a index indicates the position of the modified value.
115 \sa at()
182 \sa at()
116 */
183 */
117
184 /*!
185 \qmlsignal BoxSet::onValueChanged(int index)
186 This signal is emitted values the value in the box-and-whisker item has been modified.
187 Parameter \a index indicates the position of the modified value.
188 */
118 /*!
189 /*!
119 \fn void QBoxSet::borderColorChanged(QColor)
190 \fn void QBoxSet::borderColorChanged(QColor)
120 This signal is emitted when the line (pen) color of the box-and-whisker item has changed to \a color.
191 This signal is emitted when the line (pen) color of the box-and-whisker item has changed to \a color.
121 */
192 */
193 /*!
194 \qmlsignal BoxSet::onBorderColorChanged(QColor color)
195 This signal is emitted when the line (pen) color of the box-and-whisker item has changed to \a color.
196 */
122
197
123 /*!
198 /*!
124 Constructs QBoxSet with optional \a label and parent of \a parent
199 Constructs QBoxSet with optional \a label and parent of \a parent
@@ -425,6 +500,7 void QBoxSet::setBorderColor(QColor color)
425 QPen p = pen();
500 QPen p = pen();
426 if (p.color() != color) {
501 if (p.color() != color) {
427 p.setColor(color);
502 p.setColor(color);
503 p.setStyle(Qt::SolidLine);
428 setPen(p);
504 setPen(p);
429 emit borderColorChanged(color);
505 emit borderColorChanged(color);
430 }
506 }
General Comments 0
You need to be logged in to leave comments. Login now