diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/Messages.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/Messages.java index 32b8f1b3dd..90e627f419 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/Messages.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/Messages.java @@ -556,6 +556,8 @@ public class Messages extends NLS public static String LabelChartDetailMovingAverage_100days; public static String LabelChartDetailMovingAverage_200days; public static String LabelChartDetailSettings; + public static String LabelChartDetailSettingsShowHorizontalLinesMain; + public static String LabelChartDetailSettingsShowHorizontalLinesPercentage; public static String LabelChartDetailSettingsShowLimits; public static String LabelChartDetailSettingsShowMarkerLines; public static String LabelChartDetailSettingsShowDataLabel; diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages.properties index 0ba3b5f20b..5af1b379dc 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages.properties @@ -1132,6 +1132,10 @@ LabelChartDetailMovingAverage_90days = 90 days LabelChartDetailSettings = Settings +LabelChartDetailSettingsShowHorizontalLinesMain = Horizontal lines (Value axis) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = Horizontal lines (Percentage axis) + LabelChartDetailSettingsShowDataLabel = Show data labels LabelChartDetailSettingsShowLimits = Show limits diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_cs.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_cs.properties index 6f0a5e2e3a..45e794cfba 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_cs.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_cs.properties @@ -1120,6 +1120,10 @@ LabelChartDetailMovingAverage_90days = 90 dn\u016F LabelChartDetailSettings = Nastaven\u00ED +LabelChartDetailSettingsShowHorizontalLinesMain = Vodorovn\u00E9 \u010D\u00E1ry (osa hodnot) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = Vodorovné \u010D\u00E1ry (procentu\u00E1ln\u00ED osa) + LabelChartDetailSettingsShowDataLabel = Zobrazit popisky dat LabelChartDetailSettingsShowLimits = Zobrazit limity diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_de.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_de.properties index 6be3464382..bf54709d8b 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_de.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_de.properties @@ -1119,6 +1119,10 @@ LabelChartDetailMovingAverage_90days = 90 Tage LabelChartDetailSettings = Einstellungen +LabelChartDetailSettingsShowHorizontalLinesMain = Horizontale Linien (Werte-Achse) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = Horizontale Linien (Prozent-Achse) + LabelChartDetailSettingsShowDataLabel = Zahlenwerte anzeigen LabelChartDetailSettingsShowLimits = Zeige Limits diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_es.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_es.properties index 403f2c3e77..b8528c25ef 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_es.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_es.properties @@ -1119,6 +1119,10 @@ LabelChartDetailMovingAverage_90days = 90 d\u00EDas LabelChartDetailSettings = Opini\u00F3n +LabelChartDetailSettingsShowHorizontalLinesMain = L\u00EDneas horizontales (eje del valor) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = L\u00EDneas horizontales (eje porcentual) + LabelChartDetailSettingsShowDataLabel = Mostrar etiquetas de datos LabelChartDetailSettingsShowLimits = Mostrar l\u00EDmites diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_fr.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_fr.properties index 8c2dada68c..dfbb370fe4 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_fr.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_fr.properties @@ -1120,6 +1120,10 @@ LabelChartDetailMovingAverage_90days = 90 jours LabelChartDetailSettings = Param\u00E8tres +LabelChartDetailSettingsShowHorizontalLinesMain = Lignes horizontales (axe des valeurs) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = Lignes horizontales (axe des pourcentages) + LabelChartDetailSettingsShowDataLabel = Afficher \u00E9tiquettes de donn\u00E9es LabelChartDetailSettingsShowLimits = = Afficher les limites diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_it.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_it.properties index b6660734ed..7eb1d51058 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_it.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_it.properties @@ -1119,6 +1119,10 @@ LabelChartDetailMovingAverage_90days = 90 giorni LabelChartDetailSettings = Impostazioni +LabelChartDetailSettingsShowHorizontalLinesMain = Linee orizzontali (asse del valore) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = Linee orizzontali (asse percentuale) + LabelChartDetailSettingsShowDataLabel = Mostra etichette dati LabelChartDetailSettingsShowLimits = Mostra limiti diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_nl.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_nl.properties index 62c8bc9ea9..789a7acd31 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_nl.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_nl.properties @@ -1119,6 +1119,10 @@ LabelChartDetailMovingAverage_90days = 90 dagen LabelChartDetailSettings = Instelling +LabelChartDetailSettingsShowHorizontalLinesMain = Horizontale lijnen (waarde-as) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = Horizontale lijnen (percentage-as) + LabelChartDetailSettingsShowDataLabel = Toon datalabels LabelChartDetailSettingsShowLimits = = Toon Grenzen diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_pt.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_pt.properties index 8f3da64749..ef1a48e204 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_pt.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_pt.properties @@ -1119,6 +1119,10 @@ LabelChartDetailMovingAverage_90days = 90 dias LabelChartDetailSettings = Defini\u00E7\u00F5es +LabelChartDetailSettingsShowHorizontalLinesMain = Linhas horizontais (Eixo de valor) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = Linhas horizontais (Eixo percentual) + LabelChartDetailSettingsShowDataLabel = Mostrar r\u00F3tulos de dados LabelChartDetailSettingsShowLimits = = Mostrar limites diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_ru.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_ru.properties index f777e12749..a70542d00f 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_ru.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_ru.properties @@ -1119,6 +1119,10 @@ LabelChartDetailMovingAverage_90days = 90 \u0434\u043D\u0435\u0439 LabelChartDetailSettings = \u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 +LabelChartDetailSettingsShowHorizontalLinesMain = \u0413\u043E\u0440\u0438\u0437\u043E\u043D\u0442\u0430\u043B\u044C\u043D\u044B\u0435 \u043B\u0438\u043D\u0438\u0438 (\u043E\u0441\u044C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0439) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = \u0413\u043E\u0440\u0438\u0437\u043E\u043D\u0442\u0430\u043B\u044C\u043D\u044B\u0435 \u043B\u0438\u043D\u0438\u0438 (\u043E\u0441\u044C \u043F\u0440\u043E\u0446\u0435\u043D\u0442\u043E\u0432) + LabelChartDetailSettingsShowDataLabel = \u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u043C\u0435\u0442\u043A\u0438 \u0434\u0430\u043D\u043D\u044B\u0445 LabelChartDetailSettingsShowLimits = \u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0435\u043D\u0438\u044F diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_sk.properties b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_sk.properties index c40451c027..d574a4d958 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_sk.properties +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/messages_sk.properties @@ -1119,6 +1119,10 @@ LabelChartDetailMovingAverage_90days = 90 dn\u00ED LabelChartDetailSettings = Nastavenia +LabelChartDetailSettingsShowHorizontalLinesMain = Vodorovn\u00E9 \u010Diary (hodnotov\u00E1 os) + +LabelChartDetailSettingsShowHorizontalLinesPercentage = Vodorovn\u00E9 \u010Diary (percentu\u00E1lna os) + LabelChartDetailSettingsShowDataLabel = Zobrazi\u0165 popisky d\u00E1t LabelChartDetailSettingsShowLimits = Zobrazi\u0165 limity diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/chart/TimelineChart.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/chart/TimelineChart.java index 2bcbae2be4..186896515a 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/chart/TimelineChart.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/chart/TimelineChart.java @@ -1,5 +1,6 @@ package name.abuchen.portfolio.ui.util.chart; +import java.text.DecimalFormat; import java.time.Instant; import java.time.LocalDate; import java.time.ZoneId; @@ -105,6 +106,15 @@ public TimelineChart(Composite parent) y2Axis.getTick().setVisible(false); y2Axis.getGrid().setStyle(LineStyle.NONE); y2Axis.setPosition(Position.Primary); + + // 3rd y axis (percentage) + int axisId3rd = getAxisSet().createYAxis(); + IAxis y3Axis = getAxisSet().getYAxis(axisId3rd); + y3Axis.getTitle().setVisible(false); + y3Axis.getTick().setVisible(false); + y3Axis.getTick().setFormat(new DecimalFormat("+#.##%;-#.##%")); //$NON-NLS-1$ + y3Axis.getGrid().setStyle(LineStyle.NONE); + y3Axis.setPosition(Position.Primary); ((IPlotArea) getPlotArea()).addCustomPaintListener(new ICustomPaintListener() { diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesChart.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesChart.java index a959130970..9fa4d2aa14 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesChart.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesChart.java @@ -272,7 +272,9 @@ private enum ChartDetails SHOW_MARKER_LINES(Messages.LabelChartDetailSettingsShowMarkerLines), // SHOW_DATA_LABELS(Messages.LabelChartDetailSettingsShowDataLabel), // SHOW_MISSING_TRADING_DAYS(Messages.LabelChartDetailSettingsShowMissingTradingDays), // - SHOW_LIMITS(Messages.LabelChartDetailSettingsShowLimits); + SHOW_LIMITS(Messages.LabelChartDetailSettingsShowLimits), // + SHOW_MAIN_HORIZONTAL_LINES(Messages.LabelChartDetailSettingsShowHorizontalLinesMain), // + SHOW_PERCENTAGE_HORIZONTAL_LINES(Messages.LabelChartDetailSettingsShowHorizontalLinesPercentage); private final String label; @@ -391,7 +393,7 @@ public static ChartRange createFor(List prices, ChartInterval cha private IntervalOption intervalOption = IntervalOption.Y2; private EnumSet chartConfig = EnumSet.of(ChartDetails.INVESTMENT, ChartDetails.EVENTS, - ChartDetails.SCALING_LINEAR); + ChartDetails.SCALING_LINEAR, ChartDetails.SHOW_MAIN_HORIZONTAL_LINES); private List customPaintListeners = new ArrayList<>(); private List customTooltipEvents = new ArrayList<>(); @@ -669,6 +671,9 @@ private void chartConfigAboutToShow(IMenuManager manager) subMenuChartSettings.add(addMenuAction(ChartDetails.SHOW_MARKER_LINES)); subMenuChartSettings.add(addMenuAction(ChartDetails.SHOW_DATA_LABELS)); subMenuChartSettings.add(addMenuAction(ChartDetails.SHOW_MISSING_TRADING_DAYS)); + subMenuChartSettings.add(new Separator()); + subMenuChartSettings.add(addMenuAction(ChartDetails.SHOW_MAIN_HORIZONTAL_LINES)); + subMenuChartSettings.add(addMenuAction(ChartDetails.SHOW_PERCENTAGE_HORIZONTAL_LINES)); manager.add(subMenuChartScaling); manager.add(subMenuChartDevelopment); manager.add(subMenuChartMarker); @@ -798,7 +803,7 @@ private void updateChart() double[] valuesRelativePositive = new double[range.size]; double[] valuesRelativeNegative = new double[range.size]; double[] valuesZeroLine = new double[range.size]; - double firstQuote = 0; + Double firstQuote = null; // Disable SWT antialias for more than 1000 records due to SWT // performance issue in Drawing @@ -879,14 +884,37 @@ private void updateChart() IAxis yAxis1st = chart.getAxisSet().getYAxis(0); IAxis yAxis2nd = chart.getAxisSet().getYAxis(1); + IAxis yAxis3rd = chart.getAxisSet().getYAxis(2); + + if (firstQuote == null) + firstQuote = (prices.get(range.start).getValue() / Values.Quote.divider()); + yAxis2nd.setRange( new Range(yAxis1st.getRange().lower - firstQuote, yAxis1st.getRange().upper - firstQuote)); + if (firstQuote != 0) + { + yAxis3rd.setRange(new Range(yAxis1st.getRange().lower / firstQuote - 1, + yAxis1st.getRange().upper / firstQuote - 1)); + // hide percentage axis in logarithmic mode + yAxis3rd.getTick().setVisible(!chartConfig.contains(ChartDetails.SCALING_LOG)); + } + yAxis1st.enableLogScale(chartConfig.contains(ChartDetails.SCALING_LOG)); yAxis2nd.enableLogScale(chartConfig.contains(ChartDetails.SCALING_LOG)); yAxis1st.getTick().setVisible(true); + if (chartConfig.contains(ChartDetails.SHOW_MAIN_HORIZONTAL_LINES) || !yAxis3rd.getTick().isVisible()) + yAxis1st.getGrid().setStyle(LineStyle.DOT); + else + yAxis1st.getGrid().setStyle(LineStyle.NONE); + + if (chartConfig.contains(ChartDetails.SHOW_PERCENTAGE_HORIZONTAL_LINES) && yAxis3rd.getTick().isVisible()) + yAxis3rd.getGrid().setStyle(LineStyle.DOT); + else + yAxis3rd.getGrid().setStyle(LineStyle.NONE); + if (chartConfig.contains(ChartDetails.SHOW_MISSING_TRADING_DAYS)) { TradeCalendar tradeCalendar = TradeCalendarManager.getInstance(security); @@ -1017,6 +1045,7 @@ private void addLimitLines(ChartRange range) // attributes Optional attributeName = ReadOnlyClient.unwrap(client).getSettings().getAttributeTypes() .filter(attr -> attr.getId().equals(key)).findFirst(); + // could not find name of limit attribute --> don't draw if (attributeName.isEmpty()) return;