AAChartKit
AAChartKit copied to clipboard
graph legend for MacOS
I trying a simple graph with macOS sequoia:
-(void)drawChartType
{
[self setUpChartView];
[self setupAAChartViewWithChartType];
[self.aaChartView aa_drawChartWithChartModel: self.aaChartModel];
}
-(void)setUpChartView
{
self.aaChartView = [[AAChartView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:self.aaChartView];
}
-(void)setupAAChartViewWithChartType
{
_aaChartModel = AAChartModel.new
.chartTypeSet(self.aaChartType)
.colorsThemeSet(@[@"#fe117c",@"#ffc069",@"#06caf4",@"#7dffc0"])
.tooltipValueSuffixSet(@"β")
.yAxisLineWidthSet(@0)
.yAxisGridLineStyleSet([AALineStyle styleWithWidth:@0])
.xAxisLabelsStyleSet(AAStyleColor(AAColor.lightGrayColor))
.yAxisLabelsStyleSet(AAStyleColor(AAColor.lightGrayColor))
.xAxisLabelsEnabledSet(YES)
//.legendItemStyleSet(AAStyleColorSizeWeight(AAColor.lightGrayColor, 15, AAChartFontWeightTypeBold))
.seriesSet(@[
AASeriesElement.new
.nameSet(@"2017")
.dataSet(@[@7.0, @6.9, @9.5, @14.5, @18.2, @21.5, @25.2, @26.5, @23.3, @18.3, @13.9, @9.6]),
AASeriesElement.new
.nameSet(@"2018")
.dataSet(@[@0.2, @0.8, @5.7, @11.3, @17.0, @22.0, @24.8, @24.1, @20.1, @14.1, @8.6, @2.5]),
AASeriesElement.new
.nameSet(@"2019")
.dataSet(@[@0.9, @0.6, @3.5, @8.4, @13.5, @17.0, @18.6, @17.9, @14.3, @9.0, @3.9, @1.0]),
AASeriesElement.new
.nameSet(@"2020")
.dataSet(@[@3.9, @4.2, @5.7, @8.5, @11.9, @15.2, @17.0, @16.6, @14.2, @10.3, @6.6, @4.8]),
]);
[self configureStyleForChartType];
}
-(void)configureStyleForChartType
{
NSInteger chartTypeNum = [self.chartTypeMap[self.aaChartType] integerValue];
switch(chartTypeNum)
{
case BasicChartTypeColumn:
case BasicChartTypeBar:
[self configureColumnAndBarStyle];
break;
case BasicChartTypeArea:
case BasicChartTypeAreaspline:
[self configureAreaAndAreaSplineStyle];
break;
case BasicChartTypeLine:
case BasicChartTypeSpline:
[self configureLineAndSplineStyle];
break;
case BasicChartTypeStepLine:
case BasicChartTypeStepArea:
[self configureStepLineAndStepAreaStyle];
break;
case BasicChartTypeScatter:
[self configureScatterStyle];
break;
}
}
-(void)configureColumnAndBarStyle
{
self.aaChartModel
.categoriesSet(@[@"Java", @"Swift", @"Python", @"Ruby", @"PHP", @"Go",@"C", @"C#", @"C++", @"Perl", @"R", @"SQL"])
.animationTypeSet(AAChartAnimationEaseOutCubic)
.animationDurationSet(@(1200));
}
it kinda works, but I'm getting numbers "0, 2, 4, 6 ..." on the x-axis instead of the programming languages I defined with categoriesSet. What am I doing wrong?
Perhaps you did not assign a valid value to the categories property, or somewhere along the way this categories property value was overwritten. Please ensure that your final AAOptions JSON string includes this valid categories array value.
In the console, you can find the printed final JSON string content.