1
|
#include <Wt/Chart/WCartesianChart.h>
|
2
|
#include <Wt/WApplication.h>
|
3
|
#include <Wt/WEnvironment.h>
|
4
|
#include <Wt/WFont.h>
|
5
|
#include <Wt/WHBoxLayout.h>
|
6
|
|
7
|
using namespace Wt;
|
8
|
|
9
|
class TestApp : public WApplication {
|
10
|
public:
|
11
|
TestApp(const WEnvironment& env);
|
12
|
};
|
13
|
|
14
|
TestApp::TestApp(const WEnvironment& env) : WApplication(env)
|
15
|
{
|
16
|
setTitle("Test WCartesianChart clipping of title descenders");
|
17
|
auto root_layout = root()->setLayout(std::make_unique<WHBoxLayout>());
|
18
|
root_layout->setContentsMargins(0, 0, 0, 0);
|
19
|
std::vector<Chart::WCartesianChart *> charts;
|
20
|
|
21
|
// note: template parameters not needed with std++17
|
22
|
static std::array<std::pair<RenderMethod, std::string>, 3> const methods {
|
23
|
std::make_pair(RenderMethod::HtmlCanvas, "canvas"),
|
24
|
std::make_pair(RenderMethod::PngImage, "png" ),
|
25
|
std::make_pair(RenderMethod::InlineSvgVml, "svg" )
|
26
|
};
|
27
|
|
28
|
WFont title_font;
|
29
|
title_font.setFamily(FontFamily::SansSerif, "Arial");
|
30
|
title_font.setSize(20);
|
31
|
|
32
|
for (auto method: methods) {
|
33
|
charts.push_back(root_layout->addWidget(std::make_unique<Chart::WCartesianChart>()));
|
34
|
auto chart = charts.back();
|
35
|
chart->setTitleFont(title_font);
|
36
|
chart->setPreferredMethod(method.first);
|
37
|
chart->setTitle(std::string(method.second) + ": The quick brown fox jumps over the lazy dog");
|
38
|
}
|
39
|
}
|
40
|
|
41
|
int main(int argc, char **argv)
|
42
|
{
|
43
|
return WRun(argc, argv, [](const WEnvironment& env) {return std::make_unique<TestApp>(env);});
|
44
|
}
|