From 94c0d22f0f14edd88d61b9018848fcf8752cccf3 2012-08-08 09:14:43 From: Tero Ahola Date: 2012-08-08 09:14:43 Subject: [PATCH] Optimization: line series now uses QPainter::drawLine --- diff --git a/src/linechart/linechartitem.cpp b/src/linechart/linechartitem.cpp index 278fb3d..dba8ffd 100644 --- a/src/linechart/linechartitem.cpp +++ b/src/linechart/linechartitem.cpp @@ -96,7 +96,11 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt painter->save(); painter->setPen(m_linePen); painter->setClipRect(clipRect()); - painter->drawPath(m_path); + // Draw lines + const QVector &points = geometryPoints(); + for (int i(1); i < points.size();i++) + painter->drawLine(points.at(i-1), points.at(i)); + // Draw points if (m_pointsVisible){ painter->setPen(m_pointPen); painter->drawPoints(geometryPoints()); diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml index b507fa9..5ae4a8a 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml @@ -45,31 +45,43 @@ ChartView { XYPoint { x: 10; y: 3 } XYPoint { x: 11; y: 3 } } - lowerSeries: LineSeries { - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 0 } - XYPoint { x: 2; y: 0 } - XYPoint { x: 3; y: 0 } - XYPoint { x: 4; y: 0 } - XYPoint { x: 5; y: 0 } - XYPoint { x: 6; y: 0 } - XYPoint { x: 7; y: 0 } - XYPoint { x: 8; y: 0 } - XYPoint { x: 9; y: 0 } - XYPoint { x: 10; y: 0 } - XYPoint { x: 11; y: 0 } - } - onNameChanged: console.log("areaSeries.onNameChanged: " + name); - onVisibleChanged: console.log("areaSeries.onVisibleChanged: " + visible); + onNameChanged: console.log(name + ".onNameChanged: " + name); + onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible); onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); - onSelected: console.log("areaSeries.onSelected"); - onColorChanged: console.log("areaSeries.onColorChanged: " + color); - onBorderColorChanged: console.log("areaSeries.onBorderColorChanged: " + borderColor); -// onCountChanged: console.log("areaSeries.onCountChanged: " + count); + onSelected: console.log(name + ".onSelected"); + onColorChanged: console.log(name + ".onColorChanged: " + color); + onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); +// onCountChanged: console.log(name + ".onCountChanged: " + count); Component.onCompleted: { - createDefaultAxes(); + createDefaultAxes(); + } + } + + AreaSeries { + name: "area 2" + + upperSeries: LineSeries { + XYPoint { x: 0; y: 0.5 } + XYPoint { x: 1; y: 1.5 } + XYPoint { x: 2; y: 0.3 } + XYPoint { x: 3; y: 1.5 } + XYPoint { x: 4; y: 0.1 } + XYPoint { x: 5; y: 0.3 } + XYPoint { x: 6; y: 1.2 } + XYPoint { x: 7; y: 1.3 } + XYPoint { x: 8; y: 0.2 } + XYPoint { x: 9; y: 0.1 } + XYPoint { x: 10; y: 3.2 } + XYPoint { x: 11; y: 4.6 } } + + onNameChanged: console.log(name + ".onNameChanged: " + name); + onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible); + onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); + onSelected: console.log(name + ".onSelected"); + onColorChanged: console.log(name + ".onColorChanged: " + color); + onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); } } diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml index a25226a..753521e 100644 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml +++ b/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml @@ -22,7 +22,7 @@ import QtQuick 1.0 import QtCommercial.Chart 1.0 ChartView { - title: "Grouped bar series" + title: "Bar series" anchors.fill: parent theme: ChartView.ChartThemeLight legend.alignment: Qt.AlignBottom @@ -69,4 +69,4 @@ ChartView { setAxisX(myAxis,mySeries); } -} \ No newline at end of file +}