-
Notifications
You must be signed in to change notification settings - Fork 613
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
Allow a variety of data series for statement of assets #3754
base: master
Are you sure you want to change the base?
Changes from 5 commits
517443f
c7c857b
d161eee
f8f0275
0fa55ec
1e8f550
56758c6
9566b57
d53fef3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ workspace | |
.metadata/* | ||
.recommenders/* | ||
.DS_Store | ||
.project | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package name.abuchen.portfolio.ui.views.dataseries; | ||
|
||
import java.util.Arrays; | ||
import java.util.EnumMap; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
import org.eclipse.swt.graphics.Image; | ||
|
@@ -40,6 +43,32 @@ public enum ClientDataSeries | |
EARNINGS, EARNINGS_ACCUMULATED, FEES, FEES_ACCUMULATED; | ||
} | ||
|
||
public static final Map<ClientDataSeries, String> statementOfAssetsDataSeriesLabels = new EnumMap<>(ClientDataSeries.class) | ||
{ | ||
private static final long serialVersionUID = 1319016001158914537L; | ||
|
||
{ | ||
put(ClientDataSeries.TOTALS, Messages.LabelTotalSum); | ||
put(ClientDataSeries.TRANSFERALS, Messages.LabelTransferals); | ||
put(ClientDataSeries.INVESTED_CAPITAL, Messages.LabelInvestedCapital); | ||
put(ClientDataSeries.ABSOLUTE_INVESTED_CAPITAL, Messages.LabelAbsoluteInvestedCapital); | ||
put(ClientDataSeries.ABSOLUTE_DELTA, Messages.LabelDelta); | ||
put(ClientDataSeries.ABSOLUTE_DELTA_ALL_RECORDS, Messages.LabelAbsoluteDelta); | ||
put(ClientDataSeries.TAXES, Messages.ColumnTaxes); | ||
put(ClientDataSeries.TAXES_ACCUMULATED, Messages.LabelAccumulatedTaxes); | ||
put(ClientDataSeries.DIVIDENDS, Messages.LabelDividends); | ||
put(ClientDataSeries.DIVIDENDS_ACCUMULATED, Messages.LabelAccumulatedDividends); | ||
put(ClientDataSeries.INTEREST, Messages.LabelInterest); | ||
put(ClientDataSeries.INTEREST_ACCUMULATED, Messages.LabelAccumulatedInterest); | ||
put(ClientDataSeries.INTEREST_CHARGE, Messages.LabelInterestCharge); | ||
put(ClientDataSeries.INTEREST_CHARGE_ACCUMULATED, Messages.LabelAccumulatedInterestCharge); | ||
put(ClientDataSeries.EARNINGS, Messages.LabelEarnings); | ||
put(ClientDataSeries.EARNINGS_ACCUMULATED, Messages.LabelAccumulatedEarnings); | ||
put(ClientDataSeries.FEES, Messages.LabelFees); | ||
put(ClientDataSeries.FEES_ACCUMULATED, Messages.LabelFeesAccumulated); | ||
} | ||
}; | ||
|
||
/** | ||
* Type of objects for which the PerformanceIndex is calculated. | ||
*/ | ||
|
@@ -52,6 +81,7 @@ public enum Type | |
ACCOUNT("Account", i -> ((Account) i).getUUID()), //$NON-NLS-1$ | ||
ACCOUNT_PRETAX("Account-PreTax", i -> ((Account) i).getUUID()), //$NON-NLS-1$ | ||
PORTFOLIO("Portfolio", i -> ((Portfolio) i).getUUID()), //$NON-NLS-1$ | ||
TYPE_PARENT("Type-Parent-", i -> ((GroupedDataSeries) i).getId()), //$NON-NLS-1$ | ||
PORTFOLIO_PRETAX("Portfolio-PreTax", i -> ((Portfolio) i).getUUID()), //$NON-NLS-1$ | ||
PORTFOLIO_PLUS_ACCOUNT("[+]Portfolio", i -> ((Portfolio) i).getUUID()), //$NON-NLS-1$ | ||
PORTFOLIO_PLUS_ACCOUNT_PRETAX("[+]Portfolio-PreTax", i -> ((Portfolio) i).getUUID()), //$NON-NLS-1$ | ||
|
@@ -75,7 +105,7 @@ String buildUUID(Object instance) | |
} | ||
|
||
private Type type; | ||
private Object group; | ||
private Object[] groups; | ||
private Object instance; | ||
private String label; | ||
private boolean isLineChart = true; | ||
|
@@ -98,10 +128,19 @@ String buildUUID(Object instance) | |
this(type, null, instance, label, color); | ||
} | ||
|
||
/* package */ DataSeries(Type type, Object[] groups, Object instance, String label, RGB color) | ||
{ | ||
this.type = type; | ||
this.groups = groups; | ||
this.instance = instance; | ||
this.label = label; | ||
this.color = color; | ||
} | ||
|
||
/* package */ DataSeries(Type type, Object group, Object instance, String label, RGB color) | ||
{ | ||
this.type = type; | ||
this.group = group; | ||
this.groups = group != null ? Arrays.asList(group).toArray() : null; | ||
this.instance = instance; | ||
this.label = label; | ||
this.color = color; | ||
|
@@ -112,9 +151,9 @@ public Type getType() | |
return type; | ||
} | ||
|
||
public Object getGroup() | ||
public Object[] getGroups() | ||
{ | ||
return group; | ||
return groups; | ||
} | ||
|
||
public Object getInstance() | ||
|
@@ -124,6 +163,9 @@ public Object getInstance() | |
|
||
public String getLabel() | ||
{ | ||
if (instance instanceof GroupedDataSeries c && groups.length > 0) | ||
return groups[groups.length - 1] + " - " + label; //$NON-NLS-1$ | ||
|
||
Comment on lines
+166
to
+168
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is using the "group" essentially as second label. |
||
return isBenchmark() ? label + " " + Messages.ChartSeriesBenchmarkSuffix : label; //$NON-NLS-1$ | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,8 @@ public DataSeriesSet(Client client, IPreferenceStore preferences, DataSeries.Use | |
switch (useCase) | ||
{ | ||
case STATEMENT_OF_ASSETS: | ||
buildStatementOfAssetsDataSeries(); | ||
break; | ||
buildStatementOfAssetsDataSeries(client, preferences, wheel); | ||
return; | ||
Comment on lines
+38
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This return statement prevents existing "common" series to be added. Let's discuss in the comments of the pull request how to achieve backwards compatibility. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we can add a DataSeries property for whether it's "visible"? And then for the returned DataSeriesSet for Statement of Assets, set it to false so the old ones don't show? |
||
case PERFORMANCE: | ||
buildPerformanceDataSeries(client, preferences, wheel); | ||
break; | ||
|
@@ -68,89 +68,80 @@ public DataSeries lookup(String uuid) | |
return availableSeries.stream().filter(d -> d.getUUID().equals(uuid)).findAny().orElse(null); | ||
} | ||
|
||
private void buildStatementOfAssetsDataSeries() | ||
private void buildStatementOfAssetsDataSeries(Client client, IPreferenceStore preferences, ColorWheel wheel) | ||
{ | ||
availableSeries.add(new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.TOTALS, Messages.LabelTotalSum, | ||
Colors.TOTALS.getRGB())); | ||
|
||
DataSeries series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.TRANSFERALS, | ||
Messages.LabelTransferals, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY).getRGB()); | ||
series.setLineChart(false); | ||
availableSeries.add(series); | ||
for (var entry : DataSeries.statementOfAssetsDataSeriesLabels.entrySet()) | ||
{ | ||
// Common folder | ||
availableSeries.add(new DataSeries(DataSeries.Type.CLIENT, entry.getKey(), entry.getValue(), wheel.next())); | ||
|
||
for (Portfolio portfolio : client.getPortfolios()) | ||
{ | ||
var instance = new GroupedDataSeries(portfolio, entry.getKey()); | ||
instance.setIsPortfolioPlusReferenceAccount(true); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.INVESTED_CAPITAL, | ||
Messages.LabelInvestedCapital, Display.getDefault().getSystemColor(SWT.COLOR_GRAY).getRGB()); | ||
series.setShowArea(true); | ||
availableSeries.add(series); | ||
var name = portfolio.getName() + " + " + portfolio.getReferenceAccount().getName(); //$NON-NLS-1$ | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.ABSOLUTE_INVESTED_CAPITAL, | ||
Messages.LabelAbsoluteInvestedCapital, | ||
Display.getDefault().getSystemColor(SWT.COLOR_GRAY).getRGB()); | ||
series.setShowArea(true); | ||
availableSeries.add(series); | ||
var dataSeries = new DataSeries(DataSeries.Type.TYPE_PARENT, name, instance, entry.getValue(), | ||
wheel.next()); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.ABSOLUTE_DELTA, Messages.LabelDelta, | ||
Display.getDefault().getSystemColor(SWT.COLOR_GRAY).getRGB()); | ||
availableSeries.add(series); | ||
availableSeries.add(dataSeries); | ||
} | ||
|
||
for (Portfolio portfolio : client.getPortfolios()) | ||
{ | ||
var instance = new GroupedDataSeries(portfolio, entry.getKey()); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.ABSOLUTE_DELTA_ALL_RECORDS, | ||
Messages.LabelAbsoluteDelta, Display.getDefault().getSystemColor(SWT.COLOR_GRAY).getRGB()); | ||
availableSeries.add(series); | ||
var dataSeries = new DataSeries(DataSeries.Type.TYPE_PARENT, portfolio.getName(), instance, | ||
entry.getValue(), wheel.next()); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.TAXES, Messages.ColumnTaxes, | ||
Display.getDefault().getSystemColor(SWT.COLOR_RED).getRGB()); | ||
series.setLineChart(false); | ||
availableSeries.add(series); | ||
availableSeries.add(dataSeries); | ||
} | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.TAXES_ACCUMULATED, | ||
Messages.LabelAccumulatedTaxes, Display.getDefault().getSystemColor(SWT.COLOR_RED).getRGB()); | ||
availableSeries.add(series); | ||
for (Account account : client.getAccounts()) | ||
{ | ||
var instance = new GroupedDataSeries(account, entry.getKey()); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.DIVIDENDS, Messages.LabelDividends, | ||
Display.getDefault().getSystemColor(SWT.COLOR_DARK_MAGENTA).getRGB()); | ||
series.setLineChart(false); | ||
availableSeries.add(series); | ||
var dataSeries = new DataSeries(DataSeries.Type.TYPE_PARENT, account.getName(), instance, | ||
entry.getValue(), wheel.next()); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.DIVIDENDS_ACCUMULATED, | ||
Messages.LabelAccumulatedDividends, | ||
Display.getDefault().getSystemColor(SWT.COLOR_DARK_MAGENTA).getRGB()); | ||
availableSeries.add(series); | ||
availableSeries.add(dataSeries); | ||
} | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.INTEREST, Messages.LabelInterest, | ||
Colors.DARK_GREEN.getRGB()); | ||
series.setLineChart(false); | ||
availableSeries.add(series); | ||
for (Taxonomy taxonomy : client.getTaxonomies()) | ||
{ | ||
taxonomy.foreach(new Taxonomy.Visitor() | ||
{ | ||
@Override | ||
public void visit(Classification classification) | ||
{ | ||
if (classification.getParent() == null) | ||
return; | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.INTEREST_ACCUMULATED, | ||
Messages.LabelAccumulatedInterest, Colors.DARK_GREEN.getRGB()); | ||
availableSeries.add(series); | ||
Object[] groups = { taxonomy, classification.getName() }; | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.INTEREST_CHARGE, Messages.LabelInterestCharge, | ||
Colors.DARK_GREEN.getRGB()); | ||
series.setLineChart(false); | ||
availableSeries.add(series); | ||
var instance = new GroupedDataSeries(classification, entry.getKey()); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.INTEREST_CHARGE_ACCUMULATED, | ||
Messages.LabelAccumulatedInterestCharge, Colors.DARK_GREEN.getRGB()); | ||
availableSeries.add(series); | ||
var dataSeries = new DataSeries(DataSeries.Type.TYPE_PARENT, groups, instance, entry.getValue(), | ||
wheel.next()); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.EARNINGS, Messages.LabelEarnings, | ||
Colors.DARK_GREEN.getRGB()); | ||
series.setLineChart(false); | ||
availableSeries.add(series); | ||
availableSeries.add(dataSeries); | ||
} | ||
}); | ||
} | ||
|
||
ClientFilterMenu menu = new ClientFilterMenu(client, preferences); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.EARNINGS_ACCUMULATED, | ||
Messages.LabelAccumulatedEarnings, Colors.DARK_GREEN.getRGB()); | ||
availableSeries.add(series); | ||
for (ClientFilterMenu.Item item : menu.getCustomItems()) | ||
{ | ||
var instance = new GroupedDataSeries(item, entry.getKey()); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.FEES, Messages.LabelFees, | ||
Colors.GRAY.getRGB()); | ||
series.setLineChart(false); | ||
availableSeries.add(series); | ||
var dataSeries = new DataSeries(DataSeries.Type.TYPE_PARENT, item.getLabel(), instance, | ||
entry.getValue(), wheel.next()); | ||
|
||
series = new DataSeries(DataSeries.Type.CLIENT, ClientDataSeries.FEES_ACCUMULATED, | ||
Messages.LabelFeesAccumulated, Colors.GRAY.getRGB()); | ||
availableSeries.add(series); | ||
availableSeries.add(dataSeries); | ||
} | ||
} | ||
} | ||
|
||
private void buildPerformanceDataSeries(Client client, IPreferenceStore preferences, ColorWheel wheel) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project files are actually check-in (common praxis with Eclipse) so that everybody gets the same configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1e8f550 thanks!