2

I'm using AmCharts v4 to create an XYChart with 3 series. When each series is created, I assign a tooltip:

series.tooltipText = "{name}: [bold]{valueY}[/]";

However, the chart ends up displaying only a single tooltip (Temperature: -50).

Single tooltip, multiple series

There are many questions on StackOverflow about the opposite problem: users seeing multiple tooltips displayed by default, when they want to see a single combined tool-tip. For example, I want my chart to look like the one in this question:

Amcharts 4, xychart, limiting the number of tooltips and combining infos in one tooltip

How is it possible that I have created 3 series, each is displayed correctly, each has a tooltip assigned, but I only see one tooltip when hovering?

3 Answers 3

3

Ok, the explanation is: I was creating a chart and pushing my data directly to chart.data.

It turns out that I need to push the series-specific datapoints to series.data individually for each series. Then I get a separate tool-tip for each series. This concept is explained here:

https://www.amcharts.com/docs/v4/concepts/series/

2
  • Im facing the same issue, Can you post the code of your solution? Commented Jan 22, 2021 at 17:51
  • @NestorPerez sorry, it was for a previous job so it's proprietary. Are you doing what I suggest in this post? Creating the chart first, and pushing data-points individually?
    – afarley
    Commented Jan 22, 2021 at 21:46
0

I had the same issue and I solve it by adding

widget.chart.series.getIndex(j).data = datas;

instead of

widget.chart.data = datas;
0

I find a solution maybe it helps was written in Angular framework. I wrote a general function which is uploading the chart data one by one.

private uploadChartData(readings: Reading[], dataFieldX: string, dataFieldY: string): void {
    const seriesIndex: number = this.findSeriesIndex(dataFieldY);
    for (const reading of readings) {
        const chartData = {
            [dataFieldX]: reading.timeStamp,
            [dataFieldY]: reading.value
        };
        this.addOneChartData(chartData, seriesIndex);
    }
}

private findSeriesIndex(seriesName: string): number {
    for (let i = 0; i < this.chart.series.values.length; i++) {
        if (this.chart.series.values[i].dataFields.valueY === seriesName) {
            return i;
        }
    }
    return 0;
}

private addOneChartData(chartData: any, seriesIndex: number): void {
    this.chart.addData(chartData);
    this.chart.series.getIndex(seriesIndex).addData(chartData);
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.