Creates the pie chart example.
355 this->addWidget(cpp14::make_unique<WText>(WString::tr(
"pie chart")));
357 std::shared_ptr<WStandardItemModel> model
358 = std::make_shared<WStandardItemModel>();
359 std::unique_ptr<NumericItem> prototype
360 = cpp14::make_unique<NumericItem>();
361 model->setItemPrototype(std::move(prototype));
364 model->insertColumns(model->columnCount(), 2);
365 model->setHeaderData(0, WString(
"Item"));
366 model->setHeaderData(1, WString(
"Sales"));
369 model->insertRows(model->rowCount(), 6);
371 model->setData(row, 0, WString(
"Blueberry"));
372 model->setData(row, 1, 120);
375 model->setData(row, 0, WString(
"Cherry"));
376 model->setData(row, 1, 30);
378 model->setData(row, 0, WString(
"Apple"));
379 model->setData(row, 1, 260);
381 model->setData(row, 0, WString(
"Boston Cream"));
382 model->setData(row, 1, 160);
384 model->setData(row, 0, WString(
"Other"));
385 model->setData(row, 1, 40);
387 model->setData(row, 0, WString(
"Vanilla Cream"));
388 model->setData(row, 1, 120);
392 for (
int row = 0; row < model->rowCount(); ++row)
393 for (
int col = 0; col < model->columnCount(); ++col)
394 model->item(row, col)->setFlags(ItemFlag::Selectable | ItemFlag::Editable);
396 WContainerWidget *w = this->addWidget(cpp14::make_unique<WContainerWidget>());
397 WTableView* table = w->addWidget(cpp14::make_unique<WTableView>());
399 table->setMargin(10, Side::Top | Side::Bottom);
400 table->setMargin(WLength::Auto, Side::Left | Side::Right);
401 table->setSortingEnabled(
true);
402 table->setModel(model);
403 table->setColumnWidth(1, 100);
404 table->setRowHeight(22);
406 if (WApplication::instance()->environment().ajax()) {
407 table->resize(150 + 100 + 14, 20 + 6 * 22);
408 table->setEditTriggers(EditTrigger::SingleClicked);
410 table->resize(150 + 100 + 14, WLength::Auto);
411 table->setEditTriggers(EditTrigger::None);
417 WPieChart *chart = this->addWidget(cpp14::make_unique<WPieChart>());
418 chart->setModel(model);
419 chart->setLabelsColumn(0);
420 chart->setDataColumn(1);
423 chart->setDisplayLabels(LabelOption::Outside | LabelOption::TextLabel | LabelOption::TextPercentage);
426 chart->setPerspectiveEnabled(
true, 0.2);
427 chart->setShadowEnabled(
true);
430 chart->setExplode(0, 0.3);
432 chart->resize(800, 300);
434 chart->setMargin(10, Side::Top | Side::Bottom);
435 chart->setMargin(WLength::Auto, Side::Left | Side::Right);