Public Member Functions

CategoryExample Class Reference
[Charts example]

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

#include <ChartsExample.h>

Inherits Wt::WContainerWidget.

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.

                                                          :
  WContainerWidget(parent)
{
  new WText(WString::tr("category chart"), this);

  WAbstractItemModel *model = readCsvFile("category.csv", this);

  if (!model)
    return;

  /*
   * If we have JavaScript, show an Ext table view that allows editing
   * of the model.
   */
  if (wApp->environment().javaScript()) {
    WContainerWidget *w = new WContainerWidget(this);
    Ext::TableView *table = new Ext::TableView(w);
    table->setMargin(10, Top | Bottom);
    table->setMargin(WLength::Auto, Left | Right);
    table->resize(500, 175);
    table->setModel(model);
    table->setAutoExpandColumn(0);

    table->setEditor(0, new Ext::LineEdit());

    for (int i = 1; i < model->columnCount(); ++i) {
      Ext::NumberField *nf = new Ext::NumberField();
      table->setEditor(i, nf);
    }
  }

  /*
   * Create the category chart.
   */
  WCartesianChart *chart = new WCartesianChart(this);
  chart->setModel(model);        // set the model
  chart->setXSeriesColumn(0);    // set the column that holds the categories
  chart->setLegendEnabled(true); // enable the legend

  // Provide space for the X and Y axis and title. 
  chart->setPlotAreaPadding(100, Left);
  chart->setPlotAreaPadding(50, Top | Bottom);

  //chart->axis(YAxis).setBreak(70, 110);

  /*
   * Add all (but first) column as bar series
   */
  for (int i = 1; i < model->columnCount(); ++i) {
    WDataSeries s(i, BarSeries);
    s.setShadow(WShadow(3, 3, WColor(0, 0, 0, 127), 3));
    chart->addSeries(s);
  }

  chart->resize(800, 400); // WPaintedWidget must be given explicit size

  chart->setMargin(10, Top | Bottom);            // add margin vertically
  chart->setMargin(WLength::Auto, Left | Right); // center horizontally

  new ChartConfig(chart, this);
}


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

Generated on Mon Nov 29 2010 08:03:14 for Wt by doxygen 1.7.1