summaryrefslogtreecommitdiffstats
path: root/examples/charts/chartsgallery/splinewidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/charts/chartsgallery/splinewidget.cpp')
-rw-r--r--examples/charts/chartsgallery/splinewidget.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/charts/chartsgallery/splinewidget.cpp b/examples/charts/chartsgallery/splinewidget.cpp
new file mode 100644
index 00000000..1bda42f7
--- /dev/null
+++ b/examples/charts/chartsgallery/splinewidget.cpp
@@ -0,0 +1,38 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "splinewidget.h"
+
+#include <QChart>
+#include <QSplineSeries>
+
+SplineWidget::SplineWidget(QWidget *parent)
+ : ContentWidget(parent)
+{
+ //![1]
+ auto series = new QSplineSeries;
+ series->setName("Spline");
+ //![1]
+
+ //![2]
+ series->append(0, 6);
+ series->append(2, 4);
+ series->append(3, 8);
+ series->append(7, 4);
+ series->append(10, 5);
+ *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
+ //![2]
+
+ //![3]
+ auto chart = new QChart;
+ chart->legend()->hide();
+ chart->addSeries(series);
+ chart->setTitle("Simple Spline Chart");
+ chart->createDefaultAxes();
+ chart->axes(Qt::Vertical).first()->setRange(0, 10);
+ //![3]
+
+ //![4]
+ createDefaultChartView(chart);
+ //![4]
+}