summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrii Staikov <andrii.staikov@scythe-studio.com>2021-06-27 00:20:47 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-30 13:01:41 +0000
commit9edcfe0d3099459aa36e69f6ab4605593cefc2ef (patch)
tree6f9fe9e42f5f373000fda0f32e7651dac97d5814 /src
parentd421f565e9190b5e9e3af19b60e67bf85c8eb2cf (diff)
Add bar chart example
Example shows using setBarSelected(). Selecting bars changes their color and information of selected/unselected bars. [QtCharts][Example] Added Example Task-number: QTBUG-89445 Change-Id: Ic863e763d2cfa552629f42afd1232c1f77b95e95 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> (cherry picked from commit 72d69b22d8da004fcb27e1a549cdda3f52b9c4af) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/charts/doc/images/examples_selectedbar.pngbin0 -> 29668 bytes
-rw-r--r--src/charts/doc/src/examples-selectedbar.qdoc69
2 files changed, 69 insertions, 0 deletions
diff --git a/src/charts/doc/images/examples_selectedbar.png b/src/charts/doc/images/examples_selectedbar.png
new file mode 100644
index 00000000..0b425aeb
--- /dev/null
+++ b/src/charts/doc/images/examples_selectedbar.png
Binary files differ
diff --git a/src/charts/doc/src/examples-selectedbar.qdoc b/src/charts/doc/src/examples-selectedbar.qdoc
new file mode 100644
index 00000000..72c6a34c
--- /dev/null
+++ b/src/charts/doc/src/examples-selectedbar.qdoc
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example selectedbar
+ \title SelectedBar Example
+ \ingroup qtcharts_examples
+
+ \brief The example shows how to use a selection feature for the bar chart.
+
+ The example shows changing the color and state of bars using the selection feature.
+
+ \image examples_selectedbar.png
+
+ \include examples-run.qdocinc
+
+ \section1 Using setBarSelected()
+
+ We create the sets and fill them with the data. Then we create a series and append data to it.
+ \snippet selectedbar/main.cpp 1
+
+ We create the chart and add series to it.
+ Also, we add a title to the chart, set animation for the chart, and align the legend.
+ \snippet selectedbar/main.cpp 2
+
+ Here we set the color for the selected bars.
+ \snippet selectedbar/main.cpp 3
+
+ Next step is adding axes:
+ QBarCategoryAxis for years of measurements and QValueAxis for values range.
+ \snippet selectedbar/main.cpp 4
+
+ Then we add the chart view to put the chart in.
+ \snippet selectedbar/main.cpp 5
+
+ Here we create a widget for labels of values of selected and unselected bars.
+ \snippet selectedbar/main.cpp 6
+
+ We connect selecting of a specific bar with labels of values using a lambda.
+ \c {set->toggleSelection({index})} sets the bar selected.
+ \snippet selectedbar/main.cpp 7
+
+ Finally, we create the main widget and add other layouts to it and run the application.
+ \snippet selectedbar/main.cpp 8
+*/