From 07461031b8dfaf4ec95b8aea6daf14cac5184daf Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Wed, 4 Mar 2026 09:06:05 +0100 Subject: [PATCH] fix(VendorDataView): assign distinct color per market in all three charts Each market line (DE/ES/FR/IT/UK) now renders with its own color across Top Level BSR, Detail Level BSR, and Average Rating charts, along with per-market legend entries. Removes hardcoded single-color approach. Co-Authored-By: Claude Sonnet 4.6 --- components/VendorDataView.tsx | 126 +++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 56 deletions(-) diff --git a/components/VendorDataView.tsx b/components/VendorDataView.tsx index 9b431b7..8340de7 100644 --- a/components/VendorDataView.tsx +++ b/components/VendorDataView.tsx @@ -417,13 +417,20 @@ const VendorDataView: React.FC = ({ bsrData = [], asinMetad ); } - // Exact color values based on the screenshot const cardBg = '#161b24'; - const orangeHex = '#f37526'; - const cyanHex = '#2acbd6'; - const purpleHex = '#7950f2'; const gridLineColor = '#ffffff'; + // One distinct color per market + const MARKET_COLORS: Record = { + 'Amazon DE': '#f37526', + 'Amazon ES': '#2acbd6', + 'Amazon FR': '#7950f2', + 'Amazon IT': '#10b981', + 'Amazon UK': '#f59e0b', + }; + const FALLBACK_COLORS = ['#f37526', '#2acbd6', '#7950f2', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6']; + const getMarketColor = (m: string, idx: number) => MARKET_COLORS[m] ?? FALLBACK_COLORS[idx % FALLBACK_COLORS.length]; + return (
@@ -499,32 +506,34 @@ const VendorDataView: React.FC = ({ bsrData = [], asinMetad labelStyle={{ color: '#9ca3af', fontSize: '11px', marginBottom: '4px' }} cursor={{ stroke: '#374151', strokeWidth: 1, strokeDasharray: '3 3' }} /> - {activeMarkets.map((m) => ( - - ))} + {activeMarkets.map((m, i) => { + const color = getMarketColor(m, i); + return ( + + ); + })}
- {/* Exact Legend matching screenshot */} -
- {activeMarkets.length > 0 && ( -
-
- {activeMarkets[0]} BSR +
+ {activeMarkets.map((m, i) => ( +
+
+ {m} BSR
- )} + ))}
@@ -568,30 +577,34 @@ const VendorDataView: React.FC = ({ bsrData = [], asinMetad labelStyle={{ color: '#9ca3af', fontSize: '11px', marginBottom: '4px' }} cursor={{ stroke: '#374151', strokeWidth: 1, strokeDasharray: '3 3' }} /> - {activeMarkets.map((m) => ( - - ))} + {activeMarkets.map((m, i) => { + const color = getMarketColor(m, i); + return ( + + ); + })}
- {/* Exact Legend matching screenshot */} -
-
-
- Category Rank -
+
+ {activeMarkets.map((m, i) => ( +
+
+ {m} Rank +
+ ))}
@@ -626,30 +639,31 @@ const VendorDataView: React.FC = ({ bsrData = [], asinMetad labelStyle={{ color: '#9ca3af', fontSize: '11px', marginBottom: '4px' }} cursor={{ stroke: '#374151', strokeWidth: 1, strokeDasharray: '3 3' }} /> - {activeMarkets.map((m) => ( + {activeMarkets.map((m, i) => ( ))} - {/* Exact Legend matching screenshot */} -
-
-
- Star Rating -
+
+ {activeMarkets.map((m, i) => ( +
+
+ {m} Rating +
+ ))}