@smartnet360/svelte-components 0.0.45 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -133,13 +133,14 @@
133
133
 
134
134
  // Expand layout based on selected cells and chosen base layout
135
135
  let chartLayout = $derived.by(() => {
136
+ // Pass cellStyling - helper will decide per-section whether to use it
136
137
  const expanded = expandLayoutForCells(selectedBaseLayout, filteredData, cellStyling);
137
138
  log('📐 Chart Layout:', {
138
139
  layoutName: selectedBaseLayout.layoutName,
140
+ layoutDefaultColors: selectedBaseLayout.useDefaultChartColors ?? false,
139
141
  sectionsCount: expanded.sections.length,
140
142
  totalCharts: expanded.sections.reduce((sum, s) => sum + s.charts.length, 0),
141
- firstSection: expanded.sections[0],
142
- cellStylingEnabled: !!cellStyling
143
+ firstSection: expanded.sections[0]
143
144
  });
144
145
  return expanded;
145
146
  });
@@ -24,33 +24,53 @@ export function expandLayoutForCells(baseLayout, data, stylingConfig) {
24
24
  hoverMode: baseLayout.hoverMode, // Preserve hover mode from base layout
25
25
  coloredHover: baseLayout.coloredHover, // Preserve colored hover setting
26
26
  movingAverage: baseLayout.movingAverage, // Preserve moving average config
27
- sections: baseLayout.sections.map((section) => ({
28
- ...section,
29
- charts: section.charts.map((chart) => ({
30
- ...chart,
31
- yLeft: expandKPIs(chart.yLeft, cells, stylingConfig),
32
- yRight: expandKPIs(chart.yRight, cells, stylingConfig)
33
- }))
34
- }))
27
+ useDefaultChartColors: baseLayout.useDefaultChartColors, // Preserve layout-level default
28
+ sections: baseLayout.sections.map((section) => {
29
+ // Check per-section flag with fallback to layout-level, defaulting to false
30
+ const useDefaults = section.useDefaultChartColors ??
31
+ baseLayout.useDefaultChartColors ??
32
+ false;
33
+ // Decide styling for THIS section
34
+ const effectiveStyling = useDefaults ? undefined : stylingConfig;
35
+ return {
36
+ ...section,
37
+ charts: section.charts.map((chart) => ({
38
+ ...chart,
39
+ yLeft: expandKPIs(chart.yLeft, cells, effectiveStyling),
40
+ yRight: expandKPIs(chart.yRight, cells, effectiveStyling)
41
+ }))
42
+ };
43
+ })
35
44
  };
36
45
  return expandedLayout;
37
46
  }
38
47
  /**
39
48
  * Expand a single KPI into multiple KPIs (one per cell)
40
- * Now uses createStyledKPI to apply band colors and sector line styles
49
+ * If stylingConfig is provided: creates styled KPIs with band colors and sector line styles
50
+ * If stylingConfig is undefined: returns base KPIs as-is for Chart component default behavior
41
51
  *
42
52
  * @param baseKPIs - Array of base KPIs from layout
43
53
  * @param cells - Array of [cellName, record] tuples
44
54
  * @param stylingConfig - Optional cell styling configuration
45
- * @returns Expanded array of KPIs with cell-specific styling
55
+ * @returns Expanded array of KPIs (styled or default)
46
56
  */
47
57
  function expandKPIs(baseKPIs, cells, stylingConfig) {
48
58
  const expandedKPIs = [];
49
59
  baseKPIs.forEach((baseKPI) => {
50
60
  cells.forEach(([cellName, record]) => {
51
- // Use createStyledKPI to apply band color and sector line style
52
- const styledKPI = createStyledKPI(baseKPI.rawName, record, baseKPI.unit, stylingConfig);
53
- expandedKPIs.push(styledKPI);
61
+ if (stylingConfig) {
62
+ // Apply custom styling (band colors, sector line styles)
63
+ const styledKPI = createStyledKPI(baseKPI.rawName, record, baseKPI.unit, stylingConfig);
64
+ expandedKPIs.push(styledKPI);
65
+ }
66
+ else {
67
+ // Use Chart component default behavior: keep base KPI name
68
+ // Just update rawName to reference the pivoted column
69
+ expandedKPIs.push({
70
+ ...baseKPI,
71
+ rawName: `${baseKPI.rawName}_${cellName}`
72
+ });
73
+ }
54
74
  });
55
75
  });
56
76
  return expandedKPIs;
@@ -33,6 +33,7 @@ export interface Section {
33
33
  charts: Chart[];
34
34
  grid?: ChartGrid;
35
35
  movingAverage?: MovingAverageConfig;
36
+ useDefaultChartColors?: boolean;
36
37
  }
37
38
  export type Mode = "tabs" | "scrollspy";
38
39
  export type HoverMode = 'x' | 'y' | 'closest' | 'x unified' | 'y unified' | false;
@@ -42,6 +43,7 @@ export interface Layout {
42
43
  movingAverage?: MovingAverageConfig;
43
44
  hoverMode?: HoverMode;
44
45
  coloredHover?: boolean;
46
+ useDefaultChartColors?: boolean;
45
47
  }
46
48
  export interface ChartMarker {
47
49
  date: string | Date;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartnet360/svelte-components",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",