##// END OF EJS Templates
donutbreakdown example now has customized legendmarkers
donutbreakdown example now has customized legendmarkers

File last commit:

r2105:984dd120480b
r2233:222c26d04db8
Show More
main.cpp
92 lines | 2.3 KiB | text/x-c | CppLexer
Marek Rosa
Multiaxis support...
r2093 /****************************************************************************
**
** 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 <QApplication>
#include <QMainWindow>
#include <QChartView>
#include <QLineSeries>
#include <QValueAxis>
#include <QTime>
#include <QValueAxis>
QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Jani Honkonen
coding style fixes for examples
r2098 qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
Marek Rosa
Multiaxis support...
r2093
//![1]
Jani Honkonen
more coding style fixes for examples...
r2102 QLineSeries *series;
Marek Rosa
Multiaxis support...
r2093 QValueAxis *axisX;
QValueAxis *axisY;
Jani Honkonen
more coding style fixes for examples...
r2102 QChart *chart = new QChart();
Marek Rosa
Multiaxis support...
r2093 for (int i = 0; i < 5; i++) {
series = new QLineSeries;
for (int k(0); k < 8; k++)
Jani Honkonen
coding style fixes for examples
r2098 series->append(i + k, qrand() % 20);
Marek Rosa
Multiaxis support...
r2093 chart->addSeries(series);
axisX = new QValueAxis;
axisX->setTickCount(7 + i);
axisX->setLinePenColor(series->pen().color());
Michal Klocek
Refactors layout:...
r2105
Jani Honkonen
coding style fixes for examples
r2098 if (i % 2)
Michal Klocek
Refactors layout:...
r2105 axisX->setAlignment(Qt::AlignTop);
else
axisX->setAlignment(Qt::AlignBottom);
Marek Rosa
Multiaxis support...
r2093 axisY = new QValueAxis;
axisY->setTickCount(7 + i);
axisY->setLinePenColor(series->pen().color());
Michal Klocek
Refactors layout:...
r2105
Jani Honkonen
coding style fixes for examples
r2098 if (i % 2)
Michal Klocek
Refactors layout:...
r2105 axisY->setAlignment(Qt::AlignRight);
else
axisY->setAlignment(Qt::AlignLeft);
Marek Rosa
Multiaxis support...
r2093
chart->setAxisX(axisX, series);
chart->setAxisY(axisY, series);
}
//![2]
//![3]
chart->legend()->hide();
chart->setTitle("Simple line chart example");
//![3]
//![4]
Jani Honkonen
more coding style fixes for examples...
r2102 QChartView *chartView = new QChartView(chart);
Marek Rosa
Multiaxis support...
r2093 chartView->setRenderHint(QPainter::Antialiasing);
//![4]
//![5]
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(800, 600);
window.show();
//![5]
return a.exec();
}