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

Gantt highchart not responsive (adapting width and height) on mobile when starting on small screen/div container. More buggy when including a certain formatter() {...} code #14855

Closed
888ba8 opened this issue Dec 29, 2020 · 6 comments

Comments

@888ba8
Copy link

888ba8 commented Dec 29, 2020

Expected behaviour

The container of the Gantt highchart is responsive and thus the Gantt highchart itself should also change its width when the container resizes. Further more, the chart should load its full height as much as the height of the chart and the height of the container allows.

Actual behaviour

If you load this on mobile in portrait mode (tested on iPhone 6 and Huawei P-20 Lite), then the width of the highchart does not change (read: increase) when you hide the sidebar (thus making the chart container larger). Meaning the highchart can not be read.

If you remove the following 5 lines of code from the Gantt highchart, then

            formatter() {
            const unitName = this.tickPositionInfo.unitName;
                const format = unitName === 'day' ? '%d' : this.dateTimeLabelFormat;

                return Highcharts.dateFormat(format, this.value )
            }

part of the unexpected behaviour is mitigated, but no all. Sometimes it seems you have to scroll all the way down in order for Highcharts to recalculate the width / make the chart refresh its responsiveness? In this case, I am testing on iPhone 6 and in the case where you removed these 5 lines of code, it loads the height of the chart correctly, but not the width. However, if I loaded the page in portrait mode, then turn my phone into landscape mode (even without refreshing), the chart is adapted correctly and the full width is shown. This is not the case, however, when we included those 5 lines of code. In any of the two cases, if you stay in portrait mode, the width of the chart does not get fixed.

Note: you can toggle the width of the container in the demos below, by clicking the telephone button ☎️.

Live demo with steps to reproduce

https://jsfiddle.net/y5eom6ku/show/

  • To view https://jsfiddle.net/y5eom6ku/ (identical with the above, with the exception of the exclusion of the 5 lines of code) in full screen mode, please use:

https://jsfiddle.net/u74dyma2/show

Product version

Affected browser(s)

Mobile (probably depending on screen size).

@highsoft-bot highsoft-bot added this to To do in Development-Flow Dec 29, 2020
@sebastianbochan
Copy link
Contributor

Hi @888ba8,
Thank you for reporting.

When I run both demos, both charts are not resized or updated (the 5 lines do not have an influence on functionality). The solution is to trigger chart.reflow() or chart.setSize() in callback of the click (toggle) action on the "telephone" icon and hide the sidebar.

@888ba8
Copy link
Author

888ba8 commented Dec 29, 2020

Dear @sebastianbochan Thank you very much. Does this mean I have to include an extra Jquery/JS snippet in my code? Could you help me create a template? I am a noob when it comes to JS/Jquery but would love to figure out how this works.

@888ba8
Copy link
Author

888ba8 commented Dec 29, 2020

It seems possible by adding

document.getElementById('some-link').addEventListener('click', () => {
    chart.reflow();
});

at the bottom? This works when I use a random link, but sometimes it doesn't work for the toggler button in the demo?

@888ba8
Copy link
Author

888ba8 commented Dec 30, 2020

Hi @sebastianbochan I currently tried it with

document.getElementById('body').addEventListener('click', () => {
    chart.reflow();
});
</script>

which solves some minor margin issues (very slight cut-off on the right of the screen) on desktop. However, this does not seem to be working or solving the issues described above on mobile. Any help please?

@sebastianbochan
Copy link
Contributor

Hi @888ba8,
You should call it in the callback of the click event (toggle is a bootstrap module). If the callback does not exist, you can use setTimeout with delay (the value of delays is the same as the time of sliding animation).

Demo:

For general support questions, please use other channels like stackoverflow / forum or email.

@KacperMadej
Copy link

Closing as not a bug. In case you need help from technical support please see the above comment. If the issue should remain open please leave a comment with more info.

Development-Flow automation moved this from To do to Done Jan 7, 2021
@Izothep Izothep removed this from Done in Development-Flow Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants