| 79 | }; |
| 80 | |
| 81 | MainWindow::MainWindow(QWidget *parent) |
| 82 | : QWidget(parent) |
| 83 | { |
| 84 | auto *chartLayout = new QHBoxLayout(this); |
| 85 | m_chart = new Chart(); |
| 86 | m_chart->setGlobalLeading(5, 5, 5, 5); |
| 87 | chartLayout->addWidget(m_chart); |
| 88 | |
| 89 | m_model = new EmptyModel(this); // model contains no data at all |
| 90 | |
| 91 | // Set up the diagram |
| 92 | m_bars = new LineDiagram(); |
| 93 | m_bars->setModel(m_model); |
| 94 | auto *xAxis = new CartesianAxis(m_bars); |
| 95 | auto *yAxis = new CartesianAxis(m_bars); |
| 96 | xAxis->setPosition(KDChart::CartesianAxis::Bottom); |
| 97 | yAxis->setPosition(KDChart::CartesianAxis::Left); |
| 98 | xAxis->setTitleText("Abscissa axis at the bottom"); |
| 99 | yAxis->setTitleText("Ordinate axis at the left side"); |
| 100 | m_bars->addAxis(xAxis); |
| 101 | m_bars->addAxis(yAxis); |
| 102 | |
| 103 | m_chart->coordinatePlane()->replaceDiagram(m_bars); |
| 104 | |
| 105 | auto *legend = new Legend(m_bars, m_chart); |
| 106 | legend->setPosition(Position::South); |
| 107 | legend->setAlignment(Qt::AlignCenter); |
| 108 | legend->setShowLines(true); |
| 109 | legend->setTitleText("This is the legend - showing no data either"); |
| 110 | legend->setOrientation(Qt::Horizontal); |
| 111 | legend->addDiagram(m_bars); |
| 112 | m_chart->addLegend(legend); |
| 113 | } |
nothing calls this directly
no test coverage detected