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

Method Render

core/graphics/XChart.cpp:487–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485}
486
487bool XChart::Render() {
488 this->logTracer_->trace("#Render %s", "start render");
489 if(canvasContext_ == nullptr) {
490 this->logTracer_->trace("error: %s", "canvasContext is nullptr, render end.");
491 return false;
492 }
493
494 if(!canvasContext_->IsValid()) {
495 this->logTracer_->trace("error: %s", "canvasContext is not valid, render end.");
496 return false;
497 }
498
499 if(!this->data_.is_array() || this->data_.size() == 0) {
500 this->logTracer_->trace("error: %s", "data is not array or size is zero, render end.");
501 return false;
502 }
503
504 auto startTimeStamp = xg::CurrentTimestampAtMM();
505
506 if(!rendered_) {
507 // 1. init Coord
508 this->logTracer_->trace("%s padding: [%lf, %lf, %lf, %lf]", "call InitCoord", padding_[0], padding_[1], padding_[2], padding_[3]);
509 this->InitCoord();
510 // 2. init Geoms
511
512 this->logTracer_->trace("%s", "foreach geom init");
513 std::for_each(geoms_.begin(), geoms_.end(), [this](auto &geom) -> void { geom->Init(this); });
514 rendered_ = true;
515
516 this->NotifyAction(ACTION_CHART_AFTER_INIT);
517 }
518 // 3. legend render
519 this->logTracer_->trace("%s", "legendController render");
520 legendController_->Render(*this);
521
522 // 4. render Axis
523 this->logTracer_->trace("%s", "draw axies");
524 axisController_->DrawAxes(this, *canvasContext_);
525
526 // 5. geom paint
527 this->logTracer_->trace("%s", "foreach geom paint");
528
529 std::for_each(geoms_.begin(), geoms_.end(), [this](auto &geom) { geom->Paint(this); });
530 // 6. guide render
531 this->NotifyAction(ACTION_CHART_AFTER_GEOM_DRAW);
532
533 // 6.1 guide render
534 this->logTracer_->trace("%s", "guideController render");
535 guideController_->Render(*this, *canvasContext_);
536
537 // 7. children sort
538 this->logTracer_->trace("%s", "canvas#sort");
539 this->canvas_->Sort();
540
541 // 图元元素限定在屏幕区域内绘制。当绘制元素很多时(K线),这个操作耗时太大,先不执行这个操作。
542 // midLayout_->clip_ = std::make_unique<shape::Rect>(util::Point{coord_->GetXAxis().x, coord_->GetYAxis().y},
543 // util::Size{coord_->GetWidth(), coord_->GetHeight()});
544 // util::Matrix matrix = {0.029800, 0.000000, 0.000000, 1.000000, 104.251022, 0.000000};

Callers 2

InvokeRenderMethod · 0.45
ChartRenderFunction · 0.45

Calls 15

InitCoordMethod · 0.95
NotifyActionMethod · 0.95
CurrentTimestampAtMMFunction · 0.85
traceMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
DrawAxesMethod · 0.80
PaintMethod · 0.80
ChangeSizeMethod · 0.80
GetRenderCountMethod · 0.80
IsValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected