当前位置: 首页 > news >正文

做网站用 jsp还是asp佛山乐从网站建设

做网站用 jsp还是asp,佛山乐从网站建设,用wordpress可以做出什么网站,网站三网合一案例先给出结果图#xff0c;这个例子是将各种事件分类然后统计的其比例#xff0c;然后画饼图显示出来 这个是我仿照官方给的例子#xff0c;让后自己理解后#xff0c;修改的#xff0c;要生成饼图#xff0c;需要QT的 charts 支持#xff0c;安装QT 没有选择这个的#…先给出结果图这个例子是将各种事件分类然后统计的其比例然后画饼图显示出来 这个是我仿照官方给的例子让后自己理解后修改的要生成饼图需要QT的 charts 支持安装QT 没有选择这个的需要下载这个模块然后在.pro文件中年添加 QT charts 首先重写饼图块让鼠标悬浮在某个饼图块时让这个块弹出来然后显示块的信息这个比较简单如下所示 //头文件 #include QtCharts/QPieSliceQT_CHARTS_USE_NAMESPACEclass CustomSlice : public QPieSlice {Q_OBJECTpublic:CustomSlice(QString label, qreal value);public Q_SLOTS:void showHighlight(bool show);};//cpp文件#include customslice.hQT_CHARTS_USE_NAMESPACECustomSlice::CustomSlice(QString label, qreal value): QPieSlice(label, value) {connect(this, CustomSlice::hovered, this, CustomSlice::showHighlight); }void CustomSlice::showHighlight(bool show) {setLabelVisible(show);//显示标签setExploded(show); // 弹出 }主体代码如下主要是初始化饼图创建饼图为饼图块随机上色为饼图数据的显示做排序只需要调用接口函数把相应的数据塞进去即可生成可视化的饼图 statisticwindow.h #ifndef STATISTICCHARTSWINDOW_H #define STATISTICCHARTSWINDOW_H#include QWidget #include QVBoxLayout #include QtCharts/QPieSeries #include QtCharts/QBarCategoryAxis #include QtCharts/QValueAxis #include QtCharts/QChartViewclass QPushButton; class CustomSlice; QT_CHARTS_USE_NAMESPACEclass StatisticChartsWindow : public QWidget {Q_OBJECT public:explicit StatisticChartsWindow(QWidget *parent nullptr);~StatisticChartsWindow();//创建一个饼图1void createPie1(QMapQString, int data, QString title);//创建一个饼图2void createPie2(QMapQString, int data, QString title);// 为饼图1添加块信息void appendSlice1(QString lable, int value);// 为饼图2添加块信息void appendSlice2(QString lable, int value);// 移除所有块信息void removeAllSlice();// 获取随机颜色为饼图的每个块上色Qt::GlobalColor getRandomColor();//获取排序后的数据QListQMapQString, int getsortListByValue(QMapQString, int data);QVBoxLayout *VBoxLayout;QPieSeries *series1;QPieSeries *series2;QChart *chart1;QChart *chart2;QChartView *chartView1;QChartView *chartView2;QPushButton *closeButton;QListCustomSlice* CustomSlice1List;QListCustomSlice* CustomSlice2List;QListQt::GlobalColor colorList;signals:void closeSig();public slots: };#endif // STATISTICCHARTSWINDOW_Hstatisticwindow.cpp #include statisticwindow.h #include QtCharts/QBarSeries #include QtCharts/QBarSet #include QtCharts/QLegend #include QtCharts/QPieSeries #include QtCharts/QBarCategoryAxis #include QtCharts/QValueAxis #include QtCharts/QChartView #include QVBoxLayout #include QHBoxLayout #include QSpacerItem #include QRandomGenerator #include customslice.h #include QPushButton #include pushbutton.hStatisticChartsWindow::StatisticChartsWindow(QWidget *parent) : QWidget(parent) {VBoxLayout new QVBoxLayout(this);series1 new QPieSeries(this);// 饼图一chart1 new QChart();chart1-setAnimationOptions(QChart::AllAnimations);chart1-legend()-setVisible(true);chart1-legend()-setAlignment(Qt::AlignRight);//设置标签在右侧chartView1 new QChartView(chart1);series2 new QPieSeries(this);// 饼图一chart2 new QChart();chart2-setAnimationOptions(QChart::AllAnimations);chart2-legend()-setVisible(true);chart2-legend()-setAlignment(Qt::AlignRight);//设置标签在右侧chartView2 new QChartView(chart2);//底部添加关闭按钮closeButton new QPushButton(关闭, this);QHBoxLayout *hlayout new QHBoxLayout();hlayout-addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));hlayout-addWidget(closeButton);hlayout-addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));//SC3C::Valwell::PushButton::initStyle(closeButton);QPalette palette closeButton-palette();QColor color(19, 46, 74); // RGB红色palette.setColor(QPalette::Button, color);closeButton-setPalette(palette);closeButton-setStyleSheet(color: white;);colorListQt::redQt::whiteQt::darkGrayQt::grayQt::lightGrayQt::redQt::greenQt::blueQt::cyanQt::magentaQt::yellowQt::darkRedQt::darkGreenQt::darkBlueQt::darkCyan;chartView1-chart()-setTheme(QChart::ChartThemeBlueCerulean);chartView2-chart()-setTheme(QChart::ChartThemeBlueCerulean);VBoxLayout-addWidget(chartView1);VBoxLayout-addWidget(chartView2);VBoxLayout-addLayout(hlayout);VBoxLayout-layout()-setSpacing(1);//底部添加关闭connect(closeButton, QPushButton::clicked, []() {this-hide();emit closeSig();});this-setWindowFlags(this-windowFlags() | Qt::WindowCloseButtonHint);this-setStyleSheet(background-color: rgb(19, 46, 74);); }StatisticChartsWindow::~StatisticChartsWindow() {if(chart1) {delete chart1;}if(chart2) {delete chart2;} }void StatisticChartsWindow::createPie1(QMapQString, int data, QString title) {// 创建一个饼图系列series1-clear();int count0; //计算总数QMapint, QListQString map;for(auto itdata.begin(); it!data.end(); it) {count it.value();}QListQMapQString, int sortList getsortListByValue(data);// 根据条数比例排序从大到小for(QMapQString, int map: sortList) {QString keyLable map.firstKey();int num map.value(keyLable);double ratio num/1.0/count*100;QString ratioStr QString::number(ratio, f, 1);QString lable QString(%1,条数:%2,占比,%3%).arg(keyLable).arg(num).arg(ratioStr);appendSlice1(lable, num); // 添加到饼图中}// 创建一个新的图表并添加系列chart1-setTitle(title);//chart1-removeAllSeries();chart1-addSeries(series1); }void StatisticChartsWindow::createPie2(QMapQString, int data, QString title) {// 创建一个饼图系列series2-clear();int count0; //计算总数QMapint, QListQString map;for(auto itdata.begin(); it!data.end(); it) {count it.value();}QListQMapQString, int sortList getsortListByValue(data);for(QMapQString, int map: sortList) {QString keyLable map.firstKey();int num map.value(keyLable);double ratio num/1.0/count*100;QString ratioStr QString::number(ratio, f, 1);QString lable QString(%1,条数:%2,占比,%3%).arg(keyLable).arg(num).arg(ratioStr);appendSlice2(lable, num);}// 创建一个新的图表并添加系列chart2-setTitle(title);//chart2-removeAllSeries();chart2-addSeries(series2); }void StatisticChartsWindow::appendSlice1(QString lable, int value) {CustomSlice *customSlice new CustomSlice(lable, value);customSlice-setBrush(QBrush(getRandomColor())); //设置填充颜色//customSlice-setPen(QPen(Qt::black)); //设置线条颜色CustomSlice1List.append(customSlice);*series1 customSlice; }void StatisticChartsWindow::appendSlice2(QString lable, int value) {CustomSlice *customSlice new CustomSlice(lable, value);customSlice-setBrush(QBrush(getRandomColor())); //设置填充颜色CustomSlice2List.append(customSlice);*series2 customSlice;}void StatisticChartsWindow::removeAllSlice() {for(CustomSlice* custom: CustomSlice1List) {series1-remove(custom);}for(CustomSlice* custom: CustomSlice2List) {series2-remove(custom);}qDeleteAll(CustomSlice1List);qDeleteAll(CustomSlice2List);CustomSlice1List.clear();CustomSlice2List.clear(); }Qt::GlobalColor StatisticChartsWindow::getRandomColor() {int randomValue QRandomGenerator::global()-bounded(0, colorList.size()-1);return colorList.takeAt(randomValue); }QListQMapQString, int StatisticChartsWindow::getsortListByValue(QMapQString, int data) {QListQMapQString, int sortList;QListint valueList;for(auto itdata.begin(); it!data.end(); it) {if(!valueList.contains(it.value())) {valueList.append(it.value());}}//根据值逆序排序std::sort(valueList.begin(), valueList.end(), std::greaterint());for(int value: valueList) {for(QString key: data.keys(value)) {QMapQString, int map;map.insert(key, value);sortList.append(map);}}return sortList; }我的这个例子是点击统计按钮之后获取相应的数据然后生成相应的饼图 QObject::connect(ui.statisticsBtn, QPushButton::clicked, []() {g_dataCache-setSystemLog(SC3C::eSystemLogType::QUERY_SYSTEMLOG, QString(成功),查看日志统计);StatisticChartsWindow window;if(StatisticWindow) {tableView-hide();StatisticWindow-show();return;}StatisticWindow new StatisticChartsWindow(q);QObject::connect(StatisticWindow, StatisticChartsWindow::closeSig, q, []() {tableView-show();});// 标签名 数量QMapQString, int map1 { };QMapQString, int map2 { };int logType ui.logType-currentData().toInt();int eventType ui.eventType-currentData().toInt();QString Name ui.operatorName-currentText();tableModel.second-setFilterOperator(所有);// 获取数据map1表示饼图一需要的数据getEventTypeStatisticHash(map1, map2);//恢复之前显示的tableModel.second-setFilterType(logType, eventType);tableModel.second-setFilterOperator(Name);//SC3C::Valwell::Widget::setBackgroundCommon2WithMargins(window);StatisticWindow-setFixedSize(q-size());//StatisticWindow-setStyleSheet(background-color: transparent;);StatisticWindow-createPie1(map1, 事件类型统计);StatisticWindow-createPie2(map2, 日志类型统计);StatisticWindow-show();tableView-hide();}); 只需要把map放入创建饼图的函数即可map中对应的是QMap标签名数量也就是饼图右侧的标签 StatisticWindow-createPie1(map1, 事件类型统计);StatisticWindow-createPie2(map2, 日志类型统计); 这样就可以出饼图了
http://www.pierceye.com/news/193539/

相关文章:

  • 买奢侈品代工厂做的产品的网站名建立网站 英语怎么说
  • 网站访问者qq计算机等级培训机构
  • 可以让外国人做问卷调查的网站济南优化seo网站建设公司
  • odoo做网站创建企业需要什么条件
  • 山西省旅游网站建设分析wordpress 个人介绍
  • 山东高级网站建设赚钱
  • 做网站大概要多少钱新建网站的外链多久生效
  • 天河区建设网站品牌网站建设小8蝌蚪
  • 深圳市企业网站seo点击软件小程序游戏开发公司
  • 南宁企业网站设计公怎么进wordpress
  • 商务网站建设一万字做视频剪辑接私活的网站
  • 网站开发绪论phpstudy建wordpress
  • 网站建设的基本流程有哪些wordpress产品页布局
  • 写过太原的网站免费漫画大全免费版
  • 毕业设计做系统好还是网站好冠县网站建设公司
  • 网站管理制度建设开发一个网站需要多少时间
  • 高校网站建设说明书微信公众号涨粉 网站
  • 深圳网站建设公司哪里好中国施工企业管理协会官网
  • 网站自动抢注步步高学习机进网站怎么做
  • 带域名的网站打不开深圳网站优化多少钱
  • 中国空间站科幻作文1000字网站建设从化
  • 做网站买一个域名就够了吗cn域名知名网站
  • 社科联网站建设个人网页英文
  • 做房产推广那个网站好网站改版建设原则
  • 网站建设 语言成都app
  • 免费建站的手机app专业做网站设计公司价格
  • 江苏宜兴做网站的电话seo基础培训
  • 企业手机端网站模板下载济南公司建站模板
  • 一般公司做网站多少钱南昌市房产网
  • 惠州网站小程序建设做公司永久免费网站什么好