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