diff --git a/dashboard/public/index.html b/dashboard/public/index.html index c48ab25..fb2744c 100644 --- a/dashboard/public/index.html +++ b/dashboard/public/index.html @@ -306,6 +306,8 @@ + +
@@ -423,8 +425,24 @@ function updateSubGroupOptions() { const x = document.getElementById('axisX').value; const sub = document.getElementById('axisSub'); + + // Remove existing composite options first to avoid duplicates + // We need to reset the options or add them dynamically + + // For simplicity, we'll just enable/disable standard ones and maybe append composite ones? + // Actually, let's just make sure they exist in the HTML (I will add them there) + // and toggling disabled state here. + Array.from(sub.options).forEach(opt => { + // Disable if same as X opt.disabled = (opt.value === x); + + // Composite options are special: only allow them if X is time-based (day/month) + if (['exchange_continent', 'exchange_sector'].includes(opt.value)) { + opt.disabled = !['day', 'month'].includes(x); + opt.hidden = !['day', 'month'].includes(x); + } + if (opt.value === x && sub.value === x) sub.value = ''; }); } diff --git a/dashboard/server.py b/dashboard/server.py index f867dcc..e8f7f58 100644 --- a/dashboard/server.py +++ b/dashboard/server.py @@ -84,9 +84,11 @@ async def get_analytics( continents: str = None ): # Determine if we need to join metadata + # Determine if we need to join metadata + composite_keys = ["exchange_continent", "exchange_sector"] needs_metadata = any([ - group_by in ["name", "continent", "sector"], - sub_group_by in ["name", "continent", "sector"], + group_by in ["name", "continent", "sector"] + composite_keys, + sub_group_by in ["name", "continent", "sector"] + composite_keys, continents is not None ]) @@ -107,7 +109,9 @@ async def get_analytics( "isin": f"{t_prefix}isin", "name": f"coalesce({m_prefix}name, {t_prefix}isin)" if needs_metadata else "isin", "continent": f"coalesce({m_prefix}continent, 'Unknown')" if needs_metadata else "'Unknown'", - "sector": f"coalesce({m_prefix}sector, 'Unknown')" if needs_metadata else "'Unknown'" + "sector": f"coalesce({m_prefix}sector, 'Unknown')" if needs_metadata else "'Unknown'", + "exchange_continent": f"concat({t_prefix}exchange, ' - ', coalesce({m_prefix}continent, 'Unknown'))" if needs_metadata else "'Unknown'", + "exchange_sector": f"concat({t_prefix}exchange, ' - ', coalesce({m_prefix}sector, 'Unknown'))" if needs_metadata else "'Unknown'" } selected_metric = metrics_map.get(metric, metrics_map["volume"])