Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PNChart display issuer while using YogaKit #464

Open
Gin6x opened this issue Jul 7, 2021 · 0 comments
Open

PNChart display issuer while using YogaKit #464

Gin6x opened this issue Jul 7, 2021 · 0 comments

Comments

@Gin6x
Copy link

Gin6x commented Jul 7, 2021

I am trying to use both PNChart and Yogakit, but the chart could not display correctly. Below is the code in my projct.

UIView *root = self.view;
[root configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
    layout.isEnabled = YES;
    layout.flexDirection = YGFlexDirectionColumn;
}];

PNLineChart * lineChart = [[PNLineChart alloc] init];
lineChart.backgroundColor = UIColor.whiteColor;
[lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]];

// Line Chart No.1
NSArray * data01Array = @[@60.1, @160.1, @126.4, @262.2, @186.2];
PNLineChartData *data01 = [PNLineChartData new];
data01.color = PNFreshGreen;
data01.itemCount = lineChart.xLabels.count;
data01.getData = ^(NSUInteger index) {
    CGFloat yValue = [data01Array[index] floatValue];
    return [PNLineChartDataItem dataItemWithY:yValue];
};
// Line Chart No.2
NSArray * data02Array = @[@20.1, @180.1, @26.4, @202.2, @126.2];
PNLineChartData *data02 = [PNLineChartData new];
data02.color = PNTwitterColor;
data02.itemCount = lineChart.xLabels.count;
data02.getData = ^(NSUInteger index) {
    CGFloat yValue = [data02Array[index] floatValue];
    return [PNLineChartDataItem dataItemWithY:yValue];
};

lineChart.chartData = @[data01, data02];
[lineChart strokeChart];

[lineChart configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
    layout.isEnabled = YES;
    layout.flex = 7;
}];

[root addSubview:lineChart];

Is it possible to set the layout with yoga in pnchart? I am fairly new in ios development, please forgive me if I made it unclear, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant