| 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 |
#include <QtCharts/QValueAxis> |
| 10 |
|
| 11 |
class SizeChart: public Chart |
| 12 |
{ |
| 13 |
public: |
| 14 |
QString name() { return QObject::tr("PlotArea"); } |
| 15 |
QString category() { return QObject::tr("Size"); } |
| 16 |
QString subCategory() { return QString(); } |
| 17 |
|
| 18 |
QChart *createChart(const DataTable &table) |
| 19 |
{ |
| 20 |
|
| 21 |
QChart *chart = new QChart(); |
| 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->setContentsMargins(0,0,0,0); |
| 33 |
chart->setMargins(QMargins(0,0,0,0)); |
| 34 |
return chart; |
| 35 |
} |
| 36 |
}; |
| 37 |
|
| 38 |
class SizeChart2: public SizeChart |
| 39 |
{ |
| 40 |
public: |
| 41 |
QString name() { return QObject::tr("PA + T"); } |
| 42 |
|
| 43 |
QChart *createChart(const DataTable &table) |
| 44 |
{ |
| 45 |
QChart *chart = SizeChart::createChart(table); |
| 46 |
chart->setTitle(name()); |
| 47 |
return chart; |
| 48 |
} |
| 49 |
}; |
| 50 |
|
| 51 |
class SizeChart3: public SizeChart2 |
| 52 |
{ |
| 53 |
public: |
| 54 |
QString name() { return QObject::tr("PA+T+CM10"); } |
| 55 |
|
| 56 |
QChart *createChart(const DataTable &table) |
| 57 |
{ |
| 58 |
QChart *chart = SizeChart2::createChart(table); |
| 59 |
chart->setContentsMargins(10,10,10,10); |
| 60 |
|
| 61 |
return chart; |
| 62 |
} |
| 63 |
}; |
| 64 |
|
| 65 |
class SizeChart4: public SizeChart3 |
| 66 |
{ |
| 67 |
public: |
| 68 |
QString name() { return QObject::tr("PA+T+CM10+M25"); } |
| 69 |
|
| 70 |
QChart *createChart(const DataTable &table) |
| 71 |
{ |
| 72 |
QChart *chart = SizeChart3::createChart(table); |
| 73 |
chart->setMargins(QMargins(30,30,30,30)); |
| 74 |
return chart; |
| 75 |
} |
| 76 |
}; |
| 77 |
|
| 78 |
class SizeChart5: public SizeChart4 |
| 79 |
{ |
| 80 |
public: |
| 81 |
QString name() { return QObject::tr("PA+T+CM10+M25+AX"); } |
| 82 |
|
| 83 |
QChart *createChart(const DataTable &table) |
| 84 |
{ |
| 85 |
QChart *chart = SizeChart4::createChart(table); |
| 86 |
chart->createDefaultAxes(); |
| 87 |
chart->axisY()->hide(); |
| 88 |
return chart; |
| 89 |
} |
| 90 |
}; |
| 91 |
|
| 92 |
class SizeChart6: public SizeChart4 |
| 93 |
{ |
| 94 |
public: |
| 95 |
QString name() { return QObject::tr("PA+T+CM10+M25+AY"); } |
| 96 |
|
| 97 |
QChart *createChart(const DataTable &table) |
| 98 |
{ |
| 99 |
QChart *chart = SizeChart4::createChart(table); |
| 100 |
chart->createDefaultAxes(); |
| 101 |
chart->axisX()->hide(); |
| 102 |
return chart; |
| 103 |
} |
| 104 |
}; |
| 105 |
|
| 106 |
class SizeChart7: public SizeChart4 |
| 107 |
{ |
| 108 |
public: |
| 109 |
QString name() { return QObject::tr("PA+T+CM10+M25+AX+AY"); } |
| 110 |
|
| 111 |
QChart *createChart(const DataTable &table) |
| 112 |
{ |
| 113 |
QChart *chart = SizeChart4::createChart(table); |
| 114 |
chart->createDefaultAxes(); |
| 115 |
return chart; |
| 116 |
} |
| 117 |
}; |
| 118 |
|
| 119 |
DECLARE_CHART(SizeChart) |
| 120 |
DECLARE_CHART(SizeChart2) |
| 121 |
DECLARE_CHART(SizeChart3) |
| 122 |
DECLARE_CHART(SizeChart4) |
| 123 |
DECLARE_CHART(SizeChart5) |
| 124 |
DECLARE_CHART(SizeChart6) |
| 125 |
DECLARE_CHART(SizeChart7) |