| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses |
| 5 |
|
| 6 |
#include "charts.h" |
| 7 |
#include <QtCharts/QChart> |
| 8 |
#include <QtCharts/QLineSeries> |
| 9 |
|
| 10 |
class FontChart: public Chart |
| 11 |
{ |
| 12 |
public: |
| 13 |
FontChart(int fontSize): m_fontSize(fontSize) {}; |
| 14 |
QString name() { return QObject::tr("Font") + " " + QString::number(m_fontSize); } |
| 15 |
QString category() { return QObject::tr("Font"); } |
| 16 |
QString subCategory() { return QString(); } |
| 17 |
|
| 18 |
QChart *createChart(const DataTable &table) |
| 19 |
{ |
| 20 |
QChart *chart = new QChart(); |
| 21 |
chart->setTitle("Font size " + QString::number(m_fontSize)); |
| 22 |
QString name("Series "); |
| 23 |
int nameIndex = 0; |
| 24 |
foreach (DataList list, table) { |
| 25 |
QLineSeries *series = new QLineSeries(chart); |
| 26 |
foreach (Data data, list) |
| 27 |
series->append(data.first); |
| 28 |
series->setName(name + QString::number(nameIndex)); |
| 29 |
nameIndex++; |
| 30 |
chart->addSeries(series); |
| 31 |
} |
| 32 |
chart->createDefaultAxes(); |
| 33 |
QFont font; |
| 34 |
font.setPixelSize(m_fontSize); |
| 35 |
chart->setTitleFont(font); |
| 36 |
chart->axisX()->setLabelsFont(font); |
| 37 |
chart->axisY()->setLabelsFont(font); |
| 38 |
chart->axisX()->setTitleText("Axis X"); |
| 39 |
chart->axisY()->setTitleText("Axis Y"); |
| 40 |
chart->axisX()->setTitleFont(font); |
| 41 |
chart->axisY()->setTitleFont(font); |
| 42 |
return chart; |
| 43 |
} |
| 44 |
|
| 45 |
private: |
| 46 |
int m_fontSize; |
| 47 |
}; |
| 48 |
|
| 49 |
class FontChart6: public FontChart |
| 50 |
{ |
| 51 |
public: |
| 52 |
FontChart6(): FontChart(6) {}; |
| 53 |
}; |
| 54 |
|
| 55 |
class FontChart8: public FontChart |
| 56 |
{ |
| 57 |
public: |
| 58 |
FontChart8(): FontChart(8) {}; |
| 59 |
}; |
| 60 |
|
| 61 |
class FontChart10: public FontChart |
| 62 |
{ |
| 63 |
public: |
| 64 |
FontChart10(): FontChart(10) {}; |
| 65 |
}; |
| 66 |
|
| 67 |
class FontChart14: public FontChart |
| 68 |
{ |
| 69 |
public: |
| 70 |
FontChart14(): FontChart(14) {}; |
| 71 |
}; |
| 72 |
|
| 73 |
class FontChart18: public FontChart |
| 74 |
{ |
| 75 |
public: |
| 76 |
FontChart18(): FontChart(18) {}; |
| 77 |
}; |
| 78 |
|
| 79 |
class FontChart20: public FontChart |
| 80 |
{ |
| 81 |
public: |
| 82 |
FontChart20(): FontChart(20) {}; |
| 83 |
}; |
| 84 |
|
| 85 |
class FontChart24: public FontChart |
| 86 |
{ |
| 87 |
public: |
| 88 |
FontChart24(): FontChart(24) {}; |
| 89 |
}; |
| 90 |
|
| 91 |
class FontChart28: public FontChart |
| 92 |
{ |
| 93 |
public: |
| 94 |
FontChart28(): FontChart(28) {}; |
| 95 |
}; |
| 96 |
|
| 97 |
class FontChart32: public FontChart |
| 98 |
{ |
| 99 |
public: |
| 100 |
FontChart32(): FontChart(32) {}; |
| 101 |
}; |
| 102 |
|
| 103 |
DECLARE_CHART(FontChart6); |
| 104 |
DECLARE_CHART(FontChart8); |
| 105 |
DECLARE_CHART(FontChart10); |
| 106 |
DECLARE_CHART(FontChart14); |
| 107 |
DECLARE_CHART(FontChart18); |
| 108 |
DECLARE_CHART(FontChart20); |
| 109 |
DECLARE_CHART(FontChart24); |
| 110 |
DECLARE_CHART(FontChart28); |
| 111 |
DECLARE_CHART(FontChart32); |