AAChartKit
AAChartKit copied to clipboard
如图,曲线填充图是否可以设置默认选中某条数据,展示浮窗?
嗨,哥们 我想知道如何设置曲线填充这种渐变颜色?
我也有这样的需求
#636
#636
感谢回复,我这边的需求是可以设置默认选中某条数据,展示浮窗o-o\\
@AXUSA 解决了吗?我也有这样的需求
@AXUSA 解决了吗?我也有这样的需求
没有没有
参考相同问题:
- https://github.com/AAChartModel/AAChartKit-Swift/issues/345
OC 版本的配置方式为:
- (AAOptions *)setCrosshairAndTooltipToTheDefaultPositionAfterLoadingChart {
AAChartModel *aaChartModel = AAChartModel.new
.chartTypeSet(AAChartTypeAreaspline)//图表类型
.colorsThemeSet(@[@"#04d69f",@"#1e90ff",@"#ef476f",@"#ffd066",])
.stackingSet(AAChartStackingTypeNormal)
.yAxisVisibleSet(false)
.markerRadiusSet(@0)
.seriesSet(@[
AASeriesElement.new
.nameSet(@"Tokyo Hot")
.lineWidthSet(@5.0)
.fillOpacitySet(@0.4)
.dataSet(@[@0.45, @0.43, @0.50, @0.55, @0.58, @0.62, @0.83, @0.39, @0.56, @0.67, @0.50, @0.34, @0.50, @0.67, @0.58, @0.29, @0.46, @0.23, @0.47, @0.46, @0.38, @0.56, @0.48, @0.36]),
AASeriesElement.new
.nameSet(@"Berlin Hot")
.lineWidthSet(@5.0)
.fillOpacitySet(@0.4)
.dataSet(@[@0.38, @0.31, @0.32, @0.32, @0.64, @0.66, @0.86, @0.47, @0.52, @0.75, @0.52, @0.56, @0.54, @0.60, @0.46, @0.63, @0.54, @0.51, @0.58, @0.64, @0.60, @0.45, @0.36, @0.67]),
AASeriesElement.new
.nameSet(@"London Hot")
.lineWidthSet(@5.0)
.fillOpacitySet(@0.4)
.dataSet(@[@0.46, @0.32, @0.53, @0.58, @0.86, @0.68, @0.85, @0.73, @0.69, @0.71, @0.91, @0.74, @0.60, @0.50, @0.39, @0.67, @0.55, @0.49, @0.65, @0.45, @0.64, @0.47, @0.63, @0.64]),
AASeriesElement.new
.nameSet(@"NewYork Hot")
.lineWidthSet(@5.0)
.fillOpacitySet(@0.4)
.dataSet(@[@0.60, @0.51, @0.52, @0.53, @0.64, @0.84, @0.65, @0.68, @0.63, @0.47, @0.72, @0.60, @0.65, @0.74, @0.66, @0.65, @0.71, @0.59, @0.65, @0.77, @0.52, @0.53, @0.58, @0.53]),
]);
AAOptions *aaOptions = aaChartModel.aa_toAAOptions;
aaOptions.tooltip
.styleSet(AAStyleColor(AAColor.whiteColor))
.backgroundColorSet(@"#050505")
.borderColorSet(@"#050505");
aaOptions.xAxis
.crosshairSet(AACrosshair.new
.colorSet(AAColor.darkGrayColor)
.dashStyleSet(AAChartLineDashStyleTypeLongDashDotDot)
.widthSet(@2));
//默认选中的位置索引
NSUInteger defaultSelectedIndex = 5;
//https://api.highcharts.com/highcharts/chart.events.load
//https://www.highcharts.com/forum/viewtopic.php?t=36508
aaOptions.chart
.eventsSet(AAChartEvents.new
.loadSet([NSString stringWithFormat:@AAJSFunc(function() {
let points = [];
let chart = this;
let series = chart.series;
let length = series.length;
for (let i = 0; i < length; i++) {
let pointElement = series[i].data[%ld];
points.push(pointElement);
}
chart.xAxis[0].drawCrosshair(null, points[0]);
chart.tooltip.refresh(points);
}), defaultSelectedIndex]));
return aaOptions;
}