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

Method GetPositions

core/bridge/ChartBridge.cpp:101–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101std::string ChartBridge::GetPositions(const nlohmann::json &itemDatas) {
102 nlohmann::json array = {};
103 if (chart_ == nullptr || itemDatas.is_null() || !itemDatas.is_array() || itemDatas.empty()) {
104 return array.dump();
105 }
106 auto ratio = chart_->GetCanvasContext().GetDevicePixelRatio();
107 if (ratio <= 0) {
108 ratio = 1;
109 }
110
111 for (auto it = itemDatas.begin(); it != itemDatas.end(); ++it) {
112 const auto &position = chart_->GetPosition(*it);
113 array.push_back({position.x / ratio / pixelRatio_,
114 position.y / ratio / pixelRatio_});
115 }
116 return nlohmann::json({{"method","getPositions"}, {"positions",array}}).dump();
117}
118
119nlohmann::json ChartBridge::GetPosition(const nlohmann::json &itemData) {
120 if (chart_ == nullptr || itemData.is_null()) {

Callers

nothing calls this directly

Calls 8

dumpMethod · 0.80
GetDevicePixelRatioMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
push_backMethod · 0.80
emptyMethod · 0.45
GetCanvasContextMethod · 0.45
GetPositionMethod · 0.45

Tested by

no test coverage detected