Consistent Color reporting for multiple charts

Hi,

I’m trying to use Grist to manage my budget, investigation portfolio, etc.

One of the assumptions of my system is that I have “Wallets” (for example: long-term investments, safety-nest, retirement funds). Each wallet has some “plan” of what investment process will be used and in what proportion in this wallet.

For example:
for the long-term investment, I want to have 75% value in real estate and 25% in gold

But life is life and rarely goes according to plan, so it is crucial to me to compare my actual wallet composition to the planned one, to plan my next moves (to buy or sell something).

So I have my wallets defined in one table, investment product dictionary in another table, wallet composition in the third one, and lastly, the value of the given investment product in that wallet for a given date in the fourth one (there are some middle steps here, but not important).

So I made a page with one chart based on a wallet composition plan and a second one that calculates wallet composition from the current value. And it works great but… colors do not match. And this was a great no-go because it denied the whole point of comparing graphs. See the picture below:


It seems at first that only proportions are wrong in the wallet Implementation, but in fact - I am investing in the wrong products! It can be hardly seen on the graph because the colors are the same.
The advanced chart widget did not help - It had the same problem, that colors are just based on the series in graph source data order, and cannot be defined in any other way.

So, how to mitigate that?

After a few approaches, I go with one like this:

First, this is the worst and manual step - I think that I might automate this using API - but I needed to create a new table with all possible wallet and investment product permutations, using reference columns.
Then I added four more columns, are formula:

  1. Date - this is the date I want to create chart for, it is based on the “singletons values table” that I have defined in the document
    Sta_e_porfelowe.all[0].Report_Date
  2. Target percent, for that product in that wallet - it is not planed at all, there will be 0STRUKTURA_PORTFELA.lookupOne(Produkt=$Skladnik, PORTFEL=$Portfel2).WARTOSC_PROCENTOWA
  3. Value of the investments in that product, for the same month as in the date column
if not $Stan_portfela:
    return 0

# Extract the month and year from the rec.data
target_month = $data.month
target_year = $data.year

# Count how many Wartosc_sk_adnikow have the same month and year
count_same_month = sum(ws.wartosc for ws in $Stan_portfela if ws.data.month == target_month and ws.data.year == target_year)

return count_same_month
  1. Then, based on the value of the product in that wallet, I’m calculating the ratio to all of these wallet investments $Wartosc/SUM(Raport_portfele.lookupRecords(Portfel2=$Portfel2).Wartosc)

Based on all of this, for each possible combination of product/wallet, I have a target and current percent values. And because there are ALL possible combinations, on the chart I have ALL series, with most of them with 0 values. But because the order and number of series are the same on both charts, the colors are the same:

Now it is visible that the investment is misaligned and I need to take some decisive actions to get it back on track.

What do you think? Maybe you know any more optimal solutions or alternative ways to achieve this outcome?

Cheers!