A Widget that demonstrates a Pie chart. More...
#include <ChartsExample.h>
Public Member Functions | |
PieExample (Wt::WContainerWidget *parent) | |
Creates the pie chart example. |
A Widget that demonstrates a Pie chart.
Definition at line 59 of file ChartsExample.h.
PieExample::PieExample | ( | Wt::WContainerWidget * | parent ) |
Creates the pie chart example.
Definition at line 228 of file ChartsExample.C.
: WContainerWidget(parent) { new WText(WString::tr("pie chart"), this); WAbstractItemModel *model = readCsvFile("pie.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(300, 175); table->setModel(model); table->setAutoExpandColumn(0); table->setEditor(0, new Ext::LineEdit()); for (int i = 1; i < model->columnCount(); ++i) table->setEditor(i, new Ext::NumberField()); } /* * Create the pie chart. */ WPieChart *chart = new WPieChart(this); chart->setModel(model); // set the model chart->setLabelsColumn(0); // set the column that holds the labels chart->setDataColumn(1); // set the column that holds the data // configure location and type of labels chart->setDisplayLabels(Outside | TextLabel | TextPercentage); // enable a 3D effect chart->setPerspectiveEnabled(true, 0.2); // explode the first item chart->setExplode(0, 0.3); chart->resize(800, 300); // WPaintedWidget must be given explicit size chart->setMargin(10, Top | Bottom); // add margin vertically chart->setMargin(WLength::Auto, Left | Right); // center horizontally }