##// END OF EJS Templates
refactored legend to qseries
refactored legend to qseries

File last commit:

r349:7594bc4927de
r380:0247ffcfa93f
Show More
main.cpp
67 lines | 1.8 KiB | text/x-c | CppLexer
Michal Klocek
Adds more axis handling...
r176 #include <QApplication>
#include <QMainWindow>
#include <qchartview.h>
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 #include <qlineseries.h>
Michal Klocek
Adds more axis handling...
r176 #include <qchart.h>
#include <qchartaxis.h>
#include <cmath>
QTCOMMERCIALCHART_USE_NAMESPACE
#define PI 3.14159265358979
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 QLineSeries* series0 = new QLineSeries();
Michal Klocek
Adds more axis handling...
r176 QPen blue(Qt::blue);
blue.setWidth(3);
series0->setPen(blue);
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 QLineSeries* series1 = new QLineSeries();
Michal Klocek
Adds more axis handling...
r176 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);
Michal Klocek
Adds font handling for chart's titile...
r192 chartView->setChartTitle("This is custom axis chart example");
Michal Klocek
Adds more axis handling...
r176 chartView->addSeries(series0);
chartView->addSeries(series1);
Michal Klocek
Adds opacity to shades
r188
QLinearGradient backgroundGradient;
backgroundGradient.setColorAt(0.0, Qt::white);
backgroundGradient.setColorAt(1.0, QRgb(0xffff80));
backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
chartView->setChartBackgroundBrush(backgroundGradient);
Michal Klocek
Adds more axis handling...
r176
Michal Klocek
Fixes axischart example
r225 QChartAxis* axisX = chartView->axisX();
axisX->setLabelsAngle(45);
axisX->setGridPen(Qt::DashLine);
axisX->addAxisTickLabel(0,"low");
axisX->addAxisTickLabel(50,"medium");
axisX->addAxisTickLabel(100,"High");
Michal Klocek
Adds more axis handling...
r176
Michal Klocek
Fixes axischart example
r225 QChartAxis* axisY = chartView->axisY();
axisY->setLabelsAngle(45);
axisY->setShadesBrush(Qt::yellow);
axisY->addAxisTickLabel(0,"low");
axisY->addAxisTickLabel(50,"medium");
axisY->addAxisTickLabel(100,"High");
Michal Klocek
Adds more axis handling...
r176
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
return a.exec();
}