这个功能怎么实现
Opened this issue · 3 comments
CoderST commented
AAChartModel commented
1:自动追加最后一个新Y值 但是第一个值不被删除。
/// Add a new point to the data column after the chart has been rendered.
/// The new point can be the last point, or it can be placed in the corresponding position given the X value (first, middle position, depending on the x value)
/// Refer to https://api.highcharts.com/highcharts#Series.addPoint
///
/// @param elementIndex The specific series element
/// @param options The configuration of the data point can be a single value, indicating the y value of the data point; it can also be an array containing x and y values; it can also be an object containing detailed data point configuration. For detailed configuration, see series.data.
/// @param redraw The default is true, whether to redraw the icon after the operation is completed. When you need to add more than one point, it is highly recommended to set redraw to false and manually call chart.redraw() to redraw the chart after all operations have ended.
/// @param shift The default is false. When this property is true, adding a new point will delete the first point in the data column (that is, keep the total number of data points in the data column unchanged). This property is very useful in the inspection chart
/// @param animation The default is true, which means that when adding a point, it contains the default animation effect. This parameter can also be passed to the object form containing duration and easing. For details, refer to the animation related configuration.
- (void)aa_addPointToChartSeriesElementWithElementIndex:(NSUInteger)elementIndex
options:(id)options
redraw:(BOOL)redraw
shift:(BOOL)shift
animation:(BOOL)animation;
关键内容:
/// @param shift The default is false. When this property is true, adding a new point will delete the first point in the data column (that is, keep the total number of data points in the data column unchanged). This property is very useful in the inspection chart
也就是说, 调用这个方法的时候, 设置参数 shift 为 false 就可以保证第一个值不被删除.
附言: demo 中的这两个方法
- (void)aa_addPointToChartSeriesElementWithElementIndex:(NSUInteger)elementIndex
options:(id)options;
- (void)aa_addPointToChartSeriesElementWithElementIndex:(NSUInteger)elementIndex
options:(id)options
shift:(BOOL)shift;
内部调用的其实也还是上面的这个方法.
AAChartModel commented
2:右滑可以查看历史的值,现在Demo删除了第一个Y值,也不能右滑。
官方提供的左右或上下滑动的功能是设置 AAChart
对象的 scrollablePlotArea
属性. scrollablePlotArea
的可配置内容如下
//Refer to online API document: https://api.highcharts.com/highcharts/chart.scrollablePlotArea
@interface AAScrollablePlotArea : NSObject
AAPropStatementAndPropSetFuncStatement(strong, AAScrollablePlotArea, NSNumber *, minHeight)
AAPropStatementAndPropSetFuncStatement(strong, AAScrollablePlotArea, NSNumber *, minWidth)
AAPropStatementAndPropSetFuncStatement(strong, AAScrollablePlotArea, NSNumber *, opacity)
AAPropStatementAndPropSetFuncStatement(strong, AAScrollablePlotArea, NSNumber *, scrollPositionX)
AAPropStatementAndPropSetFuncStatement(strong, AAScrollablePlotArea, NSNumber *, scrollPositionY)
@end
但是这个功能有偶发性 bug, 官方至今也未解决, 参考:
AAChartModel commented
2:右滑可以查看历史的值,现在Demo删除了第一个Y值,也不能右滑。
还有一种设置左右滑动的方法, 为 AAChartView 如下的这个方法:
/// Update the X axis Extremes
/// @param min X axis minimum
/// @param max X axis maximum
- (void)aa_updateXAxisExtremesWithMin:(NSUInteger)min max:(NSUInteger)max;
但是这个方法实现的效果, 在移动端设备上, 左右滑动起来的体验也是一言难尽.