| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 or (at your option) any later version |
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #include "charts.h" |
| 31 | #include <QtCharts/QChart> |
| 32 | #include <QtCharts/QLineSeries> |
| 33 | |
| 34 | class FontChart: public Chart |
| 35 | { |
| 36 | public: |
| 37 | FontChart(int fontSize): m_fontSize(fontSize) {}; |
| 38 | QString name() { return QObject::tr(s: "Font") + " "+ QString::number(m_fontSize); } |
| 39 | QString category() { return QObject::tr(s: "Font"); } |
| 40 | QString subCategory() { return QString(); } |
| 41 | |
| 42 | QChart *createChart(const DataTable &table) |
| 43 | { |
| 44 | QChart *chart = new QChart(); |
| 45 | chart->setTitle("Font size "+ QString::number(m_fontSize)); |
| 46 | QString name("Series "); |
| 47 | int nameIndex = 0; |
| 48 | foreach (DataList list, table) { |
| 49 | QLineSeries *series = new QLineSeries(chart); |
| 50 | foreach (Data data, list) |
| 51 | series->append(point: data.first); |
| 52 | series->setName(name + QString::number(nameIndex)); |
| 53 | nameIndex++; |
| 54 | chart->addSeries(series); |
| 55 | } |
| 56 | chart->createDefaultAxes(); |
| 57 | QFont font; |
| 58 | font.setPixelSize(m_fontSize); |
| 59 | chart->setTitleFont(font); |
| 60 | chart->axisX()->setLabelsFont(font); |
| 61 | chart->axisY()->setLabelsFont(font); |
| 62 | chart->axisX()->setTitleText("Axis X"); |
| 63 | chart->axisY()->setTitleText("Axis Y"); |
| 64 | chart->axisX()->setTitleFont(font); |
| 65 | chart->axisY()->setTitleFont(font); |
| 66 | return chart; |
| 67 | } |
| 68 | |
| 69 | private: |
| 70 | int m_fontSize; |
| 71 | }; |
| 72 | |
| 73 | class FontChart6: public FontChart |
| 74 | { |
| 75 | public: |
| 76 | FontChart6(): FontChart(6) {}; |
| 77 | }; |
| 78 | |
| 79 | class FontChart8: public FontChart |
| 80 | { |
| 81 | public: |
| 82 | FontChart8(): FontChart(8) {}; |
| 83 | }; |
| 84 | |
| 85 | class FontChart10: public FontChart |
| 86 | { |
| 87 | public: |
| 88 | FontChart10(): FontChart(10) {}; |
| 89 | }; |
| 90 | |
| 91 | class FontChart14: public FontChart |
| 92 | { |
| 93 | public: |
| 94 | FontChart14(): FontChart(14) {}; |
| 95 | }; |
| 96 | |
| 97 | class FontChart18: public FontChart |
| 98 | { |
| 99 | public: |
| 100 | FontChart18(): FontChart(18) {}; |
| 101 | }; |
| 102 | |
| 103 | class FontChart20: public FontChart |
| 104 | { |
| 105 | public: |
| 106 | FontChart20(): FontChart(20) {}; |
| 107 | }; |
| 108 | |
| 109 | class FontChart24: public FontChart |
| 110 | { |
| 111 | public: |
| 112 | FontChart24(): FontChart(24) {}; |
| 113 | }; |
| 114 | |
| 115 | class FontChart28: public FontChart |
| 116 | { |
| 117 | public: |
| 118 | FontChart28(): FontChart(28) {}; |
| 119 | }; |
| 120 | |
| 121 | class FontChart32: public FontChart |
| 122 | { |
| 123 | public: |
| 124 | FontChart32(): FontChart(32) {}; |
| 125 | }; |
| 126 | |
| 127 | DECLARE_CHART(FontChart6); |
| 128 | DECLARE_CHART(FontChart8); |
| 129 | DECLARE_CHART(FontChart10); |
| 130 | DECLARE_CHART(FontChart14); |
| 131 | DECLARE_CHART(FontChart18); |
| 132 | DECLARE_CHART(FontChart20); |
| 133 | DECLARE_CHART(FontChart24); |
| 134 | DECLARE_CHART(FontChart28); |
| 135 | DECLARE_CHART(FontChart32); |
| 136 |
