| 10 | using namespace xg; |
| 11 | |
| 12 | void guide::Point::Render(XChart &chart, shape::Group *container, canvas::CanvasContext &context, |
| 13 | const std::vector<util::Rect> &dangerRects) { |
| 14 | const std::string &xField = chart.GetXScaleField(); |
| 15 | std::vector<std::string> yFields = chart.getYScaleFields(); |
| 16 | const std::string yField = yFields[0]; |
| 17 | |
| 18 | util::Point position = this->GetPosition(chart, |
| 19 | json::Get(this->config_, "position"), |
| 20 | xField, yField); |
| 21 | double size = json::GetNumber(config_, "size", 6.0) * context.GetDevicePixelRatio(); |
| 22 | double radius = size / 2.0; |
| 23 | nlohmann::json margin = config_["margin"]; |
| 24 | std::array<float, 2> _margin = margin; |
| 25 | position.x = position.x - _margin[0] * context.GetDevicePixelRatio(); |
| 26 | position.y = position.y - _margin[1] * context.GetDevicePixelRatio(); |
| 27 | |
| 28 | std::string strokeColor = json::GetString(config_, "stroke", ""); |
| 29 | std::string fillColor = json::GetString(config_, "fill", ""); |
| 30 | float lineWidth = |
| 31 | json::GetNumber(config_, "lineWidth", 0) * context.GetDevicePixelRatio(); |
| 32 | float fillOpacity = json::GetNumber(config_, "fillOpacity", 1); |
| 33 | std::string shape = json::GetString(config_, "shape", "circle"); |
| 34 | |
| 35 | if (shape == "rect") { |
| 36 | util::Point start = util::Point{position.x - radius, position.y - radius}; |
| 37 | auto rect = xg::make_unique<xg::shape::Rect>(start, util::Size{size, size}, fillColor, |
| 38 | strokeColor, lineWidth); |
| 39 | rect->SetFillOpacity(fillOpacity); |
| 40 | bbox_ = rect->GetBBox(context); |
| 41 | container->AddElement(std::move(rect)); |
| 42 | } else { |
| 43 | util::Point center = util::Point{position.x, position.y}; |
| 44 | auto circle = std::make_unique<xg::shape::Circle>(center, radius, fillColor, strokeColor, |
| 45 | lineWidth); |
| 46 | circle->SetFillOpacity(fillOpacity); |
| 47 | bbox_ = circle->GetBBox(context); |
| 48 | container->AddElement(std::move(circle)); |
| 49 | } |
| 50 | } |
nothing calls this directly
no test coverage detected