From 5dd68c268a201cae46e1cf6c1ae019bc36b521d4 2012-11-26 12:58:47 From: Marek Rosa Date: 2012-11-26 12:58:47 Subject: [PATCH] ChartViewer: added domain charts --- diff --git a/demos/chartviewer/charts/charts.pri b/demos/chartviewer/charts/charts.pri index 13321ef..5bef427 100644 --- a/demos/chartviewer/charts/charts.pri +++ b/demos/chartviewer/charts/charts.pri @@ -27,7 +27,22 @@ SOURCES += \ $$PWD/multiaxis/multivalueaxis3.cpp \ $$PWD/multiaxis/multivalueaxis4.cpp \ $$PWD/multiaxis/multivaluebaraxis.cpp \ - $$PWD/size/sizecharts.cpp + $$PWD/size/sizecharts.cpp \ + $$PWD/domain/barlogy.cpp \ + $$PWD/domain/barlogx.cpp \ + $$PWD/domain/barstackedlogy.cpp \ + $$PWD/domain/barstackedlogx.cpp \ + $$PWD/domain/barpercentlogy.cpp \ + $$PWD/domain/barpercentlogx.cpp \ + $$PWD/domain/linelogxlogy.cpp \ + $$PWD/domain/linelogxy.cpp \ + $$PWD/domain/linexlogy.cpp \ + $$PWD/domain/splinelogxlogy.cpp \ + $$PWD/domain/splinelogxy.cpp \ + $$PWD/domain/splinexlogy.cpp \ + $$PWD/domain/scatterlogxlogy.cpp \ + $$PWD/domain/scatterlogxy.cpp \ + $$PWD/domain/scatterxlogy.cpp !linux-arm*: { SOURCES += \ diff --git a/demos/chartviewer/charts/domain/barlogx.cpp b/demos/chartviewer/charts/domain/barlogx.cpp new file mode 100644 index 0000000..efb4c2c --- /dev/null +++ b/demos/chartviewer/charts/domain/barlogx.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qhorizontalbarseries.h" +#include "qbarset.h" +#include "qlogvalueaxis.h" +#include "qbarcategoryaxis.h" + +class BarLogX: public Chart +{ +public: + QString name() { return "Horizontal Bar"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return "Horizontal Log"; } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Bar: Log X, BarCateogry Y"); + + QString name("Series "); + QHorizontalBarSeries *series = new QHorizontalBarSeries(chart); + QLogValueAxis *logvalueaxis = new QLogValueAxis(); + logvalueaxis->setBase(2); + QBarCategoryAxis *barcategory = new QBarCategoryAxis(); + for (int i(0); i < table.count(); i++) { + QBarSet *set = new QBarSet("Bar set " + QString::number(i)); + foreach (Data data, table[i]) + *set << data.first.y(); + series->append(set); + } + chart->addSeries(series); + + int count = series->barSets().first()->count(); + + + for (int i = 0; i < count; i++) { + barcategory->append("BarSet " + QString::number(i)); + } + + chart->setAxisX(logvalueaxis, series); + chart->setAxisY(barcategory, series); + + return chart; + } +}; + +DECLARE_CHART(BarLogX); diff --git a/demos/chartviewer/charts/domain/barlogy.cpp b/demos/chartviewer/charts/domain/barlogy.cpp new file mode 100644 index 0000000..a8d01a7 --- /dev/null +++ b/demos/chartviewer/charts/domain/barlogy.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qbarseries.h" +#include "qbarset.h" +#include "qlogvalueaxis.h" +#include "qbarcategoryaxis.h" + +class BarLogY: public Chart +{ +public: + QString name() { return "Bar"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return "Vertical Log"; } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Bar: BarCateogry X, Log Y"); + + QString name("Series "); + QBarSeries *series = new QBarSeries(chart); + QLogValueAxis *logvalueaxis = new QLogValueAxis(); + logvalueaxis->setBase(2); + QBarCategoryAxis *barcategory = new QBarCategoryAxis(); + for (int i(0); i < table.count(); i++) { + QBarSet *set = new QBarSet("Bar set " + QString::number(i)); + foreach (Data data, table[i]) + *set << data.first.y(); + series->append(set); + } + chart->addSeries(series); + + int count = series->barSets().first()->count(); + + + for (int i = 0; i < count; i++) { + barcategory->append("BarSet " + QString::number(i)); + } + + chart->setAxisY(logvalueaxis, series); + chart->setAxisX(barcategory, series); + + return chart; + } +}; + +DECLARE_CHART(BarLogY); diff --git a/demos/chartviewer/charts/domain/barpercentlogx.cpp b/demos/chartviewer/charts/domain/barpercentlogx.cpp new file mode 100644 index 0000000..9bcf249 --- /dev/null +++ b/demos/chartviewer/charts/domain/barpercentlogx.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qhorizontalpercentbarseries.h" +#include "qbarset.h" +#include "qlogvalueaxis.h" +#include "qbarcategoryaxis.h" + +class BarPercentLogX: public Chart +{ +public: + QString name() { return "Horizontal PercentBar"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return "Horizontal Log"; } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("PercentBar: Log X, BarCateogry Y"); + + QString name("Series "); + QHorizontalPercentBarSeries *series = new QHorizontalPercentBarSeries(chart); + QLogValueAxis *logvalueaxis = new QLogValueAxis(); + logvalueaxis->setBase(2); + QBarCategoryAxis *barcategory = new QBarCategoryAxis(); + for (int i(0); i < table.count(); i++) { + QBarSet *set = new QBarSet("Bar set " + QString::number(i)); + foreach (Data data, table[i]) + *set << data.first.y(); + series->append(set); + } + chart->addSeries(series); + + int count = series->barSets().first()->count(); + + + for (int i = 0; i < count; i++) { + barcategory->append("BarSet " + QString::number(i)); + } + + chart->setAxisX(logvalueaxis, series); + chart->setAxisY(barcategory, series); + + return chart; + } +}; + +DECLARE_CHART(BarPercentLogX); diff --git a/demos/chartviewer/charts/domain/barpercentlogy.cpp b/demos/chartviewer/charts/domain/barpercentlogy.cpp new file mode 100644 index 0000000..f771369 --- /dev/null +++ b/demos/chartviewer/charts/domain/barpercentlogy.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qpercentbarseries.h" +#include "qbarset.h" +#include "qlogvalueaxis.h" +#include "qbarcategoryaxis.h" + +class BarPercentLogY: public Chart +{ +public: + QString name() { return "PercentBar"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return "Vertical Log"; } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("PercentBar: BarCateogry X, Log Y"); + + QString name("Series "); + QPercentBarSeries *series = new QPercentBarSeries(chart); + QLogValueAxis *logvalueaxis = new QLogValueAxis(); + logvalueaxis->setBase(2); + QBarCategoryAxis *barcategory = new QBarCategoryAxis(); + for (int i(0); i < table.count(); i++) { + QBarSet *set = new QBarSet("Bar set " + QString::number(i)); + foreach (Data data, table[i]) + *set << data.first.y(); + series->append(set); + } + chart->addSeries(series); + + int count = series->barSets().first()->count(); + + + for (int i = 0; i < count; i++) { + barcategory->append("BarSet " + QString::number(i)); + } + + chart->setAxisY(logvalueaxis, series); + chart->setAxisX(barcategory, series); + + return chart; + } +}; + +DECLARE_CHART(BarPercentLogY); diff --git a/demos/chartviewer/charts/domain/barstackedlogx.cpp b/demos/chartviewer/charts/domain/barstackedlogx.cpp new file mode 100644 index 0000000..fff7dbc --- /dev/null +++ b/demos/chartviewer/charts/domain/barstackedlogx.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qhorizontalstackedbarseries.h" +#include "qbarset.h" +#include "qlogvalueaxis.h" +#include "qbarcategoryaxis.h" + +class BarStackedLogX: public Chart +{ +public: + QString name() { return "Horizontal StackedBar"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return "Horizontal Log"; } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("StackedBar: Log X, BarCateogry Y"); + + QString name("Series "); + QHorizontalStackedBarSeries *series = new QHorizontalStackedBarSeries(chart); + QLogValueAxis *logvalueaxis = new QLogValueAxis(); + logvalueaxis->setBase(2); + QBarCategoryAxis *barcategory = new QBarCategoryAxis(); + for (int i(0); i < table.count(); i++) { + QBarSet *set = new QBarSet("Bar set " + QString::number(i)); + foreach (Data data, table[i]) + *set << data.first.y(); + series->append(set); + } + chart->addSeries(series); + + int count = series->barSets().first()->count(); + + + for (int i = 0; i < count; i++) { + barcategory->append("BarSet " + QString::number(i)); + } + + chart->setAxisX(logvalueaxis, series); + chart->setAxisY(barcategory, series); + + return chart; + } +}; + +DECLARE_CHART(BarStackedLogX); diff --git a/demos/chartviewer/charts/domain/barstackedlogy.cpp b/demos/chartviewer/charts/domain/barstackedlogy.cpp new file mode 100644 index 0000000..d504118 --- /dev/null +++ b/demos/chartviewer/charts/domain/barstackedlogy.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qstackedbarseries.h" +#include "qbarset.h" +#include "qlogvalueaxis.h" +#include "qbarcategoryaxis.h" + +class BarStackedLogY: public Chart +{ +public: + QString name() { return "StackedBar"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return "Vertical Log"; } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("StackedBar: BarCateogry X, Log Y"); + + QString name("Series "); + QStackedBarSeries *series = new QStackedBarSeries(chart); + QLogValueAxis *logvalueaxis = new QLogValueAxis(); + logvalueaxis->setBase(2); + QBarCategoryAxis *barcategory = new QBarCategoryAxis(); + for (int i(0); i < table.count(); i++) { + QBarSet *set = new QBarSet("Bar set " + QString::number(i)); + foreach (Data data, table[i]) + *set << data.first.y(); + series->append(set); + } + chart->addSeries(series); + + int count = series->barSets().first()->count(); + + + for (int i = 0; i < count; i++) { + barcategory->append("BarSet " + QString::number(i)); + } + + chart->setAxisY(logvalueaxis, series); + chart->setAxisX(barcategory, series); + + return chart; + } +}; + +DECLARE_CHART(BarStackedLogY); diff --git a/demos/chartviewer/charts/domain/linelogxlogy.cpp b/demos/chartviewer/charts/domain/linelogxlogy.cpp new file mode 100644 index 0000000..12b817a --- /dev/null +++ b/demos/chartviewer/charts/domain/linelogxlogy.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qlineseries.h" +#include "qlogvalueaxis.h" + +class LineLogXLogY: public Chart +{ +public: + QString name() { return "Line LogX LogY"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return QObject::tr("Both Log"); } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Line: Log X, Log Y"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, table) { + QLineSeries *series = new QLineSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + + QLogValueAxis *axisX= new QLogValueAxis(); + axisX->setBase(1.2); + QLogValueAxis *axisY= new QLogValueAxis(); + axisY->setBase(2); + foreach (QAbstractSeries *series, chart->series()) { + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); + } + + return chart; + } +}; + +DECLARE_CHART(LineLogXLogY); diff --git a/demos/chartviewer/charts/domain/linelogxy.cpp b/demos/chartviewer/charts/domain/linelogxy.cpp new file mode 100644 index 0000000..157af6d --- /dev/null +++ b/demos/chartviewer/charts/domain/linelogxy.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qlineseries.h" +#include "qlogvalueaxis.h" +#include "qvalueaxis.h" + +class LineLogXY: public Chart +{ +public: + QString name() { return "Line LogX Y"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return QObject::tr("Both Log"); } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Line: Log X, Y"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, table) { + QLineSeries *series = new QLineSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + + QLogValueAxis *axisX= new QLogValueAxis(); + axisX->setBase(1.2); + QValueAxis *axisY= new QValueAxis(); + foreach (QAbstractSeries *series, chart->series()) { + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); + } + + return chart; + } +}; + +DECLARE_CHART(LineLogXY); diff --git a/demos/chartviewer/charts/domain/linexlogy.cpp b/demos/chartviewer/charts/domain/linexlogy.cpp new file mode 100644 index 0000000..468f71f --- /dev/null +++ b/demos/chartviewer/charts/domain/linexlogy.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qlineseries.h" +#include "qlogvalueaxis.h" +#include "qvalueaxis.h" + +class LineXLogY: public Chart +{ +public: + QString name() { return "Line X LogY"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return QObject::tr("Both Log"); } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Line: X, Log Y"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, table) { + QLineSeries *series = new QLineSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + + QValueAxis *axisX= new QValueAxis(); + QLogValueAxis *axisY= new QLogValueAxis(); + axisY->setBase(2); + foreach (QAbstractSeries *series, chart->series()) { + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); + } + + return chart; + } +}; + +DECLARE_CHART(LineXLogY); diff --git a/demos/chartviewer/charts/domain/scatterlogxlogy.cpp b/demos/chartviewer/charts/domain/scatterlogxlogy.cpp new file mode 100644 index 0000000..2727315 --- /dev/null +++ b/demos/chartviewer/charts/domain/scatterlogxlogy.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qscatterseries.h" +#include "qlogvalueaxis.h" + +class ScatterLogXLogY: public Chart +{ +public: + QString name() { return "Scatter LogX LogY"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return QObject::tr("Both Log"); } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Scatter: Log X, Log Y"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, table) { + QScatterSeries *series = new QScatterSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + + QLogValueAxis *axisX= new QLogValueAxis(); + axisX->setBase(1.2); + QLogValueAxis *axisY= new QLogValueAxis(); + axisY->setBase(2); + foreach (QAbstractSeries *series, chart->series()) { + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); + } + + return chart; + } +}; + +DECLARE_CHART(ScatterLogXLogY); diff --git a/demos/chartviewer/charts/domain/scatterlogxy.cpp b/demos/chartviewer/charts/domain/scatterlogxy.cpp new file mode 100644 index 0000000..d48e9e2 --- /dev/null +++ b/demos/chartviewer/charts/domain/scatterlogxy.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qscatterseries.h" +#include "qlogvalueaxis.h" +#include "qvalueaxis.h" + +class ScatterLogXY: public Chart +{ +public: + QString name() { return "Scatter LogX Y"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return QObject::tr("Both Log"); } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Scatter: Log X, Y"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, table) { + QScatterSeries *series = new QScatterSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + + QLogValueAxis *axisX= new QLogValueAxis(); + axisX->setBase(1.2); + QValueAxis *axisY= new QValueAxis(); + foreach (QAbstractSeries *series, chart->series()) { + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); + } + + return chart; + } +}; + +DECLARE_CHART(ScatterLogXY); diff --git a/demos/chartviewer/charts/domain/scatterxlogy.cpp b/demos/chartviewer/charts/domain/scatterxlogy.cpp new file mode 100644 index 0000000..c05a887 --- /dev/null +++ b/demos/chartviewer/charts/domain/scatterxlogy.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qscatterseries.h" +#include "qlogvalueaxis.h" +#include "qvalueaxis.h" + +class ScatterXLogY: public Chart +{ +public: + QString name() { return "Scatter X LogY"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return QObject::tr("Both Log"); } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Scatter: X, Log Y"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, table) { + QScatterSeries *series = new QScatterSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + + QValueAxis *axisX= new QValueAxis(); + QLogValueAxis *axisY= new QLogValueAxis(); + axisY->setBase(2); + foreach (QAbstractSeries *series, chart->series()) { + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); + } + + return chart; + } +}; + +DECLARE_CHART(ScatterXLogY); diff --git a/demos/chartviewer/charts/domain/splinelogxlogy.cpp b/demos/chartviewer/charts/domain/splinelogxlogy.cpp new file mode 100644 index 0000000..a9b156b --- /dev/null +++ b/demos/chartviewer/charts/domain/splinelogxlogy.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qsplineseries.h" +#include "qlogvalueaxis.h" + +class SplineLogXLogY: public Chart +{ +public: + QString name() { return "Spline LogX LogY"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return QObject::tr("Both Log"); } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Spline: Log X, Log Y"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, table) { + QSplineSeries *series = new QSplineSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + + QLogValueAxis *axisX= new QLogValueAxis(); + axisX->setBase(1.2); + QLogValueAxis *axisY= new QLogValueAxis(); + axisY->setBase(2); + foreach (QAbstractSeries *series, chart->series()) { + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); + } + + return chart; + } +}; + +DECLARE_CHART(SplineLogXLogY); diff --git a/demos/chartviewer/charts/domain/splinelogxy.cpp b/demos/chartviewer/charts/domain/splinelogxy.cpp new file mode 100644 index 0000000..1450a3f --- /dev/null +++ b/demos/chartviewer/charts/domain/splinelogxy.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qsplineseries.h" +#include "qlogvalueaxis.h" +#include "qvalueaxis.h" + +class SplineLogXY: public Chart +{ +public: + QString name() { return "Spline LogX Y"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return QObject::tr("Both Log"); } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Spline: Log X, Y"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, table) { + QSplineSeries *series = new QSplineSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + + QLogValueAxis *axisX= new QLogValueAxis(); + axisX->setBase(1.2); + QValueAxis *axisY= new QValueAxis(); + foreach (QAbstractSeries *series, chart->series()) { + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); + } + + return chart; + } +}; + +DECLARE_CHART(SplineLogXY); diff --git a/demos/chartviewer/charts/domain/splinexlogy.cpp b/demos/chartviewer/charts/domain/splinexlogy.cpp new file mode 100644 index 0000000..e1eaf4c --- /dev/null +++ b/demos/chartviewer/charts/domain/splinexlogy.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "charts.h" +#include "qchart.h" +#include "qsplineseries.h" +#include "qlogvalueaxis.h" +#include "qvalueaxis.h" + +class SplineXLogY: public Chart +{ +public: + QString name() { return "Spline X LogY"; } + QString category() { return QObject::tr("Domain"); } + QString subCategory() { return QObject::tr("Both Log"); } + + QChart *createChart(const DataTable &table) + { + QChart *chart = new QChart(); + chart->setTitle("Spline: X, Log Y"); + + QString name("Series "); + int nameIndex = 0; + foreach (DataList list, table) { + QSplineSeries *series = new QSplineSeries(chart); + foreach (Data data, list) + series->append(data.first); + series->setName(name + QString::number(nameIndex)); + nameIndex++; + chart->addSeries(series); + } + + QValueAxis *axisX= new QValueAxis(); + QLogValueAxis *axisY= new QLogValueAxis(); + axisY->setBase(2); + foreach (QAbstractSeries *series, chart->series()) { + chart->setAxisX(axisX, series); + chart->setAxisY(axisY, series); + } + + return chart; + } +}; + +DECLARE_CHART(SplineXLogY); diff --git a/demos/chartviewer/model.h b/demos/chartviewer/model.h index c160144..2195b71 100644 --- a/demos/chartviewer/model.h +++ b/demos/chartviewer/model.h @@ -48,7 +48,7 @@ public: // generate random data for (int i(0); i < listCount; i++) { DataList dataList; - qreal yValue(0); + qreal yValue(0.1); for (int j(0); j < valueCount; j++) { yValue = yValue + (qreal)(qrand() % valueMax) / (qreal) valueCount; QPointF value(