diff options
Diffstat (limited to 'examples/charts/chartsgallery/piedrilldownchart.cpp')
-rw-r--r-- | examples/charts/chartsgallery/piedrilldownchart.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/charts/chartsgallery/piedrilldownchart.cpp b/examples/charts/chartsgallery/piedrilldownchart.cpp new file mode 100644 index 00000000..7d60f727 --- /dev/null +++ b/examples/charts/chartsgallery/piedrilldownchart.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "piedrilldownchart.h" +#include "piedrilldownslice.h" + +PieDrilldownChart::PieDrilldownChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) + : QChart(QChart::ChartTypeCartesian, parent, wFlags) +{ +} + +void PieDrilldownChart::changeSeries(QAbstractSeries *series) +{ + if (m_currentSeries) + removeSeries(m_currentSeries); + m_currentSeries = series; + addSeries(series); + setTitle(series->name()); +} + +void PieDrilldownChart::handleSliceClicked(QPieSlice *slice) +{ + auto *drilldownSlice = static_cast<PieDrilldownSlice *>(slice); + changeSeries(drilldownSlice->drilldownSeries()); +} |