Custom Tooltips as Series Sum

  • Last update:March 26, 2025
  • Overview

    Version

    Report Server Version

    11.0

    Expected Effect

    In the document Custom Label as the Series Sum, each column is topped with the sum of series values under one category in a stacked column chart. This document will describe how to achieve a similar effect by tooltip, that is, the sum of series values is displayed as a tooltip when youo hover your cursor  over a top series and the respective series values are displayed as tooltips when you hover your cursor over other series. The following figure shows the expected effect.

    1.gif

    Implementation Method

    You can select Custom for chart tooltip content and use JavaScript codes to achieve the expected result.

    image 1.png

    Example

    Template Opening

    Download the template Custom Tooltips as Series Sum.cpt. Choose File > Open in the upper left corner of the designer to open the template.

    Report Design

    Chart Title Modification

    Select the chart, choose Cell Element > Style > Title, and change the title to Custom Tooltip - Series Summary by Category, as shown in the following figure.

    image 2.png

    Chart Label Deselection

    Select the chart, choose Cell Element > Style > Label, and deselect Use Label, as shown in the following figure.

    image 3.png

    Chart Tooltip Setting

    Select the chart, choose Cell Element > Style > Prompt, select Custom, and enter the following code:

    function sumOfPoints({
      const point = this;
      const points = this.points;
      const len = points.length;
      if (point == points[len - 1]) {
      // points.length specifies how many series exist in one category. len - 1 is used to display the summary value on the top(last series).
      // To display the summary value at the bottom, use len – 5.
        let sum = 0;
        for (let i = 0; i < len; i++) { //Summarize all series in the same category.
        // If i < len-2, the first three series from the bottom up are summarized in this example.
          if (point.isVisible()) {
            sum += points[i].value;
          }
        }
    return sum;
      }
      return point.value;
    }
    Show Code

    The following figure shows the setting.

    image 4.png

    Effect Display

    Save the report and click Pagination Preview. The effect is the same as that shown in section  "Expected Effect."

    iconNote:
    During tooltip customization, only the value of the first series is displayed as the tooltip on mobile terminals by default.

    Template Download

    For details, you can download the template Custom Tooltips as Series Sum.cpt.

    Attachment List


    Theme: Chart
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy