#include #include #include #include #include #include #include using namespace Wt; #define HAPPY_RESIZING class myApplication : public WApplication { public: myApplication(const WEnvironment &env) : WApplication(env) { std::unique_ptr upBoxLayout = std::make_unique(); upBoxLayout->setPreferredImplementation(Wt::LayoutImplementation::JavaScript); #ifdef HAPPY_RESIZING upBoxLayout->addWidget(myPieChart()); #else std::unique_ptr upContainerPieChart = std::make_unique(); Wt::Chart::WPieChart *chart = upContainerPieChart->addWidget(myPieChart()); chart->resize(800, 300); upBoxLayout->addWidget(std::move(upContainerPieChart)); #endif std::unique_ptr upContainer = std::make_unique(); upContainer->addWidget(std::make_unique("")); upBoxLayout->addWidget(std::move(upContainer), 1); upBoxLayout->setResizable(0); root()->setLayout(std::move(upBoxLayout)); } private: std::unique_ptr myPieChart() { auto upModel = std::make_shared(); upModel->insertColumns(upModel->columnCount(), 2); upModel->insertRows(upModel->rowCount(), 6); int row = 0; upModel->setData(row, 0, Wt::WString("Blueberry")); upModel->setData(row, 1, 120); upModel->setData(++row, 0, Wt::WString("Cherry")); upModel->setData(row, 1, 30); std::unique_ptr upPieChart = std::make_unique(); #ifdef HAPPY_RESIZING upPieChart->resize(Wt::WLength(), 300); #else upPieChart->resize(800, 300); #endif upPieChart->setModel(upModel); upPieChart->setLabelsColumn(0); upPieChart->setDataColumn(1); upPieChart->setPerspectiveEnabled(true, 0.2); upPieChart->setShadowEnabled(true); upPieChart->setExplode(0, 0.3); upPieChart->setDisplayLabels(Wt::Chart::LabelOption::Outside | Wt::Chart::LabelOption::TextLabel | Wt::Chart::LabelOption::TextPercentage); upPieChart->setMargin(10, Wt::Side::Bottom); upPieChart->setMargin(Wt::WLength::Auto, Wt::Side::Left | Wt::Side::Right); return std::move(upPieChart); }; }; std::unique_ptr createMyApplication(const WEnvironment& env) { auto app = cpp14::make_unique(env); return std::move(app); } int main(int argc, char **argv) { return WRun(argc, argv, &createMyApplication); }