##// END OF EJS Templates
updated barchart examples
updated barchart examples

File last commit:

r169:1723c50daa1e
r170:ff886517a70e
Show More
main.cpp
49 lines | 1.3 KiB | text/x-c | CppLexer
#include <QApplication>
#include <QMainWindow>
#include <QStandardItemModel>
#include <barchartseries.h>
#include <qbarcategory.h>
#include <qbarset.h>
#include "chartwidget.h"
QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
QBarCategory category;
category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Nov" << "Dec";
BarChartSeries* series0 = new BarChartSeries(category);
QBarSet barSet0;
QBarSet barSet1;
QBarSet barSet2;
QBarSet barSet3;
QBarSet barSet4;
// Create some test data to chart
barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10;
barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0;
barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1;
barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5;
barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10;
series0->addBarSet(barSet0);
series0->addBarSet(barSet1);
series0->addBarSet(barSet2);
series0->addBarSet(barSet3);
series0->addBarSet(barSet4);
ChartWidget* chartWidget = new ChartWidget(&window);
chartWidget->addSeries(series0);
window.setCentralWidget(chartWidget);
window.resize(400, 300);
window.show();
return a.exec();
}