MCPcopy Create free account
hub / github.com/KDAB/KDChart / MainWindow

Method MainWindow

examples/NoValues/mainwindow.cpp:81–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79};
80
81MainWindow::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}

Callers

nothing calls this directly

Calls 12

setShowLinesMethod · 0.80
setGlobalLeadingMethod · 0.45
setModelMethod · 0.45
setPositionMethod · 0.45
setTitleTextMethod · 0.45
addAxisMethod · 0.45
replaceDiagramMethod · 0.45
coordinatePlaneMethod · 0.45
setAlignmentMethod · 0.45
setOrientationMethod · 0.45
addDiagramMethod · 0.45
addLegendMethod · 0.45

Tested by

no test coverage detected