From f0be46ef9f91931dfcb95d6ca686a86bded599f5 2012-08-27 10:12:53 From: Jani Honkonen Date: 2012-08-27 10:12:53 Subject: [PATCH] update donutchart example --- diff --git a/examples/donutchart/main.cpp b/examples/donutchart/main.cpp index 5549ecc..789b9b7 100644 --- a/examples/donutchart/main.cpp +++ b/examples/donutchart/main.cpp @@ -23,7 +23,7 @@ #include #include #include - +#include QTCOMMERCIALCHART_USE_NAMESPACE int main(int argc, char *argv[]) @@ -33,39 +33,30 @@ int main(int argc, char *argv[]) //![1] QPieSeries *series = new QPieSeries(); series->setHoleSize(0.35); - series->append("Jane", 1); - series->append("Joe", 2); - series->append("Andy", 3); - series->append("Barbara", 4); - series->append("Axel", 5); + series->append("Protein 4.2%", 4.2); + QPieSlice *slice = series->append("Fat 15.6%", 15.6); + slice->setExploded(); + slice->setLabelVisible(); + series->append("Other 23.8%", 23.8); + series->append("Carbs 56.4%", 56.4); //![1] //![2] - QPieSlice *slice = series->slices().at(1); - slice->setExploded(); - slice->setLabelVisible(); - slice->setPen(QPen(Qt::darkGreen, 2)); - slice->setBrush(Qt::green); + QChartView* chartView = new QChartView(); + chartView->setRenderHint(QPainter::Antialiasing); + chartView->chart()->setTitle("Donut with a lemon glaze (100g)"); + chartView->chart()->addSeries(series); + chartView->chart()->legend()->setAlignment(Qt::AlignBottom); + chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean); + chartView->chart()->legend()->setFont(QFont("Arial", 7)); //![2] //![3] - QChart* chart = new QChart(); - chart->addSeries(series); - chart->setTitle("Simple donutchart example"); - chart->legend()->hide(); -//![3] - -//![4] - QChartView* chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![4] - -//![5] QMainWindow window; window.setCentralWidget(chartView); window.resize(400, 300); window.show(); -//![5] +//![3] return a.exec(); }