2D-Plots Topic is solved
Re: 2D-Plots
Yes, but in a separate project in order to check If my wxFreeChart settings were all correct, but they're not.
I think something in my settings is wrong/missing but I don't know what exactly.
I tried nmake -fmakefile.vc WX_DIR=C:\wxWidgets WX_UNICODE=1 WX_DEBUG=0 WX_SHARED=0 WX_MONOLITHIC=0 WX_VERSION=30 ,
it works (and it worked the first time I tried this) but I still have 5 unresolved externals
I think something in my settings is wrong/missing but I don't know what exactly.
I tried nmake -fmakefile.vc WX_DIR=C:\wxWidgets WX_UNICODE=1 WX_DEBUG=0 WX_SHARED=0 WX_MONOLITHIC=0 WX_VERSION=30 ,
it works (and it worked the first time I tried this) but I still have 5 unresolved externals
Re: 2D-Plots
All the missing references are not from the core freechart library, they are in one of the sample files (democollection.cpp). What exactly are you building?
Use the source, Luke!
Re: 2D-Plots
Yes, I was building demo.cpp along with demo.h and democollection.h (because both are included in the cpp file) , without democollection.cpp ;
now, building the project with also the inclusion of democollection.cpp , I have 22 unserolved externals ; all the lines of the output
are something like this : "democollection.obj : error LNK2001: unresolved external symbol "class ChartDemo * * markersDemos" (?markersDemos@@3PAPAVChartDemo@@A) "
now, building the project with also the inclusion of democollection.cpp , I have 22 unserolved externals ; all the lines of the output
are something like this : "democollection.obj : error LNK2001: unresolved external symbol "class ChartDemo * * markersDemos" (?markersDemos@@3PAPAVChartDemo@@A) "
Re: 2D-Plots
All of the files in the sample folder are needed to build the demo. I'd really recommend starting a separate app and copying and modifying code for the graph you need from demo(I doubt you need them all). If you plan on manually building demo, check out the makefiles for it, they might have some pointers.
Don't Complain, Change It, It's Open-Source!
Re: 2D-Plots
Ooh, now I understand! thank you very much @mill-j!
I was wasting my time trying to build only a part!
In order to learn how to make easy 2d-graphs, do you suggest to study the demo sample or other tutorials?
I was wasting my time trying to build only a part!
In order to learn how to make easy 2d-graphs, do you suggest to study the demo sample or other tutorials?
Re: 2D-Plots
The sample is awesome, but it is huge. I recommend that you figure out which graph you want (e.g. bar graph) and create a minimal wxWidgets app then copy only the functions related to the graph you need, this will take time and tweaks but trust me it works. The online documentation on the wxCode website helps a lot too.
Good Luck
Good Luck
Don't Complain, Change It, It's Open-Source!
Re: 2D-Plots
thank you! I'm trying to do what you suggested .
In the meantime , I also looked at this tutorial https://iwbnwif.github.io/freechart_doc ... index.html
but i don't understand one thing; at the step number 5 of the tutorial, they write
But in my OnInit method, when I write
,
where topSizer1 is a wxBoxSizer, I have this error : error C2664: 'wxSizerItem *wxSizer::Add(wxSizerItem *)': cannot convert argument 1 from 'wxChartPanel *(__cdecl *)(Chart)' to 'wxWindow *' .
Has anyone idea of what I can do to fix it?
thanks a lot
In the meantime , I also looked at this tutorial https://iwbnwif.github.io/freechart_doc ... index.html
but i don't understand one thing; at the step number 5 of the tutorial, they write
Code: Select all
// Normal wxWidgets form / dialog / sizer stuff goes here, e.g.:
"m_pMainSizer->Add(chartPanel, 1, 1, 5); "
Code: Select all
topSizer1->Add(chartPanel,1,1,5);
where topSizer1 is a wxBoxSizer, I have this error : error C2664: 'wxSizerItem *wxSizer::Add(wxSizerItem *)': cannot convert argument 1 from 'wxChartPanel *(__cdecl *)(Chart)' to 'wxWindow *' .
Has anyone idea of what I can do to fix it?
thanks a lot
Re: 2D-Plots
You need to add your chart to the frame. Here is a modified minimal app that I cobbled together just now.
It took me awhile to figure out wxFreeChart myself, hopefully this helps.
I'd really recommend you take the time and study the wxWidgets documentation, once you figure out the syntax there's almost nothing you can't figure out.
Code: Select all
#include <wx/wx.h>
#include <wx/bars/barplot.h>
#include <wx/chartpanel.h>
#include <wx/axis/numberaxis.h>
#include <wx/axis/categoryaxis.h>
#include <wx/xy/xyhistorenderer.h>
#include <wx/category/categorysimpledataset.h>
// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
public:
// override base class virtuals
// ----------------------------
// this one is called on application startup and is a good place for the app
// initialization (doing it here and not in the ctor allows to have an error
// return: if OnInit() returns false, the application terminates)
virtual bool OnInit();
};
// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public:
// ctor(s)
MyFrame(const wxString& title);
wxChartPanel* GraphChartPanel;
void ShowGraph();
private:
// any class wishing to process wxWidgets events must use this macro
//wxDECLARE_EVENT_TABLE();
};
wxIMPLEMENT_APP(MyApp);
bool MyApp::OnInit()
{
// call the base class initialization method, currently it only parses a
// few common command-line options but it could be do more in the future
if ( !wxApp::OnInit() )
return false;
// create the main application window
MyFrame *frame = new MyFrame("Minimal wxWidgets App");
// and show it (the frames, unlike simple controls, are not shown when
// created initially)
frame->Show(true);
// success: wxApp::OnRun() will be called which will enter the main message
// loop and the application will run. If we returned false here, the
// application would exit immediately.
return true;
}
// frame constructor
MyFrame::MyFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title)
{
wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );
GraphChartPanel = new wxChartPanel(this,-1);
bSizer1->Add(GraphChartPanel, 1,wxALL|wxEXPAND, 5);
this->SetSizer( bSizer1 );
this->Layout();
this->Centre( wxBOTH );
ShowGraph();
}
void MyFrame::ShowGraph()
{
double values1[5];
wxString names[5];
values1[0] = 12;
values1[1] = 50;
values1[2] = 90;
values1[3] = 20;
values1[4] = 100;
names[0] = "Sample1";
names[1] = "Sample2";
names[2] = "Sample3";
names[3] = "Sample4";
names[4] = "Sample5";
// Create dataset
CategorySimpleDataset *dataset = new CategorySimpleDataset(names, WXSIZEOF(names));
// add serie to it
dataset->AddSerie(wxT("First Bar"), values1, WXSIZEOF(values1));
// create layered bar type with width=40 and base=0
BarType *barType = new LayeredBarType(40, 0);
// Set bar renderer for it, with layered bar type
BarRenderer *renderer = new BarRenderer(barType);
// Some eye-candy: gradient bars
renderer->SetBarDraw(0, new GradientAreaDraw(*wxBLUE, wxColor(0,171,255),
wxColor(0,171,255).ChangeLightness(150), wxNORTH));
// assign renderer to dataset
dataset->SetRenderer(renderer);
// Create bar plot
BarPlot *plot = new BarPlot();
// Add left category axis
NumberAxis *leftAxis = new NumberAxis(AXIS_LEFT);
leftAxis->SetMargins(0, 0);
plot->AddAxis(leftAxis);
// Add bottom number axis
CategoryAxis *bottomAxis = new CategoryAxis(AXIS_BOTTOM);
bottomAxis->SetMargins(20, 20);
plot->AddAxis(bottomAxis);
// Add dataset to plot
plot->AddDataset(dataset);
// Link first dataset with first horizontal axis
plot->LinkDataHorizontalAxis(0, 0);
// Link first dataset with first vertical axis
plot->LinkDataVerticalAxis(0, 0);
//test
Legend* legend = new Legend(wxCENTER, wxRIGHT, new FillAreaDraw(*wxTRANSPARENT_PEN, *wxTRANSPARENT_BRUSH));
plot->SetLegend(legend);
// and finally construct and return chart
GraphChartPanel->SetChart(new Chart(plot, "TITLE"));
}
I'd really recommend you take the time and study the wxWidgets documentation, once you figure out the syntax there's almost nothing you can't figure out.
Don't Complain, Change It, It's Open-Source!
Re: 2D-Plots
It helped, thank you very much.
You're right, I have to take my time to study more and better this new world.
really appreciated your help
You're right, I have to take my time to study more and better this new world.
really appreciated your help
Re: 2D-Plots
Hi,
I have been away from the forum for a few weeks and missed this topic before now.
Sadly, I haven't been able to work on any updates to wxFreeChart for quite a while, but I really hope that will change later in the year and I can again spend some time on the project.
Please do raise an issue for any problems you find or if you think it is possible to improve something. Of course pull requests to solve the issues are very welcome!
I have been away from the forum for a few weeks and missed this topic before now.
Sadly, I haven't been able to work on any updates to wxFreeChart for quite a while, but I really hope that will change later in the year and I can again spend some time on the project.
Please do raise an issue for any problems you find or if you think it is possible to improve something. Of course pull requests to solve the issues are very welcome!
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, 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.
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Re: 2D-Plots
@mill-j , @iwbn
thanks for posting!
I think I've found an issue.
Considering the code of @mill-j ,
With these 2 lines
I want to put my graph in a precise point and set a precise size..The size works fine, I can choose every size I want..but the position
is always the wxDefaultPosition even if I try to change it...has anyone found this issue too?
Many many thanks guys
thanks for posting!
I think I've found an issue.
Considering the code of @mill-j ,
With these 2 lines
Code: Select all
const wxPoint pos1 = wxPoint(300, 400);
GraphChartPanel = new wxChartPanel(this, wxID_ANY, 0, pos1 , { 500,500 });
is always the wxDefaultPosition even if I try to change it...has anyone found this issue too?
Many many thanks guys
Re: 2D-Plots
wxChartPanel is subclassed from wxScrolledWindow, aka wxScrolled<wxPanel> in recent versions of wxWidgets.
So the behavior will be the same as for wxScrolledWindow in this respect.
I always use sizers so haven't tried with fixed positioning, however if you are adding the wxChartPanel to a sizer then it is possible that the position value is being ignored.
I would strongly recommending using sizers rather than discrete positions with wxWidgets.
Just in case you didn't read it already, take a look at the overview here: http://docs.wxwidgets.org/3.1/overview_sizer.html or search "wxWidgets sizer tutorial".
So the behavior will be the same as for wxScrolledWindow in this respect.
I always use sizers so haven't tried with fixed positioning, however if you are adding the wxChartPanel to a sizer then it is possible that the position value is being ignored.
I would strongly recommending using sizers rather than discrete positions with wxWidgets.
Just in case you didn't read it already, take a look at the overview here: http://docs.wxwidgets.org/3.1/overview_sizer.html or search "wxWidgets sizer tutorial".
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, 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.
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Re: 2D-Plots
@wxJack I agree, you'll be better off in the long run figuring out sizers. The app that helped me get the "concept" was https://github.com/wxFormBuilder/wxFormBuilder wxFormBuilder
@iwbnwif Thanks for maintaining such a great library. One thing that comes to mind, could you modify the ./configure system to allow wxQT builds even if it doesn't currently build under that platform? Or maybe give some advice on how to accomplish this, to me the build system looks complicated
@iwbnwif Thanks for maintaining such a great library. One thing that comes to mind, could you modify the ./configure system to allow wxQT builds even if it doesn't currently build under that platform? Or maybe give some advice on how to accomplish this, to me the build system looks complicated
Don't Complain, Change It, It's Open-Source!
Re: 2D-Plots
@mill-j I haven't used wxQT before but I will try to take a look at it at some point.
I too am not a fan of the ./configure build generator (Autotools?) but the popular alternative (CMake) doesn't seem much better. I guess I will have to bite the bullet at some point and learn one or the other properly.
For the moment I have a project setup in Codelite which I find very straightforward and reliable.
I too am not a fan of the ./configure build generator (Autotools?) but the popular alternative (CMake) doesn't seem much better. I guess I will have to bite the bullet at some point and learn one or the other properly.
For the moment I have a project setup in Codelite which I find very straightforward and reliable.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, 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.
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Re: 2D-Plots
Ok never mind. I got it. I had to download the build/autoconf files from here https://sourceforge.net/p/wxcode/code/H ... Code/build and edit the wxwin.m4 file to allow wxQT, then rebuild the configure file.
I also built the wxFreeChart against wxQT and it built with no errors the first time around , however I do get errors when linking against the FreeChart lib. This means the demo doesn't build yet. No big deal, I can start tinkering now and see what needs fixing.
EDIT: I was wrong! It does link(I forget to export LD_LIBRARY_LIBS) Most charts are lacking bars, etc but the pie chart works;)
I also built the wxFreeChart against wxQT and it built with no errors the first time around , however I do get errors when linking against the FreeChart lib. This means the demo doesn't build yet. No big deal, I can start tinkering now and see what needs fixing.
EDIT: I was wrong! It does link(I forget to export LD_LIBRARY_LIBS) Most charts are lacking bars, etc but the pie chart works;)
Don't Complain, Change It, It's Open-Source!