@@ -23,7 +23,7 | |||||
23 | #include <QChartView> |
|
23 | #include <QChartView> | |
24 | #include <QPieSeries> |
|
24 | #include <QPieSeries> | |
25 | #include <QPieSlice> |
|
25 | #include <QPieSlice> | |
26 |
|
26 | #include <QDebug> | ||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | int main(int argc, char *argv[]) |
|
29 | int main(int argc, char *argv[]) | |
@@ -33,39 +33,30 int main(int argc, char *argv[]) | |||||
33 | //![1] |
|
33 | //![1] | |
34 | QPieSeries *series = new QPieSeries(); |
|
34 | QPieSeries *series = new QPieSeries(); | |
35 | series->setHoleSize(0.35); |
|
35 | series->setHoleSize(0.35); | |
36 |
series->append(" |
|
36 | series->append("Protein 4.2%", 4.2); | |
37 | series->append("Joe", 2); |
|
37 | QPieSlice *slice = series->append("Fat 15.6%", 15.6); | |
38 | series->append("Andy", 3); |
|
38 | slice->setExploded(); | |
39 | series->append("Barbara", 4); |
|
39 | slice->setLabelVisible(); | |
40 |
series->append(" |
|
40 | series->append("Other 23.8%", 23.8); | |
|
41 | series->append("Carbs 56.4%", 56.4); | |||
41 | //![1] |
|
42 | //![1] | |
42 |
|
43 | |||
43 | //![2] |
|
44 | //![2] | |
44 | QPieSlice *slice = series->slices().at(1); |
|
45 | QChartView* chartView = new QChartView(); | |
45 | slice->setExploded(); |
|
46 | chartView->setRenderHint(QPainter::Antialiasing); | |
46 | slice->setLabelVisible(); |
|
47 | chartView->chart()->setTitle("Donut with a lemon glaze (100g)"); | |
47 | slice->setPen(QPen(Qt::darkGreen, 2)); |
|
48 | chartView->chart()->addSeries(series); | |
48 | slice->setBrush(Qt::green); |
|
49 | chartView->chart()->legend()->setAlignment(Qt::AlignBottom); | |
|
50 | chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean); | |||
|
51 | chartView->chart()->legend()->setFont(QFont("Arial", 7)); | |||
49 | //![2] |
|
52 | //![2] | |
50 |
|
53 | |||
51 | //![3] |
|
54 | //![3] | |
52 | QChart* chart = new QChart(); |
|
|||
53 | chart->addSeries(series); |
|
|||
54 | chart->setTitle("Simple donutchart example"); |
|
|||
55 | chart->legend()->hide(); |
|
|||
56 | //![3] |
|
|||
57 |
|
||||
58 | //![4] |
|
|||
59 | QChartView* chartView = new QChartView(chart); |
|
|||
60 | chartView->setRenderHint(QPainter::Antialiasing); |
|
|||
61 | //![4] |
|
|||
62 |
|
||||
63 | //![5] |
|
|||
64 | QMainWindow window; |
|
55 | QMainWindow window; | |
65 | window.setCentralWidget(chartView); |
|
56 | window.setCentralWidget(chartView); | |
66 | window.resize(400, 300); |
|
57 | window.resize(400, 300); | |
67 | window.show(); |
|
58 | window.show(); | |
68 |
//![ |
|
59 | //![3] | |
69 |
|
60 | |||
70 | return a.exec(); |
|
61 | return a.exec(); | |
71 | } |
|
62 | } |
General Comments 0
You need to be logged in to leave comments.
Login now