AAChartModel / AAChartKit Public
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
折线图Y轴显示的数据错误导致图形画错了 #996
Comments
|
你的配置 AAOptions 的代码呢,贴出来看看(不要截图) |
-(void)setupDayToolTipsViewWithTime:(NSString *)time{
AAChartModel *aaChartModel = [self customDayChartSymbolContent];
//2.绘制图表
/*图表视图对象调用图表模型对象,设置对应的AAOptions,绘制最终图形*/
AAOptions *options = [AAOptionsConstructor configureChartOptionsWithAAChartModel:aaChartModel];
AATooltip *getTooltip = options.tooltip; //获取弹出框,自定义图表浮动提示框样式及内容
NSString *finalStr = [NSString stringWithFormat:@"<span style=""color:white;font-size:12px;font-weight:bold;"">客流</span><br>时间段: %@<br>",time];
getTooltip
.headerFormatSet(finalStr)
.backgroundColorSet(@"#272727") //设置背景色
.borderColorSet(@"#272727") //边框颜色
.useHTMLSet(true)
.styleSet((id)AAStyle.new //设置字体
.colorSet(@"#FFFFFF")
.fontSizeSet(@"10px"))
;
[self.dayChartView aa_updateChartWithOptions:options];
}
- (AAChartModel *)customDayChartSymbolContent {
AAChartModel *aaChartModel = AAChartModel.new
.chartTypeSet(AAChartTypeLine)
.titleSet(@"")
.colorsThemeSet(@[@"#5C89FF",@"#7C6AF2",@"#00A57C"])
.subtitleSet(@"")
.yAxisTitleSet(@"")
.animationTypeSet(AAChartAnimationEaseOutCubic)//图形的渲染动画类型
.legendEnabledSet(NO) //不显示图表底部的具体数据
// .touchEventEnabledSet(YES) //支持用户点击事件,设置为YES,才能使用监听滑动的代理回调
.yAxisGridLineWidthSet(@1) //y轴风格线的宽度
// .yAxisMaxSet(@900) //y轴的最大值
.yAxisMinSet(@0) //y轴最小值,最小为0中心点,不会有负数
.stackingSet(AAChartStackingTypeNormal)
.markerRadiusSet(@0) //连接中心圆圈为0,即不显示连接点圆圈
.yAxisLineWidthSet(@0) //隐藏y轴线
// .tooltipValueSuffixSet(@"元")//设置浮动提示框单位后缀
.xAxisCrosshairWidthSet(@01.2)//Zero width to disable crosshair by default
.categoriesSet(@[
@"0点",
@"8点",
@"9点",
@"10点",
@"11点",
@"12点",
@"13点",
@"14点",
@"15点",
@"16点",
@"17点",
@"18点",
@"19点",
@"20点",
@"21点",
@"22点",
@"24点",
]); //x轴的具体数据
NSArray *getArr = [self setupSeriesDataWithArr];
aaChartModel.series = getArr;
return aaChartModel;
}
-(NSArray *)setupSeriesDataWithArr{
NSMutableArray *dayArr = [NSMutableArray array];
NSMutableArray *lastMonthArr = [NSMutableArray array];
NSMutableArray *thisMonthArr = [NSMutableArray array];
for (DSLNewsflashCustomCountModel *model in self.dayChartDataArr) {
//当前客流
[dayArr addObject:model.traffic];
//上月均值
[lastMonthArr addObject:model.avgLastMonthTraffic];
//本月均值
[thisMonthArr addObject:model.avgMonthTraffic];
}
//写死0点数据为0,8点的数据才是0-8区间的数据
[dayArr insertObject:@0 atIndex:0];
[lastMonthArr insertObject:@0 atIndex:0];
[thisMonthArr insertObject:@0 atIndex:0];
NSArray *seriesArr = @[
AASeriesElement.new
.nameSet(@"上月均值")
.tooltipSet(AATooltip.new
.backgroundColorSet(@"#272727"))
.markerSet(AAMarker.new
.symbolSet(AAChartSymbolTypeCircle))
.dataSet(lastMonthArr),
AASeriesElement.new
.nameSet(@"本月均值")
.tooltipSet(AATooltip.new
.backgroundColorSet(@"#272727"))
.markerSet(AAMarker.new
.symbolSet(AAChartSymbolTypeCircle))
.dataSet(thisMonthArr),
AASeriesElement.new
.nameSet(@"当前日期")
.tooltipSet(AATooltip.new
.backgroundColorSet(@"#272727"))
.markerSet(AAMarker.new
.symbolSet(AAChartSymbolTypeCircle))
.dataSet(dayArr),
];
return seriesArr;
} |
.stackingSet(AAChartStackingTypeNormal)//图表为常规堆叠效果你把这句代码去掉试试看呢, 去掉之后, 图表默认效果为非堆叠效果. |
感谢大佬及时回复,注释之后显示就正常了。再次感谢哈~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

大佬:

如题。我专门看了下你的demo,我发现多条折线图时Y轴的点是错误的,对应不上。只有一条折线图才是完全正确的,我感觉Y轴的数据是几条折线图的数据相加了导致的。这是你demo的图:
只有NewYork Hot的0.68是正确的,另外三个不对
这个是我做的图:

只有当前日期图是对的,另外两个不对,Y轴的数据就是相加起来了导致图画错了。麻烦大佬看下,感谢感谢~
The text was updated successfully, but these errors were encountered: