javascript - 在 LightningChart JS 的工具提示上添加其他字段,包括 xvalue 和 yvalue
问题描述
我正在添加这样的图表
for (let tpName in tpGroupedData) {
this.series = this.chartInstance
.addPointSeries({ pointShape: shapes[shapeIndex], dataPattern: lsjs.DataPatterns.horizontalProgressive, xAxis: createdAxis })
.setPointFillStyle((solidFill) => solidFill.setColor(lsjs.ColorHEX(palette.simpleSet[seriesColorIndex])))
.setName(groupTag.slice(0, groupTag.indexOf('(')) + '( ' + tpName + ' )');
for (let dataItem of tpGroupedData[tpName]) {
this.series.add({ x: Date.parse(dataItem.testDateTime) - dateOrigin, y: dataItem.value })
}
在工具提示上,我还想添加 dataItem 的其他值,而不仅仅是显示 x 和 y 坐标
解决方案
您可以通过使用自定义设置系列的 resultTableFormatter 来显示您想要的数据。
您可以通过使用TableContentBuilder来做到这一点,如下所示:
series.setResultTableFormatter((builder, series, segment) => {
return builder
.addRow(series.getName())
// Get the data from the series X value, use formatting from Axis TickStrategy
.addRow(series.axisX.formatValue(segment.getPosition()))
// Add additional row. A single string will be centered horizontally in the resultTable.
.addRow('Additional data: ' + dataToShow ))
// Add additional row. Undefined or '' marks a gap, which will fill any extra space of row. Here the first string will be anchored to the left; third string is anchored to the right of the resultTable.
.addRow('More data', undefined, dataToShow)
} )
推荐阅读
- java - 通过单击按钮进行 Google Duo 音频/视频通话
- java - 频繁的“偏移超出范围”消息,消费者遗弃的分区
- java - 从 Google 电子表格获取数据到我的应用程序的代码突然停止工作
- python - 在 Python 中发送发布请求以登录网站所涉及的步骤
- selenium - 我们应该在 @BeforeClass 中使用 assert 还是在 TestNG 中使用 @BeforeTest 注释,这样做是一个好习惯吗?
- java - 如何为 Firebase 数据库异常添加内置类的无参数构造函数?
- java - 事件监听器的控制流
- python-3.x - 用另一个值更新熊猫数据框的正确方法
- java - login RESTFUL api,它在登录成功时返回一个 id
- python - Selenium 超时异常错误