##// END OF EJS Templates
Fixed colors in spline
Marek Rosa -
r577:d1f00b1c0524
parent child
Show More
@@ -14,14 +14,14 SplineWidget::SplineWidget(QWidget *parent)
14 14 // qsrand(time(NULL));
15 15 //! [1]
16 16 //create QSplineSeries
17 series = new QSplineSeries;
17 series = new QSplineSeries(this);
18 18 //! [1]
19 19
20 20 //! [2]
21 21 // customize the series presentation settings
22 22 QPen seriesPen(Qt::blue);
23 23 seriesPen.setWidth(3);
24 series->setPen(seriesPen);
24 // series->setPen(seriesPen);
25 25 //! [2]
26 26
27 27 //! [add points to series]
@@ -32,20 +32,32 SplineWidget::SplineWidget(QWidget *parent)
32 32 series->add(QPointF(300, 140));
33 33 series->add(QPointF(350, 160));
34 34 //! [add points to series]
35 // series->add(QPointF(400, 120));
36 // series->add(QPointF(450, 150));
37 // series->add(QPointF(500, 145));
38 // series->add(QPointF(550, 170));
35
36 QSplineSeries* series2 = new QSplineSeries;
37
38 series2->add(QPointF(400, 120));
39 series2->add(QPointF(450, 150));
40 series2->add(QPointF(500, 145));
41 series2->add(QPointF(550, 170));
42
39 43 // series->add(QPointF(600, 190));
40 44 // series->add(QPointF(650, 210));
41 45 // series->add(QPointF(700, 190));
42 46 // series->add(QPointF(750, 180));
43 47 // series->add(QPointF(800, 170));
48 QSplineSeries* series3 = new QSplineSeries;
49 series3->add(QPointF(600, 190));
50 series3->add(QPointF(650, 210));
51 series3->add(QPointF(700, 190));
52 series3->add(QPointF(750, 180));
53 series3->add(QPointF(800, 170));
44 54
45 55 //! [3]
46 56 // create chart view
47 57 QChartView* chart = new QChartView;
48 58 chart->addSeries(series);
59 chart->addSeries(series2);
60 chart->addSeries(series3);
49 61
50 62 chart->setChartTitle("Spline chart example");
51 63 chart->axisX()->setMax(1500);
@@ -192,7 +192,6 void ChartTheme::decorate(PieChartItem* item, QPieSeries* series, int index)
192 192 void ChartTheme::decorate(QSplineSeries* series, int index)
193 193 {
194 194 QPen pen;
195
196 195 if(pen == series->pen()){
197 196 pen.setColor(m_seriesColors.at(index%m_seriesColors.size()));
198 197 pen.setWidthF(2);
@@ -57,7 +57,6 void SplineChartItem::setLayout(QVector<QPointF>& points)
57 57
58 58 void SplineChartItem::handleUpdated()
59 59 {
60 //m_items.setVisible(m_series->pointsVisible());
61 60 m_pen = m_series->pen();
62 61 update();
63 62 }
@@ -70,27 +69,28 void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
70 69 Q_UNUSED(option);
71 70 painter->save();
72 71 painter->setClipRect(clipRect());
73 painter->setPen(m_pen);
72 // painter->setPen(m_pen);
73 painter->setPen(m_series->pen());
74 74 painter->drawPath(m_path);
75 75
76 const QVector<QPointF> points = XYChartItem::points();
77
78 for (int i = 0; i < points.size() - 1; i++)
79 {
80 painter->setPen(Qt::red);
81 painter->drawEllipse(points[i], 2, 2);
82
83 painter->setPen(Qt::blue);
84 // painter->drawLine(m_series->at(i), m_series->controlPoint(2 * i));
85 // painter->drawLine(m_series->at(i + 1), m_series->controlPoint(2 * i + 1));
86 // painter->drawEllipse(calculateGeometryControlPoint(2 * i), 4, 4);
87 // painter->drawEllipse(calculateGeometryControlPoint(2 * i + 1), 4, 4);
88 }
89 if (points.count() > 0)
90 {
91 painter->setPen(Qt::red);
92 painter->drawEllipse(points[points.count() - 1], 2, 2);
93 }
76 // const QVector<QPointF> points = XYChartItem::points();
77
78 // for (int i = 0; i < points.size() - 1; i++)
79 // {
80 // painter->setPen(Qt::red);
81 // painter->drawEllipse(points[i], 2, 2);
82
83 // painter->setPen(Qt::blue);
84 // // painter->drawLine(m_series->at(i), m_series->controlPoint(2 * i));
85 // // painter->drawLine(m_series->at(i + 1), m_series->controlPoint(2 * i + 1));
86 // // painter->drawEllipse(calculateGeometryControlPoint(2 * i), 4, 4);
87 // // painter->drawEllipse(calculateGeometryControlPoint(2 * i + 1), 4, 4);
88 // }
89 // if (points.count() > 0)
90 // {
91 // painter->setPen(Qt::red);
92 // painter->drawEllipse(points[points.count() - 1], 2, 2);
93 // }
94 94 painter->restore();
95 95 }
96 96
General Comments 0
You need to be logged in to leave comments. Login now