@@ -29,7 +29,7 public Q_SLOTS: | |||||
29 | void updateLabel() |
|
29 | void updateLabel() | |
30 | { |
|
30 | { | |
31 | QString label = m_prefix; |
|
31 | QString label = m_prefix; | |
32 |
label += " |
|
32 | label += " " + QString::number(this->value())+ "e ("; | |
33 | label += QString::number(this->percentage()*100, 'f', 1) + "%)"; |
|
33 | label += QString::number(this->percentage()*100, 'f', 1) + "%)"; | |
34 | setLabel(label); |
|
34 | setLabel(label); | |
35 | } |
|
35 | } | |
@@ -83,34 +83,22 int main(int argc, char *argv[]) | |||||
83 |
|
83 | |||
84 | QList<QString> months; |
|
84 | QList<QString> months; | |
85 | months << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; |
|
85 | months << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun" << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec"; | |
|
86 | QList<QString> names; | |||
|
87 | names << "Jane" << "John" << "Axel" << "Mary" << "Samantha" << "Bob"; | |||
|
88 | ||||
|
89 | foreach (QString name, names) { | |||
|
90 | QPieSeries* series = new QPieSeries(drilldownChart); | |||
|
91 | series->setTitle("Sales by month - " + name); | |||
|
92 | series->setHoverHighlighting(); | |||
|
93 | ||||
|
94 | foreach (QString month, months) | |||
|
95 | *series << new DrilldownSlice(qrand() % 1000, month, yearSeries); | |||
|
96 | ||||
|
97 | QObject::connect(series, SIGNAL(clicked(QPieSlice*)), drilldownChart, SLOT(handleSliceClicked(QPieSlice*))); | |||
|
98 | ||||
|
99 | *yearSeries << new DrilldownSlice(series->total(), name, series); | |||
|
100 | } | |||
86 |
|
101 | |||
87 | int max = 1000; |
|
|||
88 |
|
||||
89 | QPieSeries* monthSeriesJane = new QPieSeries(drilldownChart); |
|
|||
90 | monthSeriesJane->setTitle("Sales by month - Jane"); |
|
|||
91 | monthSeriesJane->setHoverHighlighting(); |
|
|||
92 | foreach (QString month, months) |
|
|||
93 | *monthSeriesJane << new DrilldownSlice(qrand() % max, month, yearSeries); |
|
|||
94 |
|
||||
95 | QPieSeries* monthSeriesJohn = new QPieSeries(drilldownChart); |
|
|||
96 | monthSeriesJohn->setTitle("Sales by month - John"); |
|
|||
97 | monthSeriesJohn->setHoverHighlighting(); |
|
|||
98 | foreach (QString month, months) |
|
|||
99 | *monthSeriesJohn << new DrilldownSlice(qrand() % max, month, yearSeries); |
|
|||
100 |
|
||||
101 | QPieSeries* monthSeriesAxel = new QPieSeries(drilldownChart); |
|
|||
102 | monthSeriesAxel->setTitle("Sales by month - Axel"); |
|
|||
103 | monthSeriesAxel->setHoverHighlighting(); |
|
|||
104 | foreach (QString month, months) |
|
|||
105 | *monthSeriesAxel << new DrilldownSlice(qrand() % max, month, yearSeries); |
|
|||
106 |
|
||||
107 | *yearSeries << new DrilldownSlice(monthSeriesJane->total(), "Jane", monthSeriesJane); |
|
|||
108 | *yearSeries << new DrilldownSlice(monthSeriesJohn->total(), "John", monthSeriesJohn); |
|
|||
109 | *yearSeries << new DrilldownSlice(monthSeriesAxel->total(), "Axel", monthSeriesAxel); |
|
|||
110 |
|
||||
111 | QObject::connect(monthSeriesJane, SIGNAL(clicked(QPieSlice*)), drilldownChart, SLOT(handleSliceClicked(QPieSlice*))); |
|
|||
112 | QObject::connect(monthSeriesJohn, SIGNAL(clicked(QPieSlice*)), drilldownChart, SLOT(handleSliceClicked(QPieSlice*))); |
|
|||
113 | QObject::connect(monthSeriesAxel, SIGNAL(clicked(QPieSlice*)), drilldownChart, SLOT(handleSliceClicked(QPieSlice*))); |
|
|||
114 | QObject::connect(yearSeries, SIGNAL(clicked(QPieSlice*)), drilldownChart, SLOT(handleSliceClicked(QPieSlice*))); |
|
102 | QObject::connect(yearSeries, SIGNAL(clicked(QPieSlice*)), drilldownChart, SLOT(handleSliceClicked(QPieSlice*))); | |
115 |
|
103 | |||
116 | drilldownChart->changeSeries(yearSeries); |
|
104 | drilldownChart->changeSeries(yearSeries); |
General Comments 0
You need to be logged in to leave comments.
Login now