Project

General

Profile

Bug #4827 ยป test_20160325a_axis_location.C

Bruce Toll, 03/25/2016 06:59 PM

 
#include <Wt/WApplication>
#include <Wt/WStandardItemModel>
#include <Wt/WText>
#include <Wt/WPushButton>
#include <Wt/Chart/WCartesianChart>
#include <Wt/Chart/WStandardPalette>

using namespace Wt;

class TestApplication : public WApplication
{
public:
TestApplication(const WEnvironment& env);
~TestApplication() { }

private:
Chart::WCartesianChart *chart_ = nullptr;
WStandardItemModel *chartModel_ = nullptr;
WPushButton *button_ = nullptr;
};

TestApplication::TestApplication(const WEnvironment& env) : WApplication(env)
{
setTitle("WCartesianChart Axis Location Update Test");

new WText("<h5>Press button to remove point at (0,0) to see resulting excess left padding on chart. NOTE: Works fine with 3.3.5.</h5>", root());
button_ = new WPushButton("Remove point (0,0)", root());

chartModel_ = new WStandardItemModel(3, 2, this);

chartModel_->setData(chartModel_->index(0, 0), 0.0);
chartModel_->setData(chartModel_->index(0, 1), 0.0);
chartModel_->setData(chartModel_->index(1, 0), 20.0);
chartModel_->setData(chartModel_->index(1, 1), 0.2);
chartModel_->setData(chartModel_->index(2, 0), 40.0);
chartModel_->setData(chartModel_->index(2, 1), 2.0);

chart_ = new Chart::WCartesianChart(Chart::ScatterPlot, root());
chart_->resize(600, 400);
chart_->setAutoLayoutEnabled();
chart_->setModel(chartModel_);
chart_->setXSeriesColumn(0);
chart_->addSeries(Chart::WDataSeries(1, Chart::LineSeries));

button_->clicked().connect(std::bind([this] {
chartModel_->removeRow(0);
button_->setEnabled(false);
}));
}

int main(int argc, char **argv)
{
return WRun(argc, argv, [](const WEnvironment& env) {return new TestApplication(env);});
}
    (1-1/1)