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