PieExample Class Reference
[Charts example]

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

#include <ChartsExample.h>

Inheritance diagram for PieExample:

Inheritance graph
[legend]

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 284 of file ChartsExample.C.

00284                                               :
00285   WContainerWidget(parent)
00286 {
00287   new WText(WString::tr("pie chart"), this);
00288 
00289   WAbstractItemModel *model = readCsvFile("pie.csv", this);
00290 
00291   if (!model)
00292     return;
00293 
00294   WContainerWidget *w = new WContainerWidget(this);
00295   WTableView* table = new WTableView(w);
00296 
00297   table->setMargin(10, Top | Bottom);
00298   table->setMargin(WLength::Auto, Left | Right);
00299   table->setSortingEnabled(true);
00300   table->setModel(model);
00301   table->setColumnWidth(1, 100);
00302   table->setRowHeight(22);
00303 
00304   if (WApplication::instance()->environment().ajax()) {
00305     table->resize(150 + 100 + 14, 20 + 6 * 22);
00306     table->setEditTriggers(WAbstractItemView::SingleClicked);
00307   } else {
00308     table->resize(150 + 100 + 14, WLength::Auto);
00309     table->setEditTriggers(WAbstractItemView::NoEditTrigger);    
00310   }
00311 
00312   /*
00313    * Create the pie chart.
00314    */
00315   WPieChart *chart = new WPieChart(this);
00316   chart->setModel(model);       // set the model
00317   chart->setLabelsColumn(0);    // set the column that holds the labels
00318   chart->setDataColumn(1);      // set the column that holds the data
00319 
00320   // configure location and type of labels
00321   chart->setDisplayLabels(Outside | TextLabel | TextPercentage);
00322 
00323   // enable a 3D and shadow effect
00324   chart->setPerspectiveEnabled(true, 0.2);
00325   chart->setShadowEnabled(true);
00326 
00327   // explode the first item
00328   chart->setExplode(0, 0.3);
00329 
00330   chart->resize(800, 300); // WPaintedWidget must be given an explicit size
00331 
00332   chart->setMargin(10, Top | Bottom);            // add margin vertically
00333   chart->setMargin(WLength::Auto, Left | Right); // center horizontally
00334 }


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

Generated on Thu May 20 18:14:57 2010 for Wt by doxygen 1.5.6