##// END OF EJS Templates
enablers for tooltip and floating values, bug fixing, updated examples. tidying up the code
enablers for tooltip and floating values, bug fixing, updated examples. tidying up the code

File last commit:

r192:5238f1b4589b
r296:8254aab7233d
Show More
main.cpp
55 lines | 1.4 KiB | text/x-c | CppLexer
Michal Klocek
Add background to chart...
r69 #include <QApplication>
#include <QMainWindow>
#include <qchartview.h>
Michal Klocek
Fix previous broken commit
r145 #include <qlinechartseries.h>
Michal Klocek
Add background to chart...
r69 #include <qchart.h>
#include <cmath>
QTCOMMERCIALCHART_USE_NAMESPACE
#define PI 3.14159265358979
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
Michal Klocek
Clean up obsolete create metods in series
r156 QLineChartSeries* series0 = new QLineChartSeries();
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 QPen blue(Qt::blue);
blue.setWidth(3);
series0->setPen(blue);
Michal Klocek
Clean up obsolete create metods in series
r156 QLineChartSeries* series1 = new QLineChartSeries();
Michal Klocek
Refactora axis and line chart to use graphics items insted of painter.
r85 QPen red(Qt::red);
red.setWidth(3);
series1->setPen(red);
Michal Klocek
Add background to chart...
r69
int numPoints = 100;
for (int x = 0; x <= numPoints; ++x) {
Michal Klocek
Refactors qchart , adds line animation...
r131 series0->add(x, fabs(sin(PI/50*x)*100));
series1->add(x, fabs(cos(PI/50*x)*100));
Michal Klocek
Add background to chart...
r69 }
QChartView* chartView = new QChartView(&window);
Michal Klocek
Add gradient bacground support...
r86 chartView->setRenderHint(QPainter::Antialiasing);
Michal Klocek
Adds font handling for chart's titile...
r192
QFont font;
font.setPixelSize(18);
chartView->setChartTitleFont(font);
chartView->setChartTitle("Custom color line chart example");
Michal Klocek
Add background to chart...
r69 chartView->addSeries(series0);
chartView->addSeries(series1);
Michal Klocek
Change background gradient to use ObjectBoundingMode...
r122
QLinearGradient backgroundGradient;
backgroundGradient.setColorAt(0.0, Qt::blue);
backgroundGradient.setColorAt(1.0, Qt::yellow);
backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
chartView->setChartBackgroundBrush(backgroundGradient);
Michal Klocek
Add background to chart...
r69
window.setCentralWidget(chartView);
window.resize(400, 300);
window.show();
return a.exec();
}