TATU
SAMARQAND FILIALI
DI 112 GURUH TALABASI
QURBONOV SAMANDARBEK
DASTURLASH 2
14-HAFTA AMALIYOTI
Qt muhitida talabalarning reyting koʻrsatkichlarini CustomPlotda tasvirlovchi dastur tuzing. Bunda guruh talabalarining bir fan (masalan, “Dasturlash II” fani) bo`yicha 1-olariq nazorat natijalari bo`yicha to`plagan ballarini “5”, “4”, “3” va “2” baholar oraliqlariga ajratib, ularning o`zaro nisbatlarini doiraviy grafik ko`rinishda, foizlarda tasvirlovchi dastur tuzish lozim. Masalan quyidagicha ko`rinishda:
https://www.qcustomplot.com/index.php/demos/scatterpixmapdemo
Javobi:
Mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->customPlot->legend->setVisible(true);
ui->customPlot->axisRect()->setBackground(QPixmap("./solarpanels.jpg"));
ui->customPlot->addGraph();
ui->customPlot->graph()->setLineStyle(QCPGraph::lsLine);
QPen pen;
pen.setColor(QColor(255, 200, 20, 200));
pen.setStyle(Qt::DashLine);
pen.setWidthF(2.5);
ui->customPlot->graph()->setPen(pen);
ui->customPlot->graph()->setBrush(QBrush(QColor(255,200,20,70)));
ui->customPlot->graph()->setScatterStyle(QCPScatterStyle(QPixmap("D:\\Soft\\Tayyor\\konus\\sun.png")));
// set graph name, will show up in legend next to icon:
ui->customPlot->graph()->setName("112-guruh talabalari");
// set data:
QVector year, value;
year << 2013 << 2014 << 2015 << 2016 << 2017 << 2018 << 2019;
value << 6.17 << 3.42 << 4.94 << 17.38 << 15.86 << 29.33 << 52.1;
ui->customPlot->graph()->setData(year, value);
// set title of plot:
ui->customPlot->plotLayout()->insertRow(0);
ui->customPlot->plotLayout()->addElement(0, 0, new QCPTextElement(ui->customPlot, "Ballar grafigi", QFont("sans", 12, QFont::Bold)));
// axis configurations:
ui->customPlot->xAxis->setLabel("Yillar");
ui->customPlot->yAxis->setLabel("Tayyorladi: QURBONOV SAMANDARBEK");
ui->customPlot->xAxis2->setVisible(true);
ui->customPlot->yAxis2->setVisible(true);
ui->customPlot->xAxis2->setTickLabels(false);
ui->customPlot->yAxis2->setTickLabels(false);
ui->customPlot->xAxis2->setTicks(false);
ui->customPlot->yAxis2->setTicks(false);
ui->customPlot->xAxis2->setSubTicks(false);
ui->customPlot->yAxis2->setSubTicks(false);
ui->customPlot->xAxis->setRange(2012.5, 2019.5);
ui->customPlot->yAxis->setRange(0, 52);
// setup legend:
ui->customPlot->legend->setFont(QFont(font().family(), 7));
ui->customPlot->legend->setIconSize(50, 20);
ui->customPlot->legend->setVisible(true);
ui->customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignLeft | Qt::AlignTop);
}
MainWindow::~MainWindow()
{
delete ui;
}
Do'stlaringiz bilan baham: |