超简单的piechart

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了超简单的piechart相关的知识,希望对你有一定的参考价值。


#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
#include <QtCharts/QChartView>
#include <QtCharts/QPieSeries>
#include <QtCharts/QPieSlice>

QT_CHARTS_USE_NAMESPACE

int main(int argc, char *argv[])

QApplication a(argc, argv);

//![1]
QPieSeries *series = new QPieSeries();
series->append("Jane", 1);
series->append("Joe", 2);
series->append("Andy", 3);
series->append("Barbara", 4);
series->append("Axel", 5);
//![1]

//![2]
QPieSlice *slice = series->slices().at(1);
slice->setExploded();
slice->setLabelVisible();
slice->setPen(QPen(Qt::darkGreen, 2));
slice->setBrush(Qt::green);
//![2]

//![3]
QChart *chart = new QChart();
chart->addSeries(series);
chart->setTitle("Simple piechart 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]

return a.exec();

超简单的piechart_Qt

以上是关于超简单的piechart的主要内容,如果未能解决你的问题,请参考以下文章

grafana-piechart-panel 安装

Android PieChart 饼图控件

Android PieChart 饼图控件

Android PieChart 饼图控件

nvd3 piechart.js - 如何编辑工具提示?

Highcharts (PieChart) - 第二次绘制时图表宽度减小