##// END OF EJS Templates
Fix setting values for BarSet using Qt.point...
Titta Heikkala -
r2678:22efebecf8c2
parent child
Show More
@@ -67,9 +67,33 void DeclarativeBarSet::setValues(QVariantList values)
67 while (count())
67 while (count())
68 remove(count() - 1);
68 remove(count() - 1);
69
69
70 for (int i(0); i < values.count(); i++) {
70 if (values.at(0).canConvert(QVariant::Point)) {
71 if (values.at(i).canConvert(QVariant::Double))
71 // Create list of values for appending if the first item is Qt.point
72 QBarSet::append(values[i].toDouble());
72 int maxValue = 0;
73 for (int i = 0; i < values.count(); i++) {
74 if (values.at(i).canConvert(QVariant::Point) &&
75 values.at(i).toPoint().x() > maxValue) {
76 maxValue = values.at(i).toPoint().x();
77 }
78 }
79
80 QVector<int> indexValueList;
81 indexValueList.resize(maxValue + 1);
82
83 for (int i = 0; i < values.count(); i++) {
84 if (values.at(i).canConvert(QVariant::Point)) {
85 indexValueList.replace(values.at(i).toPoint().x(), values.at(i).toPoint().y());
86 }
87 }
88
89 for (int i = 0; i < indexValueList.count(); i++)
90 QBarSet::append(indexValueList.at(i));
91
92 } else {
93 for (int i(0); i < values.count(); i++) {
94 if (values.at(i).canConvert(QVariant::Double))
95 QBarSet::append(values[i].toDouble());
96 }
73 }
97 }
74 }
98 }
75
99
@@ -256,10 +256,10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
256 \qmlproperty QVariantList BarSet::values
256 \qmlproperty QVariantList BarSet::values
257 The values of the bar set. You can set either a list of reals or a list of points as values. If you set a list of
257 The values of the bar set. You can set either a list of reals or a list of points as values. If you set a list of
258 reals as values, the values are automatically completed to points by using the index of a value as it's
258 reals as values, the values are automatically completed to points by using the index of a value as it's
259 x-coordinate. For example:
259 x-coordinate. For example the following sets have equal values:
260 \code
260 \code
261 myBarSet1.values = [0, 5, 1, 5];
261 myBarSet1.values = [0, 5, 1, 5];
262 myBarSet2.values = [Qt.point(0, 1), Qt.point(1, 5), Qt.point(2.2, 4.3)];
262 myBarSet2.values = [Qt.point(0, 0), Qt.point(1, 5), Qt.point(2, 1), Qt.point(3, 5)];
263 \endcode
263 \endcode
264 */
264 */
265
265
General Comments 0
You need to be logged in to leave comments. Login now