diff --git a/plugins/declarative/declarativebarseries.cpp b/plugins/declarative/declarativebarseries.cpp index 760d615..29cd26c 100644 --- a/plugins/declarative/declarativebarseries.cpp +++ b/plugins/declarative/declarativebarseries.cpp @@ -67,9 +67,33 @@ void DeclarativeBarSet::setValues(QVariantList values) while (count()) remove(count() - 1); - for (int i(0); i < values.count(); i++) { - if (values.at(i).canConvert(QVariant::Double)) - QBarSet::append(values[i].toDouble()); + if (values.at(0).canConvert(QVariant::Point)) { + // Create list of values for appending if the first item is Qt.point + int maxValue = 0; + for (int i = 0; i < values.count(); i++) { + if (values.at(i).canConvert(QVariant::Point) && + values.at(i).toPoint().x() > maxValue) { + maxValue = values.at(i).toPoint().x(); + } + } + + QVector indexValueList; + indexValueList.resize(maxValue + 1); + + for (int i = 0; i < values.count(); i++) { + if (values.at(i).canConvert(QVariant::Point)) { + indexValueList.replace(values.at(i).toPoint().x(), values.at(i).toPoint().y()); + } + } + + for (int i = 0; i < indexValueList.count(); i++) + QBarSet::append(indexValueList.at(i)); + + } else { + for (int i(0); i < values.count(); i++) { + if (values.at(i).canConvert(QVariant::Double)) + QBarSet::append(values[i].toDouble()); + } } } diff --git a/src/barchart/qbarset.cpp b/src/barchart/qbarset.cpp index fce6f80..1767177 100644 --- a/src/barchart/qbarset.cpp +++ b/src/barchart/qbarset.cpp @@ -256,10 +256,10 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE \qmlproperty QVariantList BarSet::values 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 reals as values, the values are automatically completed to points by using the index of a value as it's - x-coordinate. For example: + x-coordinate. For example the following sets have equal values: \code myBarSet1.values = [0, 5, 1, 5]; - myBarSet2.values = [Qt.point(0, 1), Qt.point(1, 5), Qt.point(2.2, 4.3)]; + myBarSet2.values = [Qt.point(0, 0), Qt.point(1, 5), Qt.point(2, 1), Qt.point(3, 5)]; \endcode */