Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Aligning Label Component in Bar Chart Rendering via Portal #435

Closed
Satyam7Jha opened this issue Oct 5, 2023 · 3 comments
Closed

Not Aligning Label Component in Bar Chart Rendering via Portal #435

Satyam7Jha opened this issue Oct 5, 2023 · 3 comments
Assignees
Labels

Comments

@Satyam7Jha
Copy link

Satyam7Jha commented Oct 5, 2023

Description

In the provided example, we implemented a column chart where the label component was rendered with proper alignment. However, when we switched the chart type from column to bar, the label component no longer aligned correctly.

Steps to reproduce

  1. Set up a column chart as described in the linked example.
  2. Observe how the label component is correctly aligned.
  3. Change the chart type from column to bar.
  4. Note that the label component fails to align properly exapmle.

Expected Behavior

When changing the chart type from column to bar, the label component should remain properly aligned, similar to the column chart rendering.

Actual Behavior

In the bar chart rendering, the label component is not properly aligned.

Relevant Screenshots

Aligned in Column
image
NotAligned in Bar
image

@ppotaczek
Copy link
Contributor

Hi @Satyam7Jha,

Thank you for contacting us!

Please note that rendering custom HTML by using React portals is an experimental feature and it is not officially supported.

To make the labels properly aligned, you can add the below style:

<Fragment>
  {createPortal(
    <div style={{ transform: "translateY(-50%)" }}>
      <div>React</div>
      {tick.pos}
    </div>,
    tick.label.element
  )}
</Fragment>

Live demo: https://codesandbox.io/s/highcharts-react-demo-1-9s7pyq?file=/demo.jsx

Best regards!

@ppotaczek ppotaczek self-assigned this Oct 5, 2023
@Satyam7Jha
Copy link
Author

Satyam7Jha commented Oct 5, 2023

Hey, @ppotaczek, I truly appreciate your assistance. Your solution worked perfectly.

I was wondering, will Highcharts implement the capability to render custom JSX components in the foreseeable future? This feature could be significantly beneficial.

@ppotaczek
Copy link
Contributor

Hi @Satyam7Jha, It's hard to say, as far as I know, it is not planned in the near future. Such implementation could be complex and complicated. Related thread here: #23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants