#include <ChartsExample.h>
Public Member Functions | |
PieExample (Wt::WContainerWidget *parent) | |
Creates the pie chart example. |
Definition at line 59 of file ChartsExample.h.
PieExample::PieExample | ( | Wt::WContainerWidget * | parent | ) |
Creates the pie chart example.
Definition at line 228 of file ChartsExample.C.
00228 : 00229 WContainerWidget(parent) 00230 { 00231 new WText(WString::tr("pie chart"), this); 00232 00233 WAbstractItemModel *model = readCsvFile("pie.csv", this); 00234 00235 if (!model) 00236 return; 00237 00238 /* 00239 * If we have JavaScript, show an Ext table view that allows editing 00240 * of the model. 00241 */ 00242 if (wApp->environment().javaScript()) { 00243 WContainerWidget *w = new WContainerWidget(this); 00244 Ext::TableView *table = new Ext::TableView(w); 00245 table->setMargin(10, Top | Bottom); 00246 table->setMargin(WLength::Auto, Left | Right); 00247 table->resize(300, 175); 00248 table->setModel(model); 00249 table->setAutoExpandColumn(0); 00250 00251 table->setEditor(0, new Ext::LineEdit()); 00252 00253 for (int i = 1; i < model->columnCount(); ++i) 00254 table->setEditor(i, new Ext::NumberField()); 00255 } 00256 00257 /* 00258 * Create the pie chart. 00259 */ 00260 WPieChart *chart = new WPieChart(this); 00261 chart->setModel(model); // set the model 00262 chart->setLabelsColumn(0); // set the column that holds the labels 00263 chart->setDataColumn(1); // set the column that holds the data 00264 00265 // configure location and type of labels 00266 chart->setDisplayLabels(Outside | TextLabel | TextPercentage); 00267 00268 // enable a 3D effect 00269 chart->setPerspectiveEnabled(true, 0.2); 00270 00271 // explode the first item 00272 chart->setExplode(0, 0.3); 00273 00274 chart->resize(800, 300); // WPaintedWidget must be given explicit size 00275 00276 chart->setMargin(10, Top | Bottom); // add margin vertically 00277 chart->setMargin(WLength::Auto, Left | Right); // center horizontally 00278 }