如何设置tooltip在某些数据满足条件才显示,不满足条件不显示?
InnocentYang opened this issue · comments
重复问题, 参考:
Java 版本的写法, 示例如下:
public static AAOptions customLineChartTooltipStyleWhenValueBeZeroDoNotShow() {
AAChartModel aaChartModel = new AAChartModel()
.chartType(AAChartType.Area)//图形类型
.markerSymbolStyle(AAChartSymbolStyleType.BorderBlank)//折线连接点样式为外边缘空白
.dataLabelsEnabled(false)
.categories(new String[]{"临床一期","临床二期","临床三期"})
.series(new AASeriesElement[]{
new AASeriesElement()
.name("上市")
.data(new Object[]{0, 0, 7}),
new AASeriesElement()
.name("中止")
.data(new Object[]{4, 5, 1}),
new AASeriesElement()
.name("无进展")
.data(new Object[]{2, 0, 1}),
new AASeriesElement()
.name("进行中")
.data(new Object[]{3, 5, 2}),
});
AATooltip aaTooltip = new AATooltip()
.useHTML(true)
.formatter("function () {\n" +
" let wholeContentStr = this.points[0].x + '<br/>';\n" +
" let length = this.points.length;\n" +
" for (let i = 0; i < length; i++) {\n" +
" let thisPoint = this.points[i];\n" +
" let yValue = thisPoint.y;\n" +
" if (yValue != 0) {\n" +
" let prefixStr = '<span style=\\\"' + 'color:'+ thisPoint.color + '; font-size:13px\\\"' + '>◉ ';\n" +
" wholeContentStr += prefixStr + thisPoint.series.name + ': ' + yValue + '<br/>';\n" +
" }\n" +
" }\n" +
" return wholeContentStr;\n" +
" }")
;
AAOptions aaOptions = aaChartModel.aa_toAAOptions();
aaOptions.tooltip(aaTooltip);
return aaOptions;
}
你可以在 AAChartCore 的 demo 中找到此示例.