| 17 | using namespace KDChart; |
| 18 | |
| 19 | MainWindow::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 | |
| 62 | void MainWindow::chooseColor() |
| 63 | { |
nothing calls this directly
no test coverage detected