diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/shared/charts/AbstractCompetitorRaceChart.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/shared/charts/AbstractCompetitorRaceChart.java index 7ab3138f5c6..14f4df17f8e 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/shared/charts/AbstractCompetitorRaceChart.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/shared/charts/AbstractCompetitorRaceChart.java @@ -34,9 +34,10 @@ import org.moxieapps.gwt.highcharts.client.plotOptions.Marker; import org.moxieapps.gwt.highcharts.client.plotOptions.ScatterPlotOptions; import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.i18n.client.NumberFormat; import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RequiresResize; import com.google.gwt.user.client.ui.Widget; @@ -65,8 +66,8 @@ import com.sap.sse.gwt.client.player.Timer.PlayModes; import com.sap.sse.gwt.client.shared.components.Component; /** - * AbstractCompetitorChart is a chart that can show one sort of competitor data (e.g. current speed over ground, windward - * distance to leader) for different races in a chart. + * AbstractCompetitorChart is a chart that can show one sort of competitor data (e.g. current speed over ground, + * windward distance to leader) for different races in a chart. * * When calling the constructor a chart is created that creates a final amount of series (so the maximum number of * competitors cannot be changed in one chart) which are connected to competitors, when the sailing service returns the @@ -100,17 +101,6 @@ public abstract class AbstractCompetitorRaceChart the old title appears - chart.setTitle(hasSecondYAxis() ? null : new ChartTitle().setText(chartTitleFromDetailTypes()), null); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + // Workaround for a highcharts bug: Set a chart title, overwrite the title, + // switch chart to invisible and visible again -> the old title appears + if (compactChart) { + applyCompactTitle(chartTitleFromDetailTypes()); + } else { + chart.setTitle(hasSecondYAxis() ? null : new ChartTitle().setText(chartTitleFromDetailTypes()), + null); + } + + chart.setSizeToMatchContainer(); + // it's important here to recall the redraw method, otherwise the bug fix for wrong checkbox + // positions + // (nativeAdjustCheckboxPosition) + // in the BaseChart class would not be called + chart.redraw(); + } + }); } + + } + + private void applyCompactTitle(String title) { + chart.setSpacingLeft(10).setSpacingRight(10).setSpacingTop(20).setOption("legend/margin", 2) + .setChartSubtitle(null).getXAxis().setAxisTitleText(null); + chart.setTitle(hasSecondYAxis() ? null : new ChartTitle().setText(title).setOption("floating",true), null); + chart.redraw(); } private int yAxisIndex(DetailType seriesDetailType) { @@ -610,12 +619,15 @@ public abstract class AbstractCompetitorRaceChart primary.timeOfLatestRequestInMillis) { updateChart(new Date(primary.timeOfLatestRequestInMillis), timeRangeWithZoomProvider.getToTime(), /* append */true);