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

这个功能怎么实现 #1512

Open
CoderST opened this issue Nov 8, 2023 · 3 comments
Open

这个功能怎么实现 #1512

CoderST opened this issue Nov 8, 2023 · 3 comments

Comments

@CoderST
Copy link

CoderST commented Nov 8, 2023

截屏2023-11-08 13 08 41
Demo的这个功能是在增加一个新值后 数组第一个值就被取消了。
我们需要功能如下:
1:自动追加最后一个新Y值 但是第一个值不被删除。
2:右滑可以查看历史的值,现在Demo删除了第一个Y值,也不能右滑。
请问大神 这个怎么实现,或者给点指点,感激不尽。

@AAChartModel
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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;

但是这个方法实现的效果, 在移动端设备上, 左右滑动起来的体验也是一言难尽.

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

2 participants