Skip to content

dongjialiang/QtCustomPieChart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

QtCustomPieChart

Development Enviroment

  • Qt 5.12.1
  • MinGW 7.3.0 (Windows10)

CustomPieChart

How does it work?

    #include "custompiechart.h" // 导入头文件

Create a custom pie chart widget.

    CustomPieChart * pieChart = new CustomPieChart(this);
    // CustomPieChart(parent)

    CustomPieChart * pieChart_1 = new CustomPieChart("逆变器31(台)", "小型", 18, Qt::blue, this);
    // CustomPieChart(titleName, tag, data, color, parent)

    QList<int> dataList = { 31, 25, 10 };
    QStringList tagList = { "正常", "离线", "异常" };
    QList<QColor> colorList = {QColor(57, 207, 206), QColor(232, 184, 232), Qt::yellow};

    CustomPieChart * pieChart_2 = new CustomPieChart("数据采集器1(台)", tagList, dataList, colorList, this);
    // CustomPieChart(titleName, tagList, dataList, colorList, parent)

Add slice.

    pieChart->addSlice(tag, data, color);

Set series.

    pieChart->setSeries(tagList, dataList, colorList);

Set global font.

    QFont tempFont;
    tempFont.setPointSize(9);
    tempFont.setFamily("Microsoft YaHei");
    tempFont.setWeight(80);
    pieChart->setGlobalFont(tempFont); // QFont tempFont

Set title font.

    pieChart->setTitleFont(tempFont); // QFont tempFont

Set tag font.

    pieChart->setTagFont(tempFont); // QFont tempFont

Set legend font.

    pieChart->setLegendFont(tempFont); // QFont tempFont

Set sum font.

    pieChart->setSumFont(tempFont); // QFont tempFont

Set "sum" text font.

    pieChart->setSumTextFont(tempFont); // QFont tempFont

Set ring size.

    pieChart->setRingSize(ringSize); // double ringSize

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages