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

Method MainWindow

examples/Stock/Advanced/mainwindow.cpp:19–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17using namespace KDChart;
18
19MainWindow::MainWindow(QWidget *parent)
20 : QWidget(parent)
21 , m_chart(new Chart())
22 , m_diagram(m_chart)
23{
24 setupUi(this);
25
26 m_HLCModel.loadFromCSV(":/HLC");
27 m_OHLCModel.loadFromCSV(":/OHLC");
28
29 m_diagram.setType(StockDiagram::HighLowClose);
30 m_diagram.setModel(&m_HLCModel);
31 m_chart->coordinatePlane()->replaceDiagram(&m_diagram);
32 auto *legend = new KDChart::Legend(&m_diagram, m_chart);
33 m_chart->addLegend(legend);
34
35 auto *chartLayout = new QHBoxLayout(chartFrame);
36 chartLayout->addWidget(m_chart);
37
38 // Abscissa
39 auto *leftAxis = new CartesianAxis(&m_diagram);
40 // Ordinate
41 auto *bottomAxis = new CartesianAxis(&m_diagram);
42
43 leftAxis->setPosition(CartesianAxis::Left);
44
45 TextAttributes attributes = bottomAxis->textAttributes();
46 attributes.setRotation(90);
47 attributes.setFontSize(Measure(7.0, KDChartEnums::MeasureCalculationModeAbsolute));
48 bottomAxis->setTextAttributes(attributes);
49 bottomAxis->setPosition(CartesianAxis::Bottom);
50 m_diagram.addAxis(leftAxis);
51 m_diagram.addAxis(bottomAxis);
52 m_diagram.addAxis(bottomAxis);
53 applyColor(QColor("chartreuse"));
54 const bool connected = connect(colorChooser, SIGNAL(clicked()), SLOT(chooseColor()));
55 Q_ASSERT(connected);
56 Q_UNUSED(connected);
57
58 // Initialize all values for the stock chart to sane defaults
59 initValues();
60}
61
62void MainWindow::chooseColor()
63{

Callers

nothing calls this directly

Calls 13

MeasureClass · 0.85
loadFromCSVMethod · 0.80
setFontSizeMethod · 0.80
setTypeMethod · 0.45
setModelMethod · 0.45
replaceDiagramMethod · 0.45
coordinatePlaneMethod · 0.45
addLegendMethod · 0.45
setPositionMethod · 0.45
textAttributesMethod · 0.45
setRotationMethod · 0.45
setTextAttributesMethod · 0.45

Tested by

no test coverage detected