summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cmake.conf3
-rw-r--r--.qmake.conf2
-rw-r--r--CMakeLists.txt2
-rw-r--r--conanfile.py139
-rw-r--r--dependencies.yaml6
-rw-r--r--examples/charts/CMakeLists.txt2
-rw-r--r--examples/charts/areachart/CMakeLists.txt2
-rw-r--r--examples/charts/audio/CMakeLists.txt2
-rw-r--r--examples/charts/audio/main.cpp5
-rw-r--r--examples/charts/audio/widget.cpp23
-rw-r--r--examples/charts/audio/widget.h6
-rw-r--r--examples/charts/barchart/CMakeLists.txt2
-rw-r--r--examples/charts/barmodelmapper/CMakeLists.txt2
-rw-r--r--examples/charts/boxplotchart/CMakeLists.txt2
-rw-r--r--examples/charts/callout/CMakeLists.txt2
-rw-r--r--examples/charts/candlestickchart/CMakeLists.txt2
-rw-r--r--examples/charts/chartinteractions/CMakeLists.txt2
-rw-r--r--examples/charts/charts.pro6
-rw-r--r--examples/charts/chartthemes/CMakeLists.txt2
-rw-r--r--examples/charts/customchart/CMakeLists.txt2
-rw-r--r--examples/charts/datetimeaxis/CMakeLists.txt2
-rw-r--r--examples/charts/donutbreakdown/CMakeLists.txt2
-rw-r--r--examples/charts/donutchart/CMakeLists.txt2
-rw-r--r--examples/charts/dynamicspline/CMakeLists.txt2
-rw-r--r--examples/charts/horizontalbarchart/CMakeLists.txt2
-rw-r--r--examples/charts/horizontalpercentbarchart/CMakeLists.txt2
-rw-r--r--examples/charts/horizontalstackedbarchart/CMakeLists.txt2
-rw-r--r--examples/charts/legend/CMakeLists.txt2
-rw-r--r--examples/charts/legendmarkers/CMakeLists.txt2
-rw-r--r--examples/charts/lineandbar/CMakeLists.txt2
-rw-r--r--examples/charts/linechart/CMakeLists.txt2
-rw-r--r--examples/charts/logvalueaxis/CMakeLists.txt2
-rw-r--r--examples/charts/modeldata/CMakeLists.txt2
-rw-r--r--examples/charts/multiaxis/CMakeLists.txt2
-rw-r--r--examples/charts/nesteddonuts/CMakeLists.txt2
-rw-r--r--examples/charts/openglseries/CMakeLists.txt2
-rw-r--r--examples/charts/percentbarchart/CMakeLists.txt2
-rw-r--r--examples/charts/piechart/CMakeLists.txt2
-rw-r--r--examples/charts/piechartcustomization/CMakeLists.txt2
-rw-r--r--examples/charts/piechartdrilldown/CMakeLists.txt2
-rw-r--r--examples/charts/pointsselectionandmarkers/CMakeLists.txt54
-rw-r--r--examples/charts/pointsselectionandmarkers/blue_triangle.pngbin0 -> 2220 bytes
-rw-r--r--examples/charts/pointsselectionandmarkers/green_triangle.pngbin0 -> 1389 bytes
-rw-r--r--examples/charts/pointsselectionandmarkers/main.cpp158
-rw-r--r--examples/charts/pointsselectionandmarkers/pointsselectionandmarkers.pro15
-rw-r--r--examples/charts/pointsselectionandmarkers/pointsselectionandmarkers.qrc6
-rw-r--r--examples/charts/pointsselectionandmarkers/utilities.cpp140
-rw-r--r--examples/charts/pointsselectionandmarkers/utilities.h66
-rw-r--r--examples/charts/polarchart/CMakeLists.txt2
-rw-r--r--examples/charts/qmlaxes/CMakeLists.txt2
-rw-r--r--examples/charts/qmlboxplot/CMakeLists.txt2
-rw-r--r--examples/charts/qmlcandlestick/CMakeLists.txt2
-rw-r--r--examples/charts/qmlchart/CMakeLists.txt2
-rw-r--r--examples/charts/qmlcustomizations/CMakeLists.txt2
-rw-r--r--examples/charts/qmlcustomlegend/CMakeLists.txt2
-rw-r--r--examples/charts/qmlf1legends/CMakeLists.txt2
-rw-r--r--examples/charts/qmloscilloscope/CMakeLists.txt2
-rw-r--r--examples/charts/qmlpiechart/CMakeLists.txt2
-rw-r--r--examples/charts/qmlpolarchart/CMakeLists.txt2
-rw-r--r--examples/charts/qmlweather/CMakeLists.txt2
-rw-r--r--examples/charts/scatterchart/CMakeLists.txt2
-rw-r--r--examples/charts/scatterinteractions/CMakeLists.txt2
-rw-r--r--examples/charts/selectedbar/CMakeLists.txt40
-rw-r--r--examples/charts/selectedbar/main.cpp146
-rw-r--r--examples/charts/selectedbar/selectedbar.pro11
-rw-r--r--examples/charts/selectedbar/utilities.cpp73
-rw-r--r--examples/charts/selectedbar/utilities.h46
-rw-r--r--examples/charts/splinechart/CMakeLists.txt2
-rw-r--r--examples/charts/stackedbarchart/CMakeLists.txt2
-rw-r--r--examples/charts/stackedbarchartdrilldown/CMakeLists.txt2
-rw-r--r--examples/charts/temperaturerecords/CMakeLists.txt2
-rw-r--r--examples/charts/zoomlinechart/CMakeLists.txt2
-rw-r--r--src/charts/axis/logvalueaxis/qlogvalueaxis.cpp2
-rw-r--r--src/charts/barchart/qbarset.cpp2
-rw-r--r--src/charts/chartpresenter.cpp2
-rw-r--r--src/charts/doc/images/examples_pointsselectionandmarkers1.pngbin0 -> 18597 bytes
-rw-r--r--src/charts/doc/images/examples_pointsselectionandmarkers2.pngbin0 -> 18545 bytes
-rw-r--r--src/charts/doc/images/examples_selectedbar.pngbin0 -> 29668 bytes
-rw-r--r--src/charts/doc/src/examples-pointsselectionandmarkers.qdoc76
-rw-r--r--src/charts/doc/src/examples-selectedbar.qdoc69
-rw-r--r--src/charts/doc/src/index.qdoc4
-rw-r--r--src/charts/doc/src/qt6-changes.qdoc54
-rw-r--r--src/charts/domain/abstractdomain.cpp3
-rw-r--r--src/charts/layout/abstractchartlayout.cpp15
-rw-r--r--src/charts/layout/cartesianchartlayout.cpp16
-rw-r--r--src/charts/legend/qlegend.cpp4
-rw-r--r--src/charts/linechart/linechartitem.cpp13
-rw-r--r--src/charts/scatterchart/qscatterseries.cpp2
-rw-r--r--src/charts/scatterchart/scatterchartitem.cpp86
-rw-r--r--src/charts/scatterchart/scatterchartitem_p.h7
-rw-r--r--src/charts/splinechart/splinechartitem.cpp86
-rw-r--r--src/charts/xychart/qxyseries.cpp20
-rw-r--r--src/charts/xychart/xychart.cpp24
-rw-r--r--src/chartsqml2/declarativechart.cpp9
-rw-r--r--src/chartsqml2/declarativepolarchart.cpp1
-rw-r--r--src/chartsqml2/designer/CMakeLists.txt3
-rw-r--r--src/chartsqml2/designer/default/CMakeLists.txt3
-rw-r--r--src/chartsqml2/designer/images/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/CMakeLists.txt2
-rw-r--r--tests/auto/qscatterseries/tst_qscatterseries.cpp4
100 files changed, 1315 insertions, 242 deletions
diff --git a/.cmake.conf b/.cmake.conf
index 4e73b3d6..77b7fa89 100644
--- a/.cmake.conf
+++ b/.cmake.conf
@@ -1 +1,2 @@
-set(QT_REPO_MODULE_VERSION "6.2.0")
+set(QT_REPO_MODULE_VERSION "6.2.1")
+set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "")
diff --git a/.qmake.conf b/.qmake.conf
index 39e35588..e5a284f2 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -2,4 +2,4 @@ load(qt_build_config)
DEFINES += QT_NO_JAVA_STYLE_ITERATORS
-MODULE_VERSION = 6.2.0
+MODULE_VERSION = 6.2.1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b824480a..7d1235e0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qtcharts.pro.
-cmake_minimum_required(VERSION 3.15.0)
+cmake_minimum_required(VERSION 3.16)
include(.cmake.conf)
project(QtCharts
diff --git a/conanfile.py b/conanfile.py
index 7434ced2..aec6f724 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -26,112 +26,57 @@
##
#############################################################################
-from conans import ConanFile, tools, CMake
-import os
+from conans import ConanFile
+import re
from pathlib import Path
+from typing import Dict, Any
+_qtcharts_features = [
+ "charts-area-chart",
+ "charts-bar-chart",
+ "charts-boxplot-chart",
+ "charts-candlestick-chart",
+ "charts-datetime-axis",
+ "charts-line-chart",
+ "charts-pie-chart",
+ "charts-scatter-chart",
+ "charts-spline-chart",
+]
-class QtConanError(Exception):
- pass
+
+def _parse_qt_version_by_key(key: str) -> str:
+ with open(Path(__file__).parent.resolve() / ".cmake.conf") as f:
+ m = re.search(fr'{key} .*"(.*)"', f.read())
+ return m.group(1) if m else ""
+
+
+def _get_qt_minor_version() -> str:
+ return ".".join(_parse_qt_version_by_key("QT_REPO_MODULE_VERSION").split(".")[:2])
class QtCharts(ConanFile):
name = "qtcharts"
- version = "6.2.0"
license = "GPL-3.0+, Commercial Qt License Agreement"
author = "The Qt Company <https://www.qt.io/contact-us>"
- url = "https://code.qt.io/cgit/qt/qtcharts.git/"
- description = "Qt Charts provides UI Components for displaying visually pleasing charts, driven by static or dynamic data models."
- topics = ("qt", "qt6", "charts", "qtquick")
- settings = "os", "compiler", "build_type", "arch"
- options = {"shared": [True, False, "default"],
- "qt6": "ANY"} # this is needed to model unique package_id for the Add-on build per used Qt6 version
- default_options = {"shared": "default", # default: Use the value of the Qt build
- "qt6": None}
+ url = "https://code.qt.io/cgit/qt/qtcharts.git"
+ description = (
+ "Qt Charts module provides a set of easy to use chart components. "
+ "It uses the Qt Graphics View Framework, therefore charts can be easily integrated "
+ "to modern user interfaces. Qt Charts can be used as QWidgets, QGraphicsWidget, or QML types. "
+ "Users can easily create impressive graphs by selecting one of the charts themes."
+ )
+ topics = "qt", "qt6", "qtcharts", "charts", "graphs"
+ settings = "os", "compiler", "arch", "build_type"
+ # for referencing the version number and prerelease tag and dependencies info
+ exports = ".cmake.conf", "dependencies.yaml"
exports_sources = "*", "!conan*.*"
- # use commit ID as the RREV (recipe revision) if this is exported from .git repository
- revision_mode = "scm" if Path(Path(__file__).parent.resolve() / ".git").exists() else "hash"
-
- def source(self):
- # sources are installed next to recipe, no need to clone etc. sources here
- pass
-
- def _get_cmake_prefix_path(self):
- # 'QTDIR' provided as env variable in profile file which is part of the Qt essential binary
- # package(s). Installed under .conan/profiles
- cmake_prefix_path = os.environ.get("QTDIR")
- if not cmake_prefix_path:
- raise QtConanError("'QTDIR' not defined! The 'QTDIR' needs to point to Qt installation directory.")
- print(f"CMAKE_PREFIX_PATH for '{self.name}/{self.version}' build is: {cmake_prefix_path}")
- return cmake_prefix_path
-
- def _read_env(self, key):
- value = os.environ.get(key)
- if not value:
- raise QtConanError(f"{self.settings.os} build specified but '{key}' was not defined?")
- return value
-
- def _get_qtcmake(self):
- qt_install_path = self._get_cmake_prefix_path()
- ext = ".bat" if tools.os_info.is_windows else ""
- qtcmake = os.path.abspath(os.path.join(qt_install_path, "bin", "qt-cmake" + ext))
- if not os.path.exists(qtcmake):
- raise QtConanError(f"Unable to locate {qtcmake} from 'QTDIR': {qt_install_path}")
- return qtcmake
-
- def _get_cmake_tool(self):
- cmake = CMake(self, cmake_program=self._get_qtcmake())
- cmake.verbose = True
-
- # Qt modules need to be 'installed'.
- # We need to direct the 'make install' to some directory under Conan cache,
- # place it under the current build directory which is also under the Conan cache.
- # Note, the actual 'make install' is called in "package()".
- install_dir = os.path.join(os.getcwd(), "_install_tmp")
- cmake.definitions["CMAKE_INSTALL_PREFIX"] = install_dir
-
- # Use the value of the Qt build
- if self.options.shared.value == "default":
- del cmake.definitions["BUILD_SHARED_LIBS"]
-
- cmake_toolchain_file = os.environ.get("CMAKE_TOOLCHAIN_FILE")
- if cmake_toolchain_file:
- cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = cmake_toolchain_file
-
- if self.settings.os == "Android":
- cmake.definitions["ANDROID_SDK_ROOT"] = self._read_env('ANDROID_SDK_ROOT')
- cmake.definitions["ANDROID_NDK_ROOT"] = self._read_env('ANDROID_NDK_ROOT')
-
- if self.settings.os == "iOS":
- # Instead of Conan's auto-added 'Darwin', explicitly pass 'iOS'.
- cmake.definitions["CMAKE_SYSTEM_NAME"] = "iOS"
-
- # Remove the explicit sysroot, let CMake detect the sysroots, to ensure
- # that multi-arch builds work.
- del cmake.definitions["CMAKE_OSX_SYSROOT"]
-
- # Remove the conan provided architecture, instead rely on the architectures set
- # by the Qt toolchain file, which with official Qt packages most likely means
- # multi-arch iOS.
- del cmake.definitions["CMAKE_OSX_ARCHITECTURES"]
-
- return cmake
-
- def build(self):
- cmake = self._get_cmake_tool()
- self.run('%s "%s" %s' % (self._get_qtcmake(), self.source_folder, cmake.command_line))
- self.run('cmake --build . %s' % cmake.build_config)
- return
-
- def package(self):
- install_dir = os.path.join(os.getcwd(), "_install_tmp") # see 'CMAKE_INSTALL_PREFIX' above
- self.run('cmake --build . --target install')
- self.copy("*", src=install_dir, dst=".")
-
- def package_info(self):
- self.cpp_info.libs = ["Qt6Charts"] # used for the actual library filename, Ordered list with the library names
+ python_requires = f"qt-conan-common/{_get_qt_minor_version()}@qt/everywhere"
+ python_requires_extend = "qt-conan-common.QtLeafModule"
- def deploy(self):
- self.copy("*") # copy from current package
- self.copy_deps("*") # copy from dependencies
+ def get_qt_leaf_module_options(self) -> Dict[str, Any]:
+ """Implements abstractmethod from qt-conan-common.QtLeafModule"""
+ return {item.replace("-", "_"): ["yes", "no", None] for item in _qtcharts_features}
+ def get_qt_leaf_module_default_options(self) -> Dict[str, Any]:
+ """Implements abstractmethod from qt-conan-common.QtLeafModule"""
+ return {item.replace("-", "_"): None for item in _qtcharts_features}
diff --git a/dependencies.yaml b/dependencies.yaml
index 0028103b..13b61b96 100644
--- a/dependencies.yaml
+++ b/dependencies.yaml
@@ -1,10 +1,10 @@
dependencies:
../qtbase:
- ref: 57015d8551ab5fe92481f9ebbe6eb80a2e831063
+ ref: 58136c0c706cc44e5f7f016b4297dbc9b38ef2ac
required: true
../qtdeclarative:
- ref: d71b605747aa5e3d308e724bbb6df498cf337132
+ ref: 5e7c341a8deacaca3e76de5c62d288e860c0385c
required: false
../qtmultimedia:
- ref: dce2c3423bec010ea1544bb27a26d3b7cdae9db8
+ ref: 47b6a81a318f7f9deec98724968684023a23d213
required: false
diff --git a/examples/charts/CMakeLists.txt b/examples/charts/CMakeLists.txt
index 8cd0211f..45e3f577 100644
--- a/examples/charts/CMakeLists.txt
+++ b/examples/charts/CMakeLists.txt
@@ -18,6 +18,7 @@ if(QT_FEATURE_charts_spline_chart)
add_subdirectory(dynamicspline)
add_subdirectory(multiaxis)
add_subdirectory(splinechart)
+ add_subdirectory(pointsselectionandmarkers)
endif()
if(QT_FEATURE_charts_area_chart AND QT_FEATURE_charts_spline_chart)
add_subdirectory(chartthemes)
@@ -34,6 +35,7 @@ if(QT_FEATURE_charts_bar_chart)
add_subdirectory(percentbarchart)
add_subdirectory(legend)
add_subdirectory(temperaturerecords)
+ add_subdirectory(selectedbar)
endif()
if(QT_FEATURE_charts_pie_chart)
add_subdirectory(donutchart)
diff --git a/examples/charts/areachart/CMakeLists.txt b/examples/charts/areachart/CMakeLists.txt
index f55320ed..bc80affe 100644
--- a/examples/charts/areachart/CMakeLists.txt
+++ b/examples/charts/areachart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from areachart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(areachart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/audio/CMakeLists.txt b/examples/charts/audio/CMakeLists.txt
index ab7ee791..6349e31d 100644
--- a/examples/charts/audio/CMakeLists.txt
+++ b/examples/charts/audio/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from audio.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(audio LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/audio/main.cpp b/examples/charts/audio/main.cpp
index 8c4eca66..712a7c14 100644
--- a/examples/charts/audio/main.cpp
+++ b/examples/charts/audio/main.cpp
@@ -29,7 +29,8 @@
#include "widget.h"
-#include <QtMultimedia/QAudioDeviceInfo>
+#include <QtMultimedia/QAudioDevice>
+#include <QtMultimedia/QMediaDevices>
#include <QtWidgets/QApplication>
#include <QtWidgets/QMessageBox>
@@ -37,7 +38,7 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- const QAudioDeviceInfo inputDevice = QAudioDeviceInfo::defaultInputDevice();
+ const QAudioDevice inputDevice = QMediaDevices::defaultAudioInput();
if (inputDevice.isNull()) {
QMessageBox::warning(nullptr, "audio",
"There is no audio input device available.");
diff --git a/examples/charts/audio/widget.cpp b/examples/charts/audio/widget.cpp
index c4945067..1a63150b 100644
--- a/examples/charts/audio/widget.cpp
+++ b/examples/charts/audio/widget.cpp
@@ -30,8 +30,9 @@
#include "widget.h"
#include "xyseriesiodevice.h"
-#include <QtMultimedia/QAudioDeviceInfo>
+#include <QtMultimedia/QAudioDevice>
#include <QtMultimedia/QAudioInput>
+#include <QtMultimedia/QAudioSource>
#include <QtCharts/QChartView>
#include <QtCharts/QLineSeries>
@@ -42,7 +43,7 @@
QT_USE_NAMESPACE
-Widget::Widget(const QAudioDeviceInfo &deviceInfo, QWidget *parent) :
+Widget::Widget(const QAudioDevice &deviceInfo, QWidget *parent) :
QWidget(parent),
m_chart(new QChart),
m_series(new QLineSeries)
@@ -62,29 +63,31 @@ Widget::Widget(const QAudioDeviceInfo &deviceInfo, QWidget *parent) :
m_chart->addAxis(axisY, Qt::AlignLeft);
m_series->attachAxis(axisY);
m_chart->legend()->hide();
- m_chart->setTitle("Data from the microphone (" + deviceInfo.deviceName() + ')');
+ m_chart->setTitle("Data from the microphone (" + deviceInfo.description() + ')');
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(chartView);
+ m_audioInput = new QAudioInput(deviceInfo, this);
+
QAudioFormat formatAudio;
formatAudio.setSampleRate(8000);
formatAudio.setChannelCount(1);
- formatAudio.setSampleSize(8);
- formatAudio.setCodec("audio/pcm");
- formatAudio.setByteOrder(QAudioFormat::LittleEndian);
- formatAudio.setSampleType(QAudioFormat::UnSignedInt);
+ formatAudio.setSampleFormat(QAudioFormat::UInt8);
- m_audioInput = new QAudioInput(deviceInfo, formatAudio, this);
+ m_audioSource = new QAudioSource(deviceInfo, formatAudio);
+ m_audioSource->setBufferSize(200);
m_device = new XYSeriesIODevice(m_series, this);
m_device->open(QIODevice::WriteOnly);
- m_audioInput->start(m_device);
+ m_audioSource->start(m_device);
}
Widget::~Widget()
{
- m_audioInput->stop();
+ m_audioSource->stop();
m_device->close();
+ delete m_audioInput;
+ delete m_device;
}
diff --git a/examples/charts/audio/widget.h b/examples/charts/audio/widget.h
index f4c3f049..64a130a2 100644
--- a/examples/charts/audio/widget.h
+++ b/examples/charts/audio/widget.h
@@ -44,7 +44,8 @@ class XYSeriesIODevice;
QT_BEGIN_NAMESPACE
class QAudioInput;
-class QAudioDeviceInfo;
+class QAudioDevice;
+class QAudioSource;
QT_END_NAMESPACE
class Widget : public QWidget
@@ -52,7 +53,7 @@ class Widget : public QWidget
Q_OBJECT
public:
- explicit Widget(const QAudioDeviceInfo &deviceInfo, QWidget *parent = nullptr);
+ explicit Widget(const QAudioDevice &deviceInfo, QWidget *parent = nullptr);
~Widget();
private:
@@ -60,6 +61,7 @@ private:
QChart *m_chart;
QLineSeries *m_series ;
QAudioInput *m_audioInput = nullptr;
+ QAudioSource *m_audioSource = nullptr;
};
#endif // WIDGET_H
diff --git a/examples/charts/barchart/CMakeLists.txt b/examples/charts/barchart/CMakeLists.txt
index 3f713b72..52e0af31 100644
--- a/examples/charts/barchart/CMakeLists.txt
+++ b/examples/charts/barchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from barchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(barchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/barmodelmapper/CMakeLists.txt b/examples/charts/barmodelmapper/CMakeLists.txt
index d1f66c96..72af0a79 100644
--- a/examples/charts/barmodelmapper/CMakeLists.txt
+++ b/examples/charts/barmodelmapper/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from barmodelmapper.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(barmodelmapper LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/boxplotchart/CMakeLists.txt b/examples/charts/boxplotchart/CMakeLists.txt
index ff1ee5a4..4007dced 100644
--- a/examples/charts/boxplotchart/CMakeLists.txt
+++ b/examples/charts/boxplotchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from boxplotchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(boxplotchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/callout/CMakeLists.txt b/examples/charts/callout/CMakeLists.txt
index 82b1d790..ec98349d 100644
--- a/examples/charts/callout/CMakeLists.txt
+++ b/examples/charts/callout/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from callout.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(callout LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/candlestickchart/CMakeLists.txt b/examples/charts/candlestickchart/CMakeLists.txt
index 94accdd6..7db565af 100644
--- a/examples/charts/candlestickchart/CMakeLists.txt
+++ b/examples/charts/candlestickchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from candlestickchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(candlestickchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/chartinteractions/CMakeLists.txt b/examples/charts/chartinteractions/CMakeLists.txt
index 1dccc30b..95f911c5 100644
--- a/examples/charts/chartinteractions/CMakeLists.txt
+++ b/examples/charts/chartinteractions/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from chartinteractions.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(chartinteractions LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/charts.pro b/examples/charts/charts.pro
index 1e60be5a..bac912e5 100644
--- a/examples/charts/charts.pro
+++ b/examples/charts/charts.pro
@@ -21,7 +21,8 @@ qtConfig(charts-spline-chart) {
SUBDIRS += \
dynamicspline \
multiaxis \
- splinechart
+ splinechart \
+ pointsselectionandmarkers
qtConfig(charts-area-chart) {
SUBDIRS += \
chartthemes \
@@ -39,7 +40,8 @@ qtConfig(charts-bar-chart) {
stackedbarchartdrilldown \
percentbarchart \
legend \
- temperaturerecords
+ temperaturerecords \
+ selectedbar
}
qtConfig(charts-pie-chart) {
SUBDIRS += \
diff --git a/examples/charts/chartthemes/CMakeLists.txt b/examples/charts/chartthemes/CMakeLists.txt
index 8caf3c79..3d6f9639 100644
--- a/examples/charts/chartthemes/CMakeLists.txt
+++ b/examples/charts/chartthemes/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from chartthemes.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(chartthemes LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/customchart/CMakeLists.txt b/examples/charts/customchart/CMakeLists.txt
index 164d55f4..70b3f14c 100644
--- a/examples/charts/customchart/CMakeLists.txt
+++ b/examples/charts/customchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from customchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(customchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/datetimeaxis/CMakeLists.txt b/examples/charts/datetimeaxis/CMakeLists.txt
index 128aa126..d34f4746 100644
--- a/examples/charts/datetimeaxis/CMakeLists.txt
+++ b/examples/charts/datetimeaxis/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from datetimeaxis.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(datetimeaxis LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/donutbreakdown/CMakeLists.txt b/examples/charts/donutbreakdown/CMakeLists.txt
index 63ba5b5f..eceaa86c 100644
--- a/examples/charts/donutbreakdown/CMakeLists.txt
+++ b/examples/charts/donutbreakdown/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from donutbreakdown.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(donutbreakdown LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/donutchart/CMakeLists.txt b/examples/charts/donutchart/CMakeLists.txt
index 40316cab..a19232dd 100644
--- a/examples/charts/donutchart/CMakeLists.txt
+++ b/examples/charts/donutchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from donutchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(donutchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/dynamicspline/CMakeLists.txt b/examples/charts/dynamicspline/CMakeLists.txt
index 8d65964b..734fddc7 100644
--- a/examples/charts/dynamicspline/CMakeLists.txt
+++ b/examples/charts/dynamicspline/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from dynamicspline.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(dynamicspline LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/horizontalbarchart/CMakeLists.txt b/examples/charts/horizontalbarchart/CMakeLists.txt
index 2ba0d249..541b7134 100644
--- a/examples/charts/horizontalbarchart/CMakeLists.txt
+++ b/examples/charts/horizontalbarchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from horizontalbarchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(horizontalbarchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/horizontalpercentbarchart/CMakeLists.txt b/examples/charts/horizontalpercentbarchart/CMakeLists.txt
index 005e2ba5..4740e4da 100644
--- a/examples/charts/horizontalpercentbarchart/CMakeLists.txt
+++ b/examples/charts/horizontalpercentbarchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from horizontalpercentbarchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(horizontalpercentbarchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/horizontalstackedbarchart/CMakeLists.txt b/examples/charts/horizontalstackedbarchart/CMakeLists.txt
index 17be4111..3a83038d 100644
--- a/examples/charts/horizontalstackedbarchart/CMakeLists.txt
+++ b/examples/charts/horizontalstackedbarchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from horizontalstackedbarchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(horizontalstackedbarchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/legend/CMakeLists.txt b/examples/charts/legend/CMakeLists.txt
index 434909d5..837a0eff 100644
--- a/examples/charts/legend/CMakeLists.txt
+++ b/examples/charts/legend/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from legend.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(legend LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/legendmarkers/CMakeLists.txt b/examples/charts/legendmarkers/CMakeLists.txt
index 9a06c081..ebd4a8c3 100644
--- a/examples/charts/legendmarkers/CMakeLists.txt
+++ b/examples/charts/legendmarkers/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from legendmarkers.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(legendmarkers LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/lineandbar/CMakeLists.txt b/examples/charts/lineandbar/CMakeLists.txt
index ca6d9054..7488c42c 100644
--- a/examples/charts/lineandbar/CMakeLists.txt
+++ b/examples/charts/lineandbar/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from lineandbar.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(lineandbar LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/linechart/CMakeLists.txt b/examples/charts/linechart/CMakeLists.txt
index 74076d20..6b18cbdd 100644
--- a/examples/charts/linechart/CMakeLists.txt
+++ b/examples/charts/linechart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from linechart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(linechart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/logvalueaxis/CMakeLists.txt b/examples/charts/logvalueaxis/CMakeLists.txt
index f2841b88..600c42fd 100644
--- a/examples/charts/logvalueaxis/CMakeLists.txt
+++ b/examples/charts/logvalueaxis/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from logvalueaxis.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(logvalueaxis LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/modeldata/CMakeLists.txt b/examples/charts/modeldata/CMakeLists.txt
index 65478668..650f236b 100644
--- a/examples/charts/modeldata/CMakeLists.txt
+++ b/examples/charts/modeldata/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from modeldata.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(modeldata LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/multiaxis/CMakeLists.txt b/examples/charts/multiaxis/CMakeLists.txt
index d333f519..e5396390 100644
--- a/examples/charts/multiaxis/CMakeLists.txt
+++ b/examples/charts/multiaxis/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from multiaxis.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(multiaxis LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/nesteddonuts/CMakeLists.txt b/examples/charts/nesteddonuts/CMakeLists.txt
index 4e55b578..47a62951 100644
--- a/examples/charts/nesteddonuts/CMakeLists.txt
+++ b/examples/charts/nesteddonuts/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from nesteddonuts.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(nesteddonuts LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/openglseries/CMakeLists.txt b/examples/charts/openglseries/CMakeLists.txt
index 26be0522..de21d0d3 100644
--- a/examples/charts/openglseries/CMakeLists.txt
+++ b/examples/charts/openglseries/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from openglseries.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(openglseries LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/percentbarchart/CMakeLists.txt b/examples/charts/percentbarchart/CMakeLists.txt
index c3243045..2b2e51d2 100644
--- a/examples/charts/percentbarchart/CMakeLists.txt
+++ b/examples/charts/percentbarchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from percentbarchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(percentbarchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/piechart/CMakeLists.txt b/examples/charts/piechart/CMakeLists.txt
index e37c2a6d..9450dce1 100644
--- a/examples/charts/piechart/CMakeLists.txt
+++ b/examples/charts/piechart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from piechart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(piechart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/piechartcustomization/CMakeLists.txt b/examples/charts/piechartcustomization/CMakeLists.txt
index 3bf78144..94a02914 100644
--- a/examples/charts/piechartcustomization/CMakeLists.txt
+++ b/examples/charts/piechartcustomization/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from piechartcustomization.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(piechartcustomization LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/piechartdrilldown/CMakeLists.txt b/examples/charts/piechartdrilldown/CMakeLists.txt
index 923803cd..567f5c2a 100644
--- a/examples/charts/piechartdrilldown/CMakeLists.txt
+++ b/examples/charts/piechartdrilldown/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from piechartdrilldown.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(piechartdrilldown LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/pointsselectionandmarkers/CMakeLists.txt b/examples/charts/pointsselectionandmarkers/CMakeLists.txt
new file mode 100644
index 00000000..c2e68bd3
--- /dev/null
+++ b/examples/charts/pointsselectionandmarkers/CMakeLists.txt
@@ -0,0 +1,54 @@
+# Generated from pointsselectionandmarkers.pro.
+
+cmake_minimum_required(VERSION 3.14)
+project(pointsselectionandmarkers LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/charts/pointsselectionandmarkers")
+
+find_package(Qt6 COMPONENTS Core)
+find_package(Qt6 COMPONENTS Gui)
+find_package(Qt6 COMPONENTS Charts)
+
+qt_add_executable(pointsselectionandmarkers
+ utilities.h utilities.cpp
+ main.cpp
+)
+
+set_target_properties(pointsselectionandmarkers PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(pointsselectionandmarkers PUBLIC
+ Qt::Charts
+ Qt::Core
+ Qt::Gui
+)
+
+set(pointsselectionandmarkers_resource_files
+ "blue_triangle.png"
+ "green_triangle.png"
+)
+
+qt6_add_resources(pointsselectionandmarkers "images"
+ PREFIX
+ "/"
+ FILES
+ ${pointsselectionandmarkers_resource_files}
+)
+
+install(TARGETS pointsselectionandmarkers
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/charts/pointsselectionandmarkers/blue_triangle.png b/examples/charts/pointsselectionandmarkers/blue_triangle.png
new file mode 100644
index 00000000..7790453c
--- /dev/null
+++ b/examples/charts/pointsselectionandmarkers/blue_triangle.png
Binary files differ
diff --git a/examples/charts/pointsselectionandmarkers/green_triangle.png b/examples/charts/pointsselectionandmarkers/green_triangle.png
new file mode 100644
index 00000000..29ae043f
--- /dev/null
+++ b/examples/charts/pointsselectionandmarkers/green_triangle.png
Binary files differ
diff --git a/examples/charts/pointsselectionandmarkers/main.cpp b/examples/charts/pointsselectionandmarkers/main.cpp
new file mode 100644
index 00000000..376d49f9
--- /dev/null
+++ b/examples/charts/pointsselectionandmarkers/main.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Charts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "utilities.h"
+
+#include <QApplication>
+#include <QChart>
+#include <QChartView>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QGridLayout>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QMainWindow>
+#include <QSplineSeries>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ QMainWindow mainWindow;
+ mainWindow.setWindowTitle("Chart");
+
+ //![1]
+ constexpr qreal marker_size = 20.;
+
+ QSplineSeries *series = new QSplineSeries();
+ series->append({QPointF(0., 0.),
+ QPointF(0.5, 2.27),
+ QPointF(1.5, 2.2),
+ QPointF(3.3, 1.7),
+ QPointF(4.23, 3.1),
+ QPointF(5.3, 2.3),
+ QPointF(6.47, 4.1)
+ });
+ series->setMarkerSize(marker_size);
+ series->setLightMarker(Utilities::redRectangle(marker_size));
+ series->setSelectedLightMarker(Utilities::blueTriangle(marker_size));
+ QObject::connect(series, &QXYSeries::clicked, series, [&](const QPointF &point) {
+ int index = series->points().indexOf(point);
+ if (index != -1)
+ series->toggleSelection({index});
+ });
+ //![1]
+
+ //![2]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->createDefaultAxes();
+ chart->legend()->setVisible(false);
+
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+
+ QWidget *controlWidget = new QWidget(&mainWindow);
+ QGridLayout *controlLayout = new QGridLayout(controlWidget);
+ //![2]
+
+ //![3]
+ QComboBox *charPointCombobox = new QComboBox();
+ QComboBox *charPointSelectedCombobox = new QComboBox();
+ QComboBox *lineColorCombobox = new QComboBox();
+ QCheckBox *showUnselectedPointsCheckbox = new QCheckBox();
+ //![3]
+
+ //![4]
+ QLabel *charPoint = new QLabel(QCoreApplication::tr("Char point: "));
+ charPointCombobox->addItems({QCoreApplication::tr("Red rectangle"),
+ QCoreApplication::tr("Green triangle"),
+ QCoreApplication::tr("Orange circle")
+ });
+ QObject::connect(charPointCombobox, &QComboBox::currentIndexChanged, series, [&](const int index) {
+ if (showUnselectedPointsCheckbox->isChecked())
+ series->setLightMarker(Utilities::getPointRepresentation(Utilities::PointType(index), marker_size));
+ });
+ //![4]
+
+ //![5]
+ QLabel *charPointSelected = new QLabel(QCoreApplication::tr("Char point selected: "));
+ charPointSelectedCombobox->addItems({QCoreApplication::tr("Blue triangle"),
+ QCoreApplication::tr("Yellow rectangle"),
+ QCoreApplication::tr("Lavender circle")
+ });
+ QObject::connect(charPointSelectedCombobox, &QComboBox::currentIndexChanged, series, [&](const int index) {
+ series->setSelectedLightMarker(Utilities::getSelectedPointRepresentation(Utilities::SelectedPointType(index), marker_size));
+ });
+
+ QLabel *lineColorLabel = new QLabel(QCoreApplication::tr("Line color: "));
+ lineColorCombobox->addItems({QCoreApplication::tr("Blue"),
+ QCoreApplication::tr("Black"),
+ QCoreApplication::tr("Mint")
+ });
+ QObject::connect(lineColorCombobox, &QComboBox::currentIndexChanged, series, [&](const int index) {
+ series->setColor(Utilities::makeLineColor(Utilities::LineColor(index)));
+ });
+ //![5]
+
+ //![6]
+ QLabel *showUnselectedPointsLabel = new QLabel(QCoreApplication::tr("Display unselected points: "));
+ showUnselectedPointsCheckbox->setChecked(true);
+ QObject::connect(showUnselectedPointsCheckbox, &QCheckBox::stateChanged, series, [&](const int state) {
+ if (state) {
+ series->setLightMarker(Utilities::getPointRepresentation(Utilities::PointType(charPointCombobox->currentIndex()), marker_size));
+ } else {
+ series->setLightMarker(QImage());
+ }
+ });
+ //![6]
+
+ //![7]
+ controlLayout->addWidget(charPoint, 0, 0);
+ controlLayout->addWidget(charPointCombobox, 0, 1);
+
+ controlLayout->addWidget(charPointSelected, 1, 0);
+ controlLayout->addWidget(charPointSelectedCombobox, 1, 1);
+
+ controlLayout->addWidget(lineColorLabel, 2, 0);
+ controlLayout->addWidget(lineColorCombobox, 2, 1);
+
+ controlLayout->addWidget(showUnselectedPointsLabel, 3, 0);
+ controlLayout->addWidget(showUnselectedPointsCheckbox, 3, 1, 1, 2);
+
+ QWidget *mainWidget = new QWidget(&mainWindow);
+ QHBoxLayout *mainLayout = new QHBoxLayout(mainWidget);
+ mainLayout->addWidget(chartView);
+ mainLayout->addWidget(controlWidget);
+
+ mainWindow.setCentralWidget(mainWidget);
+ mainWindow.resize(1080, 720);
+ mainWindow.show();
+ return a.exec();
+ //![7]
+}
diff --git a/examples/charts/pointsselectionandmarkers/pointsselectionandmarkers.pro b/examples/charts/pointsselectionandmarkers/pointsselectionandmarkers.pro
new file mode 100644
index 00000000..ac8adffb
--- /dev/null
+++ b/examples/charts/pointsselectionandmarkers/pointsselectionandmarkers.pro
@@ -0,0 +1,15 @@
+QT += charts \
+ widgets
+
+SOURCES += \
+ main.cpp \
+ utilities.cpp
+
+HEADERS += \
+ utilities.h
+
+RESOURCES += \
+ pointsselectionandmarkers.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/charts/pointsselectionandmarkers
+INSTALLS += target
diff --git a/examples/charts/pointsselectionandmarkers/pointsselectionandmarkers.qrc b/examples/charts/pointsselectionandmarkers/pointsselectionandmarkers.qrc
new file mode 100644
index 00000000..920bf0cc
--- /dev/null
+++ b/examples/charts/pointsselectionandmarkers/pointsselectionandmarkers.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>blue_triangle.png</file>
+ <file>green_triangle.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/charts/pointsselectionandmarkers/utilities.cpp b/examples/charts/pointsselectionandmarkers/utilities.cpp
new file mode 100644
index 00000000..7b3ef7f4
--- /dev/null
+++ b/examples/charts/pointsselectionandmarkers/utilities.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Charts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "utilities.h"
+
+#include <QBrush>
+#include <QList>
+#include <QPainter>
+#include <QPainterPath>
+
+namespace Utilities
+{
+ QImage redRectangle(qreal imageSize)
+ {
+ QImage image(imageSize, imageSize, QImage::Format_RGB32);
+ QPainter painter;
+ painter.begin(&image);
+ painter.fillRect(0, 0, imageSize, imageSize, Qt::red);
+ painter.end();
+ return image;
+ }
+
+ QImage yellowRectangle(qreal imageSize)
+ {
+ QImage image(imageSize, imageSize, QImage::Format_RGB32);
+ QPainter painter;
+ painter.begin(&image);
+ painter.fillRect(0, 0, imageSize, imageSize, Qt::yellow);
+ painter.end();
+ return image;
+ }
+
+ QImage blueTriangle(qreal imageSize)
+ {
+ return QImage(":/blue_triangle.png").scaled(imageSize, imageSize);
+ }
+
+ QImage greenTriangle(qreal imageSize)
+ {
+ return QImage(":/green_triangle.png").scaled(imageSize, imageSize);
+ }
+
+ QImage orangeCircle(qreal imageSize)
+ {
+ QImage image(imageSize, imageSize, QImage::Format_ARGB32);
+ image.fill(QColor(0, 0, 0, 0));
+ QPainter paint;
+ paint.begin(&image);
+ paint.setBrush(QColor(255,127,80));
+ QPen pen = paint.pen();
+ pen.setWidth(0);
+ paint.setPen(pen);
+ paint.drawEllipse(0, 0, imageSize * 0.9, imageSize * 0.9);
+ paint.end();
+ return image;
+ }
+
+ QImage lavenderCircle(qreal imageSize)
+ {
+ QImage image(imageSize, imageSize, QImage::Format_ARGB32);
+ image.fill(QColor(0, 0, 0, 0));
+ QPainter paint;
+ paint.begin(&image);
+ paint.setBrush(QColor(147,112,219));
+ QPen pen = paint.pen();
+ pen.setWidth(0);
+ paint.setPen(pen);
+ paint.drawEllipse(0, 0, imageSize * 0.9, imageSize * 0.9);
+ paint.end();
+ return image;
+ }
+
+ QImage getPointRepresentation(PointType pointType, int imageSize)
+ {
+ switch (pointType) {
+ case Utilities::PointType::RedRectangle:
+ return redRectangle(imageSize);
+ case Utilities::PointType::GreenTriangle:
+ return greenTriangle(imageSize);
+ case Utilities::PointType::OrangeCircle:
+ return orangeCircle(imageSize);
+ default:
+ return redRectangle(imageSize);
+ }
+ }
+
+ QImage getSelectedPointRepresentation(SelectedPointType pointType, int imageSize)
+ {
+ switch (pointType) {
+ case Utilities::SelectedPointType::BlueTriangle:
+ return blueTriangle(imageSize);
+ case Utilities::SelectedPointType::YellowRectangle:
+ return yellowRectangle(imageSize);
+ case Utilities::SelectedPointType::LavenderCircle:
+ return lavenderCircle(imageSize);
+ default:
+ return blueTriangle(imageSize);
+ }
+ }
+
+ QColor makeLineColor(LineColor lineColor)
+ {
+ switch (lineColor) {
+ case Utilities::LineColor::Blue:
+ return QColor(65, 105, 225);
+ case Utilities::LineColor::Black:
+ return QColor(0,0,0);
+ case Utilities::LineColor::Mint:
+ return QColor(70, 203, 155);
+ default:
+ return QColor(0, 0, 0);
+ }
+ }
+}
diff --git a/examples/charts/pointsselectionandmarkers/utilities.h b/examples/charts/pointsselectionandmarkers/utilities.h
new file mode 100644
index 00000000..79a6a0c6
--- /dev/null
+++ b/examples/charts/pointsselectionandmarkers/utilities.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Charts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef UTILITIES_H
+#define UTILITIES_H
+
+#include <QImage>
+
+namespace Utilities
+{
+ enum class PointType {
+ RedRectangle,
+ GreenTriangle,
+ OrangeCircle
+ };
+
+ enum class SelectedPointType {
+ BlueTriangle,
+ YellowRectangle,
+ LavenderCircle
+ };
+
+ enum class LineColor {
+ Blue,
+ Black,
+ Mint
+ };
+
+ QImage redRectangle(qreal imageSize);
+ QImage yellowRectangle(qreal imageSize);
+ QImage blueTriangle(qreal imageSize);
+ QImage greenTriangle(qreal imageSize);
+ QImage orangeCircle(qreal imageSize);
+ QImage lavenderCircle(qreal imageSize);
+ QImage getPointRepresentation(PointType pointType, int imageSize);
+ QImage getSelectedPointRepresentation(SelectedPointType pointType, int imageSize);
+ QColor makeLineColor(LineColor lineColor);
+}
+
+#endif // UTILITIES_H
diff --git a/examples/charts/polarchart/CMakeLists.txt b/examples/charts/polarchart/CMakeLists.txt
index 7047de38..7c94a7eb 100644
--- a/examples/charts/polarchart/CMakeLists.txt
+++ b/examples/charts/polarchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from polarchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(polarchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlaxes/CMakeLists.txt b/examples/charts/qmlaxes/CMakeLists.txt
index bb061691..738ff295 100644
--- a/examples/charts/qmlaxes/CMakeLists.txt
+++ b/examples/charts/qmlaxes/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlaxes.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlaxes LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlboxplot/CMakeLists.txt b/examples/charts/qmlboxplot/CMakeLists.txt
index e60aa879..ce55be21 100644
--- a/examples/charts/qmlboxplot/CMakeLists.txt
+++ b/examples/charts/qmlboxplot/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlboxplot.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlboxplot LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlcandlestick/CMakeLists.txt b/examples/charts/qmlcandlestick/CMakeLists.txt
index c78b7950..df2a7015 100644
--- a/examples/charts/qmlcandlestick/CMakeLists.txt
+++ b/examples/charts/qmlcandlestick/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlcandlestick.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlcandlestick LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlchart/CMakeLists.txt b/examples/charts/qmlchart/CMakeLists.txt
index 6496ca8b..fd2aa325 100644
--- a/examples/charts/qmlchart/CMakeLists.txt
+++ b/examples/charts/qmlchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlcustomizations/CMakeLists.txt b/examples/charts/qmlcustomizations/CMakeLists.txt
index 00f59f59..7af83332 100644
--- a/examples/charts/qmlcustomizations/CMakeLists.txt
+++ b/examples/charts/qmlcustomizations/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlcustomizations.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlcustomizations LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlcustomlegend/CMakeLists.txt b/examples/charts/qmlcustomlegend/CMakeLists.txt
index e51e7f67..1c3aef8a 100644
--- a/examples/charts/qmlcustomlegend/CMakeLists.txt
+++ b/examples/charts/qmlcustomlegend/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlcustomlegend.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlcustomlegend LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlf1legends/CMakeLists.txt b/examples/charts/qmlf1legends/CMakeLists.txt
index 69b418e9..f5438a22 100644
--- a/examples/charts/qmlf1legends/CMakeLists.txt
+++ b/examples/charts/qmlf1legends/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlf1legends.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlf1legends LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmloscilloscope/CMakeLists.txt b/examples/charts/qmloscilloscope/CMakeLists.txt
index 5db06367..6d8bf8f9 100644
--- a/examples/charts/qmloscilloscope/CMakeLists.txt
+++ b/examples/charts/qmloscilloscope/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmloscilloscope.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmloscilloscope LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlpiechart/CMakeLists.txt b/examples/charts/qmlpiechart/CMakeLists.txt
index 787e5235..35a880fc 100644
--- a/examples/charts/qmlpiechart/CMakeLists.txt
+++ b/examples/charts/qmlpiechart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlpiechart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlpiechart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlpolarchart/CMakeLists.txt b/examples/charts/qmlpolarchart/CMakeLists.txt
index b1c927f9..39685151 100644
--- a/examples/charts/qmlpolarchart/CMakeLists.txt
+++ b/examples/charts/qmlpolarchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlpolarchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlpolarchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/qmlweather/CMakeLists.txt b/examples/charts/qmlweather/CMakeLists.txt
index 314ece1b..8142fb8c 100644
--- a/examples/charts/qmlweather/CMakeLists.txt
+++ b/examples/charts/qmlweather/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from qmlweather.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(qmlweather LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/scatterchart/CMakeLists.txt b/examples/charts/scatterchart/CMakeLists.txt
index fa498df7..facd2538 100644
--- a/examples/charts/scatterchart/CMakeLists.txt
+++ b/examples/charts/scatterchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from scatterchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(scatterchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/scatterinteractions/CMakeLists.txt b/examples/charts/scatterinteractions/CMakeLists.txt
index 51eb2bea..6d1cada9 100644
--- a/examples/charts/scatterinteractions/CMakeLists.txt
+++ b/examples/charts/scatterinteractions/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from scatterinteractions.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(scatterinteractions LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/selectedbar/CMakeLists.txt b/examples/charts/selectedbar/CMakeLists.txt
new file mode 100644
index 00000000..a293d64b
--- /dev/null
+++ b/examples/charts/selectedbar/CMakeLists.txt
@@ -0,0 +1,40 @@
+# Generated from selectedbar.pro.
+
+cmake_minimum_required(VERSION 3.16)
+project(selectedbar LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/charts/selectedbar")
+
+find_package(Qt6 COMPONENTS Core)
+find_package(Qt6 COMPONENTS Gui)
+find_package(Qt6 COMPONENTS Charts)
+
+qt_add_executable(selectedbar
+ utilities.h utilities.cpp
+ main.cpp
+)
+set_target_properties(selectedbar PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+target_link_libraries(selectedbar PUBLIC
+ Qt::Charts
+ Qt::Core
+ Qt::Gui
+)
+
+install(TARGETS selectedbar
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/charts/selectedbar/main.cpp b/examples/charts/selectedbar/main.cpp
new file mode 100644
index 00000000..9ed62441
--- /dev/null
+++ b/examples/charts/selectedbar/main.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Charts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "utilities.h"
+#include <QBarSet>
+#include <QApplication>
+#include <QBarSeries>
+#include <QList>
+#include <QChart>
+#include <QBarCategoryAxis>
+#include <QValueAxis>
+#include <QChartView>
+#include <QWindow>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QMainWindow>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ QMainWindow mainWindow;
+ mainWindow.setWindowTitle(QCoreApplication::tr("Meat consumption series"));
+
+ //![1]
+ QBarSet *setChicken = Utilities::createChickenSet();
+ QBarSet *setPork = Utilities::createPorkSet();
+ QBarSet *setTurkey = Utilities::createTurkeySet();
+ QBarSet *setHam = Utilities::createHamSet();
+ qreal totalSum = setChicken->sum() + setPork->sum() + setTurkey->sum() + setHam->sum();
+ QList<QBarSet *> setList = QList<QBarSet *>{setChicken, setPork, setTurkey, setHam};
+
+ QBarSeries *series = new QBarSeries();
+ series->append(setList);
+ //![1]
+
+ //![2]
+ QChart *chart = new QChart();
+ chart->addSeries(series);
+ chart->setTitle(QCoreApplication::tr("Meat consumption"));
+ chart->setAnimationOptions(QChart::SeriesAnimations);
+ chart->legend()->setVisible(true);
+ chart->legend()->setAlignment(Qt::AlignBottom);
+ //![2]
+
+ //![3]
+ for (QBarSet *barSet : series->barSets())
+ barSet->setSelectedColor(barSet->brush().color().darker());
+ //![3]
+
+ //![4]
+ QStringList categories = Utilities::createYearCategories();
+ QBarCategoryAxis *axisX = new QBarCategoryAxis();
+ axisX->setCategories(categories);
+ chart->addAxis(axisX, Qt::AlignBottom);
+ series->attachAxis(axisX);
+
+ QValueAxis *axisY = new QValueAxis();
+ axisY->setRange(0, 20);
+ axisY->setTitleText(QCoreApplication::tr("Tons"));
+ axisY->setLabelsAngle(-90);
+ axisY->setTitleVisible(true);
+ chart->addAxis(axisY, Qt::AlignLeft);
+ series->attachAxis(axisY);
+ //![4]
+
+ //![5]
+ QChartView *chartView = new QChartView(chart);
+ chartView->setRenderHint(QPainter::Antialiasing);
+ //![5]
+
+ //![6]
+ QWidget *labelWidget = new QWidget(&mainWindow);
+ QHBoxLayout *labelLayout = new QHBoxLayout(labelWidget);
+ labelLayout->setAlignment(Qt::AlignCenter);
+
+ QLabel *totalSumLabel = new QLabel(QCoreApplication::tr("Total sum: %1 T").arg(totalSum));
+ labelLayout->addWidget(totalSumLabel);
+ totalSumLabel->setContentsMargins(0, 0, 54, 0);
+
+ QLabel *selectedSumLabel = new QLabel(QCoreApplication::tr("Selected sum: 0 T"));
+ labelLayout->addWidget(selectedSumLabel);
+
+ QLabel *unselectedSumLabel = new QLabel(QCoreApplication::tr("Unselected sum: %1 T").arg(totalSum));
+ labelLayout->addWidget(unselectedSumLabel);
+ unselectedSumLabel->setContentsMargins(54, 0, 0, 0);
+ //![6]
+
+ //![7]
+ QObject::connect(series, &QAbstractBarSeries::clicked, series, [=](int index, QBarSet *set) {
+ set->toggleSelection({index});
+ qreal selectedSum = 0.;
+ for (int i = 0; i < setList.size(); ++i) {
+ auto selectedIndices = setList.at(i)->selectedBars();
+ for (int k = 0; k < selectedIndices.size(); ++k)
+ selectedSum += setList.at(i)->at(selectedIndices.at(k));
+ }
+ selectedSumLabel->setText(QCoreApplication::tr("Selected sum: %1 T").arg(selectedSum));
+ // Because of rounding errors, selectedSum can result in being bigger than total sum
+ qreal unselectedSum = totalSum - selectedSum < 0 ? 0. : totalSum - selectedSum;
+ unselectedSumLabel->setText(
+ QCoreApplication::tr("Unselected sum: %1 T")
+ .arg(unselectedSum)
+ );
+ });
+ //![7]
+
+ //![8]
+ QWidget *mainWidget = new QWidget(&mainWindow);
+ QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
+
+ mainLayout->addWidget(chartView);
+ mainLayout->addWidget(labelWidget);
+
+ mainWindow.setCentralWidget(mainWidget);
+ mainWindow.resize(800, 600);
+
+ mainWindow.show();
+ return a.exec();
+ //![8]
+}
diff --git a/examples/charts/selectedbar/selectedbar.pro b/examples/charts/selectedbar/selectedbar.pro
new file mode 100644
index 00000000..24d0de08
--- /dev/null
+++ b/examples/charts/selectedbar/selectedbar.pro
@@ -0,0 +1,11 @@
+QT += charts widgets
+
+SOURCES += \
+ main.cpp \
+ utilities.cpp
+
+HEADERS += \
+ utilities.h
+
+target.path = $$[QT_INSTALL_EXAMPLES]/charts/selectedbar
+INSTALLS += target
diff --git a/examples/charts/selectedbar/utilities.cpp b/examples/charts/selectedbar/utilities.cpp
new file mode 100644
index 00000000..4bbf2c74
--- /dev/null
+++ b/examples/charts/selectedbar/utilities.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Charts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "utilities.h"
+#include <QCoreApplication>
+
+namespace Utilities
+{
+
+QBarSet *createChickenSet()
+{
+ QBarSet *set = new QBarSet(QCoreApplication::tr("Chicken"));
+ set->append({15.0, 12.0, 8.0, 11.5, 13.7});
+ return set;
+}
+
+QBarSet *createPorkSet()
+{
+ QBarSet *set = new QBarSet(QCoreApplication::tr("Pork"));
+ set->append({9.0, 11.0, 9.0, 7, 12.2});
+ return set;
+}
+
+QBarSet *createTurkeySet()
+{
+ QBarSet *set = new QBarSet(QCoreApplication::tr("Turkey"));
+ set->append({5.0, 7.6, 9.3, 8, 8.1});
+ return set;
+}
+
+QBarSet *createHamSet()
+{
+ QBarSet *set = new QBarSet(QCoreApplication::tr("Ham"));
+ set->append({5.4, 7.1, 9.3, 12.3, 11.3});
+ return set;
+}
+
+QStringList createYearCategories()
+{
+ return QStringList{QCoreApplication::tr("2017"),
+ QCoreApplication::tr("2018"),
+ QCoreApplication::tr("2019"),
+ QCoreApplication::tr("2020"),
+ QCoreApplication::tr("2021")};
+}
+
+}
diff --git a/examples/charts/selectedbar/utilities.h b/examples/charts/selectedbar/utilities.h
new file mode 100644
index 00000000..41fe9610
--- /dev/null
+++ b/examples/charts/selectedbar/utilities.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Charts module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef UTILITIES_H
+#define UTILITIES_H
+
+#include <QList>
+#include <QBarSet>
+
+namespace Utilities
+{
+ QBarSet *createChickenSet();
+ QBarSet *createPorkSet();
+ QBarSet *createTurkeySet();
+ QBarSet *createHamSet();
+ QStringList createYearCategories();
+ qreal totalSum(const QList<QBarSet *> &setList);
+}
+
+#endif // UTILITIES_H
diff --git a/examples/charts/splinechart/CMakeLists.txt b/examples/charts/splinechart/CMakeLists.txt
index 62e369d0..1e8c0092 100644
--- a/examples/charts/splinechart/CMakeLists.txt
+++ b/examples/charts/splinechart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from splinechart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(splinechart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/stackedbarchart/CMakeLists.txt b/examples/charts/stackedbarchart/CMakeLists.txt
index 782258bf..c96be256 100644
--- a/examples/charts/stackedbarchart/CMakeLists.txt
+++ b/examples/charts/stackedbarchart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from stackedbarchart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(stackedbarchart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/stackedbarchartdrilldown/CMakeLists.txt b/examples/charts/stackedbarchartdrilldown/CMakeLists.txt
index f8374cf9..576960bc 100644
--- a/examples/charts/stackedbarchartdrilldown/CMakeLists.txt
+++ b/examples/charts/stackedbarchartdrilldown/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from stackedbarchartdrilldown.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(stackedbarchartdrilldown LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/temperaturerecords/CMakeLists.txt b/examples/charts/temperaturerecords/CMakeLists.txt
index c6bd04d5..b1a0588b 100644
--- a/examples/charts/temperaturerecords/CMakeLists.txt
+++ b/examples/charts/temperaturerecords/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from temperaturerecords.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(temperaturerecords LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/examples/charts/zoomlinechart/CMakeLists.txt b/examples/charts/zoomlinechart/CMakeLists.txt
index 5c0f299d..6c6b8222 100644
--- a/examples/charts/zoomlinechart/CMakeLists.txt
+++ b/examples/charts/zoomlinechart/CMakeLists.txt
@@ -1,6 +1,6 @@
# Generated from zoomlinechart.pro.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(zoomlinechart LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/src/charts/axis/logvalueaxis/qlogvalueaxis.cpp b/src/charts/axis/logvalueaxis/qlogvalueaxis.cpp
index b4a88e17..3ea5dd1b 100644
--- a/src/charts/axis/logvalueaxis/qlogvalueaxis.cpp
+++ b/src/charts/axis/logvalueaxis/qlogvalueaxis.cpp
@@ -154,7 +154,7 @@ QT_BEGIN_NAMESPACE
\sa QString::asprintf()
*/
/*!
- \qmlproperty real LogValueAxis::labelFormat
+ \qmlproperty string LogValueAxis::labelFormat
The label format of the axis.
The format string supports the following conversion specifiers, length modifiers, and flags
diff --git a/src/charts/barchart/qbarset.cpp b/src/charts/barchart/qbarset.cpp
index faccf07f..f7ad4909 100644
--- a/src/charts/barchart/qbarset.cpp
+++ b/src/charts/barchart/qbarset.cpp
@@ -691,7 +691,7 @@ QColor QBarSet::selectedColor() const
}
/*!
- Sets the color of the selected bars.
+ Sets the \a color of the selected bars.
\sa selectedColor
\since 6.2
*/
diff --git a/src/charts/chartpresenter.cpp b/src/charts/chartpresenter.cpp
index 39ba35f6..b33a3355 100644
--- a/src/charts/chartpresenter.cpp
+++ b/src/charts/chartpresenter.cpp
@@ -98,7 +98,7 @@ void ChartPresenter::setFixedGeometry(const QRectF &rect)
void ChartPresenter::setGeometry(const QRectF rect)
{
- if (m_rect != rect) {
+ if (rect.isValid() && m_rect != rect) {
m_rect = rect;
if (!m_fixedRect.isNull())
return;
diff --git a/src/charts/doc/images/examples_pointsselectionandmarkers1.png b/src/charts/doc/images/examples_pointsselectionandmarkers1.png
new file mode 100644
index 00000000..7a98ddea
--- /dev/null
+++ b/src/charts/doc/images/examples_pointsselectionandmarkers1.png
Binary files differ
diff --git a/src/charts/doc/images/examples_pointsselectionandmarkers2.png b/src/charts/doc/images/examples_pointsselectionandmarkers2.png
new file mode 100644
index 00000000..8b8b0800
--- /dev/null
+++ b/src/charts/doc/images/examples_pointsselectionandmarkers2.png
Binary files differ
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-pointsselectionandmarkers.qdoc b/src/charts/doc/src/examples-pointsselectionandmarkers.qdoc
new file mode 100644
index 00000000..c3fe2e84
--- /dev/null
+++ b/src/charts/doc/src/examples-pointsselectionandmarkers.qdoc
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** 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 pointsselectionandmarkers
+ \title Light Markers Points Selection Example
+ \ingroup qtcharts_examples
+
+ \brief The example shows a usage of light markers
+ and points selection for the series.
+
+ \image examples_pointsselectionandmarkers1.png
+ \image examples_pointsselectionandmarkers2.png
+
+ \include examples-run.qdocinc
+
+ \section1 Light Markers Feature
+
+ We start with creating a series, filling it with the data, and setting up selection funcionality.
+ It's important not to set points visibility to \c true, because light markers functionality is
+ an independent feature and setting both would result in undesired behavior.
+ \snippet pointsselectionandmarkers/main.cpp 1
+
+ Then we create the \c {QChart}, the \c {QChartview} and the control widget with its layout to arrange customization elements.
+ \snippet pointsselectionandmarkers/main.cpp 2
+
+ The next step is creating elements of customization.
+ \snippet pointsselectionandmarkers/main.cpp 3
+
+ We create the label for the marker selection combobox and add fill the combobox with the items.
+ Also, we provide functionality to the combobox. Considering the implementation of the light markers
+ functionality, we need to make sure if displaying of unselected points is checked.
+ Switching the visibility of the light marker off is achieved by setting it to \c "empty" \c {QImage}.
+ If the user unchecks the displaying of unselected points and changes the light marker image, unselected points
+ have to remain invisible.
+ If checking isn't performed, new \c {QImage} will be set for light marker
+ and unselected points will be visible even though it has been switched off.
+ \snippet pointsselectionandmarkers/main.cpp 4
+
+ Almost the same procedure applies to the selected point light marker and line color. The only difference is
+ that there's no need to check visibility of unselected points as it doesn't affect the functionality.
+ \snippet pointsselectionandmarkers/main.cpp 5
+
+ A small difference comes with changing visibility of unselected points. As it was mentioned before,
+ making light markers invisible is achieved by setting them to "empty" \c {QImage}.
+ That is why, depending on checkbox state, selected point light marker is set to "empty" \c {QImage} or
+ to the light marker extracted from the current index of the corresponding combobox.
+ \snippet pointsselectionandmarkers/main.cpp 6
+
+ The final part is to arrange the elements, add all the widgets to the main widget, and set the main window size.
+ \snippet pointsselectionandmarkers/main.cpp 7
+*/
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
+*/
diff --git a/src/charts/doc/src/index.qdoc b/src/charts/doc/src/index.qdoc
index 92f75ea7..ab35d16b 100644
--- a/src/charts/doc/src/index.qdoc
+++ b/src/charts/doc/src/index.qdoc
@@ -59,6 +59,10 @@
\snippet doc_src_qtcharts.pro 0
\endif
+ \section1 Module Evolution
+ \l{Changes to Qt Charts} lists important changes in the module API
+ and functionality that were done for the Qt 6 series of Qt.
+
\section1 Licenses
Qt Charts is available under commercial licenses from \l{The Qt Company}.
diff --git a/src/charts/doc/src/qt6-changes.qdoc b/src/charts/doc/src/qt6-changes.qdoc
new file mode 100644
index 00000000..74f24dbe
--- /dev/null
+++ b/src/charts/doc/src/qt6-changes.qdoc
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \page qtcharts-changes-qt6.html
+ \title Changes to Qt Charts
+ \ingroup changes-qt-5-to-6
+ \brief Migrate Qt Charts to Qt 6.
+
+ Qt 6 is a result of the conscious effort to make the framework more
+ efficient and easy to use.
+
+ We try to maintain binary and source compatibility for all the public
+ APIs in each release. But some changes were inevitable in an effort to
+ make Qt a better framework.
+
+ In this document we summarize those changes in Qt Charts.
+
+ \section1 QtCharts Namespace
+
+ Qt Charts no longer has a custom \c QtCharts namespace. Instead, the normal Qt
+ namespace is used if one is configured for the Qt build.
+
+ \section1 OpenGL Acceleration in QML
+
+ As the name implies, \l{AbstractSeries::useOpenGL}{AbstractSeries.useOpenGL} still only
+ supports OpenGL acceleration, so it won't work if QML RHI backend is defined as something
+ else, as it typically is by default in Qt 6. Force RHI OpenGL backend into use to fix this
+ issue by using the environment variable \c{QSG_RHI_BACKEND=opengl}, for example.
+*/
diff --git a/src/charts/domain/abstractdomain.cpp b/src/charts/domain/abstractdomain.cpp
index 263c72a4..1ccffde0 100644
--- a/src/charts/domain/abstractdomain.cpp
+++ b/src/charts/domain/abstractdomain.cpp
@@ -58,6 +58,9 @@ AbstractDomain::~AbstractDomain()
void AbstractDomain::setSize(const QSizeF &size)
{
+ if (!size.isValid())
+ return;
+
if (m_size != size) {
m_size=size;
emit updated();
diff --git a/src/charts/layout/abstractchartlayout.cpp b/src/charts/layout/abstractchartlayout.cpp
index 3826c75e..e5c3eb36 100644
--- a/src/charts/layout/abstractchartlayout.cpp
+++ b/src/charts/layout/abstractchartlayout.cpp
@@ -53,6 +53,7 @@ void AbstractChartLayout::setGeometry(const QRectF &rect)
{
if (!rect.isValid())
return;
+
// If the chart has a fixed geometry then don't update visually
const bool updateLayout = (!m_presenter->isFixedGeometry() || m_presenter->geometry() == rect);
if (m_presenter->chart()->isVisible()) {
@@ -73,12 +74,14 @@ void AbstractChartLayout::setGeometry(const QRectF &rect)
contentGeometry = calculateAxisGeometry(contentGeometry, axes, updateLayout);
- m_presenter->setGeometry(contentGeometry);
- if (updateLayout) {
- if (m_presenter->chart()->chartType() == QChart::ChartTypeCartesian)
- static_cast<QGraphicsRectItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry);
- else
- static_cast<QGraphicsEllipseItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry);
+ if (contentGeometry.isValid()) {
+ m_presenter->setGeometry(contentGeometry);
+ if (updateLayout) {
+ if (m_presenter->chart()->chartType() == QChart::ChartTypeCartesian)
+ static_cast<QGraphicsRectItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry);
+ else
+ static_cast<QGraphicsEllipseItem *>(m_presenter->plotAreaElement())->setRect(contentGeometry);
+ }
}
}
diff --git a/src/charts/layout/cartesianchartlayout.cpp b/src/charts/layout/cartesianchartlayout.cpp
index ae4f8d3d..e46b3f15 100644
--- a/src/charts/layout/cartesianchartlayout.cpp
+++ b/src/charts/layout/cartesianchartlayout.cpp
@@ -193,18 +193,14 @@ QRectF CartesianChartLayout::calculateAxisGeometry(const QRectF &geometry,
if (leftSqueezeRatio < 1.0)
width *= leftSqueezeRatio;
leftOffset+=width;
- axis->setGeometry(QRect(chartRect.left() - leftOffset, chartRect.top(),
- width, chartRect.bottom()),
- chartRect);
+ axis->setGeometry(QRect(chartRect.left()-leftOffset, geometry.top(),width, geometry.bottom()),chartRect);
break;
}
case Qt::AlignRight:{
qreal width = size.width();
if (rightSqueezeRatio < 1.0)
width *= rightSqueezeRatio;
- axis->setGeometry(QRect(chartRect.right() + rightOffset, chartRect.top(),
- width, chartRect.bottom()),
- chartRect);
+ axis->setGeometry(QRect(chartRect.right()+rightOffset,geometry.top(),width,geometry.bottom()),chartRect);
rightOffset+=width;
break;
}
@@ -212,9 +208,7 @@ QRectF CartesianChartLayout::calculateAxisGeometry(const QRectF &geometry,
qreal height = size.height();
if (topSqueezeRatio < 1.0)
height *= topSqueezeRatio;
- axis->setGeometry(QRect(chartRect.left(), chartRect.top() - topOffset - height,
- chartRect.width(), height),
- chartRect);
+ axis->setGeometry(QRect(geometry.left(), chartRect.top() - topOffset - height, geometry.width(), height), chartRect);
topOffset += height;
break;
}
@@ -222,9 +216,7 @@ QRectF CartesianChartLayout::calculateAxisGeometry(const QRectF &geometry,
qreal height = size.height();
if (bottomSqueezeRatio < 1.0)
height *= bottomSqueezeRatio;
- axis->setGeometry(QRect(chartRect.left(), chartRect.bottom() + bottomOffset,
- chartRect.width(), height),
- chartRect);
+ axis->setGeometry(QRect(geometry.left(), chartRect.bottom() + bottomOffset, geometry.width(), height), chartRect);
bottomOffset += height;
break;
}
diff --git a/src/charts/legend/qlegend.cpp b/src/charts/legend/qlegend.cpp
index 49766c6f..9e2778e9 100644
--- a/src/charts/legend/qlegend.cpp
+++ b/src/charts/legend/qlegend.cpp
@@ -236,8 +236,8 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QLegend::attachedToChartChanged(bool)
- This signal is emitted when the legend is attached to or detached from the legend.
+ \fn void QLegend::attachedToChartChanged(bool attached)
+ This signal is emitted when the legend is \a attached to or detached from the chart.
\since 6.2
*/
diff --git a/src/charts/linechart/linechartitem.cpp b/src/charts/linechart/linechartitem.cpp
index c2c3c694..1da16e07 100644
--- a/src/charts/linechart/linechartitem.cpp
+++ b/src/charts/linechart/linechartitem.cpp
@@ -58,6 +58,7 @@ LineChartItem::LineChartItem(QLineSeries *series, QGraphicsItem *item)
connect(series->d_func(), &QXYSeriesPrivate::seriesUpdated,
this, &LineChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::lightMarkerChanged, this, &LineChartItem::handleSeriesUpdated);
+ connect(series, &QXYSeries::selectedLightMarkerChanged, this, &LineChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::markerSizeChanged, this, &LineChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::visibleChanged, this, &LineChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::opacityChanged, this, &LineChartItem::handleSeriesUpdated);
@@ -322,7 +323,9 @@ void LineChartItem::updateGeometry()
// For mouse interactivity, we have to add the rects *after* the 'createStroke',
// as we don't need the outline - we need it filled up.
- if (!m_series->lightMarker().isNull()) {
+ if (!m_series->lightMarker().isNull()
+ || (!m_series->selectedLightMarker().isNull()
+ && !m_series->selectedPoints().isEmpty())) {
// +1, +2: a margin to guarantee we cover all of the pixmap
qreal markerHalfSize = (m_markerSize / 2.0) + 1;
qreal markerSize = m_markerSize + 2;
@@ -449,8 +452,10 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
int pointLabelsOffset = m_linePen.width() / 2;
- // Draw markers if a marker has been set (set to QImage() to disable)
- if (!m_series->lightMarker().isNull()) {
+ // Draw markers if a marker or marker for selected points only has been
+ // set (set to QImage() to disable)
+ if (!m_series->lightMarker().isNull() || (!m_series->selectedLightMarker().isNull()
+ && !m_series->selectedPoints().isEmpty())) {
const QImage &marker = m_series->lightMarker();
const QImage &selectedMarker = m_series->selectedLightMarker();
qreal markerHalfSize = m_markerSize / 2.0;
@@ -461,7 +466,7 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
// light markers are independent features. Therefore m_pointsVisible
// is not used here as light markers are drawn if lightMarker is not null.
// However points visibility configuration can be still used here.
- bool drawPoint = true;
+ bool drawPoint = !m_series->lightMarker().isNull();
if (m_pointsConfiguration.contains(i)) {
const auto &conf = m_pointsConfiguration[i];
diff --git a/src/charts/scatterchart/qscatterseries.cpp b/src/charts/scatterchart/qscatterseries.cpp
index 1467a839..44ab2a49 100644
--- a/src/charts/scatterchart/qscatterseries.cpp
+++ b/src/charts/scatterchart/qscatterseries.cpp
@@ -206,6 +206,8 @@ QT_BEGIN_NAMESPACE
QScatterSeries::QScatterSeries(QObject *parent)
: QXYSeries(*new QScatterSeriesPrivate(this), parent)
{
+ setPointsVisible(true);
+
// Emit QScatterSeries' markerSizeChanged signal as it's not the same as
// QXYSeries' markerSizeChanged
connect(this, &QXYSeries::markerSizeChanged, this, &QScatterSeries::markerSizeChanged);
diff --git a/src/charts/scatterchart/scatterchartitem.cpp b/src/charts/scatterchart/scatterchartitem.cpp
index 3c9c8cfb..15201e7e 100644
--- a/src/charts/scatterchart/scatterchartitem.cpp
+++ b/src/charts/scatterchart/scatterchartitem.cpp
@@ -50,17 +50,20 @@ ScatterChartItem::ScatterChartItem(QScatterSeries *series, QGraphicsItem *item)
m_items(this),
m_visible(true),
m_markerShape(QScatterSeries::MarkerShapeRectangle),
+ m_pointsVisible(true),
m_pointLabelsVisible(false),
m_markerSize(series->markerSize()),
m_pointLabelsFormat(series->pointLabelsFormat()),
m_pointLabelsFont(series->pointLabelsFont()),
m_pointLabelsColor(series->pointLabelsColor()),
m_pointLabelsClipping(true),
+ m_lastHoveredPoint(QPointF(qQNaN(), qQNaN())),
m_mousePressed(false)
{
connect(series->d_func(), &QXYSeriesPrivate::seriesUpdated,
this, &ScatterChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::lightMarkerChanged, this, &ScatterChartItem::handleSeriesUpdated);
+ connect(series, &QXYSeries::selectedLightMarkerChanged, this, &ScatterChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::markerSizeChanged, this, &ScatterChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::visibleChanged, this, &ScatterChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::opacityChanged, this, &ScatterChartItem::handleSeriesUpdated);
@@ -81,8 +84,9 @@ ScatterChartItem::ScatterChartItem(QScatterSeries *series, QGraphicsItem *item)
connect(series, &QScatterSeries::pointsConfigurationChanged,
this, &ScatterChartItem::handleSeriesUpdated);
+ setAcceptHoverEvents(true);
setZValue(ChartPresenter::ScatterSeriesZValue);
- setFlags(QGraphicsItem::ItemClipsChildrenToShape);
+ setFlags(QGraphicsItem::ItemClipsChildrenToShape | QGraphicsItem::ItemIsSelectable);
handleSeriesUpdated();
@@ -281,7 +285,7 @@ void ScatterChartItem::updateGeometry()
if (!m_visible || offGridStatus.at(i)) {
item->setVisible(false);
} else {
- bool drawPoint = true;
+ bool drawPoint = m_pointsVisible;
if (m_pointsConfiguration.contains(i)) {
const auto &conf = m_pointsConfiguration[i];
@@ -298,6 +302,9 @@ void ScatterChartItem::updateGeometry()
}
}
+ if (m_series->isPointSelected(i))
+ drawPoint = m_series->selectedLightMarker().isNull();
+
item->setVisible(drawPoint);
}
}
@@ -307,6 +314,62 @@ void ScatterChartItem::updateGeometry()
}
}
+void ScatterChartItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ QPointF matchedP = matchForLightMarker(event->pos());
+ if (!qIsNaN(matchedP.x())) {
+ emit XYChart::pressed(matchedP);
+ m_lastMousePos = event->pos();
+ m_mousePressed = true;
+ }
+
+ QGraphicsItem::mousePressEvent(event);
+}
+
+void ScatterChartItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
+{
+ QPointF matchedP = matchForLightMarker(event->pos());
+ if (!qIsNaN(matchedP.x())) {
+ if (matchedP != m_lastHoveredPoint) {
+ if (!qIsNaN(m_lastHoveredPoint.x()))
+ emit XYChart::hovered(m_lastHoveredPoint, false);
+
+ m_lastHoveredPoint = matchedP;
+ emit XYChart::hovered(matchedP, true);
+ }
+ } else if (!qIsNaN(m_lastHoveredPoint.x())) {
+ emit XYChart::hovered(m_lastHoveredPoint, false);
+ m_lastHoveredPoint = QPointF(qQNaN(), qQNaN());
+ }
+
+ QGraphicsItem::hoverMoveEvent(event);
+}
+
+void ScatterChartItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ QPointF result;
+ QPointF matchedP = matchForLightMarker(m_lastMousePos);
+ if (!qIsNaN(matchedP.x()) && m_mousePressed) {
+ result = matchedP;
+ emit XYChart::released(result);
+ emit XYChart::clicked(result);
+ }
+
+ m_mousePressed = false;
+ QGraphicsItem::mouseReleaseEvent(event);
+}
+
+void ScatterChartItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ QPointF matchedP = matchForLightMarker(event->pos());
+ if (!qIsNaN(matchedP.x()))
+ emit XYChart::doubleClicked(matchedP);
+ else
+ emit XYChart::doubleClicked(domain()->calculateDomainPoint(m_lastMousePos));
+
+ QGraphicsItem::mouseDoubleClickEvent(event);
+}
+
void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
@@ -315,8 +378,14 @@ void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
if (m_series->useOpenGL())
return;
- // Draw markers if a marker has been set (set to QImage() to disable)
- if (!m_series->lightMarker().isNull()) {
+ QRectF clipRect = QRectF(QPointF(0, 0), domain()->size());
+
+ painter->save();
+ painter->setClipRect(clipRect);
+
+ // Draw markers if a marker or marker for selected points only has been
+ // set (set to QImage() to disable)
+ if (!m_series->lightMarker().isNull() || !m_series->selectedLightMarker().isNull()) {
const QImage &marker = m_series->lightMarker();
const QImage &selectedMarker = m_series->selectedLightMarker();
qreal markerHalfSize = m_markerSize / 2.0;
@@ -326,7 +395,7 @@ void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
// light markers are independent features. Therefore m_pointsVisible
// is not used here as light markers are drawn if lightMarker is not null.
// However points visibility configuration can be still used here.
- bool drawPoint = true;
+ bool drawPoint = !m_series->lightMarker().isNull();
if (m_pointsConfiguration.contains(i)) {
const auto &conf = m_pointsConfiguration[i];
@@ -350,11 +419,6 @@ void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
}
}
- QRectF clipRect = QRectF(QPointF(0, 0), domain()->size());
-
- painter->save();
- painter->setClipRect(clipRect);
-
if (m_series->bestFitLineVisible())
m_series->d_func()->drawBestFitLine(painter, clipRect);
@@ -422,6 +486,7 @@ void ScatterChartItem::handleSeriesUpdated()
m_pointsConfigurationDirty = m_series->pointsConfiguration() != m_pointsConfiguration;
bool recreate = m_visible != m_series->isVisible()
+ || m_pointsVisible != m_series->pointsVisible()
|| m_markerSize != m_series->markerSize()
|| m_markerShape != m_series->markerShape()
|| m_selectedColor != m_series->selectedColor()
@@ -432,6 +497,7 @@ void ScatterChartItem::handleSeriesUpdated()
m_markerShape = m_series->markerShape();
setVisible(m_visible);
setOpacity(m_series->opacity());
+ m_pointsVisible = m_series->pointsVisible();
m_pointLabelsFormat = m_series->pointLabelsFormat();
m_pointLabelsVisible = m_series->pointLabelsVisible();
m_pointLabelsFont = m_series->pointLabelsFont();
diff --git a/src/charts/scatterchart/scatterchartitem_p.h b/src/charts/scatterchart/scatterchartitem_p.h
index 1770d043..93969173 100644
--- a/src/charts/scatterchart/scatterchartitem_p.h
+++ b/src/charts/scatterchart/scatterchartitem_p.h
@@ -85,6 +85,10 @@ private:
protected:
void updateGeometry() override;
+ void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
+ void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
private:
QScatterSeries *m_series;
@@ -94,6 +98,7 @@ private:
QRectF m_rect;
QMap<QGraphicsItem *, QPointF> m_markerMap;
+ bool m_pointsVisible;
bool m_pointLabelsVisible;
qreal m_markerSize;
QString m_pointLabelsFormat;
@@ -101,6 +106,8 @@ private:
QColor m_pointLabelsColor;
bool m_pointLabelsClipping;
+ QPointF m_lastHoveredPoint;
+ QPointF m_lastMousePos;
bool m_mousePressed;
};
diff --git a/src/charts/splinechart/splinechartitem.cpp b/src/charts/splinechart/splinechartitem.cpp
index 7e0601e4..4dba01f2 100644
--- a/src/charts/splinechart/splinechartitem.cpp
+++ b/src/charts/splinechart/splinechartitem.cpp
@@ -56,6 +56,7 @@ SplineChartItem::SplineChartItem(QSplineSeries *series, QGraphicsItem *item)
connect(m_series->d_func(), &QXYSeriesPrivate::seriesUpdated,
this, &SplineChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::lightMarkerChanged, this, &SplineChartItem::handleSeriesUpdated);
+ connect(series, &QXYSeries::selectedLightMarkerChanged, this, &SplineChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::markerSizeChanged, this, &SplineChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::visibleChanged, this, &SplineChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::opacityChanged, this, &SplineChartItem::handleSeriesUpdated);
@@ -69,8 +70,13 @@ SplineChartItem::SplineChartItem(QSplineSeries *series, QGraphicsItem *item)
this, &SplineChartItem::handleSeriesUpdated);
connect(series, &QXYSeries::pointLabelsClippingChanged,
this, &SplineChartItem::handleSeriesUpdated);
+ connect(series, &QSplineSeries::selectedColorChanged,
+ this, &SplineChartItem::handleSeriesUpdated);
connect(series, &QLineSeries::selectedPointsChanged,
this, &SplineChartItem::handleSeriesUpdated);
+ connect(series, &QSplineSeries::pointsConfigurationChanged,
+ this, &SplineChartItem::handleSeriesUpdated);
+
handleSeriesUpdated();
}
@@ -316,7 +322,8 @@ void SplineChartItem::updateGeometry()
// For mouse interactivity, we have to add the rects *after* the 'createStroke',
// as we don't need the outline - we need it filled up.
- if (!m_series->lightMarker().isNull()) {
+ if (!m_series->lightMarker().isNull() || (!m_series->selectedLightMarker().isNull()
+ && !m_series->selectedPoints().isEmpty())) {
// +1, +2: a margin to guarantee we cover all of the pixmap
qreal markerHalfSize = (m_series->markerSize() / 2.0) + 1;
qreal markerSize = m_series->markerSize() + 2;
@@ -452,6 +459,8 @@ void SplineChartItem::handleSeriesUpdated()
m_markerSize = m_series->markerSize();
m_pointLabelsFont = m_series->pointLabelsFont();
m_pointLabelsColor = m_series->pointLabelsColor();
+ m_selectedPoints = m_series->selectedPoints();
+ m_selectedColor = m_series->selectedColor();
bool labelClippingChanged = m_pointLabelsClipping != m_series->pointLabelsClipping();
m_pointLabelsClipping = m_series->pointLabelsClipping();
// Update whole chart in case label clipping changed as labels can be outside series area
@@ -495,18 +504,12 @@ void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter->drawPath(m_path);
- if (m_pointsVisible) {
- painter->setPen(m_pointPen);
- if (m_series->chart()->chartType() == QChart::ChartTypePolar)
- painter->drawPoints(m_visiblePoints);
- else
- painter->drawPoints(geometryPoints());
- }
-
int pointLabelsOffset = m_linePen.width() / 2;
- // Draw markers if a marker has been set (set to QImage() to disable)
- if (!m_series->lightMarker().isNull()) {
+ // Draw markers if a marker or marker for selected points only has been
+ // set (set to QImage() to disable)
+ if (!m_series->lightMarker().isNull() || (!m_series->selectedLightMarker().isNull()
+ && !m_series->selectedPoints().isEmpty())) {
const QImage &marker = m_series->lightMarker();
const QImage &selectedMarker = m_series->selectedLightMarker();
qreal markerHalfSize = m_markerSize / 2.0;
@@ -517,7 +520,7 @@ void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
// light markers are independent features. Therefore m_pointsVisible
// is not used here as light markers are drawn if lightMarker is not null.
// However points visibility configuration can be still used here.
- bool drawPoint = true;
+ bool drawPoint = !m_series->lightMarker().isNull();
if (m_pointsConfiguration.contains(i)) {
const auto &conf = m_pointsConfiguration[i];
@@ -549,6 +552,65 @@ void SplineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
m_series->d_func()->drawSeriesPointLabels(painter, m_points, pointLabelsOffset);
}
+ painter->setPen(m_pointPen);
+ if (m_series->chart()->chartType() == QChart::ChartTypePolar && m_pointsVisible) {
+ painter->drawPoints(m_visiblePoints);
+ } else {
+ const bool simpleDraw = m_selectedPoints.isEmpty() && m_pointsConfiguration.isEmpty();
+ painter->setPen(Qt::NoPen);
+ painter->setBrush(m_linePen.color());
+ painter->setClipping(true);
+
+ if (m_pointsVisible && simpleDraw && m_series->lightMarker().isNull()) {
+ for (int i = 0; i < m_points.size(); ++i)
+ painter->drawEllipse(m_points.at(i), m_markerSize, m_markerSize);
+ } else if (!simpleDraw) {
+ qreal ptSize = m_markerSize;
+ for (int i = 0; i < m_points.size(); ++i) {
+ if (clipRect.contains(m_points.at(i))) {
+ painter->save();
+ ptSize = m_markerSize;
+ bool drawPoint = m_pointsVisible && m_series->lightMarker().isNull();
+ if (m_pointsConfiguration.contains(i)) {
+ const auto &conf = m_pointsConfiguration[i];
+ if (conf.contains(QXYSeries::PointConfiguration::Visibility)) {
+ drawPoint =
+ m_pointsConfiguration[i][QXYSeries::PointConfiguration::Visibility]
+ .toBool();
+ }
+
+ if (drawPoint) {
+ if (conf.contains(QXYSeries::PointConfiguration::Size)) {
+ ptSize = m_pointsConfiguration[i][QXYSeries::PointConfiguration::Size]
+ .toReal();
+ }
+
+ if (conf.contains(QXYSeries::PointConfiguration::Color)) {
+ painter->setBrush(
+ m_pointsConfiguration[i][QXYSeries::PointConfiguration::Color]
+ .value<QColor>());
+ }
+ }
+ }
+
+ if (m_series->isPointSelected(i)) {
+ // Selected points are drawn regardless of m_pointsVisible settings and
+ // custom point configuration. However, they are not drawn if light markers
+ // are used. The reason of this is to avoid displaying selected point
+ // over selected light marker.
+ drawPoint = m_series->selectedLightMarker().isNull();
+ ptSize = ptSize * 1.5;
+ if (m_selectedColor.isValid())
+ painter->setBrush(m_selectedColor);
+ }
+
+ if (drawPoint)
+ painter->drawEllipse(m_points.at(i), ptSize, ptSize);
+ painter->restore();
+ }
+ }
+ }
+ }
painter->restore();
}
diff --git a/src/charts/xychart/qxyseries.cpp b/src/charts/xychart/qxyseries.cpp
index 9c30b1e4..5f15f0ad 100644
--- a/src/charts/xychart/qxyseries.cpp
+++ b/src/charts/xychart/qxyseries.cpp
@@ -1585,12 +1585,12 @@ const QImage &QXYSeries::lightMarker() const
/*!
Sets the image used for drawing markers on selected series's points to \a selectedLightMarker.
- The default value is QImage(), meaning usual QXYSeries::lightMarker() will be painted.
+ The default value is QImage(), meaning usual lightMarker() will be painted.
- This is an equivalent for QXYSeries::setSelectedColor() if you prefer light markers over
- normal points, but you still want to distinguish selected points.
+ This is an equivalent for \l{selectedColor} if you prefer light markers over
+ normal points, but still want to distinguish selected points.
- \sa QXYSeries::lightMarker(), QXYSeries::selectedColor(), QXYSeries::setPointSelected()
+ \sa lightMarker(), selectedColor, setPointSelected()
\since 6.2
*/
void QXYSeries::setSelectedLightMarker(const QImage &selectedLightMarker)
@@ -1605,14 +1605,14 @@ void QXYSeries::setSelectedLightMarker(const QImage &selectedLightMarker)
}
/*!
- Returns the image used for drawing markers on selected series's points.
+ Returns the image used for drawing markers on selected series' points.
- The default value is QImage(), meaning usual QXYSeries::lightMarker() will be painted.
+ The default value is QImage(), meaning usual lightMarker() will be painted.
- This is an equivalent for QXYSeries::selectedColor() if you prefer light markers over
- normal points, but you still want to distinguish selected points.
+ This is equivalent to \l{selectedColor} if you prefer light markers over
+ normal points, but still want to distinguish selected points.
- \sa QXYSeries::lightMarker(), QXYSeries::selectedColor(), QXYSeries::setPointSelected()
+ \sa lightMarker(), selectedColor, setPointSelected()
\since 6.2
*/
const QImage &QXYSeries::selectedLightMarker() const
@@ -1622,7 +1622,7 @@ const QImage &QXYSeries::selectedLightMarker() const
}
/*!
- Sets the size of the marker used to render points in the series.
+ Sets the \a size of the marker used to render points in the series.
The default size is 15.0.
\sa QScatterSeries::markerSize
diff --git a/src/charts/xychart/xychart.cpp b/src/charts/xychart/xychart.cpp
index 7eda3819..f09c2d66 100644
--- a/src/charts/xychart/xychart.cpp
+++ b/src/charts/xychart/xychart.cpp
@@ -258,13 +258,23 @@ bool XYChart::isEmpty()
QPointF XYChart::matchForLightMarker(const QPointF &eventPos)
{
- if (m_series->lightMarker().isNull())
+ if (m_series->lightMarker().isNull()
+ && (m_series->selectedLightMarker().isNull()
+ || m_series->selectedPoints().isEmpty()))
return QPointF(qQNaN(), qQNaN()); // 0,0 could actually be in points()
- int markerWidth = m_series->lightMarker().width();
- int markerHeight = m_series->lightMarker().height();
+ const bool useSelectedMarker = m_series->lightMarker().isNull();
- for (const QPointF &dp : m_series->points()) {
+ QList<QPointF> points;
+ if (useSelectedMarker) {
+ const auto selectedPoints = m_series->selectedPoints();
+ for (const int &selectedPointIndex : selectedPoints)
+ points << m_series->at(selectedPointIndex);
+ } else {
+ points = m_series->points();
+ }
+
+ for (const QPointF &dp : points) {
bool ok;
const QPointF gp = domain()->calculateGeometryPoint(dp, ok);
if (ok) {
@@ -274,9 +284,9 @@ QPointF XYChart::matchForLightMarker(const QPointF &eventPos)
// but as there is a bunch of 'translations' and therefore inaccuracies,
// so it is necessary to increase that margin to 2
// (otherwise you can click next to an icon, get a click event but not match it)
- QRectF r(gp.x() - (markerWidth / 2 + 2),
- gp.y() - (markerHeight / 2 + 2),
- markerWidth + 4, markerHeight + 4);
+ QRectF r(gp.x() - (m_series->markerSize() / 2 + 2),
+ gp.y() - (m_series->markerSize() / 2 + 2),
+ m_series->markerSize() + 4, m_series->markerSize() + 4);
if (r.contains(eventPos))
return dp;
diff --git a/src/chartsqml2/declarativechart.cpp b/src/chartsqml2/declarativechart.cpp
index 67bf1864..8a55feb4 100644
--- a/src/chartsqml2/declarativechart.cpp
+++ b/src/chartsqml2/declarativechart.cpp
@@ -70,6 +70,7 @@
#include <QtCore/QTimer>
#include <QtCore/QThread>
#include <QtQuick/QQuickWindow>
+#include <QtWidgets/QGraphicsLayout>
#if QT_CONFIG(charts_datetime_axis)
#include <QtCharts/QDateTimeAxis>
@@ -79,7 +80,6 @@ QT_BEGIN_NAMESPACE
/*!
\qmltype ChartView
- \instantiates DeclarativeChart
\inqmlmodule QtCharts
\brief Manages the graphical representation of the chart's series, legends,
@@ -652,9 +652,12 @@ void DeclarativeChart::seriesAxisAttachHelper(QAbstractSeries *series, QAbstract
{
if (!series->attachedAxes().contains(axis)) {
// Remove & delete old axes that are not attached to any other series
+ // Detach old axis from series so that if it is shared with other series
+ // It can be deleted.
foreach (QAbstractAxis* oldAxis, m_chart->axes(orientation, series)) {
bool otherAttachments = false;
if (oldAxis != axis) {
+ series->detachAxis(oldAxis);
foreach (QAbstractSeries *oldSeries, m_chart->series()) {
if (oldSeries != series && oldSeries->attachedAxes().contains(oldAxis)) {
otherAttachments = true;
@@ -1551,6 +1554,10 @@ QPointF DeclarativeChart::mapToPosition(const QPointF &value, QAbstractSeries *s
void DeclarativeChart::setPlotArea(const QRectF &rect)
{
m_chart->setPlotArea(rect);
+
+ // If plotArea is set inside ChartView, contentGeometry is updated too early and we end up
+ // with incorrect plotArea. Invalidate the layout to correct the geometry.
+ m_chart->layout()->invalidate();
}
QT_END_NAMESPACE
diff --git a/src/chartsqml2/declarativepolarchart.cpp b/src/chartsqml2/declarativepolarchart.cpp
index ba35256a..2f1431d1 100644
--- a/src/chartsqml2/declarativepolarchart.cpp
+++ b/src/chartsqml2/declarativepolarchart.cpp
@@ -35,7 +35,6 @@ QT_BEGIN_NAMESPACE
/*!
\qmltype PolarChartView
\inherits ChartView
- \instantiates DeclarativePolarChart
\inqmlmodule QtCharts
\brief Presents data in polar charts.
diff --git a/src/chartsqml2/designer/CMakeLists.txt b/src/chartsqml2/designer/CMakeLists.txt
index 42115e7b..b0f18096 100644
--- a/src/chartsqml2/designer/CMakeLists.txt
+++ b/src/chartsqml2/designer/CMakeLists.txt
@@ -1,8 +1,9 @@
+qt_path_join(destination ${QT_INSTALL_DIR} "${INSTALL_QMLDIR}/QtCharts/designer")
qt_copy_or_install(
FILES
ChartViewSpecifics.qml
qtcharts.metainfo
- DESTINATION "${INSTALL_QMLDIR}/QtCharts/designer"
+ DESTINATION ${destination}
)
add_subdirectory(default)
diff --git a/src/chartsqml2/designer/default/CMakeLists.txt b/src/chartsqml2/designer/default/CMakeLists.txt
index ccf366d8..dc2c2dda 100644
--- a/src/chartsqml2/designer/default/CMakeLists.txt
+++ b/src/chartsqml2/designer/default/CMakeLists.txt
@@ -1,3 +1,4 @@
+qt_path_join(destination ${QT_INSTALL_DIR} "${INSTALL_QMLDIR}/QtCharts/designer/default")
qt_copy_or_install(
FILES
AreaSeries.qml
@@ -16,5 +17,5 @@ qt_copy_or_install(
PolarLineSeries.qml
PolarScatterSeries.qml
PolarSplineSeries.qml
- DESTINATION "${INSTALL_QMLDIR}/QtCharts/designer/default"
+ DESTINATION "${destination}"
)
diff --git a/src/chartsqml2/designer/images/CMakeLists.txt b/src/chartsqml2/designer/images/CMakeLists.txt
index 0487f007..ec85d9c7 100644
--- a/src/chartsqml2/designer/images/CMakeLists.txt
+++ b/src/chartsqml2/designer/images/CMakeLists.txt
@@ -1,3 +1,4 @@
+qt_path_join(destination ${QT_INSTALL_DIR} "${INSTALL_QMLDIR}/QtCharts/designer/images")
qt_copy_or_install(
FILES
areaseries-chart-icon.png
@@ -32,5 +33,5 @@ qt_copy_or_install(
scatterseries-polar-icon16.png
splineseries-polar-icon.png
splineseries-polar-icon16.png
- DESTINATION "${INSTALL_QMLDIR}/QtCharts/designer/images"
+ DESTINATION "${destination}"
)
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 7f772845..6c8b1122 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.16)
project(qmake_cmake_files)
diff --git a/tests/auto/qscatterseries/tst_qscatterseries.cpp b/tests/auto/qscatterseries/tst_qscatterseries.cpp
index e91a881b..8d369660 100644
--- a/tests/auto/qscatterseries/tst_qscatterseries.cpp
+++ b/tests/auto/qscatterseries/tst_qscatterseries.cpp
@@ -87,7 +87,7 @@ void tst_QScatterSeries::qscatterseries()
QCOMPARE(series.brush(), QBrush());
QCOMPARE(series.points(), QList<QPointF>());
QCOMPARE(series.pen(), QPen());
- QCOMPARE(series.pointsVisible(), false);
+ QCOMPARE(series.pointsVisible(), true);
series.append(QList<QPointF>());
series.append(0.0,0.0);
@@ -102,7 +102,7 @@ void tst_QScatterSeries::qscatterseries()
series.setBrush(QBrush());
series.setPen(QPen());
- series.setPointsVisible(false);
+ series.setPointsVisible(true);
m_chart->addSeries(&series);
m_view->show();