AAChartModel / AAChartKit

📈📊🚀🚀🚀An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的现代化声明式数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.
https://cocoapods.org/pods/AAChartKit
MIT License
4.7k stars 751 forks source link

Background color change is late, so it flashes from white to selected color #1534

Open mladjan opened 5 months ago

mladjan commented 5 months ago

I have a graph which is part of my UIView subclass (looks like this):

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupUI];
}

- (void)setupUI {
    // Create AAChartView instance
    _aaChartView = [[AAChartView alloc] init];
    _aaChartView.scrollEnabled = NO;
    _aaChartView.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:_aaChartView];

    // Add constraints to position and size _aaChartView within RBGraphView
    NSLayoutConstraint *topConstraint = [_aaChartView.topAnchor constraintEqualToAnchor:self.topAnchor];
    NSLayoutConstraint *bottomConstraint = [_aaChartView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor];
    NSLayoutConstraint *leadingConstraint = [_aaChartView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor];
    NSLayoutConstraint *trailingConstraint = [_aaChartView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor];

    [NSLayoutConstraint activateConstraints:@[topConstraint, bottomConstraint, leadingConstraint, trailingConstraint]];

    AAChart *aaChart = AAChart.new
    .backgroundColorSet(@"#191923");

    AATitle *aaTitle = AATitle.new
    .textSet(@"");

    AAOptions *aaaOptions = AAOptions.new
    .chartSet(aaChart)
    .titleSet(aaTitle) ;

    [_aaChartView aa_drawChartWithOptions:aaaOptions];

}

It is added to ViewController in viewDidLoad:


 public override func viewDidLoad() {
        super.viewDidLoad()

        rbGraphView = RBGraphView()
        guard let rbGraphView = rbGraphView else {return}
        rbGraphView.translatesAutoresizingMaskIntoConstraints = false
        graphContentView.addSubview(rbGraphView)

// some auto layout constraints

}

The problem is that background color change is happening when the screen is shown, so it flashes from white to #191923

I can't add and draw it earlier then viewDidLoad.

Is there any way to make it earlier?