| 25 | using namespace KDChart; |
| 26 | |
| 27 | MainWindow::MainWindow(QWidget *parent) |
| 28 | : QWidget(parent) |
| 29 | { |
| 30 | setupUi(this); |
| 31 | |
| 32 | auto *chartLayout = new QHBoxLayout(chartFrame); |
| 33 | m_chart = new Chart(); |
| 34 | chartLayout->addWidget(m_chart); |
| 35 | |
| 36 | m_model.loadFromCSV(":/data"); |
| 37 | |
| 38 | // Set up the diagram |
| 39 | m_bars = new BarDiagram(); |
| 40 | m_bars->setModel(&m_model); |
| 41 | |
| 42 | // define custom color for the borders of the bars |
| 43 | QPen pen(m_bars->pen()); |
| 44 | pen.setColor(Qt::black); |
| 45 | pen.setWidth(0); |
| 46 | m_bars->setPen(pen); |
| 47 | m_chart->coordinatePlane()->replaceDiagram(m_bars); |
| 48 | |
| 49 | // define custom colours for the bars |
| 50 | QList<QColor> bcolor; |
| 51 | bcolor.append(Qt::darkGreen); |
| 52 | bcolor.append(Qt::green); |
| 53 | bcolor.append(Qt::darkRed); |
| 54 | bcolor.append(Qt::red); |
| 55 | for (int row = 0; row < m_model.columnCount(); ++row) { |
| 56 | m_bars->setBrush(row, QBrush(bcolor[row])); |
| 57 | } |
| 58 | |
| 59 | // Configure the plane's Background |
| 60 | BackgroundAttributes pba; |
| 61 | // pba.setBrush( QBrush(QColor(0x20,0x20,0x60)) ); |
| 62 | pba.setVisible(true); |
| 63 | m_chart->coordinatePlane()->setBackgroundAttributes(pba); |
| 64 | |
| 65 | m_chart->setGlobalLeadingTop(20); |
| 66 | } |
| 67 | |
| 68 | void MainWindow::on_barTypeCB_currentIndexChanged(int index) |
| 69 | { |
nothing calls this directly
no test coverage detected