Left-Aligned Category Name in a Bar Chart

  • Last update:March 16, 2025
  • Overview

    Version

    Report Server Version

    Functional Change

    11.0

    -

    Function Description

    Category names in a bar chart are right aligned by default, which  makes the left side of the chart looks messy.

    You want the category names in the bar chart to be left aligned for a more organized visual effect.

    Before optimization:

    image 35.png

    After optimization:

    image 36.png

    Example

    Dataset Creation

    Create a general report and enter the SQL statement SELECT * FROM Sales_Volume to create a dataset named ds1.

    image 27.png

    Chart Design

    Insert a bar chart in cell A1 and set Data Source of the chart to dataset ds1, as shown in the following table.

    image 28.png

    Adding a Loading End Event

    Choose Template > Web Attribute in the menu bar, select Pagination Preview Setting, select Set for This Template Separately, and add a Load End event.

    Enter the  JavaScript codes, as shown in the following figure.

    image 34.png

    The JavaScript codes are as follows:

    setTimeout(function({
    $("td[id^=A1-] svg > g.backGroup > g:nth-child(6) > g:nth-child(2) text").each(function(i, item{
    var str = $(item).attr("transform").replace("translate(""").replace(")""");
    str = str.split(" ")[1];
    $(item).attr("transform""translate(8 " + str + ")");
    })
    }, 100)

    Effect Display

    Save the template, click the Preview icon, and the category names in the bar chart will be left aligned, as shown in the following figure.

    iconNote:
    The effect cannot be previewed on mobile terminals.

    image 36.png

    Template Download

    For details, you can click to download the template Left-Aligned Category Name in a Bar Chart.cpt.

    Attachment List


    Theme: Chart
    • Helpful
    • Not helpful
    • Only read

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

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

    不再提示

    9s后關閉

    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