MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / CtStatChart

Method CtStatChart

src/client/ui/ct_stat_chart.cpp:18–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16{
17
18 CtStatChart::CtStatChart(const std::shared_ptr<ClientContext>& ctx,
19 const QString& title,
20 const std::vector<QString>& line_names,
21 const CtStatChartAxisSettings& x_axis_settings,
22 const CtStatChartAxisSettings& y_axis_settings,
23 QWidget* parent) : QWidget(parent) {
24 ctx_ = ctx;
25 setStyleSheet("background-color:#ffffff; border: 1px solid #eeeeee;");
26 auto layout = new NoMarginVLayout();
27 chart_ = new QChart();
28 chart_->setTitle(title);
29 QFont font;
30 font.setPixelSize(16);
31 font.setBold(true);
32 chart_->setTitleFont(font);
33 for (auto& n : line_names) {
34 auto s = new QLineSeries();
35 s->setName(n);
36 series_.insert({n, s});
37 chart_->addSeries(s);
38 }
39
40 chart_view_ = new QChartView(this);
41 chart_view_->setRenderHint(QPainter::Antialiasing);
42 chart_view_->setChart(chart_);
43 layout->addWidget(chart_view_);
44
45 x_axis_ = new QValueAxis();
46 x_axis_->setTickCount(x_axis_settings.count_);
47 x_axis_->setRange(x_axis_settings.rng_beg_, x_axis_settings.rng_end_);
48 x_axis_->setLabelFormat(x_axis_settings.format_);
49 chart_->addAxis(x_axis_, Qt::AlignBottom);
50 for (auto& [n, s] : series_) {
51 s->attachAxis(x_axis_);
52 }
53
54 y_axis_ = new QValueAxis();
55 y_axis_->setTickCount(y_axis_settings.count_);
56 y_axis_->setRange(y_axis_settings.rng_beg_, y_axis_settings.rng_end_);
57 y_axis_->setLabelFormat(y_axis_settings.format_);
58 chart_->addAxis(y_axis_, Qt::AlignLeft);
59 for (auto& [n, s] : series_) {
60 s->attachAxis(y_axis_);
61 }
62
63 setLayout(layout);
64 }
65
66 void CtStatChart::UpdateTitle(const QString& title) {
67 chart_->setTitle(title);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected