Successfully!

Error!

Chart Label Wrap Display

  • Last update:  2021-03-12
  • I. Overview

    1.1 Problem Description

    When the content of the chart label is too long, if the label is set inside, it will exceed the scope of the graph and affect the beauty of the report, as shown in the following figure:

    1.png


    1.2 Solution

    By customizing the label, the label text can be displayed in a new line.

    2. Example

    2.1 Report Design

    1) Create a new normal report, and create a new embedded dataset Embedded1, as shown in the figure below:

    2.png

    2) Merge a range of cells and insert a column chart, as shown in the figure below:

    3.png

    3) Select the column chart, select Cell Element> Style> Label in the attribute pane on the right, check Use Label, and enter the custom label code, as shown in the following figure:

    4.png

    Code show as below:

    function(){
       var a = this.value.toString();//Can convert a logical value into a string and return the result
       var length = a.length;
       var b = parseInt((a.length)/2);//Divide into 2 parts and round
       var value= a.substring(0,b)+"<br>"+a.substring(b,length);//The part before the display, the part after the line break
       return value
    }

    2.2 Effect Preview

    Save the report, click Pagination Preview, the effect is shown in the following figure:

    5.png

    III. Template Download

    Click to download template:

    Chart_Label _Wrap_Display.cpt


    Attachment List


    Theme: Chart
    • Helpful
    • Not helpful
    • Only read

    Doc Feedback