PieExample Class Reference
[Charts example]

A Widget that demonstrates a Pie chart. More...

#include <ChartsExample.h>

Inherits Wt::WContainerWidget.

List of all members.

Public Member Functions

 PieExample (Wt::WContainerWidget *parent)
 Creates the pie chart example.

Detailed Description

A Widget that demonstrates a Pie chart.

Definition at line 59 of file ChartsExample.h.


Constructor & Destructor Documentation

PieExample::PieExample ( Wt::WContainerWidget parent  ) 

Creates the pie chart example.

Definition at line 228 of file ChartsExample.C.

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


The documentation for this class was generated from the following files:

Generated on Thu May 13 05:16:01 2010 for Wt by doxygen 1.6.3