hi Shawn
Hope you can answer this. I have already read your previous comments on resizing and rescaling but I did not find my answers there.
Here is my issue. -
I am currently trying to display 'click to add points' chart from gwt-highcharts showcase in the following ui.xml of mine. I provide a snippet below. I am adding it into the g:HTMLPanel with ui:field attribute 'controlPanelTopChart. (artifact 2) I noticed that the bottom of the chart was getting clipped of. So I changed my css to be as follows (see artifact 1)
This still did not help. At this point in my java code i added the method setHeight100(). I also tried setSizeToMatchingContainer but that too did not help. With setHeight100() I noticed the following, when the browser loads initially the bottom of the chart is clipped of. If I resize the browser then the chart rescales and thereafter the scaling works well and the chart is visible completely. Hope you can help with this. Can you let me know what is going on and how I can resolve this. Please let me know if you need anything more from me.
Artifact1
Hard to tell what may be going on here without a full code example, but here are a few things for you to consider when you're trying to support dynamically sized charts (as opposed to fixed width/height):
By default Highcharts attempts to resize itself to match the size of whatever div/container element it's inside of, and watches for whenever the browser window size changes to trigger the resizing logic. You can enable/disable that functionality using the Chart.setReflow() option.
If you want to trigger the chart to update its size on your own (instead of waiting for the browser window resize event), you can explicitly call the Chart.reflow() method.
Depending on what you're doing in the DOM, it's important to make sure that the chart has a chance to reflow itself once the size of the container is stable. If the container is hidden at first or part of an animation (for example) that could affect the size that Highcharts is able to determine. In one of our projects here the chart size can't be acurately determined until after an animation has taken place. So, we use "Chart.setReflow(false)" to prevent Highcharts from attempting to resize itself during the animation. And then we use code like the following to ensure that the chart is resized correctly after the animation is done (would have been even nicer to do this in an animation "end" event instead of a timer, but in our case it was a CSS animation so no real "end" event is available).
// Wait a moment for the animation to end, and then let the chart update its size
Timer timer = new Timer() {
public void run() {
menuStatsChart.reflow();
}
};
timer.schedule(100);
If you don't want to use Highcharts automatic "resize/reflow" logic, you can always just manage the chart size on your own as well. E.g. set "chart.setReflow(false)" and then something like the following whenever you want the chart size updated:
hi Shawn
thanks for the suggestions, as soon as I get time time I will try these in successive order to see which ones work for me. If still not able to resolve, I might share some more code so that you can have better understanding. Nevertheless I will keep you updated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi Shawn
I finally managed to fix the scaling issue. This is what i had to do
I set up a separate sandbox project out of the formal project so I could do all kinds of nasty things there. I noticed that GWT.log(this.controlPanelTopChart.getElementById("chartContainer").getClientWidth() + " Offsetwidth"); never returned any width so finally I had to go to window height and use vw.
Also I changed my layout. I initially had DockLayout and then flowPanel within it but flowPanel does not allow scaling. So I changed it to DockLayoutPanel with DockLayout within it. See below my Ui.xml and a screen shot of the sandbox project.
Had a question for you. What are your thoughts on it ? Do you see any pitfalls ? Any suggestions for improvements ?
hi Shawn
Hope you can answer this. I have already read your previous comments on resizing and rescaling but I did not find my answers there.
Here is my issue. -
I am currently trying to display 'click to add points' chart from gwt-highcharts showcase in the following ui.xml of mine. I provide a snippet below. I am adding it into the g:HTMLPanel with ui:field attribute 'controlPanelTopChart. (artifact 2) I noticed that the bottom of the chart was getting clipped of. So I changed my css to be as follows (see artifact 1)
This still did not help. At this point in my java code i added the method setHeight100(). I also tried setSizeToMatchingContainer but that too did not help. With setHeight100() I noticed the following, when the browser loads initially the bottom of the chart is clipped of. If I resize the browser then the chart rescales and thereafter the scaling works well and the chart is visible completely. Hope you can help with this. Can you let me know what is going on and how I can resolve this. Please let me know if you need anything more from me.
Artifact1
Artifact 2
I am attaching two images that might help.
Image 1 - ChartBottomclippedOff- shows how the chart displays on initial load of the browser, with clipped off bottom
Hard to tell what may be going on here without a full code example, but here are a few things for you to consider when you're trying to support dynamically sized charts (as opposed to fixed width/height):
By default Highcharts attempts to resize itself to match the size of whatever div/container element it's inside of, and watches for whenever the browser window size changes to trigger the resizing logic. You can enable/disable that functionality using the Chart.setReflow() option.
If you want to trigger the chart to update its size on your own (instead of waiting for the browser window resize event), you can explicitly call the Chart.reflow() method.
Depending on what you're doing in the DOM, it's important to make sure that the chart has a chance to reflow itself once the size of the container is stable. If the container is hidden at first or part of an animation (for example) that could affect the size that Highcharts is able to determine. In one of our projects here the chart size can't be acurately determined until after an animation has taken place. So, we use "Chart.setReflow(false)" to prevent Highcharts from attempting to resize itself during the animation. And then we use code like the following to ensure that the chart is resized correctly after the animation is done (would have been even nicer to do this in an animation "end" event instead of a timer, but in our case it was a CSS animation so no real "end" event is available).
chart.setSize(container.getOffsetWidth() + "px", container.getOffsetHeight() + "px");
Hope that helps!
hi Shawn
thanks for the suggestions, as soon as I get time time I will try these in successive order to see which ones work for me. If still not able to resolve, I might share some more code so that you can have better understanding. Nevertheless I will keep you updated.
hi Shawn
I finally managed to fix the scaling issue. This is what i had to do
I set up a separate sandbox project out of the formal project so I could do all kinds of nasty things there. I noticed that GWT.log(this.controlPanelTopChart.getElementById("chartContainer").getClientWidth() + " Offsetwidth"); never returned any width so finally I had to go to window height and use vw.
Also I changed my layout. I initially had DockLayout and then flowPanel within it but flowPanel does not allow scaling. So I changed it to DockLayoutPanel with DockLayout within it. See below my Ui.xml and a screen shot of the sandbox project.
Had a question for you. What are your thoughts on it ? Do you see any pitfalls ? Any suggestions for improvements ?
Thanks for your help.
Last edit: GeneticMogambo 2016-02-24