Creates the category chart example.
112 WContainerWidget(parent)
114 new WText(WString::tr(
"category chart"),
this);
116 WAbstractItemModel *model
117 = readCsvFile(WApplication::appRoot() +
"category.csv",
this);
123 WContainerWidget *w =
new WContainerWidget(
this);
124 WTableView *table =
new WTableView(w);
126 table->setMargin(10, Top | Bottom);
127 table->setMargin(WLength::Auto, Left | Right);
129 table->setModel(model);
130 table->setSortingEnabled(
true);
131 table->setColumnResizeEnabled(
true);
133 table->setAlternatingRowColors(
true);
134 table->setColumnAlignment(0, AlignCenter);
135 table->setHeaderAlignment(0, AlignCenter);
136 table->setRowHeight(22);
140 if (WApplication::instance()->environment().ajax()) {
141 table->resize(600, 20 + 5*22);
142 table->setEditTriggers(WAbstractItemView::SingleClicked);
144 table->resize(600, WLength::Auto);
145 table->setEditTriggers(WAbstractItemView::NoEditTrigger);
150 WItemDelegate *delegate =
new WItemDelegate(
this);
151 delegate->setTextFormat(
"%.f");
152 table->setItemDelegate(delegate);
154 table->setColumnWidth(0, 80);
155 for (
int i = 1; i < model->columnCount(); ++i)
156 table->setColumnWidth(i, 120);
161 WCartesianChart *chart =
new WCartesianChart(
this);
162 chart->setModel(model);
163 chart->setXSeriesColumn(0);
164 chart->setLegendEnabled(
true);
165 chart->setZoomEnabled(
true);
166 chart->setPanEnabled(
true);
169 chart->setAutoLayoutEnabled(
true);
171 chart->setBackground(WColor(200,200,200));
176 for (
int i = 1; i < model->columnCount(); ++i) {
177 WDataSeries *s =
new WDataSeries(i, BarSeries);
178 s->setShadow(WShadow(3, 3, WColor(0, 0, 0, 127), 3));
182 chart->resize(800, 400);
184 chart->setMargin(10, Top | Bottom);
185 chart->setMargin(WLength::Auto, Left | Right);
A class that allows configuration of a cartesian chart.