| 376 | } |
| 377 | |
| 378 | const std::string XChart::OnTapEvent(const std::string &json) { |
| 379 | if(!canvasContext_ || !canvasContext_->IsValid()) { |
| 380 | return ""; |
| 381 | } |
| 382 | nlohmann::json cfg = xg::json::ParseString(json); |
| 383 | if(!cfg.is_object() || !cfg.contains("eventType") || !cfg.contains("points")) |
| 384 | return ""; |
| 385 | event::Event event; |
| 386 | event.eventType = cfg["eventType"]; |
| 387 | nlohmann::json &_points = cfg["points"]; |
| 388 | if(!_points.is_array() || _points.empty()) { |
| 389 | return ""; |
| 390 | } |
| 391 | |
| 392 | for(std::size_t i = 0; i < _points.size(); ++i) { |
| 393 | nlohmann::json &_point = _points[i]; |
| 394 | util::Point point{_point["x"], _point["y"]}; |
| 395 | event.points.push_back(std::move(point)); |
| 396 | } |
| 397 | event.devicePixelRatio = ratio_; |
| 398 | event.timeStamp = xg::CurrentTimestampAtMM(); |
| 399 | this->logTracer_->trace("#OnTapEvent: %s", json.data()); |
| 400 | return this->eventController_->OnTapEvent(event); |
| 401 | } |
| 402 | |
| 403 | XChart &XChart::Scale(const std::string &field, const std::string &json) { |
| 404 | return ScaleObject(field, xg::json::ParseString(json)); |
no test coverage detected