MCPcopy Create free account
hub / github.com/antvis/F2Native / DrawLine

Method DrawLine

core/graphics/axis/AxisController.cpp:644–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642}
643
644void xg::axis::AxisController::DrawLine(XChart &chart, std::array<util::Point, 2> &&line, const nlohmann::json &lineCfg) {
645 float lineWidth = lineCfg["lineWidth"].get<float>() * chart.GetCanvasContext().GetDevicePixelRatio();
646 if(lineCfg["type"] == "line") {
647 std::unique_ptr<xg::shape::Element> _line = xg::make_unique<xg::shape::Line>(line[0], line[1], lineWidth, lineCfg["color"]);
648 this->container_->AddElement(std::move(_line));
649 } else if(lineCfg["type"] == "dash") {
650 std::vector<util::Point> _points = {line[0], line[1]};
651 auto l = xg::make_unique<xg::shape::Polyline>(lineWidth, _points, false);
652 l->SetStorkColor(lineCfg["color"]);
653 l->SetZIndex(-1);
654 std::vector<float> dash = xg::json::ParseDashArray(lineCfg["dash"], chart.GetCanvasContext().GetDevicePixelRatio());
655 l->SetDashLine(dash);
656 this->container_->AddElement(std::move(l));
657 }
658}
659
660void xg::axis::AxisController::DrawLabel(XChart &chart, std::unique_ptr<xg::axis::Axis> &axis, canvas::CanvasContext &context) {
661 // xg::util::Point start = GetOffsetPoint(axis, label.value);

Callers

nothing calls this directly

Calls 7

ParseDashArrayFunction · 0.85
GetDevicePixelRatioMethod · 0.80
AddElementMethod · 0.80
SetStorkColorMethod · 0.80
SetZIndexMethod · 0.80
GetCanvasContextMethod · 0.45
SetDashLineMethod · 0.45

Tested by

no test coverage detected