@smartnet360/svelte-components 0.0.26 → 0.0.28

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.
@@ -27,9 +27,11 @@
27
27
  layoutMovingAverage?: MovingAverageConfig; // Layout-level MA config
28
28
  runtimeMAOverride?: MovingAverageConfig | null; // Runtime override from global controls
29
29
  runtimeShowOriginal?: boolean; // Runtime control for showing original lines
30
+ runtimeShowMarkers?: boolean; // Runtime control for showing markers (default: true)
31
+ runtimeShowLegend?: boolean; // Runtime control for showing legend (default: true)
30
32
  }
31
33
 
32
- let { chart, data, markers, plotlyLayout, enableAdaptation = true, sectionId, sectionMovingAverage, layoutMovingAverage, runtimeMAOverride, runtimeShowOriginal }: Props = $props();
34
+ let { chart, data, markers, plotlyLayout, enableAdaptation = true, sectionId, sectionMovingAverage, layoutMovingAverage, runtimeMAOverride, runtimeShowOriginal, runtimeShowMarkers = true, runtimeShowLegend = true }: Props = $props();
33
35
 
34
36
  // Chart container div and state
35
37
  let chartDiv: HTMLElement;
@@ -198,8 +200,16 @@
198
200
  { enableAdaptation }
199
201
  );
200
202
 
201
- // Add markers to the layout
202
- finalLayout = addMarkersToLayout(finalLayout, markers || [], containerSize, enableAdaptation);
203
+ // Add markers to the layout only if runtime control allows
204
+ if (runtimeShowMarkers) {
205
+ finalLayout = addMarkersToLayout(finalLayout, markers || [], containerSize, enableAdaptation);
206
+ }
207
+
208
+ // Apply legend visibility control
209
+ if (finalLayout.showlegend === undefined || finalLayout.showlegend) {
210
+ // Only override if legend would normally be shown
211
+ finalLayout.showlegend = runtimeShowLegend;
212
+ }
203
213
 
204
214
  const config = {
205
215
  responsive: true,
@@ -10,6 +10,8 @@ interface Props {
10
10
  layoutMovingAverage?: MovingAverageConfig;
11
11
  runtimeMAOverride?: MovingAverageConfig | null;
12
12
  runtimeShowOriginal?: boolean;
13
+ runtimeShowMarkers?: boolean;
14
+ runtimeShowLegend?: boolean;
13
15
  }
14
16
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
17
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
@@ -54,12 +54,18 @@
54
54
 
55
55
  let { layout, data, mode, markers, plotlyLayout, enableAdaptation = true, showGlobalControls = true }: Props = $props();
56
56
 
57
- // Global runtime controls state
57
+ // Global runtime controls state - initialize from layout config
58
58
  let globalControls = $state<GlobalChartControls>({
59
59
  movingAverage: {
60
- enabled: true,
60
+ enabled: layout.movingAverage?.enabled ?? true,
61
61
  windowOverride: undefined,
62
- showOriginal: true
62
+ showOriginal: layout.movingAverage?.showOriginal ?? true
63
+ },
64
+ markers: {
65
+ enabled: true // Default to showing markers
66
+ },
67
+ legend: {
68
+ enabled: true // Default to showing legend
63
69
  }
64
70
  });
65
71
 
@@ -294,6 +300,8 @@
294
300
  layoutMovingAverage={layout.movingAverage}
295
301
  runtimeMAOverride={effectiveMAOverride}
296
302
  runtimeShowOriginal={globalControls.movingAverage?.showOriginal}
303
+ runtimeShowMarkers={globalControls.markers?.enabled}
304
+ runtimeShowLegend={globalControls.legend?.enabled}
297
305
  on:chartcontextmenu={(event) => handleChartContextMenu(event.detail, section)}
298
306
  />
299
307
  </div>
@@ -434,6 +442,8 @@
434
442
  layoutMovingAverage={layout.movingAverage}
435
443
  runtimeMAOverride={effectiveMAOverride}
436
444
  runtimeShowOriginal={globalControls.movingAverage?.showOriginal}
445
+ runtimeShowMarkers={globalControls.markers?.enabled}
446
+ runtimeShowLegend={globalControls.legend?.enabled}
437
447
  on:chartcontextmenu={(event) => handleChartContextMenu(event.detail, activeZoom.section)}
438
448
  />
439
449
  </div>
@@ -26,6 +26,26 @@
26
26
  }
27
27
  });
28
28
  }
29
+
30
+ function updateMarkers(updates: Partial<NonNullable<GlobalChartControls['markers']>>) {
31
+ onUpdate({
32
+ ...controls,
33
+ markers: {
34
+ ...controls.markers!,
35
+ ...updates
36
+ }
37
+ });
38
+ }
39
+
40
+ function updateLegend(updates: Partial<NonNullable<GlobalChartControls['legend']>>) {
41
+ onUpdate({
42
+ ...controls,
43
+ legend: {
44
+ ...controls.legend!,
45
+ ...updates
46
+ }
47
+ });
48
+ }
29
49
  </script>
30
50
 
31
51
  <div class="global-controls">
@@ -117,16 +137,39 @@
117
137
  {/if}
118
138
  </div>
119
139
  {/if}
120
-
121
- <!-- Future controls can be added here -->
122
- <!-- Example:
123
- <div class="control-group">
124
- <div class="form-check form-check-inline">
125
- <input type="checkbox" id="markersToggle" />
126
- <label for="markersToggle">Markers</label>
140
+
141
+ <!-- Markers Toggle -->
142
+ {#if controls.markers}
143
+ <div class="control-group">
144
+ <input
145
+ type="checkbox"
146
+ class="btn-check"
147
+ id="markersToggle"
148
+ checked={controls.markers.enabled}
149
+ onchange={() => updateMarkers({ enabled: !controls.markers!.enabled })}
150
+ />
151
+ <label class="btn btn-outline-secondary btn-sm" for="markersToggle">
152
+ Markers
153
+ </label>
127
154
  </div>
128
- </div>
129
- -->
155
+ {/if}
156
+
157
+ <!-- Legend Toggle -->
158
+ {#if controls.legend}
159
+ <div class="control-group">
160
+ <input
161
+ type="checkbox"
162
+ class="btn-check"
163
+ id="legendToggle"
164
+ checked={controls.legend.enabled}
165
+ onchange={() => updateLegend({ enabled: !controls.legend!.enabled })}
166
+ />
167
+ <label class="btn btn-outline-secondary btn-sm" for="legendToggle">
168
+ Legend
169
+ </label>
170
+ </div>
171
+ {/if}
172
+
130
173
  </div>
131
174
  </div>
132
175
 
@@ -147,12 +190,6 @@
147
190
  flex-wrap: wrap;
148
191
  }
149
192
 
150
- .controls-label {
151
- font-weight: 600;
152
- color: #495057;
153
- margin-right: 0.5rem;
154
- }
155
-
156
193
  .control-group {
157
194
  display: flex;
158
195
  align-items: center;
@@ -49,4 +49,10 @@ export interface GlobalChartControls {
49
49
  windowOverride?: number;
50
50
  showOriginal?: boolean;
51
51
  };
52
+ markers?: {
53
+ enabled: boolean;
54
+ };
55
+ legend?: {
56
+ enabled: boolean;
57
+ };
52
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartnet360/svelte-components",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",