Добавление других полей, включая xvalue и yvalue, во всплывающую подсказку для LightningChart JS - PullRequest
1 голос
/ 22 января 2020

Я добавляю диаграмму вот так

 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

1 Ответ

0 голосов
/ 24 января 2020

Вы можете отобразить нужные данные, установив для параметра 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)
} )
...