##// END OF EJS Templates
Revert "Theme change now affects also XY series"...
Revert "Theme change now affects also XY series" This reverts commit 91322882c9fdeca5ce2206f5b5c1fb3b4a2a2b7c.

File last commit:

r572:1af1de97a8a5
r644:7baa2715935c
Show More
main.cpp
81 lines | 2.1 KiB | text/x-c | CppLexer
#include <QApplication>
#include <QMainWindow>
#include <qchartview.h>
#include <qlineseries.h>
#include <qchart.h>
#include <qchartaxis.h>
#include <qchartaxiscategories.h>
#include <cmath>
QTCOMMERCIALCHART_USE_NAMESPACE
#define PI 3.14159265358979
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
QLineSeries* series0 = new QLineSeries();
QPen blue(Qt::blue);
blue.setWidth(3);
series0->setPen(blue);
QLineSeries* series1 = new QLineSeries();
QPen red(Qt::red);
red.setWidth(3);
series1->setPen(red);
int numPoints = 100;
for (int x = 0; x <= numPoints; ++x) {
series0->add(x, fabs(sin(PI/50*x)*100));
series1->add(x, fabs(cos(PI/50*x)*100));
}
QChartView* chartView = new QChartView(&window);
chartView->setRenderHint(QPainter::Antialiasing);
chartView->setChartTitle("This is custom axis chart example");
chartView->addSeries(series0);
chartView->addSeries(series1);
QLinearGradient backgroundGradient;
backgroundGradient.setColorAt(0.0, Qt::white);
backgroundGradient.setColorAt(1.0, Qt::white);
backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
chartView->setChartBackgroundBrush(backgroundGradient);
QChartAxis* axisX = chartView->axisX();
axisX->setLabelsAngle(45);
axisX->setGridLinePen(red);
axisX->setGridLineVisible(false);
axisX->setShadesVisible(true);
QChartAxisCategories* categoriesX = axisX->categories();
categoriesX->insert(0,"low");
categoriesX->insert(50,"medium");
categoriesX->insert(100,"High");
// axisX->setMin(-10);
// axisX->setMax(2200);
QChartAxis* axisY = chartView->axisY();
axisY->setLabelsAngle(45);
axisY->setShadesBrush(Qt::yellow);
axisY->setGridLineVisible(false);
QChartAxisCategories* categoriesY = axisY->categories();
categoriesY->insert(0,"low");
categoriesY->insert(50,"medium");
categoriesY->insert(100,"High");
// axisY->setMin(-10);
// axisY->setMax(200);
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
return a.exec();
}