CategoryExample Class Reference
[Charts example]

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

#include <ChartsExample.h>

Inheritance diagram for CategoryExample:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 CategoryExample (Wt::WContainerWidget *parent)
 Creates the category chart example.


Detailed Description

A Widget that demonstrates a category chart.

Definition at line 39 of file ChartsExample.h.


Constructor & Destructor Documentation

CategoryExample::CategoryExample ( Wt::WContainerWidget parent  ) 

Creates the category chart example.

Definition at line 66 of file ChartsExample.C.

00066                                                           :
00067   WContainerWidget(parent)
00068 {
00069   new WText(WString::tr("category chart"), this);
00070 
00071   WAbstractItemModel *model = readCsvFile("category.csv", this);
00072 
00073   if (!model)
00074     return;
00075 
00076   /*
00077    * If we have JavaScript, show an Ext table view that allows editing
00078    * of the model.
00079    */
00080   if (wApp->environment().javaScript()) {
00081     WContainerWidget *w = new WContainerWidget(this);
00082     Ext::TableView *table = new Ext::TableView(w);
00083     table->setMargin(10, Top | Bottom);
00084     table->setMargin(WLength::Auto, Left | Right);
00085     table->resize(500, 175);
00086     table->setModel(model);
00087     table->setAutoExpandColumn(0);
00088 
00089     table->setEditor(0, new Ext::LineEdit());
00090 
00091     for (int i = 1; i < model->columnCount(); ++i) {
00092       Ext::NumberField *nf = new Ext::NumberField();
00093       table->setEditor(i, nf);
00094     }
00095   }
00096 
00097   /*
00098    * Create the category chart.
00099    */
00100   WCartesianChart *chart = new WCartesianChart(this);
00101   chart->setModel(model);        // set the model
00102   chart->setXSeriesColumn(0);    // set the column that holds the categories
00103   chart->setLegendEnabled(true); // enable the legend
00104 
00105   // Provide space for the X and Y axis and title. 
00106   chart->setPlotAreaPadding(100, Left);
00107   chart->setPlotAreaPadding(50, Top | Bottom);
00108 
00109   //chart->axis(YAxis).setBreak(70, 110);
00110 
00111   /*
00112    * Add all (but first) column as bar series
00113    */
00114   for (int i = 1; i < model->columnCount(); ++i) {
00115     WDataSeries s(i, BarSeries);
00116     chart->addSeries(s);
00117   }
00118 
00119   chart->resize(800, 400); // WPaintedWidget must be given explicit size
00120 
00121   chart->setMargin(10, Top | Bottom);            // add margin vertically
00122   chart->setMargin(WLength::Auto, Left | Right); // center horizontally
00123 
00124   new ChartConfig(chart, this);
00125 }


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

Generated on Tue Nov 3 15:34:40 2009 for Wt by doxygen 1.5.6