Line-Wrapping Display of Chart Labels

  • Last update:February 24, 2025
  • Overview

    Problem

    For a label with long content, if you set the label inside a chart, the label will exceed the scope of the graphic, which affects the aesthetic appeal of the report, as shown in the following figure.

    Solution

    You can achieve a line-wrapping display for label texts by customizing the label.

    Example

    Report Design

    1. Create a general report and create a built-in dataset named Embedded1, as shown in the following figure.

    2. Merge required cells, and insert a column chart, as shown in the following figure.

    3. Select the column chart, choose Cell Element > Style > Label on the right attribute panel, tick Use Label, and enter the custom label code, as shown in the following figure.

    The code is as follows:

    function(){  var a = this.value.toString(); //Convert a logical value into a string and return the result.
    var length = a.length; var b = parseInt((a.length)/2); // Divide the label into two parts and round it up.
    var value= a.substring(0,b)+"<br>"+a.substring(b,length); //Display the former part, and display the latter part in the next line.
    return value
    }

    Effect Display

    1. PC

    Save the report and click Pagination Preview. The following figure shows the preview effect.

    2. Mobile Terminal

    Template Download

    The completed template can be found in: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Chart\NewColumnChart\Line-Wrapping Display of Chart Labels.cpt

    You can download the example template: Line-Wrapping Display of Chart Labels.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