|
1 | 1 | import { ChangeDetectionStrategy, Component, computed, input, effect, viewChild, ElementRef, ChangeDetectorRef, inject, WritableSignal, signal } from '@angular/core'; |
2 | 2 | import { CommonModule } from '@angular/common'; |
3 | 3 | import { FormsModule } from '@angular/forms'; |
4 | | -import { Cell, AnalysisType, AnalysisOption, DropdownOption, SavedDistributionAnalysisState, ColumnConfig } from '../../models/spreadsheet.model'; |
| 4 | +import { Cell, AnalysisType, AnalysisOption, DropdownOption, SavedDistributionAnalysisState, ColumnConfig, SpreadsheetTheme } from '../../models/spreadsheet.model'; |
5 | 5 | import { |
6 | 6 | select, |
7 | 7 | max, |
@@ -38,6 +38,7 @@ export class DistributionAnalysisComponent { |
38 | 38 | initialAnalysisField = input<number | null>(null); |
39 | 39 | state = input.required<WritableSignal<SavedDistributionAnalysisState>>(); |
40 | 40 | columnConfig = input.required<ColumnConfig[]>(); |
| 41 | + theme = input.required<SpreadsheetTheme>(); |
41 | 42 |
|
42 | 43 | private chartContainer = viewChild<ElementRef<HTMLDivElement>>('distributionChartContainer'); |
43 | 44 | private tooltip = viewChild<ElementRef<HTMLDivElement>>('statsTooltip'); |
@@ -299,7 +300,7 @@ export class DistributionAnalysisComponent { |
299 | 300 | if (data.length === 0) return; |
300 | 301 |
|
301 | 302 | const isDark = document.documentElement.classList.contains('dark'); |
302 | | - const textColor = isDark ? '#94a3b8' : '#64748b'; // More visible |
| 303 | + const textColor = this.theme().colors.graphSecondary; |
303 | 304 | const barStep = 25; |
304 | 305 | const margin = { top: 5, right: 20, bottom: 60, left: 120 }; |
305 | 306 | const height = data.length * barStep; |
@@ -359,7 +360,7 @@ export class DistributionAnalysisComponent { |
359 | 360 |
|
360 | 361 | svg.selectAll('.bar').data(data).enter().append('rect') |
361 | 362 | .attr('class', 'bar').attr('x', x(0)).attr('y', d => y(d.key)!) |
362 | | - .attr('width', d => x(d.value) - x(0)).attr('height', y.bandwidth()).attr('fill', '#3b82f6') |
| 363 | + .attr('width', d => x(d.value) - x(0)).attr('height', y.bandwidth()).attr('fill', this.theme().colors.graphPrimary) |
363 | 364 | .on('mouseover', (event, d) => { |
364 | 365 | select(event.currentTarget).style('opacity', '0.85'); |
365 | 366 | tooltip.style('opacity', '1').html(`<strong>${d.key}</strong><br/>Count: ${d.value}`); |
@@ -393,7 +394,7 @@ export class DistributionAnalysisComponent { |
393 | 394 | const series = stack().keys(stackKeys)(data as any); |
394 | 395 |
|
395 | 396 | const isDark = document.documentElement.classList.contains('dark'); |
396 | | - const textColor = isDark ? '#94a3b8' : '#64748b'; // More visible |
| 397 | + const textColor = this.theme().colors.graphSecondary; |
397 | 398 | const barStep = 30; |
398 | 399 | const margin = { top: 5, right: 120, bottom: 60, left: 120 }; |
399 | 400 | const height = data.length * barStep; |
@@ -502,8 +503,7 @@ export class DistributionAnalysisComponent { |
502 | 503 | } |
503 | 504 |
|
504 | 505 | private _renderGradientLegend(svg: Selection<SVGGElement, unknown, null, undefined>, colorScale: ScaleSequentialType<string>, legendX: number, legendY: number, height: number, title: string) { |
505 | | - const isDark = document.documentElement.classList.contains('dark'); |
506 | | - const textColor = isDark ? '#94a3b8' : '#64748b'; |
| 506 | + const textColor = this.theme().colors.graphSecondary; |
507 | 507 | const [min, max] = colorScale.domain(); |
508 | 508 | if (min === undefined || max === undefined) return; |
509 | 509 | const legendId = `legend-gradient-${Math.random().toString(36).substring(2, 9)}`; |
|
0 commit comments