wxFreeChart vs wxMathPlot
-
- Knows some wx things
- Posts: 26
- Joined: Fri Jul 30, 2010 6:19 am
wxFreeChart vs wxMathPlot
Hello,
I would like to create 2D charts : histogram, scatter diagrams... I am working with wxWidgets 2.9.1.
I noticed wxFreeChart and wxMathPlot among others. Which one do you use and why ? (I am looking for simple components.)
Thank you for your help.
Benoît
I would like to create 2D charts : histogram, scatter diagrams... I am working with wxWidgets 2.9.1.
I noticed wxFreeChart and wxMathPlot among others. Which one do you use and why ? (I am looking for simple components.)
Thank you for your help.
Benoît
- evstevemd
- Part Of The Furniture
- Posts: 2293
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
- Contact:
wxFreeChart. I have never used any of those but I think projet is well alive. I tried sometime ago and failed because there was no tutorial for beginners.
If you succeed with your project please take time to write jump start tutorial
If you succeed with your project please take time to write jump start tutorial
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]
-
- Knows some wx things
- Posts: 26
- Joined: Fri Jul 30, 2010 6:19 am
- evstevemd
- Part Of The Furniture
- Posts: 2293
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
- Contact:
Thanks Beno,b_grottier wrote:I eventually chose wxFreeChart because I needed histograms. I do not think that wxMathPlot handles them.
Where did you fail exactly ? I do not have time to write a tutorial but I can help if needed.I tried sometime ago and failed
Regards,
Benoît
I wanted to write an app that ws to plot data in graphs and save as images from massive CSV files. I didn't knew which classes to use for plotting any graph. Its like, if let say you want to write wx program you create parent window (which is top level window) and then create an instance on wxApp derived class and there you are.
I was looking for same intro to wxFreeChart and I found none. Samples were too complex for me. I'll be happy to see few simple examples on how to draw histogram and something like O'give
Thanks
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]
-
- Knows some wx things
- Posts: 26
- Joined: Fri Jul 30, 2010 6:19 am
First of all, did you manage to build wxFreeChart ? Which OS do you use ? The readme file explains how to create the libraries. If you use Visual Studio, you will find in the build directory some VS projects to compile the libraries.
For the moment, I just defined my own panel based on an example provided with wxFreeChart:
I have not tried histograms yet. Nonetheless, I hope this will help you.
Benoît
For the moment, I just defined my own panel based on an example provided with wxFreeChart:
Code: Select all
MyPanel::MyPanel(wxFrame *frame, int x, int y, int w, int h)
: wxPanel( frame, wxID_ANY, wxPoint(x, y), wxSize(w, h) )
{
wxBoxSizer * sz = new wxBoxSizer( wxVERTICAL ) ;
// first serie data
double data1[][2] = {
{ 10, 20, },
{ 13, 16, },
{ 7, 30, },
{ 15, 34, },
{ 25, 4, },
};
// second serie data
double data2[][2] = {
{ 45, 40, },
{ 23, 16, },
{ 43, 60, },
{ 25, 7, },
{ 66, 4, },
};
// first step: create plot
XYPlot *plot = new XYPlot();
// create dataset
XYSimpleDataset *dataset = new XYSimpleDataset();
// and add to series to it
dataset->AddSerie((double *) data1, WXSIZEOF(data1));
dataset->AddSerie((double *) data2, WXSIZEOF(data2));
// set line renderer with symbols enabled and lines disabled
dataset->SetRenderer(new XYLineRenderer(true, false));
// add our dataset to plot
plot->AddDataset(dataset);
// create left and bottom number axes
plot->AddAxis(new NumberAxis(AXIS_LEFT));
plot->AddAxis(new NumberAxis(AXIS_BOTTOM));
// link axes and dataset
plot->LinkDataVerticalAxis(0, 0);
plot->LinkDataHorizontalAxis(0, 0);
// set serie names to be displayed on legend
dataset->SetSerieName(0, wxT("First"));
dataset->SetSerieName(1, wxT("Second"));
// set legend to plot
plot->SetLegend(new Legend(wxCENTER, wxRIGHT));
wxChartPanel * m_chartPanel = new wxChartPanel(this);
m_chartPanel->SetChart(new Chart(plot)) ;
sz->Add(m_chartPanel, 1, wxEXPAND );
SetSizerAndFit(sz) ;
}
Benoît
- evstevemd
- Part Of The Furniture
- Posts: 2293
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
- Contact:
Compiling wasn't a problem.b_grottier wrote:First of all, did you manage to build wxFreeChart ? Which OS do you use ? The readme file explains how to create the libraries. If you use Visual Studio, you will find in the build directory some VS projects to compile the libraries.
For the moment, I just defined my own panel based on an example provided with wxFreeChart:
I have not tried histograms yet. Nonetheless, I hope this will help you.Code: Select all
MyPanel::MyPanel(wxFrame *frame, int x, int y, int w, int h) : wxPanel( frame, wxID_ANY, wxPoint(x, y), wxSize(w, h) ) { wxBoxSizer * sz = new wxBoxSizer( wxVERTICAL ) ; // first serie data double data1[][2] = { { 10, 20, }, { 13, 16, }, { 7, 30, }, { 15, 34, }, { 25, 4, }, }; // second serie data double data2[][2] = { { 45, 40, }, { 23, 16, }, { 43, 60, }, { 25, 7, }, { 66, 4, }, }; // first step: create plot XYPlot *plot = new XYPlot(); // create dataset XYSimpleDataset *dataset = new XYSimpleDataset(); // and add to series to it dataset->AddSerie((double *) data1, WXSIZEOF(data1)); dataset->AddSerie((double *) data2, WXSIZEOF(data2)); // set line renderer with symbols enabled and lines disabled dataset->SetRenderer(new XYLineRenderer(true, false)); // add our dataset to plot plot->AddDataset(dataset); // create left and bottom number axes plot->AddAxis(new NumberAxis(AXIS_LEFT)); plot->AddAxis(new NumberAxis(AXIS_BOTTOM)); // link axes and dataset plot->LinkDataVerticalAxis(0, 0); plot->LinkDataHorizontalAxis(0, 0); // set serie names to be displayed on legend dataset->SetSerieName(0, wxT("First")); dataset->SetSerieName(1, wxT("Second")); // set legend to plot plot->SetLegend(new Legend(wxCENTER, wxRIGHT)); wxChartPanel * m_chartPanel = new wxChartPanel(this); m_chartPanel->SetChart(new Chart(plot)) ; sz->Add(m_chartPanel, 1, wxEXPAND ); SetSizerAndFit(sz) ; }
Benoît
Thanks for snippet. I will try in these few days AND i WILL POST BACK. (My Laptop is out for maintanance about a month. It got a serious screen bug

Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]