新增超级曲线图表

master
feiyangqingyun 2021-12-10 20:23:28 +08:00
parent 9091bd5540
commit 40a3558323
136 changed files with 73164 additions and 322 deletions

View File

@ -1,4 +1,4 @@
#### 一、特别说明
#### 一、特别说明
1. 可以选择打开QWidgetDemo.pro一次性编译所有的也可以到目录下打开pro编译。
2. 如果发现有些子项目没有加载请打开对应目录下的.pro仔细看里面的注释。
3. 编译好的可执行文件在源码同级目录下的bin目录。
@ -153,6 +153,9 @@
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/third/0snap/qcustomplotdemo3.jpg)
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/third/0snap/qcustomplotdemo4.jpg)
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/third/0snap/qcustomplotdemo5.jpg)
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/third/0snap/qcustomplotdemo6.jpg)
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/third/0snap/qcustomplotdemo7.jpg)
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/third/0snap/qcustomplotdemo8.jpg)
##### 4.8、网友提供
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/netfriend/0snap/astackwidget.jpg)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -1,7 +1,35 @@
greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
greaterThan(QT_MAJOR_VERSION, 4): CONFIG += c++11
#lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11
HEADERS += \
$$PWD/qcustomplot.h
!contains(DEFINES, qcustomplot_v1_3) {
!contains(DEFINES, qcustomplot_v2_0) {
!contains(DEFINES, qcustomplot_v2_1) {
DEFINES += qcustomplot_v2_0
}}}
SOURCES += \
$$PWD/qcustomplot.cpp
!contains(DEFINES, qcustomplot_v2_1) {
greaterThan(QT_MAJOR_VERSION, 4) {
DEFINES -= qcustomplot_v1_3
DEFINES -= qcustomplot_v2_0
DEFINES += qcustomplot_v2_1
}}
contains(DEFINES, qcustomplot_v1_3) {
INCLUDEPATH += $$PWD/v1_3
HEADERS += $$PWD/v1_3/qcustomplot.h
SOURCES += $$PWD/v1_3/qcustomplot.cpp
} else {
contains(DEFINES, qcustomplot_v2_0) {
INCLUDEPATH += $$PWD/v2_0
HEADERS += $$PWD/v2_0/qcustomplot.h
SOURCES += $$PWD/v2_0/qcustomplot.cpp
} else {
INCLUDEPATH += $$PWD/v2_1
greaterThan(QT_MAJOR_VERSION, 5) {
HEADERS += $$PWD/v2_1_6/qcustomplot.h
} else {
HEADERS += $$PWD/v2_1/qcustomplot.h
}
SOURCES += $$PWD/v2_1/qcustomplot.cpp
}}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
00 00 06 35 09 6E 0A 76 09 C2 09 03 07 BF 06 B5 05 59 04 51 03 74 03 30 03 2A 03 3A 03 52 03 63 03 77 03 86 03 96 03 A0 03 AC 03 B4 03 BE 03 C6 03 CB 03 CD 03 D1 03 D1 03 D1 03 D3 03 D7 03 D9 03 DB 03 DB 03 DD 03 DF 03 E3 03 E5 03 E6 03 E4 03 E4 03 E4 03 E5 03 E5 03 E4 03 E4 03 E6 03 E5 03 E1 03 DC 03 D6 03 D4 03 D2 03 D1 03 D0 03 D1 03 D2 03 D3 03 D5 03 D9 03 DF 03 E6 03 F4 04 05 04 21 04 39 04 5D 04 7A 04 A5 04 CB 05 01 05 30 05 6E 05 A1 05 E6 06 1D 06 68 06 9F 06 D8 06 F7 07 14 07 27 07 43 07 5B 07 7A 07 94 07 B2 07 C9 07 E0 07 EF 08 03 08 11 08 21 08 30 08 41 08 4D 08 5E 08 6C 08 7C 08 8A 08 9B 08 A8 08 B7 08 C3 08 D0 08 DB 08 EA 08 F8 09 05 09 0F 09 19 09 22 09 2F 09 3B 09 45 09 4C 09 55 09 61 09 6D 09 76 09 83 09 8E 09 9C 09 A6 09 B1 09 B9 09 C8 09 D2 09 E0 09 EC 09 F6 0A 01 0A 0F 0A 19 0A 24 0A 2E 0A 3A 0A 43 0A 55 0A 61 0A 53 0A 67 0A 83 0A 91 0A 98 0A A0 0A B2 0A BF 0A D2 0A E8 0A F9 0B 05 0B 14 0B 20 0B 30 0B 3C 0B 4B 0B 59 0B 68 0B 77 0B 87 0B 93 0B A1 0B AE 0B BF 0B CD 0B DB 0B E5 0B F4 0C 00 0C 0F 0C 19 0C 25 0C 34 0C 40 0C 49 0C 56 0C 62 0C 6D 0C 75 0C 81 0C 8B 0C 98 0C A2 0C AD 0C B5 0C C4 0C D0 0C DA 0C E1 0C ED 0C FA 0D 07 0D 11 0D 1A 0D 22 0D 2F 0D 36 0D 41 0D 4A 0D 58 0D 63 0D 70 0D 7C 0D 8E 0D 9E 0D B4 0D C8 0D E3 0D F7 0E 0F 0E 24 0E 3F 0E 55 0E 71 0E 87 0E 9F 0E B3 0E CC 0E E0 0E FC 0F 10 0F 28 0F 41 0F 60 0F 78 0F 96 0F B1 0F CE 0F EA 10 0B 10 27 10 4A 10 63 10 83 10 9B 10 B8 10 CD 10 E3 10 BF 10 40 0F C2 0F 24 0E B2 0E 2E 0D D4 0D 7C 0D 52 0D 44 0D 5A 0D 71 0D 7F 0D 9F 0D C5 0D EF 0E 01 0E 12 0E 1C 0E 1D 0E 1C 0E 1A 0E 14 0E 05 0D F6 0D E5 0D DF 0D D9 0D D5 0D CE 0D C5 0D C0 0D C0 0D BB 0D B5 0D A8 0D A2 0D 9C 0D 95 0D 8C 0D 84 0D 75 0D 69 0D 5C 0D 51 0D 3C 0D 2A 0D 10 0D 00 0C EC 0C DD 0C C2 0C AB 0C 99 0C 8D 0C 7D 0C 6D 0C 57 0C 49 0C 3C 0C 31 0C 1D 0C 07 0B F0 0B E4 0B D0 0B BE 0B A7 0B 94 0B 7B 0B 6C 0B 59 0B 43 0B 26 0B 15 0B 03 0A F2 0A DB 0A B7 0A 94 0A 82 0A 6B 0A 52 0A 2F 0A 14 09 F7 09 DF 09 C2 09 A6 09 83 09 6F 09 55 09 3F 09 23 09 0E 08 F2 08 DB 08 C4 08 B1 08 96 08 7F 08 65 08 51 08 3B 08 22 08 01 07 EF 07 D8 07 C6 07 AA 07 93 07 7C 07 6E 07 5A 07 43 07 23 07 0A 06 F1 06 DB 06 BE 06 A6 06 86 06 6B 06 49 06 2F 06 14 05 F9 05 D4 05 BB 05 A0 05 8B 05 6C 05 50 05 30 05 1C 05 02 04 E9 04 C9 04 B0 04 98 04 86 04 6B 04 55 04 39 04 26 04 14 04 07 03 EE 03 D8 03 C0 03 B5 03 A9 03 9A 03 7D 03 68 03 51 03 42 03 31 03 20 03 07 02 F0 02 D8 02 C6 02 AA 02 90 02 68 02 45 02 1F 02 1F 01 D3 01 AE 01 8A 01 68 01 39 01 1B 01 01 00 EA 00 CE 00 BE 00 B1 00 A7 00 99 00 93 00 90 00 8E 00 8E 00 8E 00 90 00 92 00 91 00 91 00 92 00 92 00 90 00 91 00 92 00 93 00 92 00 91 00 91 00 92 00 91 00 91 00 91 00 90 00 91 00 91 00 91 00 91 00 92 00 92 00 91 00 91 00 90 00 90 00 91 00 92 00 92 00 92 00 91 00 90 00 92 00 91 00 91 00 92 00 92 00 92 00 92 00 91 00 91 00 90 00 90 00 92 00 90 00 91 00 92 00 92 00 91 00 91 00 92 00 92 00 92 00 92 00 91 00 91 00 92 00 91 00 91 00 91 00 92 00 92 00 92 00 92 00 91 00 91 00 91 00 91 00 92 00 92 00 92 00 92 00 92 00 92 00 91 00 90 00 8F 00 90 00 91 00 91 00 91 00 91 00 91 00 92 00 92 00 92 00 92 00 92 00 92 00 92 00 91 00 90 00 92 00 90 00 90 00 92 00 92 00 91 00

View File

@ -0,0 +1 @@
00 00 05 4D 07 E2 09 44 08 C6 07 FC 07 16 05 F4 05 05 03 E0 03 23 02 A3 02 9E 02 B3 02 B9 02 CE 02 DE 02 EF 02 FB 03 09 03 10 03 19 03 1E 03 23 03 28 03 29 03 29 03 2C 03 2C 03 2C 03 2E 03 31 03 31 03 32 03 31 03 32 03 30 03 2F 03 31 03 33 03 33 03 33 03 32 03 33 03 33 03 32 03 31 03 2F 03 2A 03 23 03 20 03 1F 03 1F 03 22 03 24 03 22 03 23 03 27 03 2B 03 32 03 39 03 47 03 55 03 6F 03 89 03 AF 03 D0 03 FF 04 2C 04 69 04 9D 04 E3 05 1E 05 61 05 9A 05 E1 06 1B 06 6A 06 A8 06 EE 07 18 07 41 07 5D 07 83 07 A3 07 CC 07 EA 08 0F 08 2A 08 4E 08 65 08 84 08 99 08 B0 08 C0 08 D8 08 E8 08 FB 09 09 09 1B 09 28 09 37 09 42 09 53 09 5D 09 68 09 72 09 80 09 8E 09 99 09 A2 09 AD 09 B7 09 C4 09 CE 09 DA 09 E4 09 F3 0A 00 0A 0E 0A 16 0A 20 0A 28 0A 35 0A 40 0A 4E 0A 57 0A 61 0A 69 0A 75 0A 7C 0A 96 0A A3 0A B6 0A C5 0A B8 0A C6 0A E0 0A ED 0A F6 0A FF 0B 0B 0B 16 0B 22 0B 2B 0B 33 0B 3C 0B 4A 0B 56 0B 65 0B 72 0B 81 0B 8F 0B 9E 0B AA 0B BC 0B C8 0B D8 0B E3 0B F1 0B FB 0C 08 0C 13 0C 23 0C 31 0C 41 0C 4E 0C 60 0C 6F 0C 7E 0C 88 0C 97 0C A5 0C B3 0C BD 0C C9 0C D5 0C E9 0C FA 0D 0E 0D 1A 0D 2C 0D 3A 0D 4A 0D 58 0D 69 0D 79 0D 89 0D 97 0D AA 0D B8 0D CE 0D DF 0D F3 0D FF 0E 13 0E 23 0E 34 0E 42 0E 55 0E 64 0E 79 0E 86 0E 98 0E A5 0E B7 0E C8 0E DD 0E ED 0E FF 0F 0B 0F 1B 0F 27 0F 33 0F 3D 0F 49 0F 54 0F 5F 0F 67 0F 6F 0F 77 0F 84 0F 8B 0F 93 0F 9C 0F A7 0F AE 0F B8 0F BF 0F C9 0F D0 0F D6 0F DF 0F E9 0F F2 0F FE 10 09 10 1A 10 27 10 35 10 41 10 4B 10 55 10 61 10 6C 10 7A 10 85 10 95 10 A4 10 B5 10 C6 10 D3 10 C6 10 5E 0F DD 0F 28 0E 9F 0E 09 0D 9A 0D 1A 0C BE 0C 69 0C 44 0C 64 0C 99 0C BB 0C CA 0C E8 0D 10 0D 33 0D 3A 0D 32 0D 2D 0D 1D 0D 08 0C E7 0C CD 0C AE 0C 97 0C 78 0C 63 0C 56 0C 4D 0C 3F 0C 33 0C 20 0C 12 0C 03 0B F7 0B DC 0B C6 0B B2 0B A2 0B 8D 0B 7B 0B 60 0B 52 0B 4A 0B 43 0B 32 0B 1A 0B 08 0B 03 0A FA 0A EE 0A DB 0A BD 0A B8 0A BC 0A C1 0A CA 0A A4 0A 99 0A 93 0A 8E 0A 7C 0A 5E 0A 4F 0A 4A 0A 3F 0A 31 0A 1B 0A 0B 09 FC 09 F4 09 E6 09 D4 09 BE 09 B1 09 A1 09 96 09 83 09 6F 09 57 09 49 09 3A 09 2A 09 11 08 FA 08 E5 08 D9 08 C4 08 B2 08 95 08 7E 08 6A 08 5B 08 45 08 2B 08 11 08 01 07 EE 07 DE 07 C1 07 A7 07 93 07 85 07 73 07 64 07 47 07 35 07 25 07 1A 07 06 06 F3 06 DD 06 D0 06 C4 06 B9 06 A7 06 96 06 86 06 7E 06 75 06 66 06 4E 06 3E 06 32 06 2A 06 19 06 08 05 F3 05 E6 05 DB 05 D0 05 BE 05 AC 05 96 05 8B 05 7E 05 72 05 5B 05 47 05 36 05 2B 05 1B 05 09 04 F1 04 E1 04 D2 04 C6 04 B2 04 9E 04 8A 04 7D 04 71 04 64 04 4B 04 38 04 21 04 13 04 01 03 F5 03 DB 03 C9 03 B3 03 A7 03 99 03 89 03 6F 03 59 03 35 03 35 03 23 03 0B 02 EA 02 D9 02 C2 02 A5 02 B8 02 A4 02 97 02 92 02 8A 02 88 02 86 02 86 02 86 02 86 02 85 02 83 02 83 02 81 02 80 02 80 02 7D 02 7B 02 7A 02 78 02 77 02 75 02 74 02 74 02 74 02 72 02 71 02 71 02 70 02 70 02 6F 02 6F 02 70 02 70 02 6F 02 6F 02 6F 02 6F 02 6F 02 70 02 70 02 70 02 71 02 71 02 72 02 72 02 74 02 76 02 74 02 74 02 74 02 75 02 75 02 75 02 75 02 75 02 76 02 76 02 76 02 76 02 75 02 75 02 76 02 77 02 74 02 74 02 74 02 76 02 75 02 74 02 74 02 76 02 75 02 74 02 74 02 76 02 76 02 75 02 75 02 75 02 74 02 75 02 75 02 74 02 76 02 76 02 75 02 75 02 75 02 75 02 76 02 76 02 75 02 75 02 74 02 74 02 75 02 75 02 74 02 74 02 74 02 74 02 75 02 75 02 76 02 75 02 74 02 74 02 74 02 74 02

View File

@ -0,0 +1 @@
00 08 00 27 00 36 00 56 00 68 00 68 00 6C 00 D7 01 6A 01 EB 02 4E 02 89 02 AE 02 DB 03 0F 03 3A 03 63 03 8B 03 BB 03 EA 04 15 04 34 04 50 04 65 04 7D 04 A2 04 BF 04 D5 04 EB 05 03 05 16 05 27 05 3D 05 49 05 4D 05 58 05 72 05 99 05 B3 05 BC 05 CB 05 F2 06 12 06 2E 06 3F 06 54 06 76 06 A0 06 C0 06 C2 06 BB 06 C6 06 F4 07 27 07 52 07 69 07 76 07 7C 07 9B 07 C0 07 E2 08 11 08 38 08 47 08 77 08 8F 08 B1 09 0A 08 F8 08 C6 08 E9 09 30 09 65 09 72 09 6B 09 6D 09 A5 09 F3 0A 11 0A 1D 0A 3A 0A 51 0A 6D 0A 95 0A C3 0A EC 0B 06 0B 15 0B 2A 0B 42 0B 54 0B 86 0B C7 0B FB 0C 08 0C 1D 0C 3E 0C 65 0C 7D 0C 75 0C 90 0C DE 0D 1A 0D 17 0D 15 0D 4D 0D 9E 0D E5 0E 10 0E 16 0E 19 0E 40 0E 6C 0E 86 0E A5 0E D0 0E F1 0F 01 0F 1C 0F 42 0F 5F 0F 89 0F A0 0F A2 0F B5 0F DC 0F F8 10 0B 10 23 10 43 10 5E 10 74 10 85 10 9B 10 BA 10 D8 10 F7 11 12 11 22 11 26 11 1F 11 2A 11 3B 11 40 11 49 11 60 11 6D 11 68 11 68 11 7C 11 9A 11 A6 11 A5 11 B9 11 DB 11 EB 11 F2 11 FF 12 1A 12 32 12 39 12 4A 12 80 12 94 12 A2 12 C9 12 F9 13 1E 13 2C 13 3A 13 4A 13 56 13 7D 13 B1 13 CA 13 E2 14 09 14 36 14 64 14 95 14 BF 14 87 12 8F 0D 98 09 93 08 2F 08 65 08 CD 08 93 07 B4 06 E9 06 C0 08 17 0A EF 0C 1E 0A CF 09 97 0A 3A 0B C7 0C 6E 0C 29 0C 30 0C A6 0C D3 0C C0 0C AB 0C 84 0C 6C 0C 26 0B B9 0B BB 0B E9 0B DB 0B A6 0B 5E 0B 40 0B 65 0B 9E 0B 71 0A F7 0A D2 0A FB 0B 09 0A EC 0A 85 0A 4C 0A 81 0A EA 0A DD 0A 21 09 9F 09 E3 0A 64 0A 71 0A 12 09 B8 09 BB 0A 0B 0A 60 0A 52 0A 08 09 C8 09 B5 0A 0B 0A 25 09 B8 09 56 09 78 09 CC 09 B2 09 3A 08 C0 08 CC 09 20 09 46 09 05 08 76 08 36 08 5D 08 88 08 86 08 44 07 C4 07 A1 07 E7 08 12 07 CA 07 55 07 2F 07 40 07 60 07 5B 07 0C 06 B3 06 A9 06 D0 06 D9 06 7C 06 22 06 23 06 5A 06 69 06 0D 05 7E 05 55 05 75 05 93 05 72 05 14 04 BC 04 AF 04 C8 04 CB 04 88 04 3D 04 28 04 3B 04 40 04 25 03 EC 03 C8 03 CE 03 E7 03 D4 03 82 03 51 03 55 03 77 03 85 03 4D 03 0D 03 01 03 10 03 18 03 0B 02 D8 02 A8 02 9D 02 A9 02 AD 02 7B 02 4C 02 38 02 3B 02 3D 02 1A 01 F5 01 D9 01 CF 01 D3 01 C2 01 9B 01 84 01 7D 01 7E 01 7B 01 5D 01 3A 01 1C 01 0C 01 06 00 FE 00 E5 00 C9 00 B3 00 A5 00 9C 00 8F 00 76 00 5D 00 4C 00 42 00 30 00 1D 00 18 00 16 00 17 00 16 00 14 00 16 00 1A 00 18 00 18 00 1A 00 1E 00 28 00 30 00 33 00 33 00 35 00 35 00 35 00 35 00 35 00 34 00 33 00 33 00 32 00 32 00 32 00 32 00 32 00 32 00 32 00 34 00 32 00 31 00 30 00 30 00 2F 00 2D 00 2B 00 2A 00 29 00 27 00 25 00 21 00 1D 00 19 00 15 00 11 00 0B 00 08 00 05 00 02 FF FF FF FF FF FF 00 00 FF FD 00 00 00 01 00 01 FF FE FF FF FF FE FF FC FF FF 00 01 00 01 00 00 FF FD FF FF 00 00 00 00 00 01 00 01 00 02 00 02 00 02 00 01 00 01 00 01 FF FF 00 02 00 02 00 00 00 00 00 00 00 01 00 03 00 03 00 03 00 04 00 04 00 04 00 02 00 03 00 05 00 02 00 04 00 06 00 07 00 04 00 05 00 04 00

View File

@ -1,19 +0,0 @@
#include "frmtest.h"
#include "ui_frmtest.h"
#include "qdebug.h"
frmTest::frmTest(QWidget *parent) : QWidget(parent), ui(new Ui::frmTest)
{
ui->setupUi(this);
this->initForm();
}
frmTest::~frmTest()
{
delete ui;
}
void frmTest::initForm()
{
}

View File

@ -1,25 +0,0 @@
#ifndef FRMTEST_H
#define FRMTEST_H
#include <QWidget>
namespace Ui {
class frmTest;
}
class frmTest : public QWidget
{
Q_OBJECT
public:
explicit frmTest(QWidget *parent = 0);
~frmTest();
private:
Ui::frmTest *ui;
private slots:
void initForm();
};
#endif // FRMTEST_H

View File

@ -0,0 +1,13 @@
FORMS += \
$$PWD/frmmain.ui \
$$PWD/frmmultiaxes.ui
HEADERS += \
$$PWD/frmmain.h \
$$PWD/frmmultiaxes.h \
$$PWD/iconhelper.h
SOURCES += \
$$PWD/frmmain.cpp \
$$PWD/frmmultiaxes.cpp \
$$PWD/iconhelper.cpp

View File

@ -26,7 +26,11 @@
#include "frmcolormap.h"
#include "frmfinancial.h"
#include "frmpolarplot.h"
#include "frmtest.h"
#include "frmaxistag.h"
#include "frminteraction.h"
#include "frmscrollbar.h"
#include "frmmultiaxes.h"
frmMain::frmMain(QWidget *parent) : QWidget(parent), ui(new Ui::frmMain)
{
@ -42,6 +46,13 @@ frmMain::~frmMain()
delete ui;
}
void frmMain::showEvent(QShowEvent *)
{
//滚动到底部
QScrollBar *bar = ui->scrollArea->verticalScrollBar();
bar->setValue(bar->maximum());
}
void frmMain::initForm()
{
ui->scrollArea->setFixedWidth(170);
@ -72,7 +83,10 @@ void frmMain::initWidget()
ui->stackedWidget->addWidget(new frmColorMap);
ui->stackedWidget->addWidget(new frmFinancial);
ui->stackedWidget->addWidget(new frmPolarPlot);
ui->stackedWidget->addWidget(new frmTest);
ui->stackedWidget->addWidget(new frmAxisTag);
ui->stackedWidget->addWidget(new frmInterAction);
ui->stackedWidget->addWidget(new frmScrollBar);
ui->stackedWidget->addWidget(new frmMultiAxes);
}
void frmMain::initNav()
@ -83,7 +97,7 @@ void frmMain::initNav()
<< "曲线条样式" << "日期数据图" << "纹理画刷图" << "双坐标曲线" << "对数曲线图"
<< "动态正弦图" << "环形曲线图" << "垂直柱状图" << "箱形盒须图" << "静态指示线"
<< "动态指示线" << "曲线样式图" << "高级坐标轴" << "颜色热力图" << "金融曲线图"
<< "南丁格尔图" << "测试曲线";
<< "南丁格尔图" << "坐标轴指示" << "相互作用图" << "滚动条曲线" << "多坐标轴";
//自动生成按钮
for (int i = 0; i < names.count(); i++) {

View File

@ -16,6 +16,9 @@ public:
explicit frmMain(QWidget *parent = 0);
~frmMain();
protected:
void showEvent(QShowEvent *);
private:
Ui::frmMain *ui;

View File

@ -0,0 +1,186 @@
#include "frmmultiaxes.h"
#include "ui_frmmultiaxes.h"
#include "qfile.h"
#include "qdebug.h"
frmMultiAxes::frmMultiAxes(QWidget *parent) : QWidget(parent), ui(new Ui::frmMultiAxes)
{
ui->setupUi(this);
this->initForm();
}
frmMultiAxes::~frmMultiAxes()
{
delete ui;
}
void frmMultiAxes::initForm()
{
//Y坐标轴的数量
count = 4;
this->initPlot(ui->customPlot1, QCPAxis::atLeft, count);
this->initPlot(ui->customPlot2, QCPAxis::atRight, count);
this->loadPlot(ui->customPlot1, QCPAxis::atLeft, count);
this->loadPlot(ui->customPlot2, QCPAxis::atRight, count);
for (int i = 0; i < count; ++i) {
this->loadData(ui->customPlot1, i);
this->loadData(ui->customPlot2, i);
}
}
void frmMultiAxes::selectionChangedByUser()
{
//联动处理 坐标轴、刻度尺、画布曲线 选中一样则选中所有
QCustomPlot *customPlot = (QCustomPlot *)sender();
QCPAxis::AxisType type;
if (customPlot == ui->customPlot1) {
type = QCPAxis::atLeft;
} else if (customPlot == ui->customPlot2) {
type = QCPAxis::atRight;
}
int selecteIndex = -1;
for (int i = 0; i < count; ++i) {
//获取对应的坐标轴
QCPAxis *axis = customPlot->axisRect()->axis(type, i);
//获取对应的画布曲线
QCPGraph *graph = customPlot->graph(i);
//判断 坐标轴、刻度尺、画布曲线 是否选中了一个
if (axis->selectedParts().testFlag(QCPAxis::spAxis) || axis->selectedParts().testFlag(QCPAxis::spTickLabels) || graph->selected()) {
//设置坐标轴、刻度尺同时选中
axis->setSelectedParts(QCPAxis::spAxis | QCPAxis::spTickLabels);
//设置画布曲线选中
graph->setSelection(QCPDataSelection(graph->data()->dataRange()));
selecteIndex = i;
break;
}
}
//存在选中则设置当前选中的可拖动和缩放
//不存在则设置所有的可拖动和缩放
QCPAxisRect *axisRect = customPlot->axisRect();
if (selecteIndex >= 0) {
QCPAxis *axis = axisRect->axis(type, selecteIndex);
axisRect->setRangeDragAxes(customPlot->xAxis, axis);
axisRect->setRangeZoomAxes(customPlot->xAxis, axis);
} else {
#ifndef qcustomplot_v1_3
axisRect->setRangeDragAxes(axisRect->axes());
axisRect->setRangeZoomAxes(axisRect->axes());
#endif
}
}
void frmMultiAxes::initPlot(QCustomPlot *customPlot, const QCPAxis::AxisType &type, int count)
{
//选中对应的坐标轴或者画布等
connect(customPlot, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChangedByUser()));
//connect(customPlot->yAxis2, SIGNAL(rangeChanged(QCPRange)), customPlot->yAxis, SLOT(setRange(QCPRange)));
if (type == QCPAxis::atLeft) {
customPlot->yAxis->setVisible(true);
customPlot->yAxis2->setVisible(false);
} else if (type == QCPAxis::atRight) {
customPlot->yAxis->setVisible(false);
customPlot->yAxis2->setVisible(true);
}
//添加多个坐标轴
for (int i = 0; i < count - 1; ++i) {
customPlot->axisRect()->addAxis(type);
}
//设置边距、范围值、网格可见、刻度数量等
for (int i = 0; i < count; ++i) {
QCPAxis *axis = customPlot->axisRect()->axis(type, i);
axis->setPadding(10);
axis->setRange(0, 1);
axis->grid()->setVisible(true);
//axis->grid()->setSubGridVisible(true);
axis->ticker()->setTickCount(10);
}
//设置初始范围值
customPlot->xAxis->setRange(0.5, 10.5);
//设置刻度数量
customPlot->xAxis->ticker()->setTickCount(10);
//设置可拖动和缩放选中等
customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | QCP::iSelectPlottables);
}
void frmMultiAxes::loadPlot(QCustomPlot *customPlot, const QCPAxis::AxisType &type, int count)
{
//颜色集合
QList<QColor> colors;
colors << QColor(211, 78, 78) << QColor(29, 185, 242) << QColor(170, 162, 119) << QColor(255, 192, 1);
colors << QColor(0, 176, 180) << QColor(0, 113, 193) << QColor(255, 192, 0);
colors << QColor(72, 103, 149) << QColor(185, 87, 86) << QColor(0, 177, 125);
colors << QColor(214, 77, 84) << QColor(71, 164, 233) << QColor(34, 163, 169);
colors << QColor(59, 123, 156) << QColor(162, 121, 197) << QColor(72, 202, 245);
colors << QColor(0, 150, 121) << QColor(111, 9, 176) << QColor(250, 170, 20);
for (int i = 0; i < count; ++i) {
//分配一种颜色
QColor color;
if (i < colors.count()) {
color = colors.at(i);
}
QPen pen(color);
QCPAxis *axis = customPlot->axisRect()->axis(type, i);
//刻度文本颜色
axis->setTickLabelColor(color);
//刻度线条颜色
axis->setBasePen(pen);
//大刻度尺颜色
axis->setTickPen(pen);
//小刻度尺颜色
axis->setSubTickPen(pen);
//画布线条颜色
QCPGraph *graph = customPlot->addGraph(customPlot->xAxis, axis);
graph->setPen(pen);
}
}
void frmMultiAxes::loadData(QCustomPlot *customPlot, int index)
{
//下面演示从文本文件读取数据,具体格式可以自行打开文件查看
//真实场景自己准备数据调用 setData 即可
int flag = index > 2 ? 0 : index;
QString fileName = QString(":/data/data%1.txt").arg(flag);
QFile file(fileName);
if (file.open(QFile::ReadOnly | QIODevice::Text)) {
QString value = file.readAll();
file.close();
QVector<double> keys, values;
QStringList list = value.split(" ");
int len = list.length();
//如果不是2的倍数则长度要减去1
if (len % 2 != 0) {
len = (len - 1);
}
for (int i = 0; i < len / 2; i++) {
keys << i;
}
//每两个16进制数字组合成一个数字
for (int i = 0; i < len; i = i + 2) {
QString strHex = QString("%1%2").arg(list.at(i)).arg(list.at(i + 1));
qint16 value = strHex.toUShort(NULL, 16);
values << value;
}
//获取对应画布
QCPGraph *graph = customPlot->graph(index);
//设置数据到画布
graph->setData(keys, values);
//自适应坐标轴
graph->rescaleAxes();
}
}

View File

@ -0,0 +1,36 @@
#ifndef FRMMULTIAXES_H
#define FRMMULTIAXES_H
#include <QWidget>
#include "qcustomplot.h"
namespace Ui {
class frmMultiAxes;
}
class frmMultiAxes : public QWidget
{
Q_OBJECT
public:
explicit frmMultiAxes(QWidget *parent = 0);
~frmMultiAxes();
private:
Ui::frmMultiAxes *ui;
int count;
private slots:
//初始化界面数据
void initForm();
//用户按下区域改变
void selectionChangedByUser();
//初始化图表控件
void initPlot(QCustomPlot *customPlot, const QCPAxis::AxisType &type, int count);
//加载图表控件
void loadPlot(QCustomPlot *customPlot, const QCPAxis::AxisType &type, int count);
//加载数据到图表控件
void loadData(QCustomPlot *customPlot, int index);
};
#endif // FRMMULTIAXES_H

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>frmMultiAxes</class>
<widget class="QWidget" name="frmMultiAxes">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCustomPlot" name="customPlot1" native="true"/>
</item>
<item>
<widget class="QCustomPlot" name="customPlot2" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QCustomPlot</class>
<extends>QWidget</extends>
<header location="global">qcustomplot.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -15,6 +15,7 @@ frmAdvancedAxes::~frmAdvancedAxes()
void frmAdvancedAxes::initForm()
{
#ifndef qcustomplot_v1_3
// configure axis rect:
ui->customPlot->plotLayout()->clear(); // clear default axis rect so we can start from scratch
QCPAxisRect *wideAxisRect = new QCPAxisRect(ui->customPlot);
@ -109,4 +110,5 @@ void frmAdvancedAxes::initForm()
subBars->keyAxis()->setTicker(intTicker);
ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
#endif
}

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -15,6 +15,7 @@ frmBarChart::~frmBarChart()
void frmBarChart::initForm()
{
#ifndef qcustomplot_v1_3
// set dark background gradient:
QLinearGradient gradient(0, 0, 0, 400);
gradient.setColorAt(0, QColor(90, 90, 90));
@ -96,4 +97,5 @@ void frmBarChart::initForm()
legendFont.setPointSize(10);
ui->customPlot->legend->setFont(legendFont);
ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
#endif
}

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -15,6 +15,7 @@ frmDate::~frmDate()
void frmDate::initForm()
{
#ifndef qcustomplot_v1_3
// set locale to english, so we get english month names:
ui->customPlot->setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom));
// seconds of current time, we'll use it as starting point in time for data:
@ -68,4 +69,5 @@ void frmDate::initForm()
ui->customPlot->legend->setVisible(true);
ui->customPlot->legend->setBrush(QColor(255, 255, 255, 150));
ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
#endif
}

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -7,7 +7,6 @@ FORMS += \
$$PWD/frmitem.ui \
$$PWD/frmlinestyle.ui \
$$PWD/frmlogarithmic.ui \
$$PWD/frmmain.ui \
$$PWD/frmmultiaxis.ui \
$$PWD/frmparametriccurve.ui \
$$PWD/frmpolarplot.ui \
@ -20,7 +19,6 @@ FORMS += \
$$PWD/frmsincscatter.ui \
$$PWD/frmstatistical.ui \
$$PWD/frmstyled.ui \
$$PWD/frmtest.ui \
$$PWD/frmtexturebrush.ui
HEADERS += \
@ -32,7 +30,6 @@ HEADERS += \
$$PWD/frmitem.h \
$$PWD/frmlinestyle.h \
$$PWD/frmlogarithmic.h \
$$PWD/frmmain.h \
$$PWD/frmmultiaxis.h \
$$PWD/frmparametriccurve.h \
$$PWD/frmpolarplot.h \
@ -45,7 +42,6 @@ HEADERS += \
$$PWD/frmsincscatter.h \
$$PWD/frmstatistical.h \
$$PWD/frmstyled.h \
$$PWD/frmtest.h \
$$PWD/frmtexturebrush.h
SOURCES += \
@ -57,7 +53,6 @@ SOURCES += \
$$PWD/frmitem.cpp \
$$PWD/frmlinestyle.cpp \
$$PWD/frmlogarithmic.cpp \
$$PWD/frmmain.cpp \
$$PWD/frmmultiaxis.cpp \
$$PWD/frmparametriccurve.cpp \
$$PWD/frmpolarplot.cpp \
@ -70,5 +65,4 @@ SOURCES += \
$$PWD/frmsincscatter.cpp \
$$PWD/frmstatistical.cpp \
$$PWD/frmstyled.cpp \
$$PWD/frmtest.cpp \
$$PWD/frmtexturebrush.cpp

View File

@ -20,7 +20,7 @@ void frmFinancial::initForm()
// generate two sets of random walk data (one for candlestick and one for ohlc chart):
int n = 500;
QVector<double> time(n), value1(n), value2(n);
QDateTime start(QDate(2014, 6, 11), QTime(0, 0));
QDateTime start(QDate(2022, 1, 1), QTime(0, 0));
start.setTimeSpec(Qt::UTC);
double startTime = start.toMSecsSinceEpoch() / 1000.0;
double binSize = 3600 * 24; // bin data in 1 day intervals

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -15,6 +15,8 @@ frmPolarPlot::~frmPolarPlot()
void frmPolarPlot::initForm()
{
//南丁格尔图示 2.1 版本新增加的
#ifdef qcustomplot_v2_1
// Warning: Polar plots are a still a tech preview
ui->customPlot->plotLayout()->clear();
@ -50,4 +52,5 @@ void frmPolarPlot::initForm()
angularAxis->setRange(0, 360);
angularAxis->radialAxis()->setRange(-10, 10);
#endif
}

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -1,5 +1,6 @@
#include "frmscatterstyle.h"
#include "ui_frmscatterstyle.h"
#include "qmetaobject.h"
#include "qdebug.h"
frmScatterStyle::frmScatterStyle(QWidget *parent) : QWidget(parent), ui(new Ui::frmScatterStyle)
@ -18,6 +19,7 @@ void frmScatterStyle::initForm()
ui->customPlot->legend->setVisible(true);
ui->customPlot->legend->setFont(QFont("Helvetica", 9));
ui->customPlot->legend->setRowSpacing(-3);
QVector<QCPScatterStyle::ScatterShape> shapes;
shapes << QCPScatterStyle::ssCross;
shapes << QCPScatterStyle::ssPlus;
@ -49,7 +51,13 @@ void frmScatterStyle::initForm()
ui->customPlot->graph()->setData(x, y);
ui->customPlot->graph()->rescaleAxes(true);
ui->customPlot->graph()->setPen(pen);
ui->customPlot->graph()->setName(QCPScatterStyle::staticMetaObject.enumerator(QCPScatterStyle::staticMetaObject.indexOfEnumerator("ScatterShape")).valueToKey(shapes.at(i)));
//枚举值转字符串
QMetaObject metaObject = QCPScatterStyle::staticMetaObject;
QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("ScatterShape"));
QString name = metaEnum.valueToKey(shapes.at(i));
ui->customPlot->graph()->setName(name);
ui->customPlot->graph()->setLineStyle(QCPGraph::lsLine);
// set scatter style:
if (shapes.at(i) != QCPScatterStyle::ssCustom) {

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>

View File

@ -0,0 +1,112 @@
/***************************************************************************
** **
** QCustomPlot, an easy to use, modern plotting widget for Qt **
** Copyright (C) 2011-2021 Emanuel Eichhammer **
** **
** This program is free software: you can redistribute it and/or modify **
** it under the terms of the GNU General Public License as published by **
** the Free Software Foundation, either version 3 of the License, or **
** (at your option) any later version. **
** **
** This program is distributed in the hope that it will be useful, **
** but WITHOUT ANY WARRANTY; without even the implied warranty of **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
** GNU General Public License for more details. **
** **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see http://www.gnu.org/licenses/. **
** **
****************************************************************************
** Author: Emanuel Eichhammer **
** Website/Contact: http://www.qcustomplot.com/ **
** Date: 29.03.21 **
** Version: 2.1.0 **
****************************************************************************/
#include "axistag.h"
AxisTag::AxisTag(QCPAxis *parentAxis) :
QObject(parentAxis),
mAxis(parentAxis)
{
// The dummy tracer serves here as an invisible anchor which always sticks to the right side of
// the axis rect
mDummyTracer = new QCPItemTracer(mAxis->parentPlot());
mDummyTracer->setVisible(false);
mDummyTracer->position->setTypeX(QCPItemPosition::ptAxisRectRatio);
mDummyTracer->position->setTypeY(QCPItemPosition::ptPlotCoords);
mDummyTracer->position->setAxisRect(mAxis->axisRect());
mDummyTracer->position->setAxes(0, mAxis);
mDummyTracer->position->setCoords(1, 0);
// the arrow end (head) is set to move along with the dummy tracer by setting it as its parent
// anchor. Its coordinate system (setCoords) is thus pixels, and this is how the needed horizontal
// offset for the tag of the second y axis is achieved. This horizontal offset gets dynamically
// updated in AxisTag::updatePosition. the arrow "start" is simply set to have the "end" as parent
// anchor. It is given a horizontal offset to the right, which results in a 15 pixel long arrow.
mArrow = new QCPItemLine(mAxis->parentPlot());
mArrow->setLayer("overlay");
mArrow->setClipToAxisRect(false);
mArrow->setHead(QCPLineEnding::esSpikeArrow);
mArrow->end->setParentAnchor(mDummyTracer->position);
mArrow->start->setParentAnchor(mArrow->end);
mArrow->start->setCoords(15, 0);
// The text label is anchored at the arrow start (tail) and has its "position" aligned at the
// left, and vertically centered to the text label box.
mLabel = new QCPItemText(mAxis->parentPlot());
mLabel->setLayer("overlay");
mLabel->setClipToAxisRect(false);
mLabel->setPadding(QMargins(3, 0, 3, 0));
mLabel->setBrush(QBrush(Qt::white));
mLabel->setPen(QPen(Qt::blue));
mLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignVCenter);
mLabel->position->setParentAnchor(mArrow->start);
}
AxisTag::~AxisTag()
{
if (mDummyTracer) {
mDummyTracer->parentPlot()->removeItem(mDummyTracer);
}
if (mArrow) {
mArrow->parentPlot()->removeItem(mArrow);
}
if (mLabel) {
mLabel->parentPlot()->removeItem(mLabel);
}
}
void AxisTag::setPen(const QPen &pen)
{
mArrow->setPen(pen);
mLabel->setPen(pen);
}
void AxisTag::setBrush(const QBrush &brush)
{
mLabel->setBrush(brush);
}
void AxisTag::setText(const QString &text)
{
mLabel->setText(text);
}
void AxisTag::updatePosition(double value)
{
// since both the arrow and the text label are chained to the dummy tracer (via anchor
// parent-child relationships) it is sufficient to update the dummy tracer coordinates. The
// Horizontal coordinate type was set to ptAxisRectRatio so to keep it aligned at the right side
// of the axis rect, it is always kept at 1. The vertical coordinate type was set to
// ptPlotCoordinates of the passed parent axis, so the vertical coordinate is set to the new
// value.
mDummyTracer->position->setCoords(1, value);
// We want the arrow head to be at the same horizontal position as the axis backbone, even if
// the axis has a certain offset from the axis rect border (like the added second y axis). Thus we
// set the horizontal pixel position of the arrow end (head) to the axis offset (the pixel
// distance to the axis rect border). This works because the parent anchor of the arrow end is
// the dummy tracer, which, as described earlier, is tied to the right axis rect border.
mArrow->end->setCoords(mAxis->offset(), 0);
}

View File

@ -0,0 +1,60 @@
/***************************************************************************
** **
** QCustomPlot, an easy to use, modern plotting widget for Qt **
** Copyright (C) 2011-2021 Emanuel Eichhammer **
** **
** This program is free software: you can redistribute it and/or modify **
** it under the terms of the GNU General Public License as published by **
** the Free Software Foundation, either version 3 of the License, or **
** (at your option) any later version. **
** **
** This program is distributed in the hope that it will be useful, **
** but WITHOUT ANY WARRANTY; without even the implied warranty of **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
** GNU General Public License for more details. **
** **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see http://www.gnu.org/licenses/. **
** **
****************************************************************************
** Author: Emanuel Eichhammer **
** Website/Contact: http://www.qcustomplot.com/ **
** Date: 29.03.21 **
** Version: 2.1.0 **
****************************************************************************/
#ifndef AXISTAG_H
#define AXISTAG_H
#include <QObject>
#include "qcustomplot.h"
class AxisTag : public QObject
{
Q_OBJECT
public:
explicit AxisTag(QCPAxis *parentAxis);
virtual ~AxisTag();
// setters:
void setPen(const QPen &pen);
void setBrush(const QBrush &brush);
void setText(const QString &text);
// getters:
QPen pen() const { return mLabel->pen(); }
QBrush brush() const { return mLabel->brush(); }
QString text() const { return mLabel->text(); }
// other methods:
void updatePosition(double value);
protected:
QCPAxis *mAxis;
QPointer<QCPItemTracer> mDummyTracer;
QPointer<QCPItemLine> mArrow;
QPointer<QCPItemText> mLabel;
};
#endif // AXISTAG_H

View File

@ -0,0 +1,67 @@
#include "frmaxistag.h"
#include "ui_frmaxistag.h"
#include "qdebug.h"
frmAxisTag::frmAxisTag(QWidget *parent) : QWidget(parent), ui(new Ui::frmAxisTag)
{
ui->setupUi(this);
this->initForm();
}
frmAxisTag::~frmAxisTag()
{
delete ui;
}
void frmAxisTag::initForm()
{
mPlot = ui->customPlot;
// configure plot to have two right axes:
mPlot->yAxis->setTickLabels(false);
connect(mPlot->yAxis2, SIGNAL(rangeChanged(QCPRange)), mPlot->yAxis, SLOT(setRange(QCPRange))); // left axis only mirrors inner right axis
mPlot->yAxis2->setVisible(true);
mPlot->axisRect()->addAxis(QCPAxis::atRight);
mPlot->axisRect()->axis(QCPAxis::atRight, 0)->setPadding(30); // add some padding to have space for tags
mPlot->axisRect()->axis(QCPAxis::atRight, 1)->setPadding(30); // add some padding to have space for tags
// create graphs:
mGraph1 = mPlot->addGraph(mPlot->xAxis, mPlot->axisRect()->axis(QCPAxis::atRight, 0));
mGraph2 = mPlot->addGraph(mPlot->xAxis, mPlot->axisRect()->axis(QCPAxis::atRight, 1));
mGraph1->setPen(QPen(QColor(250, 120, 0)));
mGraph2->setPen(QPen(QColor(0, 180, 60)));
// create tags with newly introduced AxisTag class (see axistag.h/.cpp):
mTag1 = new AxisTag(mGraph1->valueAxis());
mTag1->setPen(mGraph1->pen());
mTag2 = new AxisTag(mGraph2->valueAxis());
mTag2->setPen(mGraph2->pen());
connect(&mDataTimer, SIGNAL(timeout()), this, SLOT(timerSlot()));
mDataTimer.start(40);
}
void frmAxisTag::timerSlot()
{
// calculate and add a new data point to each graph:
int count1 = mGraph1->dataCount();
mGraph1->addData(count1, qSin(count1 / 50.0) + qSin(count1 / 50.0 / 0.3843) * 0.25);
int count2 = mGraph2->dataCount();
mGraph2->addData(count2, qCos(count2 / 50.0) + qSin(count2 / 50.0 / 0.4364) * 0.15);
// make key axis range scroll with the data:
mPlot->xAxis->rescale();
mGraph1->rescaleValueAxis(false, true);
mGraph2->rescaleValueAxis(false, true);
mPlot->xAxis->setRange(mPlot->xAxis->range().upper, 100, Qt::AlignRight);
// update the vertical axis tag positions and texts to match the rightmost data point of the graphs:
double graph1Value = mGraph1->dataMainValue(mGraph1->dataCount() - 1);
double graph2Value = mGraph2->dataMainValue(mGraph2->dataCount() - 1);
mTag1->updatePosition(graph1Value);
mTag2->updatePosition(graph2Value);
mTag1->setText(QString::number(graph1Value, 'f', 2));
mTag2->setText(QString::number(graph2Value, 'f', 2));
mPlot->replot();
}

View File

@ -0,0 +1,34 @@
#ifndef FRMAXISTAG_H
#define FRMAXISTAG_H
#include <QWidget>
#include "qcustomplot.h"
#include "axistag.h"
namespace Ui {
class frmAxisTag;
}
class frmAxisTag : public QWidget
{
Q_OBJECT
public:
explicit frmAxisTag(QWidget *parent = 0);
~frmAxisTag();
private:
Ui::frmAxisTag *ui;
QCustomPlot *mPlot;
QPointer<QCPGraph> mGraph1;
QPointer<QCPGraph> mGraph2;
AxisTag *mTag1;
AxisTag *mTag2;
QTimer mDataTimer;
private slots:
void initForm();
void timerSlot();
};
#endif // FRMAXISTAG_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>frmTest</class>
<widget class="QWidget" name="frmTest">
<class>frmAxisTag</class>
<widget class="QWidget" name="frmAxisTag">
<property name="geometry">
<rect>
<x>0</x>
@ -14,18 +14,6 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCustomPlot" name="customPlot" native="true"/>
</item>
@ -35,7 +23,7 @@
<customwidget>
<class>QCustomPlot</class>
<extends>QWidget</extends>
<header location="global">qcustomplot.h</header>
<header>qcustomplot.h</header>
<container>1</container>
</customwidget>
</customwidgets>

Some files were not shown because too many files have changed in this diff Show More