@@ -1,45 +1,46 | |||||
1 | #include <QApplication> |
|
1 | #include <QApplication> | |
2 | #include <QMainWindow> |
|
2 | #include <QMainWindow> | |
3 | #include <qchartview.h> |
|
3 | #include <qchartview.h> | |
4 | #include <qxychartseries.h> |
|
4 | #include <qxychartseries.h> | |
5 | #include <qchart.h> |
|
5 | #include <qchart.h> | |
6 | #include <cmath> |
|
6 | #include <cmath> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
8 | QTCOMMERCIALCHART_USE_NAMESPACE | |
9 |
|
9 | |||
10 | #define PI 3.14159265358979 |
|
10 | #define PI 3.14159265358979 | |
11 |
|
11 | |||
12 | int main(int argc, char *argv[]) |
|
12 | int main(int argc, char *argv[]) | |
13 | { |
|
13 | { | |
14 | QApplication a(argc, argv); |
|
14 | QApplication a(argc, argv); | |
15 |
|
15 | |||
16 | QMainWindow window; |
|
16 | QMainWindow window; | |
17 |
|
17 | |||
18 | QXYChartSeries* series0 = QXYChartSeries::create(); |
|
18 | QXYChartSeries* series0 = QXYChartSeries::create(); | |
19 | QPen blue(Qt::blue); |
|
19 | QPen blue(Qt::blue); | |
20 | blue.setWidth(3); |
|
20 | blue.setWidth(3); | |
21 | series0->setPen(blue); |
|
21 | series0->setPen(blue); | |
22 | QXYChartSeries* series1 = QXYChartSeries::create(); |
|
22 | QXYChartSeries* series1 = QXYChartSeries::create(); | |
23 | QPen red(Qt::red); |
|
23 | QPen red(Qt::red); | |
24 | red.setWidth(3); |
|
24 | red.setWidth(3); | |
25 | series1->setPen(red); |
|
25 | series1->setPen(red); | |
26 |
|
26 | |||
27 | int numPoints = 100; |
|
27 | int numPoints = 100; | |
28 |
|
28 | |||
29 | for (int x = 0; x <= numPoints; ++x) { |
|
29 | for (int x = 0; x <= numPoints; ++x) { | |
30 | series0->add(x, abs(sin(PI/50*x)*100)); |
|
30 | series0->add(x, abs(sin(PI/50*x)*100)); | |
31 | series1->add(x, abs(cos(PI/50*x)*100)); |
|
31 | series1->add(x, abs(cos(PI/50*x)*100)); | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | QChartView* chartView = new QChartView(&window); |
|
34 | QChartView* chartView = new QChartView(&window); | |
35 | chartView->setRenderHint(QPainter::Antialiasing); |
|
35 | chartView->setRenderHint(QPainter::Antialiasing); | |
|
36 | chartView->setTitle("Custom color line chart example"); | |||
36 | chartView->addSeries(series0); |
|
37 | chartView->addSeries(series0); | |
37 | chartView->addSeries(series1); |
|
38 | chartView->addSeries(series1); | |
38 | chartView->setBackground(Qt::blue,Qt::yellow,QChart::HorizonatlGradientOrientation); |
|
39 | chartView->setBackground(Qt::blue,Qt::yellow,QChart::HorizonatlGradientOrientation); | |
39 |
|
40 | |||
40 | window.setCentralWidget(chartView); |
|
41 | window.setCentralWidget(chartView); | |
41 | window.resize(400, 300); |
|
42 | window.resize(400, 300); | |
42 | window.show(); |
|
43 | window.show(); | |
43 |
|
44 | |||
44 | return a.exec(); |
|
45 | return a.exec(); | |
45 | } |
|
46 | } |
@@ -1,42 +1,44 | |||||
1 | #include "chartwidget.h" |
|
1 | #include "chartwidget.h" | |
2 | #include <QApplication> |
|
2 | #include <QApplication> | |
3 | #include <QMainWindow> |
|
3 | #include <QMainWindow> | |
4 | #include <qxychartseries.h> |
|
4 | #include <qxychartseries.h> | |
5 | #include <cmath> |
|
5 | #include <cmath> | |
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
7 | QTCOMMERCIALCHART_USE_NAMESPACE | |
8 |
|
8 | |||
9 | #define PI 3.14159265358979 |
|
9 | #define PI 3.14159265358979 | |
10 |
|
10 | |||
11 | int main(int argc, char *argv[]) |
|
11 | int main(int argc, char *argv[]) | |
12 | { |
|
12 | { | |
13 | QApplication a(argc, argv); |
|
13 | QApplication a(argc, argv); | |
14 |
|
14 | |||
15 | QMainWindow window; |
|
15 | QMainWindow window; | |
16 |
|
16 | |||
17 | QXYChartSeries* series0 = QXYChartSeries::create(); |
|
17 | QXYChartSeries* series0 = QXYChartSeries::create(); | |
18 | QPen blue(Qt::blue); |
|
18 | QPen blue(Qt::blue); | |
19 | blue.setWidth(3); |
|
19 | blue.setWidth(3); | |
20 | series0->setPen(blue); |
|
20 | series0->setPen(blue); | |
21 | QXYChartSeries* series1 = QXYChartSeries::create(); |
|
21 | QXYChartSeries* series1 = QXYChartSeries::create(); | |
22 | QPen red(Qt::red); |
|
22 | QPen red(Qt::red); | |
23 | red.setWidth(3); |
|
23 | red.setWidth(3); | |
24 | series1->setPen(red); |
|
24 | series1->setPen(red); | |
25 |
|
25 | |||
26 | int numPoints = 100; |
|
26 | int numPoints = 100; | |
27 |
|
27 | |||
28 | for (int x = 0; x <= numPoints; ++x) { |
|
28 | for (int x = 0; x <= numPoints; ++x) { | |
29 | series0->add(x, abs(sin(PI/50*x)*100)); |
|
29 | series0->add(x, abs(sin(PI/50*x)*100)); | |
30 | series1->add(x, abs(cos(PI/50*x)*100)); |
|
30 | series1->add(x, abs(cos(PI/50*x)*100)); | |
31 | } |
|
31 | } | |
32 |
|
32 | |||
33 | ChartWidget* chartWidget = new ChartWidget(&window); |
|
33 | ChartWidget* chartWidget = new ChartWidget(&window); | |
|
34 | chartWidget->setRenderHint(QPainter::Antialiasing); | |||
|
35 | chartWidget->setTitle("Zoom in/out line chart example"); | |||
34 | chartWidget->addSeries(series0); |
|
36 | chartWidget->addSeries(series0); | |
35 | chartWidget->addSeries(series1); |
|
37 | chartWidget->addSeries(series1); | |
36 |
|
38 | |||
37 | window.setCentralWidget(chartWidget); |
|
39 | window.setCentralWidget(chartWidget); | |
38 | window.resize(400, 300); |
|
40 | window.resize(400, 300); | |
39 | window.show(); |
|
41 | window.show(); | |
40 |
|
42 | |||
41 | return a.exec(); |
|
43 | return a.exec(); | |
42 | } |
|
44 | } |
General Comments 0
You need to be logged in to leave comments.
Login now