Closed Livjxbill993 closed 1 year ago
示例中的
NSString *jsFormatterStr = [NSString stringWithFormat:@AAJSFunc(
function () {
const 总时长数组 = %@;
const 有效时长数组 = %@;
const 看近时长数组 = %@;
const 看中时长数组 = %@;
const 看远时长数组 = %@;
const 切换次数数组 = %@;
const 停止次数数组 = %@;
const 干预次数数组 = %@;
const 时间单位后缀 = "min<br/>";
const 频率单位后缀 = "次<br/>";
const selectedSeries = this.points[0];
const pointIndex = selectedSeries.point.index;
const 单个总时长字符串 = "总时长:    " + 总时长数组[pointIndex] + 时间单位后缀;
const 单个有效时长字符串 = "有效时长:  " + 有效时长数组[pointIndex] + 时间单位后缀;
const 单个看近时长字符串 = "看近时长:  " + 看近时长数组[pointIndex] + 时间单位后缀;
const 单个看中时长字符串 = "看中时长:  " + 看中时长数组[pointIndex] + 时间单位后缀;
const 单个看远时长字符串 = "看远时长:  " + 看远时长数组[pointIndex] + 时间单位后缀;
const 单个切换次数字符串 = "切换次数:  " + 切换次数数组[pointIndex] + 频率单位后缀;
const 单个停止次数字符串 = "停止次数:  " + 停止次数数组[pointIndex] + 频率单位后缀;
const 单个干预次数字符串 = "干预次数:  " + 干预次数数组[pointIndex] + 频率单位后缀;
const wholeContentStr = 单个总时长字符串 + 单个有效时长字符串 + 单个看近时长字符串 + 单个看中时长字符串 + 单个看远时长字符串 + 单个切换次数字符串 + 单个停止次数字符串 + 单个干预次数字符串;
return wholeContentStr;
}),总时长JS数组, 有效时长JS数组, 看近时长JS数组, 看中时长JS数组, 看远时长JS数组, 切换次数JS数组, 停止次数JS数组, 干预次数JS数组];
其中的
const selectedSeries = this.points[0];
const pointIndex = selectedSeries.point.index;
这个 pointIndex
应该就是你想要的.
我需要根据索引从外部的数组中获取对应值显示到tooplip中
此示例正是为了实现这种需求.
aaOptions.tooltip
//‼️以 this.point.index 这种方式获取选中的点的索引必须设置 tooltip 的 shared 为 false
//‼️共享时是 this.points (由多个 point 组成的 points 数组)
//‼️非共享时是 this.point 单个 point 对象
.sharedSet(true)
.useHTMLSet(true)
.formatterSet(jsFormatterStr)
.backgroundColorSet(AAColor.blackColor)//黑色背景色
.borderColorSet(@"#FFD700")//边缘颜色纯金色
.styleSet(AAStyleColorSize(@"#FFD700", 12))//文字颜色纯金色
;
注意这段示例代码中的 ‼️ 标注的注释内容.
//‼️以 this.point.index 这种方式获取选中的点的索引必须设置 tooltip 的 shared 为 false //‼️共享时是 this.points (由多个 point 组成的 points 数组) //‼️非共享时是 this.point 单个 point 对象
AATooltip
的 formatter
属性, 详细内容参考:
参考相同问题:
demo 中有此完整示例, 下载运行查看即可.
谢谢!解决了
参考相同问题: