summaryrefslogtreecommitdiffstats
path: root/examples/charts/gallery/piedrilldownchart.cpp
blob: 7d60f727089c8fdcd95197b46a581e6d3d6179e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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());
}