@trebco/treb 29.3.4 → 29.5.0

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.
Files changed (44) hide show
  1. package/dist/treb-spreadsheet-light.mjs +12 -12
  2. package/dist/treb-spreadsheet.mjs +12 -12
  3. package/dist/treb.d.ts +36 -41
  4. package/package.json +1 -1
  5. package/treb-base-types/src/area.ts +7 -0
  6. package/treb-base-types/src/cell.ts +2 -46
  7. package/treb-base-types/src/cells.ts +14 -8
  8. package/treb-base-types/src/gradient.ts +2 -2
  9. package/treb-base-types/src/import.ts +2 -2
  10. package/treb-base-types/src/style.ts +79 -6
  11. package/treb-base-types/src/theme.ts +24 -15
  12. package/treb-calculator/src/calculator.ts +22 -12
  13. package/treb-calculator/src/dag/graph.ts +12 -3
  14. package/treb-calculator/src/expression-calculator.ts +66 -74
  15. package/treb-calculator/src/functions/base-functions.ts +2 -2
  16. package/treb-calculator/src/functions/sparkline.ts +2 -2
  17. package/treb-calculator/src/functions/statistics-functions.ts +31 -1
  18. package/treb-data-model/src/data-validation.ts +44 -0
  19. package/treb-data-model/src/data_model.ts +11 -7
  20. package/treb-data-model/src/index.ts +1 -1
  21. package/treb-data-model/src/named.ts +35 -10
  22. package/treb-data-model/src/sheet.ts +75 -15
  23. package/treb-data-model/src/sheet_types.ts +4 -0
  24. package/treb-embed/src/custom-element/spreadsheet-constructor.ts +7 -3
  25. package/treb-embed/src/embedded-spreadsheet.ts +50 -28
  26. package/treb-embed/src/progress-dialog.ts +4 -1
  27. package/treb-embed/src/types.ts +9 -0
  28. package/treb-export/src/drawing2/chart2.ts +20 -38
  29. package/treb-export/src/drawing2/drawing2.ts +2 -107
  30. package/treb-export/src/export-worker/export-worker.ts +1 -1
  31. package/treb-export/src/{export2.ts → export.ts} +439 -628
  32. package/treb-export/src/import2.ts +63 -26
  33. package/treb-export/src/workbook-style2.ts +16 -14
  34. package/treb-export/src/workbook2.ts +2 -18
  35. package/treb-export/src/xml-utils.ts +50 -2
  36. package/treb-export/src/zip-wrapper.ts +1 -1
  37. package/treb-grid/src/editors/overlay_editor.ts +3 -3
  38. package/treb-grid/src/layout/base_layout.ts +5 -14
  39. package/treb-grid/src/render/tile_renderer.ts +49 -48
  40. package/treb-grid/src/types/grid.ts +164 -26
  41. package/treb-grid/src/types/grid_base.ts +93 -17
  42. package/treb-grid/src/types/grid_command.ts +2 -1
  43. package/treb-parser/src/parser-types.ts +10 -0
  44. package/treb-parser/src/parser.ts +55 -17
@@ -26,7 +26,7 @@ import { ValueType, Cells, Style,
26
26
  type PropertyKeys,
27
27
  type Color,
28
28
  Area, IsFlatDataArray,
29
- IsNestedRowArray, IsCellAddress, DOMContext
29
+ IsNestedRowArray, IsCellAddress, DOMContext, IsHTMLColor, IsThemeColor
30
30
  } from 'treb-base-types';
31
31
  import { NumberFormatCache } from 'treb-format';
32
32
  import { Measurement, ValidateURI } from 'treb-utils';
@@ -43,6 +43,7 @@ import type { GridSelection } from './sheet_selection';
43
43
  import { CreateSelection } from './sheet_selection';
44
44
  import { Annotation } from './annotation';
45
45
  import type { ConditionalFormatList } from './conditional_format';
46
+ import type { DataValidation } from './data-validation';
46
47
 
47
48
  // --- constants --------------------------------------------------------------
48
49
 
@@ -163,6 +164,11 @@ export class Sheet {
163
164
  */
164
165
  public conditional_formats: ConditionalFormatList = [];
165
166
 
167
+ /**
168
+ * @internal
169
+ */
170
+ public data_validation: DataValidation[] = [];
171
+
166
172
  /**
167
173
  * @internal
168
174
  *
@@ -255,6 +261,7 @@ export class Sheet {
255
261
  */
256
262
  private conditional_format_checklist: IArea[] = [];
257
263
 
264
+
258
265
  // --- accessors ------------------------------------------------------------
259
266
 
260
267
  // public get column_header_count() { return this.column_header_count_; }
@@ -383,6 +390,11 @@ export class Sheet {
383
390
  sheet.conditional_formats = source.conditional_formats;
384
391
  }
385
392
 
393
+ sheet.data_validation = (source.data_validations || []).map(validation => ({
394
+ ...validation,
395
+ target: (validation.target||[]).map(target => new Area(target.start, target.end)),
396
+ }));
397
+
386
398
  // persist ID, name
387
399
 
388
400
  if (source.id) {
@@ -740,6 +752,45 @@ export class Sheet {
740
752
 
741
753
  }
742
754
 
755
+ /** add a data validation. */
756
+ public AddValidation(validation: DataValidation) {
757
+ this.data_validation.push({
758
+ ...validation,
759
+ target: (validation.target||[]).map(target => new Area(target.start, target.end)), // ensure class instance
760
+ });
761
+ }
762
+
763
+ /**
764
+ * remove validations from area. must be an exact match (FIXME).
765
+ * if there are multiple areas, only remove the matching area.
766
+ */
767
+ public RemoveValidations(area: IArea) {
768
+
769
+ const check = new Area(area.start, area.end);
770
+ this.data_validation = this.data_validation.filter(validation => {
771
+ validation.target = validation.target.filter(compare => !check.Equals2(compare));
772
+ return validation.target.length > 0;
773
+ });
774
+ }
775
+
776
+ /** return data validation(s) that apply to a given address */
777
+ public GetValidation(address: ICellAddress) {
778
+
779
+ // switch to imperative
780
+
781
+ const list: DataValidation[] = [];
782
+ for (const entry of this.data_validation) {
783
+ for (const area of entry.target) {
784
+ if ((area as Area).Contains(address)) {
785
+ list.push(entry);
786
+ break;
787
+ }
788
+ }
789
+ }
790
+
791
+ return list;
792
+
793
+ }
743
794
 
744
795
  public Activate(DOM: DOMContext) {
745
796
 
@@ -2260,12 +2311,11 @@ export class Sheet {
2260
2311
  number_format_map[style.number_format] = 1;
2261
2312
  }
2262
2313
 
2263
- if (style.text?.text && style.text.text !== 'none') {
2264
- // const color = Measurement.MeasureColorARGB(style.text_color);
2314
+ if (IsHTMLColor(style.text)) {
2265
2315
  color_map[style.text.text] = 1;
2266
2316
  }
2267
2317
 
2268
- if (style.fill?.text) {
2318
+ if (IsHTMLColor(style.fill)) {
2269
2319
  color_map[style.fill.text] = 1;
2270
2320
  }
2271
2321
 
@@ -2273,16 +2323,16 @@ export class Sheet {
2273
2323
  // color_map[style.background] = 1;
2274
2324
  //}
2275
2325
 
2276
- if (style.border_top_fill?.text) {
2326
+ if (IsHTMLColor(style.border_top_fill)) {
2277
2327
  color_map[style.border_top_fill.text] = 1;
2278
2328
  }
2279
- if (style.border_left_fill?.text) {
2329
+ if (IsHTMLColor(style.border_left_fill)) {
2280
2330
  color_map[style.border_left_fill.text] = 1;
2281
2331
  }
2282
- if (style.border_right_fill?.text) {
2332
+ if (IsHTMLColor(style.border_right_fill)) {
2283
2333
  color_map[style.border_right_fill.text] = 1;
2284
2334
  }
2285
- if (style.border_bottom_fill?.text) {
2335
+ if (IsHTMLColor(style.border_bottom_fill)) {
2286
2336
  color_map[style.border_bottom_fill.text] = 1;
2287
2337
  }
2288
2338
 
@@ -2525,13 +2575,15 @@ export class Sheet {
2525
2575
  ...default_color,
2526
2576
  ...color,
2527
2577
  };
2528
- if (result.text) {
2578
+
2579
+ if (IsHTMLColor(result)) {
2529
2580
  result.text = Measurement.MeasureColorARGB(result.text);
2530
2581
  return result;
2531
2582
  }
2532
- else if (typeof result.theme === 'number') {
2583
+ else if (IsThemeColor(result)) {
2533
2584
  return result;
2534
2585
  }
2586
+
2535
2587
  return undefined;
2536
2588
  };
2537
2589
 
@@ -2566,7 +2618,7 @@ export class Sheet {
2566
2618
  fill = translate_border_fill(style.border_bottom_fill, Style.DefaultProperties.border_bottom_fill);
2567
2619
  if (fill !== undefined) { style.border_bottom_fill = fill; }
2568
2620
 
2569
- if (style.fill?.text) {
2621
+ if (IsHTMLColor(style.fill)) {
2570
2622
  style.fill.text = Measurement.MeasureColorARGB(style.fill.text);
2571
2623
  }
2572
2624
 
@@ -2574,10 +2626,8 @@ export class Sheet {
2574
2626
  // style.background = Measurement.MeasureColorARGB(style.background);
2575
2627
  //}
2576
2628
 
2577
- if (style.text) {
2578
- if (style.text.text && style.text.text !== 'none') {
2579
- style.text.text = Measurement.MeasureColorARGB(style.text.text);
2580
- }
2629
+ if (IsHTMLColor(style.text)) {
2630
+ style.text.text = Measurement.MeasureColorARGB(style.text.text);
2581
2631
  }
2582
2632
 
2583
2633
  }
@@ -2665,6 +2715,11 @@ export class Sheet {
2665
2715
  JSON.parse(JSON.stringify(this.conditional_formats.map(format => ({...format, internal: undefined })))) :
2666
2716
  undefined;
2667
2717
 
2718
+ // yes, here. we should have a serialized type so we know to convert. TODO
2719
+
2720
+ const data_validations = this.data_validation.length ? JSON.parse(JSON.stringify(this.data_validation)) : undefined;
2721
+
2722
+
2668
2723
  const result: SerializedSheet = {
2669
2724
 
2670
2725
  // not used atm, but in the event we need to gate
@@ -2688,6 +2743,7 @@ export class Sheet {
2688
2743
  column_style,
2689
2744
 
2690
2745
  conditional_formats,
2746
+ data_validations,
2691
2747
 
2692
2748
  row_pattern: row_pattern.length ? row_pattern : undefined,
2693
2749
 
@@ -2886,6 +2942,10 @@ export class Sheet {
2886
2942
  this.conditional_formats.push(format);
2887
2943
  }
2888
2944
 
2945
+ for (const validation of data.data_validations || []) {
2946
+ this.AddValidation(validation);
2947
+ }
2948
+
2889
2949
  if (data.hidden) {
2890
2950
  this.visible = false;
2891
2951
  }
@@ -23,6 +23,7 @@ import type { IArea, SerializedCellData, CellStyle } from 'treb-base-types';
23
23
  import type { AnnotationData } from './annotation';
24
24
  import type { GridSelection, SerializedGridSelection } from './sheet_selection';
25
25
  import type { ConditionalFormatList } from './conditional_format';
26
+ import type { DataValidation } from './data-validation';
26
27
 
27
28
  export interface UpdateHints {
28
29
  data?: boolean;
@@ -72,6 +73,9 @@ export interface SerializedSheet {
72
73
  /** @internal */
73
74
  conditional_formats?: ConditionalFormatList;
74
75
 
76
+ /** @internal */
77
+ data_validations?: DataValidation[];
78
+
75
79
  /**
76
80
  * @deprecated use `styles` instead
77
81
  */
@@ -7,7 +7,7 @@ import html from '../../markup/layout.html';
7
7
  import toolbar_html from '../../markup/toolbar.html';
8
8
 
9
9
  import { NumberFormatCache } from 'treb-format';
10
- import { ColorFunctions, type Color } from 'treb-base-types';
10
+ import { ColorFunctions, type Color, IsThemeColor } from 'treb-base-types';
11
11
  import { Measurement } from 'treb-utils';
12
12
  import type { ToolbarMessage } from '../toolbar-message';
13
13
 
@@ -729,8 +729,7 @@ export class SpreadsheetConstructor<USER_DATA_TYPE = unknown> {
729
729
  const entry = sheet.document_styles.theme_colors[j][i];
730
730
  const style = `background: ${entry.resolved};`;
731
731
  let title = themes[j] || themes[4];
732
- if (entry.color.tint) {
733
- // title += ` (${Math.abs(entry.color.tint) * 100}% ${ entry.color.tint > 0 ? 'lighter' : 'darker'})`;
732
+ if (IsThemeColor(entry.color) && entry.color.tint) {
734
733
  title += ` (${(entry.color.tint > 0 ? '+' : '') + (entry.color.tint) * 100}%)`;
735
734
  }
736
735
  else {
@@ -1372,6 +1371,11 @@ export class SpreadsheetConstructor<USER_DATA_TYPE = unknown> {
1372
1371
  this.UpdateRevertState(sheet);
1373
1372
  break;
1374
1373
 
1374
+ case 'theme-change':
1375
+ this.UpdateDocumentStyles(sheet, format_menu);
1376
+ this.UpdateSelectionStyle(sheet, toolbar, comment_box);
1377
+ break;
1378
+
1375
1379
  case 'selection':
1376
1380
  this.UpdateSelectionStyle(sheet, toolbar, comment_box);
1377
1381
  break;
@@ -21,9 +21,6 @@
21
21
 
22
22
  // --- imports -----------------------------------------------------------------
23
23
 
24
- // eslint-disable-next-line @typescript-eslint/triple-slash-reference
25
- /// <reference path="./content-types.d.ts" />
26
-
27
24
  import type {
28
25
  GridEvent,
29
26
  SheetChangeEvent, GridOptions,
@@ -76,7 +73,7 @@ import type {
76
73
 
77
74
  import {
78
75
  IsArea, ThemeColorTable, ComplexToString, Rectangle, IsComplex, type CellStyle,
79
- Localization, Style, type Color, ThemeColor2, IsCellAddress, Area, IsFlatData, IsFlatDataArray, Gradient, DOMContext,
76
+ Localization, Style, type Color, ResolveThemeColor, IsCellAddress, Area, IsFlatData, IsFlatDataArray, Gradient, DOMContext,
80
77
  } from 'treb-base-types';
81
78
 
82
79
  import { EventSource, ValidateURI } from 'treb-utils';
@@ -103,6 +100,11 @@ import type { StateLeafVertex } from 'treb-calculator';
103
100
 
104
101
  // --- worker ------------------------------------------------------------------
105
102
 
103
+ /**
104
+ * import type for our worker, plus markup files
105
+ */
106
+ import './content-types.d.ts';
107
+
106
108
  /**
107
109
  * import the worker as a script file. tsc will read this on typecheck but
108
110
  * that's actually to the good; when we build with esbuild we will inline
@@ -192,14 +194,22 @@ export interface LoadDocumentOptions {
192
194
  formula?: boolean;
193
195
 
194
196
  /**
195
- * optional style for returned values (replaces old flags).
197
+ * by default, GetRange returns cell values. the optional type field
198
+ * can be used to returns data in different formats.
196
199
  *
197
200
  * @remarks
198
201
  *
199
202
  * `formatted` returns formatted values, applying number formatting and
200
- * returning strings. `formula` returns cell formulas instead of values.
203
+ * returning strings.
204
+ *
205
+ * `A1` returns cell formulas instead of values, in A1 format.
206
+ *
207
+ * `R1C1` returns cell formauls in R1C1 format.
208
+ *
209
+ * `formula` is an alias for 'A1', for backwards compatibility.
210
+ *
201
211
  */
202
- type?: 'formatted'|'formula';
212
+ type?: 'formatted'|'A1'|'R1C1'|'formula';
203
213
 
204
214
  }
205
215
 
@@ -2113,6 +2123,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
2113
2123
  this.ApplyConditionalFormats(this.grid.active_sheet, false);
2114
2124
  this.grid.Update(true);
2115
2125
 
2126
+ this.Publish({ type: 'theme-change' });
2127
+
2116
2128
  }
2117
2129
 
2118
2130
  /**
@@ -2586,9 +2598,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
2586
2598
  * @public
2587
2599
  */
2588
2600
  public SetColumnWidth(column?: number | number[], width?: number): void {
2589
-
2590
- // API v1 OK
2591
-
2601
+
2592
2602
  this.grid.SetColumnWidth(column, width);
2593
2603
  }
2594
2604
 
@@ -3005,7 +3015,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
3005
3015
 
3006
3016
  this.grid.Reset();
3007
3017
  this.ResetInternal();
3008
- this.calculator.AttachModel();
3018
+ // this.calculator.AttachModel();
3009
3019
  this.UpdateAC();
3010
3020
 
3011
3021
  this.Publish({ type: 'reset' });
@@ -3491,25 +3501,30 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
3491
3501
  /**
3492
3502
  * set or clear cell valiation.
3493
3503
  *
3494
- * @param address - target cell
3504
+ * @param target - target cell/area
3495
3505
  * @param validation - a spreadsheet range, list of data, or undefined. pass
3496
3506
  * undefined to remove existing cell validation.
3497
3507
  * @param error - setting an invalid value in the target cell is an error (and
3498
3508
  * is blocked). defaults to false.
3499
3509
  */
3500
- public SetValidation(address: AddressReference, validation?: RangeReference|CellValue[], error?: boolean) {
3510
+ public SetValidation(target: RangeReference, validation?: RangeReference|CellValue[], error?: boolean) {
3501
3511
 
3502
- if (typeof address === 'string') {
3503
- const reference = this.model.ResolveAddress(address, this.grid.active_sheet);
3504
- address = IsCellAddress(reference) ? reference : reference.start;
3512
+ if (typeof target === 'string') {
3513
+ const reference = this.model.ResolveAddress(target, this.grid.active_sheet);
3514
+ target = IsArea(reference) ? new Area(reference.start, reference.end) : new Area(reference);
3515
+ // address = IsCellAddress(reference) ? reference : reference.start;
3516
+ }
3517
+
3518
+ if (IsCellAddress(target)) {
3519
+ target = new Area(target);
3505
3520
  }
3506
3521
 
3507
3522
  if (typeof validation === 'undefined' || Array.isArray(validation)) {
3508
- this.grid.SetValidation(address, validation, error);
3523
+ this.grid.SetValidation(target, validation, error);
3509
3524
  }
3510
3525
  else {
3511
3526
  const range = this.model.ResolveArea(validation, this.grid.active_sheet);
3512
- this.grid.SetValidation(address, range, error);
3527
+ this.grid.SetValidation(target, range, error);
3513
3528
  }
3514
3529
 
3515
3530
  }
@@ -4294,16 +4309,24 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4294
4309
 
4295
4310
  // handle the old flags and the precedence rule. type takes precedence.
4296
4311
 
4297
- if (!options.type) {
4312
+ let type = options.type;
4313
+
4314
+ if (!type) {
4298
4315
  if (options.formatted) {
4299
- options.type = 'formatted';
4316
+ type = 'formatted';
4300
4317
  }
4301
4318
  if (options.formula) {
4302
- options.type = 'formula';
4319
+ type = 'A1';
4303
4320
  }
4304
4321
  }
4305
4322
 
4306
- return this.grid.GetRange(this.model.ResolveAddress(range, this.grid.active_sheet), options.type);
4323
+ // alias
4324
+
4325
+ if (type === 'formula') {
4326
+ type = 'A1';
4327
+ }
4328
+
4329
+ return this.grid.GetRange(this.model.ResolveAddress(range, this.grid.active_sheet), type);
4307
4330
 
4308
4331
  }
4309
4332
 
@@ -4626,7 +4649,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4626
4649
 
4627
4650
  // this one _is_ the grid cells
4628
4651
 
4629
- this.calculator.AttachModel();
4652
+ // this.calculator.AttachModel();
4630
4653
  this.Publish({ type: 'load', source, });
4631
4654
  this.UpdateDocumentStyles();
4632
4655
 
@@ -5324,7 +5347,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5324
5347
  const update_textbox = () => {
5325
5348
 
5326
5349
  if (style.fill) {
5327
- const color = ThemeColor2(this.grid.theme, style.fill);
5350
+ const color = ResolveThemeColor(this.grid.theme, style.fill);
5328
5351
  container.style.background = color;
5329
5352
  }
5330
5353
 
@@ -5590,7 +5613,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5590
5613
  for (let i = 0; i < 10; i++) {
5591
5614
  this.document_styles.theme_colors.push(tints.map(tint => {
5592
5615
  const color: Color = { theme: i, tint };
5593
- const resolved = ThemeColor2(this.grid.theme, color);
5616
+ const resolved = ResolveThemeColor(this.grid.theme, color);
5594
5617
  return { color, resolved };
5595
5618
  }));
5596
5619
  }
@@ -5845,9 +5868,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5845
5868
 
5846
5869
  this.grid.UpdateSheets(sheets, undefined, override_sheet || data.active_sheet);
5847
5870
 
5848
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
5849
- for (const [name, table] of this.model.tables.entries()) {
5850
- if (table.area.start.sheet_id) {
5871
+ for (const table of this.model.tables.values()) {
5872
+ if (table.area.start.sheet_id) {
5851
5873
  const sheet = model.sheets.Find(table.area.start.sheet_id);
5852
5874
  if (sheet) {
5853
5875
  for (let row = table.area.start.row; row <= table.area.end.row; row++) {
@@ -57,7 +57,6 @@ export type ResolutionFunction = () => void;
57
57
  */
58
58
  export class Dialog {
59
59
 
60
- // private model: NodeModel;
61
60
  private model: Record<string, HTMLElement> = {};
62
61
 
63
62
  private layout_element: HTMLElement;
@@ -192,6 +191,10 @@ export class Dialog {
192
191
 
193
192
  }
194
193
 
194
+ public Node(name: string): HTMLElement|undefined {
195
+ return this.model[name];
196
+ }
197
+
195
198
  public Update(options: Partial<MessageDialogOptions>, delta = true): void {
196
199
  if (delta) {
197
200
  options = { ...this.options_, ... options};
@@ -144,6 +144,14 @@ export interface ViewChangeEvent {
144
144
  type: 'view-change';
145
145
  }
146
146
 
147
+ /**
148
+ * this event is sent when the theme is updated. it's intended for any
149
+ * subscribers to update corresponding colors or fonts.
150
+ */
151
+ export interface ThemeChangeEvent {
152
+ type: 'theme-change';
153
+ }
154
+
147
155
  /**
148
156
  * This event is sent when a document is loaded, and also on undo. The
149
157
  * source field can help determine if it was triggered by an undo operation.
@@ -206,6 +214,7 @@ export type EmbeddedSheetEvent
206
214
  = DocumentChangeEvent
207
215
  | DocumentResetEvent
208
216
  | DocumentLoadEvent
217
+ | ThemeChangeEvent
209
218
  | ViewChangeEvent
210
219
  | DataChangeEvent
211
220
  | FocusViewEvent
@@ -19,8 +19,6 @@
19
19
  *
20
20
  */
21
21
 
22
- // import * as ElementTree from 'elementtree';
23
- // import { Element, ElementTree as Tree } from 'elementtree';
24
22
  import type { UnitAddress, UnitRange, UnitLiteral, ExpressionUnit } from 'treb-parser';
25
23
 
26
24
  import { static_title, ref_title, chart_template } from './chart-template-components2';
@@ -29,18 +27,6 @@ import { donut_json } from './donut-chart-template2';
29
27
  import { scatter_json, scatter_series } from './scatter-chart-template2';
30
28
  import { bubble_json, bubble_series } from './bubble-chart-template';
31
29
 
32
- import { XMLUtils } from '../xml-utils';
33
-
34
- /*
35
- import { donut_json } from './donut-chart-template';
36
- import { static_title, ref_title, chart_template } from './chart-template-components';
37
- import { column_json, column_series } from './column-chart-template';
38
- import { scatter_json, scatter_series } from './scatter-chart-template';
39
- import { scatter_series as scatter2_series } from './scatter2-chart-template';
40
- */
41
-
42
- // import { v4 as uuidv4 } from 'uuid';
43
-
44
30
  import { Localization } from 'treb-base-types';
45
31
  import type { RelationshipMap } from '../relationship';
46
32
 
@@ -73,31 +59,27 @@ export class Chart {
73
59
  type: 'literal', value: '',
74
60
  };
75
61
 
76
- // const CC = this.FindNode('c:chart', obj);
77
- // if (CC) {
78
- if (unit && unit.type === 'literal') {
79
- const title = JSON.parse(JSON.stringify(static_title));
80
- //const AP = this.FindNode('a:p', title);
81
- const AP = title['c:tx']['c:rich']['a:p'];
82
-
83
- AP['a:r'] = {
84
- 'a:rPr': {
85
- a$: {
86
- lang: Localization.locale,
87
- },
62
+ if (unit && unit.type === 'literal') {
63
+ const title = JSON.parse(JSON.stringify(static_title));
64
+ const AP = title['c:tx']['c:rich']['a:p'];
65
+
66
+ AP['a:r'] = {
67
+ 'a:rPr': {
68
+ a$: {
69
+ lang: Localization.locale,
88
70
  },
89
- 'a:t': unit.value,
90
- };
91
- chartnode['c:title'] = title;
92
- }
93
- else if (unit) {
94
- const title = JSON.parse(JSON.stringify(ref_title));
95
- //const CF = title['c:tx']['c:strRef']['c:f'];
96
- //CF.t$ = unit.label;
97
- title['c:tx']['c:strRef']['c:f'] = unit.label;
98
- chartnode['c:title'] = title;
99
- }
100
- //}
71
+ },
72
+ 'a:t': unit.value,
73
+ };
74
+ chartnode['c:title'] = title;
75
+ }
76
+ else if (unit) {
77
+ const title = JSON.parse(JSON.stringify(ref_title));
78
+ //const CF = title['c:tx']['c:strRef']['c:f'];
79
+ //CF.t$ = unit.label;
80
+ title['c:tx']['c:strRef']['c:f'] = unit.label;
81
+ chartnode['c:title'] = title;
82
+ }
101
83
 
102
84
  }
103
85