Overlapping issue with Amcharts combination chart labels when disabling the labels

Check out this combination chart created with Amchart's codepen: https://codepen.io/amcharts/pen/68f79624039495969a04c80b86a90272

"valueAxes": [{
    "id": "v1",
    "unit": "%",
    "position": "right",
    "title": "GDP growth rate",
  }, {
    "id": "v2",
    "unit": "$",
    "unitPosition": "left",
    "position": "left",
    "title": "Sales volume (M)"
  }],

To align all the labels on the right side, I have created an example here: https://jsfiddle.net/hansyulian/ymb2vcsa/

 "valueAxes": [{
    "id": "v1",
    "unit": "%",
    "position": "right",
    "title": "GDP growth rate",
  }, {
    "id": "v2",
    "unit": "$",
    "unitPosition": "left",
    "position": "right",
    "title": "Sales volume (M)"
  }],

I encountered overlapping labels which I resolved by adding an "offset" to the label: https://jsfiddle.net/hansyulian/ymb2vcsa/2/

"valueAxes": [{
    "id": "v1",
    "unit": "%",
    "position": "right",
    "title": "GDP growth rate",
  }, {
    "id": "v2",
    "unit": "$",
    "unitPosition": "left",
    "position": "right",
    "offset": 70,
    "title": "Sales volume (M)"
  }],

Further, I disabled the labels using "labelsEnabled": false as shown here: https://jsfiddle.net/hansyulian/ymb2vcsa/3/

  "valueAxes": [{
    "id": "v1",
    "unit": "%",
    "position": "right",
    "labelsEnabled": false,// comment this and the label no longer overlapped
    "title": "GDP growth rate",
  }, {
    "id": "v2",
    "unit": "$",
    "unitPosition": "left",
    "position": "right",
    "labelsEnabled": false, // comment this and the title no longer overlapped
    "offset": 70, // this offset not working if labelsEnabled = false
    "title": "Sales volume (M)"
  }],

The issue arises where the y-axis title overlaps due to the disabled "offset". Any suggestions for a solution?

Answer №1

To keep labelsEnabled turned on and also enable addClassNames, you can follow this approach:

Simply use CSS to hide the labels:

.value-axis-v2 .amcharts-axis-label {
    visibility: hidden;
}

For a working example, check out this link: https://jsfiddle.net/ymb2vcsa/7/

Answer №2

It appears that one of my coworkers shared a helpful solution with me, but preferred not to disclose it here (shoutout to TCY) just before we submitted a support ticket to AmCharts. There is a clever workaround using fontSize : 0 to hide the label text:

https://jsfiddle.net/hansyulian/ymb2vcsa/8/

"valueAxes": [{
    "id": "v1",
    "unit": "%",
    "position": "right",
    "labelsEnabled": true, // comment this line and the label will no longer overlap
    "title": "GDP growth rate",
    "fontSize": 0
  }, {
    "id": "v2",
    "unit": "$",
    "unitPosition": "left",
    "position": "right",
    "labelsEnabled": true, // commenting this hides the title from overlapping
    "offset": 70, // this offset does not work if labelsEnabled = false
    "title": "Sales volume (M)",
    "fontSize": 0
  }],

This adjustment allows for a more coherent visualization in our chart while also enabling us to include legends so viewers can easily identify the dataset represented by each column.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to fill a dropdown menu with names and corresponding numeric IDs?

How can I effectively link my dropdown to a variable in the controller, using the id property of the dropdown array instead of the value for assignment? Meanwhile, still displaying the content of the drop down using the name property of the array for user ...

submitting URL from dropdown menu without using the 'submit' button

My situation involves a dropdown list: @Html.DropDownList("InnerId", Model.GroupDropDownList, new { @class = "select_change" }) I am looking to achieve submitting the value when a user clicks on the selection without needing to select and then use a subm ...

Hidden Navigation Bar in AngularJS

Is there a way to hide the navBar when the route is "/"? I managed to successfully hide/show the navbar, but the issue arises when the navbar is hidden. The "app-body" div then has 50px of padding top (where the navbar should be). Here is my HT ...

Installation of a cloned Parse server

I downloaded the Parse server repository from parse-server-example and set up MongoDB, as well as installed Node.js packages using npm install. However, when I try to start the app with npm start, I encounter this error in the terminal!! How can I resolve ...

The error message "unit test undefined is not an object (evaluating 'this.groups.map')" indicates a problem with the mapping function

Currently, I am working with this script: groups: Group[] = [] constructor( ) { this.groups = AuthenticationService.getUserGroups() let menuList: any = [] this.groups.map((permission: Group) => { menuList.push(...this.menuGene ...

arrange elements by their relationship with parents and children using typescript and angular

Here is a list that needs to be sorted by parent and child relationships: 0: {id: 7, name: "333", code: "333", type: 3, hasParent: true, parentId: 4} 1: {id: 6, name: "dfgdfg", code: "dfgdfg", type: 3, hasParent: false, parentId: null} 2: {id: 5, name: ...

Starting objects before utilizing them in the useFrame() function in react-three-fiber

I am currently working on a project using react-three-fiber to create a scene. However, I am facing an issue with placing 3D objects at different random positions. I tried using a for loop inside useFrame to set random positions, but this causes the partic ...

Leverage the power of an Express server to manage a Node.js application

I have a node.js application that communicates with a REST API hosted on a separate server. To control this application, I want to create a web interface using express.js which includes HTML, CSS, and Javascript. How can I enable the browser to interact w ...

When the button is clicked, Shopify will automatically send an email notification to the Admin

Is there a Shopify API available to send an email to the admin when a button is clicked? Please note, this is not related to a contact form. I am looking for a way to trigger an email to the admin with dynamic information from the page by simply clicking ...

What is the correct way to express an object in an array?

I've encountered an issue: I'm working with an array called _daysConfig<DayConfig> When I manually populate it like this, everything functions correctly: _daysConfig: DayConfig[] = [ { date: new Date('Wed Jul 22 2020 21:06:00 GMT+02 ...

Opening a Material Dialog automatically scrolls the body to the top of the page

I'm currently using Material UI within a React application and I'm facing an issue where opening a dialog causes the body of my page to scroll to the top. This behavior also occurs when opening a Material Popover or a Material TextBox selector. D ...

Learn the process of extracting query parameters from a URL with the format `example.com/path#p1=v1&p2=v2...` using Angular

Callback URLs from singly.com are coming in the format of example.com/path#p1=v1&p2=v2... Is there a more Angular-friendly way to extract query parameters since $location.search and $routeParams do not work without the presence of the ? in the URL? ...

Enhancing Browser Validation Appearance Across Modern Web Browsers

Modern browsers now automatically validate forms using new HTML attributes. How can we style the auto browser validation for forms to have a consistent look across different browsers like Firefox, Chrome, IE, Opera, and Safari? I am seeking to achieve thi ...

express-validator, no validation errors have been found so far

How can I verify if a given string is in the format of an email address? Here's a snippet of code that attempts to do so: req.checkBody('email', 'Invalid email address').isEmail(); var validationErrors = req.validationErrors(); i ...

Tips for concealing subsequent pages and displaying pagination in jQuery ajax response

Is there a way to display pagination based on a limiter in an ajax response? For example, if the limiter is set to 5, only show 10 page links and hide the rest. 1 2 3 4 5 6 7 8 9 10 .. next 11 12 13 14 15.. next I attempted to count the li elements in ...

Continuously receive data from a reactive socket

My current approach involves using this code to receive data from sockets: socket.on('send_image', (message) => { setImage(message.image) console.log(message) }) The server is constantly sending data (images from camera ...

What is the best way to dynamically load my React component?

Is there a way to dynamically load my React toolbar component based on state changes? constructor(props) { super(props); this.state = { currentPageNumber: 0, }; } render(){ return( <View> ...

Issue with ERR_HTTP_HEADERS_SENT persists despite implementation of return statements

When attempting to send a POST request to the server, an error is encountered: Error [ERR_HTTP_HEADERS_SENT]: Cannot modify headers after they are sent to the client at new NodeError (node:internal/errors:371:5) at ServerResponse.setHeader (node:_h ...

Tips for combining values with Reactive Forms

Is there a way to merge two values into a single label using Reactive Forms without utilizing ngModel binding? <label id="identificationCode" name="identificationCode" formControlName="lb ...

Issue with alignment of inline elements

I recently added a more button to my share buttons, sourced from simplesharebuttons.com, with the intention of revealing less popular social media icons on smaller screens. However, I am encountering an issue where the button is not aligning with the rest ...