Creates the time series scatter plot example.
192 WContainerWidget(parent)
194 new WText(WString::tr(
"scatter plot"),
this);
196 WAbstractItemModel *model = readCsvFile(
197 WApplication::appRoot() +
"timeseries.csv",
this);
205 for (
int i = 0; i < model->rowCount(); ++i) {
206 WString s = asString(model->data(i, 0));
207 WDate d = WDate::fromString(s,
"dd/MM/yy");
208 model->setData(i, 0, d);
212 WContainerWidget *w =
new WContainerWidget(
this);
213 WTableView *table =
new WTableView(w);
215 table->setMargin(10, Top | Bottom);
216 table->setMargin(WLength::Auto, Left | Right);
218 table->setModel(model);
219 table->setSortingEnabled(
false);
220 table->setColumnResizeEnabled(
true);
221 table->setSelectionMode(NoSelection);
222 table->setAlternatingRowColors(
true);
223 table->setColumnAlignment(0, AlignCenter);
224 table->setHeaderAlignment(0, AlignCenter);
225 table->setRowHeight(22);
229 if (WApplication::instance()->environment().ajax()) {
230 table->resize(800, 20 + 5*22);
231 table->setEditTriggers(WAbstractItemView::SingleClicked);
233 table->resize(800, 20 + 5*22 + 25);
234 table->setEditTriggers(WAbstractItemView::NoEditTrigger);
237 WItemDelegate *delegate =
new WItemDelegate(
this);
238 delegate->setTextFormat(
"%.1f");
239 table->setItemDelegate(delegate);
240 table->setItemDelegateForColumn(0,
new WItemDelegate(
this));
242 table->setColumnWidth(0, 80);
243 for (
int i = 1; i < model->columnCount(); ++i)
244 table->setColumnWidth(i, 90);
249 WCartesianChart *chart =
new WCartesianChart(
this);
252 chart->setModel(model);
253 chart->setXSeriesColumn(0);
254 chart->setLegendEnabled(
true);
256 chart->setType(ScatterPlot);
257 chart->axis(XAxis).setScale(DateScale);
260 chart->setPlotAreaPadding(80, Left);
261 chart->setPlotAreaPadding(40, Top | Bottom);
266 for (
int i = 1; i < 3; ++i) {
267 WDataSeries s(i, LineSeries);
268 s.setShadow(WShadow(3, 3, WColor(0, 0, 0, 127), 3));
272 chart->resize(800, 400);
274 chart->setMargin(10, Top | Bottom);
275 chart->setMargin(WLength::Auto, Left | Right);
A class that allows configuration of a cartesian chart.