I am trying to draw a Pie Chart using wxFreeChart Lib here is the code I wrote, The problem is the charts is blank not showing anything. Anyone knows what is wrong with my code.
Thanks!
Code: Select all
// serie pieplot data
double data[] = {1.0, 2.0, 3.0} ;
wxString categories[] = {_("cat 1"), _("cat 2"), _("cat 3")};
wxColour colours[] = {wxColour(0x99, 0xCC, 0xFF), wxColour(0xFF, 0xFF, 0x99), wxColour(0x3D, 0xEB, 0x3D)} ;
ColorScheme* colorScheme = new ColorScheme(colours, WXSIZEOF(colours));
// first step: create plot
PiePlot *plot = new PiePlot();
// create dataset
CategorySimpleDataset* dataset = new CategorySimpleDataset(categories, WXSIZEOF(categories));
// and add serie to it
dataset->AddSerie(_("Serie 1"), data, WXSIZEOF(data));
// create category renderer for legend drawing
dataset->SetRenderer(new CategoryRenderer(*colorScheme));
// set color scheme
plot->SetColorScheme(colorScheme);
plot->SetDataset(dataset);
// set legend to plot
plot->SetLegend(new Legend(wxCENTER, wxRIGHT));
// Create a chart object with our plot.
Chart* chart = new Chart(plot, "My First Chart");
// Create a chart panel to display the chart.
wxChartPanel* chartPanel = new wxChartPanel(Panel1,
wxID_ANY, chart, wxPoint(0, 0), wxSize(1, 1));
BoxSizer1->Add(chartPanel, 1, wxGROW | wxEXPAND, 5);
BoxSizer1->Layout();
BoxSizer1->Fit(Panel1);