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

Class ScaleController

core/graphics/scale/ScaleController.h:135–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135class ScaleController {
136 public:
137 const std::unique_ptr<AbstractScale> &CreateScale(const std::string &field_,
138 const nlohmann::json &data,
139 utils::Tracer *tracer,
140 std::unique_ptr<canvas::coord::AbstractCoord> &coord) {
141 nlohmann::json fieldConfig = json::Get(colConfigs, field_);
142 if(!scales_.empty()) {
143 std::string _key = field_;
144 if(fieldConfig.contains("assign")) {
145 _key = fieldConfig["assign"];
146 }
147
148 std::vector<std::unique_ptr<AbstractScale>>::iterator it =
149 std::find_if(scales_.begin(), scales_.end(),
150 [&](const std::unique_ptr<AbstractScale> &item) { return (item->field == _key); });
151
152 if(it != scales_.end()) {
153 // TODO 更新 scale config, 暂时没有什么 config
154 return (*it);
155 }
156 }
157 std::unique_ptr<AbstractScale> _target = MakeScale(field_, data, colConfigs[field_], tracer, coord);
158 scales_.push_back(std::move(_target));
159 return scales_[scales_.size() - 1];
160 }
161
162 void UpdateColConfig(const std::string &field, nlohmann::json cfg) { colConfigs[field] = cfg; }
163
164 bool Empty() { return scales_.empty(); }
165
166 void Clear() {
167 scales_.clear();
168 colConfigs = {};
169 };
170
171 size_t ScaleCount() {
172 return scales_.size();
173 }
174
175 private:
176 std::vector<std::unique_ptr<AbstractScale>> scales_{};
177 nlohmann::json colConfigs;
178};
179} // namespace scale
180} // namespace xg
181

Callers

nothing calls this directly

Calls 7

GetFunction · 0.85
MakeScaleFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
push_backMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected