How to use gnuPlot in wxWidget project  [SOLVED]

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

How to use gnuPlot in wxWidget project

Postby TSib » Thu Jun 16, 2016 8:35 am

Hi,
I am working on project in which I want to plot graph. I use WxWidgets to create the GUI. My goal is to display a graph on a wxAuiNotebook page. After a long time to look for a library to deal with graph, I found that gnuPlot works well. So my question is "How can use gnuplot to display graph in a wxAuiNotebook page?" Or is there other libraries? Thanks in advance

Best regards,

S.T.

User avatar
doublemax
Moderator
Moderator
Posts: 12818
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to use gnuPlot in wxWidget project

Postby doublemax » Thu Jun 16, 2016 8:49 am

I don't know gnuPlot, so i can't tell how hard it would be to use it from inside wxWidgets.

Depending on what kind of graph you need, check out wxFreeChart and wxMathPlot first:
http://wxcode.sourceforge.net/components/freechart/
http://wxmathplot.sourceforge.net/
Use the source, Luke!

iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 263
Joined: Tue Mar 19, 2013 8:52 pm

Re: How to use gnuPlot in wxWidget project

Postby iwbnwif » Thu Jun 16, 2016 8:55 am

If you are using a newer version of wxWidgets (I think >= 3.0) and you want to use wxFreeChart, then you might like to try this version which has some bug fixes:

https://github.com/iwbnwif/wxFreeChart
wxWidgets 3.10, TDM MinGW64 5.1.0, g++ 4.8.2, Ubuntu 16.04LTS, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.

TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

Re: How to use gnuPlot in wxWidget project

Postby TSib » Thu Jun 16, 2016 9:32 am

Thanks for your answers. In fact I want to display mainly curves and histogram. Concerning the "wxFreeChart", is still maintained? I found that wxArd2D works well; What do you think about.

S. T.

iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 263
Joined: Tue Mar 19, 2013 8:52 pm

Re: How to use gnuPlot in wxWidget project

Postby iwbnwif » Thu Jun 16, 2016 11:53 am

Concerning the "wxFreeChart", is still maintained?


No, it is not actively maintained. PB and myself have made some recent changes to fix bugs and improve performance, but no real active development work.

That said, depending on what you need, it does what it does quite well and is documented. Also you are welcome to report any issues or suggestions you may have.
wxWidgets 3.10, TDM MinGW64 5.1.0, g++ 4.8.2, Ubuntu 16.04LTS, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.

TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

Re: How to use gnuPlot in wxWidget project

Postby TSib » Thu Jun 16, 2016 2:46 pm

Thank you for your answer. Finally I will use wxFreeChart. Concerning GnuPlot, it seems to be used as terminal not as library that we can integrate in a wxWidgets project. Thanks!

best regards,

S.T.

TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

Re: How to use gnuPlot in wxWidget project

Postby TSib » Thu Jun 16, 2016 3:24 pm

I try to build "wxFreeChart" with MinGW (on Eclipse) like this :

Code: Select all

mingw32-make -f makefile.gcc WX_DIR=D:\Worskspace\Libs\wxWidgets-3.1.0 WX_UNICODE=1 WX_DEBUG=1 WX_SHARED=1 SHARED=1

but some errors occur :

g++ -shared -fPIC -o ..\lib\gcc_dll\wxcode_msw28ud_freechart.dll gccmswud_dll\wx
freechart_dll_legend.o gccmswud_dll\wxfreechart_dll_pieplot.o gccmswud_dll\wxfre
echart_dll_art.o gccmswud_dll\wxfreechart_dll_multiplot.o gccmswud_dll\wxfreecha
rt_dll_ganttdataset.o gccmswud_dll\wxfreechart_dll_ganttsimpledataset.o gccmswud
_dll\wxfreechart_dll_ganttplot.o gccmswud_dll\wxfreechart_dll_ganttrenderer.o gc
cmswud_dll\wxfreechart_dll_tooltips.o gccmswud_dll\wxfreechart_dll_plot.o gccmsw
ud_dll\wxfreechart_dll_renderer.o gccmswud_dll\wxfreechart_dll_title.o gccmswud_
dll\wxfreechart_dll_barrenderer.o gccmswud_dll\wxfreechart_dll_barplot.o gccmswu
d_dll\wxfreechart_dll_marker.o gccmswud_dll\wxfreechart_dll_chart.o gccmswud_dll
\wxfreechart_dll_labelaxis.o gccmswud_dll\wxfreechart_dll_logarithmicnumberaxis.
o gccmswud_dll\wxfreechart_dll_compdateaxis.o gccmswud_dll\wxfreechart_dll_julia
ndateaxis.o gccmswud_dll\wxfreechart_dll_axis.o gccmswud_dll\wxfreechart_dll_num
beraxis.o gccmswud_dll\wxfreechart_dll_categoryaxis.o gccmswud_dll\wxfreechart_d
ll_dateaxis.o gccmswud_dll\wxfreechart_dll_axisplot.o gccmswud_dll\wxfreechart_d
ll_areadraw.o gccmswud_dll\wxfreechart_dll_bubbleplot.o gccmswud_dll\wxfreechart
_dll_xyzdataset.o gccmswud_dll\wxfreechart_dll_xyzrenderer.o gccmswud_dll\wxfree
chart_dll_polynom.o gccmswud_dll\wxfreechart_dll_sinefunction.o gccmswud_dll\wxf
reechart_dll_timeseriesdataset.o gccmswud_dll\wxfreechart_dll_xyplot.o gccmswud_
dll\wxfreechart_dll_xyarearenderer.o gccmswud_dll\wxfreechart_dll_xydynamicdatas
et.o gccmswud_dll\wxfreechart_dll_vectordataset.o gccmswud_dll\wxfreechart_dll_x
yhistorenderer.o gccmswud_dll\wxfreechart_dll_xyrenderer.o gccmswud_dll\wxfreech
art_dll_xydataset.o gccmswud_dll\wxfreechart_dll_xysimpledataset.o gccmswud_dll\
wxfreechart_dll_xylinerenderer.o gccmswud_dll\wxfreechart_dll_juliantimeseriesda
taset.o gccmswud_dll\wxfreechart_dll_ohlcsimpledataset.o gccmswud_dll\wxfreechar
t_dll_ohlcrenderer.o gccmswud_dll\wxfreechart_dll_ohlcbarrenderer.o gccmswud_dll
\wxfreechart_dll_ohlcplot.o gccmswud_dll\wxfreechart_dll_ohlccandlestickrenderer
.o gccmswud_dll\wxfreechart_dll_movingaverage.o gccmswud_dll\wxfreechart_dll_ohl
cdataset.o gccmswud_dll\wxfreechart_dll_categorydataset.o gccmswud_dll\wxfreecha
rt_dll_categoryrenderer.o gccmswud_dll\wxfreechart_dll_categorysimpledataset.o g
ccmswud_dll\wxfreechart_dll_symbol.o gccmswud_dll\wxfreechart_dll_dataset.o gccm
swud_dll\wxfreechart_dll_chartsplitpanel.o gccmswud_dll\wxfreechart_dll_colorsch
eme.o gccmswud_dll\wxfreechart_dll_zoompan.o gccmswud_dll\wxfreechart_dll_crossh
air.o gccmswud_dll\wxfreechart_dll_chartpanel.o -mthreads -LD:\Worskspace\Libs\
wxWidgets-3.1.0\lib\gcc_dll -g -L..\lib\gcc_dll -Wl,--out-implib=..\lib\gcc_dll\
libwxcode_msw28ud_freechart.a -lwxmsw28ud_core -lwxbase28ud -lwxtiffd -lwxjpeg
d -lwxpngd -lwxzlibd -lwxregexud -lwxexpatd -lkernel32 -luser32 -lgdi32 -lcomdlg
32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -l
advapi32 -lwsock32 -lodbc32
c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/ld.exe: cannot fin
d -lwxmsw28ud_core
c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/ld.exe: cannot fin
d -lwxbase28ud
collect2.exe: error: ld returned 1 exit status
makefile.gcc:364: recipe for target '..\lib\gcc_dll\wxcode_msw28ud_freechart.dll
' failed
mingw32-make: *** [..\lib\gcc_dll\wxcode_msw28ud_freechart.dll] Error 1



It seems that the maker uses the libraries of wxWidgets 2.8. However I use wxWidgets 3.1.0. How can I solve this problem. Thanks you in advance.

S. T.

TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

Re: How to use gnuPlot in wxWidget project

Postby TSib » Thu Jun 16, 2016 3:58 pm

I solved my problem by adding the option "VERSION" like this :

Code: Select all

mingw32-make -f makefile.gcc WX_DIR=%WxLIBS% WX_UNICODE=1 WX_DEBUG=1 WX_SHARED=1 WX_VERSION=31 SHARED=1

However another problem occur :

gccmswud_dll\wxfreechart_dll_chartsplitpanel.o: In function `ZN17wxChartSplitPan
elC2EP8wxWindowiRK7wxPointRK6wxSize':
D:\Worskspace\Libs\wxFreeChart-master\wxFreeChart-master\build/../src/chartsplit
panel.cpp:17: undefined reference to `_imp___ZN12wxAuiManagerC1EP8wxWindowj'
D:\Worskspace\Libs\wxFreeChart-master\wxFreeChart-master\build/../src/chartsplit
panel.cpp:19: undefined reference to `_imp___ZN12wxAuiManager6UpdateEv'
gccmswud_dll\wxfreechart_dll_chartsplitpanel.o: In function `ZN17wxChartSplitPan
el7AddPlotEP4Plotib':
D:\Worskspace\Libs\wxFreeChart-master\wxFreeChart-master\build/../src/chartsplit
panel.cpp:50: undefined reference to `_imp___ZN12wxAuiManager7AddPaneEP8wxWindow
RK13wxAuiPaneInfo'
D:\Worskspace\Libs\wxFreeChart-master\wxFreeChart-master\build/../src/chartsplit
panel.cpp:52: undefined reference to `_imp___ZN12wxAuiManager6UpdateEv'
gccmswud_dll\wxfreechart_dll_chartsplitpanel.o: In function `ZN13wxAuiPaneInfoC1
Ev':
D:/Worskspace/Libs/wxWidgets-3.1.0/include/wx/aui/framemanager.h:151: undefined
reference to `_imp___ZN20wxAuiPaneButtonArrayD1Ev'
gccmswud_dll\wxfreechart_dll_chartsplitpanel.o: In function `ZN13wxAuiPaneInfoD1
Ev':
D:/Worskspace/Libs/wxWidgets-3.1.0/include/wx/aui/framemanager.h:169: undefined
reference to `_imp___ZN20wxAuiPaneButtonArrayD1Ev'
gccmswud_dll\wxfreechart_dll_chartsplitpanel.o: In function `ZN13wxAuiPaneInfoC1
ERKS_':
D:/Worskspace/Libs/wxWidgets-3.1.0/include/wx/aui/framemanager.h:190: undefined
reference to `_imp___ZN20wxAuiPaneButtonArrayaSERKS_'
D:/Worskspace/Libs/wxWidgets-3.1.0/include/wx/aui/framemanager.h:173: undefined
reference to `_imp___ZN20wxAuiPaneButtonArrayD1Ev'
gccmswud_dll\wxfreechart_dll_chartsplitpanel.o: In function `ZN13wxAuiPaneInfoaS
ERKS_':
D:/Worskspace/Libs/wxWidgets-3.1.0/include/wx/aui/framemanager.h:211: undefined
reference to `_imp___ZN20wxAuiPaneButtonArrayaSERKS_'
gccmswud_dll\wxfreechart_dll_chartsplitpanel.o: In function `ZN13wxAuiPaneInfo11
DefaultPaneEv':
D:/Worskspace/Libs/wxWidgets-3.1.0/include/wx/aui/framemanager.h:333: undefined
reference to `_imp___ZNK13wxAuiPaneInfo7IsValidEv'
gccmswud_dll\wxfreechart_dll_chartsplitpanel.o: In function `ZN13wxAuiPaneInfo7S
etFlagEib':
D:/Worskspace/Libs/wxWidgets-3.1.0/include/wx/aui/framemanager.h:363: undefined
reference to `_imp___ZNK13wxAuiPaneInfo7IsValidEv'
collect2.exe: error: ld returned 1 exit status
makefile.gcc:364: recipe for target '..\lib\gcc_dll\wxcode_msw31ud_freechart.dll
' failed
mingw32-make: *** [..\lib\gcc_dll\wxcode_msw31ud_freechart.dll] Error 1


Please help me!!!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 2787
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to use gnuPlot in wxWidget project

Postby ONEEYEMAN » Thu Jun 16, 2016 4:17 pm

Hi,
Are you linking with AUI library?
Please show the command used for linking...

Thank you.

TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

Re: How to use gnuPlot in wxWidget project

Postby TSib » Fri Jun 17, 2016 7:45 am

Hi,
please find below the commande line that I used to compile wxFreeChart library :

Code: Select all

mingw32-make -f makefile.gcc WX_DIR=D:\Worskspace\Libs\wxWidgets-3.1.0 WX_UNICODE=1 WX_DEBUG=1 WX_SHARED=1 WX_VERSION=31 SHARED=1

TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

Re: How to use gnuPlot in wxWidget project

Postby TSib » Fri Jun 17, 2016 8:27 am

Hi,
After checking the makefile.gcc content, it seemed that the commande line defined at line 294 :

Code: Select all

ifeq ($(WX_MONOLITHIC),0)
__WXLIB_AUI_NAME_p = -lwxmsw$(WX_VERSION)$(WXLIBPOSTFIX)_aui
endif


is not taken into account at line 378 :

Code: Select all

ifeq ($(WX_SHARED),1)
..\sample\wxFreeChartDemo_dll.exe: $(WXFREECHARTDEMO_DLL_OBJECTS) make_sample_dir_wxFreeChartDemo_dll  $(__wxfreechart_dll___depname)
   $(CXX) -o [email protected] $(WXFREECHARTDEMO_DLL_OBJECTS)  -mthreads -L$(WX_DIR)$(WXLIBPATH) $(____wx_3) -L..$(WXLIBPATH) -Wl,--subsystem,windows -mwindows  $(LDFLAGS)  ..\lib\gcc_$(____wxfreechart_dll__DIRNAME_SHARED_SUFFIX_FILENAMES)\libwxcode_msw$(WX_VERSION)$(WXLIBPOSTFIX)_freechart.a $(__WXLIB_AUI_NAME_p) $(__WXLIB_ADV_NAME_p) $(__WXLIB_CORE_NAME_p) $(__WXLIB_BASE_NAME_p) -lwxtiff$(WX3RDPARTYLIBPOSTFIX) -lwxjpeg$(WX3RDPARTYLIBPOSTFIX) -lwxpng$(WX3RDPARTYLIBPOSTFIX) -lwxzlib$(WX3RDPARTYLIBPOSTFIX) -lwxregex$(WXLIBPOSTFIX) -lwxexpat$(WX3RDPARTYLIBPOSTFIX) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
endif


In fact, when I compile, I have the following outputs on the MS DOS

wxWidgets-3.1.0\lib\gcc_dll -g -L..\lib\gcc_dll -Wl,--out-implib=..\lib\gcc_dll\
libwxcode_msw31ud_freechart.a -lwxmsw31ud_core -lwxbase31ud -lwxtiffd -lwxjpeg
d -lwxpngd -lwxzlibd -lwxregexud -lwxexpatd -lkernel32 -luser32 -lgdi32 -lcomdlg
32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -l
advapi32 -lwsock32 -lodbc32


Obviously, the AUI library is not taken into account. Please help me!!!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 2787
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to use gnuPlot in wxWidget project

Postby ONEEYEMAN » Fri Jun 17, 2016 2:31 pm

Hi,
Could you try manually add the missing aui library and see if it compiles?

Thank you.

TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

Re: How to use gnuPlot in wxWidget project  [SOLVED]

Postby TSib » Thu Jun 23, 2016 1:48 pm

Hi,
All is OK now. I just add manually the missing lib as @ONEEYEMAN suggested. Thanks you very much for your availability and helps.

TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

Re: How to use gnuPlot in wxWidget project

Postby TSib » Thu Jun 23, 2016 3:00 pm

Another question concerning wxFreeChart : is It possible to plot 4 graphs for example in the same windows, i.e. split window into 4?

TSib
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jun 16, 2016 8:22 am

Re: How to use gnuPlot in wxWidget project

Postby TSib » Fri Jun 24, 2016 9:15 am

is it also possible to zoom plot?


Return to “C++ Development”

Who is online

Users browsing this forum: Bing [Bot] and 20 guests