Jimin Huang commited on
Commit
9f701c8
·
1 Parent(s): 51fa349

Change settings

Browse files
Files changed (1) hide show
  1. src/components/CompareChartE.vue +24 -4
src/components/CompareChartE.vue CHANGED
@@ -26,6 +26,26 @@ const ASSET_CUTOFF = {
26
  // ETH: '2025-08-15',
27
  };
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  // helper: convert [ [date, y], ... ] into % since first y
30
  function toPct(points){
31
  if (!Array.isArray(points) || !points.length) return points
@@ -98,7 +118,7 @@ async function composeBadge(agent, model, color = '#666') {
98
 
99
  // model puck (bottom-right)
100
  if (mImg) {
101
- const d = 14, r = d / 2; // puck diameter
102
  const cx = S - r + 1, cy = S - r + 1; // slight outside bias
103
  // white border
104
  ctx.fillStyle = '#fff';
@@ -196,12 +216,12 @@ export default defineComponent({
196
  showSymbol: false,
197
  smooth: false,
198
  emphasis: { focus: 'series' },
199
- lineStyle: { width: 2, color: getStrategyColor(sel.strategy || '', false, idx) },
200
  data: points
201
  })
202
  const last = points?.[points.length - 1];
203
  if (last && Number.isFinite(last[1])) {
204
- const lineColor = getStrategyColor(sel.strategy || '', false, idx);
205
  const badgeUrl = await composeBadge(agent, sel.model, lineColor); // ← NEW
206
  series.push({
207
  name: name + ' •badge',
@@ -251,7 +271,7 @@ export default defineComponent({
251
  const lastBH = bhPoints[bhPoints.length - 1]
252
  if (lastBH && Number.isFinite(lastBH[1])) {
253
  const baseColor = getStrategyColor('', true, 0);
254
- const badgeUrl = await composeBadge(asset, null, '#fff'); // ← NEW
255
  series.push({
256
  name: `${asset} · Buy&Hold •badge`,
257
  type: 'scatter',
 
26
  // ETH: '2025-08-15',
27
  };
28
 
29
+ // Stable palette per agent (tweak as you like)
30
+ const AGENT_PALETTE = [
31
+ '#6D4CFE', // indigo
32
+ '#FF6B6B', // coral
33
+ '#10B981', // emerald
34
+ '#F59E0B', // amber
35
+ '#06B6D4', // cyan
36
+ '#A855F7', // violet
37
+ '#64748B', // slate
38
+ '#E11D48', // rose
39
+ '#0EA5E9', // sky
40
+ '#84CC16', // lime
41
+ ]
42
+
43
+ // pick color by agent name + index (from agentColorIndex map)
44
+ function getAgentColor(agent, idx = 0) {
45
+ // keep simple + deterministic
46
+ return AGENT_PALETTE[idx % AGENT_PALETTE.length]
47
+ }
48
+
49
  // helper: convert [ [date, y], ... ] into % since first y
50
  function toPct(points){
51
  if (!Array.isArray(points) || !points.length) return points
 
118
 
119
  // model puck (bottom-right)
120
  if (mImg) {
121
+ const d = 30, r = d / 2; // puck diameter
122
  const cx = S - r + 1, cy = S - r + 1; // slight outside bias
123
  // white border
124
  ctx.fillStyle = '#fff';
 
216
  showSymbol: false,
217
  smooth: false,
218
  emphasis: { focus: 'series' },
219
+ lineStyle: { width: 2, color: getAgentColor(agent, idx) },
220
  data: points
221
  })
222
  const last = points?.[points.length - 1];
223
  if (last && Number.isFinite(last[1])) {
224
+ const lineColor = getAgentColor(agent, idx);
225
  const badgeUrl = await composeBadge(agent, sel.model, lineColor); // ← NEW
226
  series.push({
227
  name: name + ' •badge',
 
271
  const lastBH = bhPoints[bhPoints.length - 1]
272
  if (lastBH && Number.isFinite(lastBH[1])) {
273
  const baseColor = getStrategyColor('', true, 0);
274
+ const badgeUrl = await composeBadge(asset, null, baseColor); // ← NEW
275
  series.push({
276
  name: `${asset} · Buy&Hold •badge`,
277
  type: 'scatter',