Creates the category chart example.
117 this->addWidget(std::make_unique<WText>(WString::tr(
"category chart")));
119 std::shared_ptr<WAbstractItemModel> model
120 = readCsvFile(WApplication::appRoot() +
"category.csv",
this);
126 auto *w = this->addWidget(std::make_unique<WContainerWidget>());
127 auto *table = w->addWidget(std::make_unique<WTableView>());
129 table->setMargin(10, Side::Top | Side::Bottom);
130 table->setMargin(WLength::Auto, Side::Left | Side::Right);
132 table->setModel(model);
133 table->setSortingEnabled(
true);
134 table->setColumnResizeEnabled(
true);
136 table->setAlternatingRowColors(
true);
137 table->setColumnAlignment(0, AlignmentFlag::Center);
138 table->setHeaderAlignment(0, AlignmentFlag::Center);
139 table->setRowHeight(22);
143 if (WApplication::instance()->environment().ajax()) {
144 table->resize(600, 20 + 5*22);
145 table->setEditTriggers(EditTrigger::SingleClicked);
147 table->resize(600, WLength::Auto);
148 table->setEditTriggers(EditTrigger::None);
153 std::shared_ptr<WItemDelegate> delegate
154 = std::make_shared<WItemDelegate>();
155 delegate->setTextFormat(
"%.f");
156 table->setItemDelegate(delegate);
158 table->setColumnWidth(0, 80);
159 for (
int i = 1; i < model->columnCount(); ++i)
160 table->setColumnWidth(i, 120);
165 WCartesianChart *chart = this->addWidget(std::make_unique<WCartesianChart>());
166 chart->setModel(model);
167 chart->setXSeriesColumn(0);
168 chart->setLegendEnabled(
true);
169 chart->setZoomEnabled(
true);
170 chart->setPanEnabled(
true);
173 chart->setAutoLayoutEnabled(
true);
175 chart->setBackground(WColor(200,200,200));
180 for (
int i = 1; i < model->columnCount(); ++i) {
181 std::unique_ptr<WDataSeries> s
182 = std::make_unique<WDataSeries>(i, SeriesType::Bar);
183 s->setShadow(WShadow(3, 3, WColor(0, 0, 0, 127), 3));
184 chart->addSeries(std::move(s));
187 chart->resize(800, 400);
189 chart->setMargin(10, Side::Top | Side::Bottom);
190 chart->setMargin(WLength::Auto, Side::Left | Side::Right);
195 this->addWidget(std::make_unique<ChartConfig>(chart));