Closed YuanJiaShuai closed 1 year ago
/// Function of only refresh the chart data
/// @param series Series array of AAOptions instance object
- (void)aa_onlyRefreshTheChartDataWithOptionsSeries:(NSArray<AASeriesElement *> *)series;
由注释可知, 此方法只会刷新 AASeriesElement 的 data 数组数据, 不会更新图例的名称.
- (void)aa_onlyRefreshTheChartDataWithOptionsSeries:(NSArray<AASeriesElement *> *)series;
此方法实际上调用的是 JavaScript 的这个方法.:
function onlyRefreshTheChartDataWithSeries(receivedSeries, animation) {
var receivedSeriesArr = JSON.parse(receivedSeries);
var seriesArrLength = receivedSeriesArr.length;
for (var i = 0; i < seriesArrLength; i++) {
var receivedSeriesElementData = receivedSeriesArr[i].data;
var seriesElement = aaGlobalChart.series[i];
seriesElement.setData(receivedSeriesElementData, false);
}
var animationBool = (animation == "1") ? true:false;
aaGlobalChart.redraw(animationBool);
}
由此可知实际上调用的是 Highcharts 的 series
更新数据的方法:
setData(data [, redraw] [, animation] [, updatePoints])
Highcharts 在线 API 文档:
大佬,如果我想更新图例,应该怎么写啊?我试过用这个方法 [_upDownChart aa_drawChartWithOptions:aaOptions];,但是会用动画
查看 AAChartView
中的这个方法:
/// A common chart update function
/// (you can update any chart element) to open, close, delete, add, resize, reformat, etc. elements in the chart.
/// Refer to https://api.highcharts.com/highcharts#Chart.update
///
/// It should be noted that when updating the array configuration,
/// for example, when updating configuration attributes including arrays such as xAxis, yAxis, series, etc., the updated data will find existing objects based on id and update them. If no id is configured or passed If the id does not find the corresponding object, the first element of the array is updated. Please refer to this example for details.
///
/// In a responsive configuration, the response of the different rules responsive.rules is actually calling chart.update, and the updated content is configured in chartOptions.
///
/// @param options A configuration object for the new chart options as defined in the options section of the API.
/// @param redraw Whether to redraw after updating the chart, the default is true
- (void)aa_updateChartWithOptions:(id)options redraw:(BOOL)redraw;
使用示例:
AAOptions *testOptions = AAOptions.new
.seriesSet(@[]);//此处添加你的由 AASeriesElement 元素组成的数组
[self.aaChartView aa_updateChartWithOptions:testOptions redraw:true];
这个是图表的高级更新功能, AAChartKit 的 demo 中有此方法的详细使用示例. 下载运行查看即可.
此方法的在线文档:
感谢大佬的指点,可以了
这是我更新数据的方法,但是我使用最后一行代码更新图例,结果不生效
大佬,能帮我看看这是为啥吗?