mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-28 00:16:46 +00:00
Added tooltips to the time line; Refactoring of the chart tool tip creation
This commit is contained in:
+18
-8
@@ -113,12 +113,22 @@ public class WindChart extends SimplePanel implements Component<WindChartSetting
|
||||
chart.setToolTip(new ToolTip().setEnabled(true).setFormatter(new ToolTipFormatter() {
|
||||
@Override
|
||||
public String format(ToolTipData toolTipData) {
|
||||
final String unit = toolTipData.getSeriesName().startsWith(stringMessages.fromDeg()+" ") ? stringMessages.degreesShort() :
|
||||
stringMessages.averageSpeedInKnotsUnit();
|
||||
return "<b>" + toolTipData.getSeriesName() + (toolTipData.getPointName() != null ? " "+toolTipData.getPointName() : "")
|
||||
+ "</b><br/>" +
|
||||
dateFormat.format(new Date(toolTipData.getXAsLong())) + ": " +
|
||||
numberFormat.format(toolTipData.getYAsDouble()) + unit;
|
||||
String seriesName = toolTipData.getSeriesName();
|
||||
|
||||
if (seriesName.equals(WindChart.this.stringMessages.time())) {
|
||||
return "<b>" + seriesName + ":</b> " + dateFormat.format(new Date(toolTipData.getXAsLong()))
|
||||
+ "<br/>(" + stringMessages.clickChartToSetTime() + ")";
|
||||
} else if (seriesName.startsWith(stringMessages.fromDeg()+" ")) {
|
||||
return "<b>" + seriesName + (toolTipData.getPointName() != null ? " "+toolTipData.getPointName() : "")
|
||||
+ "</b><br/>" +
|
||||
dateFormat.format(new Date(toolTipData.getXAsLong())) + ": " +
|
||||
numberFormat.format(toolTipData.getYAsDouble()) + stringMessages.degreesShort();
|
||||
} else {
|
||||
return "<b>" + seriesName + (toolTipData.getPointName() != null ? " "+toolTipData.getPointName() : "")
|
||||
+ "</b><br/>" +
|
||||
dateFormat.format(new Date(toolTipData.getXAsLong())) + ": " +
|
||||
numberFormat.format(toolTipData.getYAsDouble()) + stringMessages.averageSpeedInKnotsUnit();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -267,9 +277,9 @@ public class WindChart extends SimplePanel implements Component<WindChartSetting
|
||||
return chart
|
||||
.createSeries()
|
||||
.setType(Series.Type.LINE)
|
||||
.setName("TIME_LINE")
|
||||
.setName(stringMessages.time())
|
||||
.setYAxis(0)
|
||||
.setPlotOptions(new LinePlotOptions().setEnableMouseTracking(false).setShowInLegend(false).setHoverStateEnabled(false).setLineWidth(2));
|
||||
.setPlotOptions(new LinePlotOptions().setShowInLegend(false).setHoverStateEnabled(false).setLineWidth(2));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -271,4 +271,5 @@ public interface StringMessages extends Messages {
|
||||
String trackBasedEstimationWindSourceTypeName();
|
||||
String expeditionWindSourceTypeName();
|
||||
String webWindSourceTypeName();
|
||||
String clickChartToSetTime();
|
||||
}
|
||||
+1
@@ -266,3 +266,4 @@ courseBasedWindSourceTypeName=Course Layout
|
||||
trackBasedEstimationWindSourceTypeName=Estimation
|
||||
expeditionWindSourceTypeName=Measured
|
||||
webWindSourceTypeName=Manual
|
||||
clickChartToSetTime=Click on the chart to set the time
|
||||
+2
-1
@@ -266,4 +266,5 @@ combinedWindSourceTypeName=Kombiniert
|
||||
courseBasedWindSourceTypeName=Kurslayout
|
||||
trackBasedEstimationWindSourceTypeName=Schätzung
|
||||
expeditionWindSourceTypeName=Messung
|
||||
webWindSourceTypeName=Manuell
|
||||
webWindSourceTypeName=Manuell
|
||||
clickChartToSetTime=Klicke auf das Diagramm um die Zeit zu setzen
|
||||
+13
-6
@@ -211,10 +211,17 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
|
||||
chart.setToolTip(new ToolTip().setEnabled(true).setFormatter(new ToolTipFormatter() {
|
||||
@Override
|
||||
public String format(ToolTipData toolTipData) {
|
||||
return "<b>" + toolTipData.getSeriesName() + (toolTipData.getPointName() != null ? " "+toolTipData.getPointName() : "")
|
||||
+ "</b><br/>" +
|
||||
dateFormat.format(new Date(toolTipData.getXAsLong())) + ": " +
|
||||
numberFormat.format(toolTipData.getYAsDouble()) + unit;
|
||||
String seriesName = toolTipData.getSeriesName();
|
||||
|
||||
if (seriesName.equals(stringMessages.time())) {
|
||||
return "<b>" + seriesName + ":</b> " + dateFormat.format(new Date(toolTipData.getXAsLong()))
|
||||
+ "<br/>(" + stringMessages.clickChartToSetTime() + ")";
|
||||
} else {
|
||||
return "<b>" + seriesName
|
||||
+ (toolTipData.getPointName() != null ? " " + toolTipData.getPointName() : "")
|
||||
+ "</b><br/>" + dateFormat.format(new Date(toolTipData.getXAsLong())) + ": "
|
||||
+ numberFormat.format(toolTipData.getYAsDouble()) + unit;
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -429,8 +436,8 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
|
||||
return chart
|
||||
.createSeries()
|
||||
.setType(Series.Type.LINE)
|
||||
.setName("TIME_LINE")
|
||||
.setPlotOptions(new LinePlotOptions().setEnableMouseTracking(false).setShowInLegend(false).setHoverStateEnabled(false).setLineWidth(2));
|
||||
.setName(stringMessages.time())
|
||||
.setPlotOptions(new LinePlotOptions().setShowInLegend(false).setHoverStateEnabled(false).setLineWidth(2));
|
||||
}
|
||||
|
||||
private String getUnit() {
|
||||
|
||||
Reference in New Issue
Block a user