@trebco/treb 23.6.5 → 25.0.0-rc2
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.
- package/.eslintignore +8 -0
- package/.eslintrc.js +164 -0
- package/README-shadow-DOM.md +88 -0
- package/README.md +37 -130
- package/api-config.json +29 -0
- package/api-generator/api-generator-types.ts +82 -0
- package/api-generator/api-generator.ts +1172 -0
- package/api-generator/package.json +3 -0
- package/build/treb-spreadsheet.mjs +14 -0
- package/{treb.d.ts → build/treb.d.ts} +323 -271
- package/esbuild-custom-element.mjs +336 -0
- package/esbuild.js +305 -0
- package/package.json +49 -14
- package/treb-base-types/package.json +5 -0
- package/treb-base-types/src/api_types.ts +36 -0
- package/treb-base-types/src/area.ts +583 -0
- package/treb-base-types/src/basic_types.ts +45 -0
- package/treb-base-types/src/cell.ts +612 -0
- package/treb-base-types/src/cells.ts +1066 -0
- package/treb-base-types/src/color.ts +124 -0
- package/treb-base-types/src/import.ts +71 -0
- package/treb-base-types/src/index-standalone.ts +29 -0
- package/treb-base-types/src/index.ts +42 -0
- package/treb-base-types/src/layout.ts +47 -0
- package/treb-base-types/src/localization.ts +187 -0
- package/treb-base-types/src/rectangle.ts +145 -0
- package/treb-base-types/src/render_text.ts +72 -0
- package/treb-base-types/src/style.ts +545 -0
- package/treb-base-types/src/table.ts +109 -0
- package/treb-base-types/src/text_part.ts +54 -0
- package/treb-base-types/src/theme.ts +608 -0
- package/treb-base-types/src/union.ts +152 -0
- package/treb-base-types/src/value-type.ts +164 -0
- package/treb-base-types/style/resizable.css +59 -0
- package/treb-calculator/modern.tsconfig.json +11 -0
- package/treb-calculator/package.json +5 -0
- package/treb-calculator/src/calculator.ts +2546 -0
- package/treb-calculator/src/complex-math.ts +558 -0
- package/treb-calculator/src/dag/array-vertex.ts +198 -0
- package/treb-calculator/src/dag/graph.ts +951 -0
- package/treb-calculator/src/dag/leaf_vertex.ts +118 -0
- package/treb-calculator/src/dag/spreadsheet_vertex.ts +327 -0
- package/treb-calculator/src/dag/spreadsheet_vertex_base.ts +44 -0
- package/treb-calculator/src/dag/vertex.ts +352 -0
- package/treb-calculator/src/descriptors.ts +162 -0
- package/treb-calculator/src/expression-calculator.ts +1069 -0
- package/treb-calculator/src/function-error.ts +103 -0
- package/treb-calculator/src/function-library.ts +103 -0
- package/treb-calculator/src/functions/base-functions.ts +1214 -0
- package/treb-calculator/src/functions/checkbox.ts +164 -0
- package/treb-calculator/src/functions/complex-functions.ts +253 -0
- package/treb-calculator/src/functions/finance-functions.ts +399 -0
- package/treb-calculator/src/functions/information-functions.ts +102 -0
- package/treb-calculator/src/functions/matrix-functions.ts +182 -0
- package/treb-calculator/src/functions/sparkline.ts +335 -0
- package/treb-calculator/src/functions/statistics-functions.ts +350 -0
- package/treb-calculator/src/functions/text-functions.ts +298 -0
- package/treb-calculator/src/index.ts +27 -0
- package/treb-calculator/src/notifier-types.ts +59 -0
- package/treb-calculator/src/primitives.ts +428 -0
- package/treb-calculator/src/utilities.ts +305 -0
- package/treb-charts/package.json +5 -0
- package/treb-charts/src/chart-functions.ts +156 -0
- package/treb-charts/src/chart-types.ts +230 -0
- package/treb-charts/src/chart.ts +1288 -0
- package/treb-charts/src/index.ts +24 -0
- package/treb-charts/src/main.ts +37 -0
- package/treb-charts/src/rectangle.ts +52 -0
- package/treb-charts/src/renderer.ts +1841 -0
- package/treb-charts/src/util.ts +122 -0
- package/treb-charts/style/charts.scss +221 -0
- package/treb-charts/style/old-charts.scss +250 -0
- package/treb-embed/markup/layout.html +137 -0
- package/treb-embed/markup/toolbar.html +175 -0
- package/treb-embed/modern.tsconfig.json +25 -0
- package/treb-embed/src/custom-element/content-types.d.ts +18 -0
- package/treb-embed/src/custom-element/global.d.ts +11 -0
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +1228 -0
- package/treb-embed/src/custom-element/treb-global.ts +44 -0
- package/treb-embed/src/custom-element/treb-spreadsheet-element.ts +52 -0
- package/treb-embed/src/embedded-spreadsheet.ts +5358 -0
- package/treb-embed/src/index.ts +16 -0
- package/treb-embed/src/language-model.ts +41 -0
- package/treb-embed/src/options.ts +298 -0
- package/treb-embed/src/progress-dialog.ts +228 -0
- package/treb-embed/src/selection-state.ts +16 -0
- package/treb-embed/src/spinner.ts +42 -0
- package/treb-embed/src/toolbar-message.ts +96 -0
- package/treb-embed/src/types.ts +167 -0
- package/treb-embed/style/autocomplete.scss +103 -0
- package/treb-embed/style/dark-theme.scss +114 -0
- package/treb-embed/style/defaults.scss +36 -0
- package/treb-embed/style/dialog.scss +181 -0
- package/treb-embed/style/dropdown-select.scss +101 -0
- package/treb-embed/style/formula-bar.scss +193 -0
- package/treb-embed/style/grid.scss +374 -0
- package/treb-embed/style/layout.scss +424 -0
- package/treb-embed/style/mouse-mask.scss +67 -0
- package/treb-embed/style/note.scss +92 -0
- package/treb-embed/style/overlay-editor.scss +102 -0
- package/treb-embed/style/spinner.scss +92 -0
- package/treb-embed/style/tab-bar.scss +228 -0
- package/treb-embed/style/table.scss +80 -0
- package/treb-embed/style/theme-defaults.scss +444 -0
- package/treb-embed/style/toolbar.scss +416 -0
- package/treb-embed/style/tooltip.scss +68 -0
- package/treb-embed/style/treb-icons.scss +130 -0
- package/treb-embed/style/treb-spreadsheet-element.scss +20 -0
- package/treb-embed/style/z-index.scss +43 -0
- package/treb-export/docs/charts.md +68 -0
- package/treb-export/modern.tsconfig.json +19 -0
- package/treb-export/package.json +4 -0
- package/treb-export/src/address-type.ts +77 -0
- package/treb-export/src/base-template.ts +22 -0
- package/treb-export/src/column-width.ts +85 -0
- package/treb-export/src/drawing2/chart-template-components2.ts +389 -0
- package/treb-export/src/drawing2/chart2.ts +282 -0
- package/treb-export/src/drawing2/column-chart-template2.ts +521 -0
- package/treb-export/src/drawing2/donut-chart-template2.ts +296 -0
- package/treb-export/src/drawing2/drawing2.ts +355 -0
- package/treb-export/src/drawing2/embedded-image.ts +71 -0
- package/treb-export/src/drawing2/scatter-chart-template2.ts +555 -0
- package/treb-export/src/export-worker/export-worker.ts +99 -0
- package/treb-export/src/export-worker/index-modern.ts +22 -0
- package/treb-export/src/export2.ts +2204 -0
- package/treb-export/src/import2.ts +882 -0
- package/treb-export/src/relationship.ts +36 -0
- package/treb-export/src/shared-strings2.ts +128 -0
- package/treb-export/src/template-2.ts +22 -0
- package/treb-export/src/unescape_xml.ts +47 -0
- package/treb-export/src/workbook-sheet2.ts +182 -0
- package/treb-export/src/workbook-style2.ts +1285 -0
- package/treb-export/src/workbook-theme2.ts +88 -0
- package/treb-export/src/workbook2.ts +491 -0
- package/treb-export/src/xml-utils.ts +201 -0
- package/treb-export/template/base/[Content_Types].xml +2 -0
- package/treb-export/template/base/_rels/.rels +2 -0
- package/treb-export/template/base/docProps/app.xml +2 -0
- package/treb-export/template/base/docProps/core.xml +12 -0
- package/treb-export/template/base/xl/_rels/workbook.xml.rels +2 -0
- package/treb-export/template/base/xl/sharedStrings.xml +2 -0
- package/treb-export/template/base/xl/styles.xml +2 -0
- package/treb-export/template/base/xl/theme/theme1.xml +2 -0
- package/treb-export/template/base/xl/workbook.xml +2 -0
- package/treb-export/template/base/xl/worksheets/sheet1.xml +2 -0
- package/treb-export/template/base.xlsx +0 -0
- package/treb-format/package.json +8 -0
- package/treb-format/src/format.test.ts +213 -0
- package/treb-format/src/format.ts +942 -0
- package/treb-format/src/format_cache.ts +199 -0
- package/treb-format/src/format_parser.ts +723 -0
- package/treb-format/src/index.ts +25 -0
- package/treb-format/src/number_format_section.ts +100 -0
- package/treb-format/src/value_parser.ts +337 -0
- package/treb-grid/package.json +5 -0
- package/treb-grid/src/editors/autocomplete.ts +394 -0
- package/treb-grid/src/editors/autocomplete_matcher.ts +260 -0
- package/treb-grid/src/editors/formula_bar.ts +473 -0
- package/treb-grid/src/editors/formula_editor_base.ts +910 -0
- package/treb-grid/src/editors/overlay_editor.ts +511 -0
- package/treb-grid/src/index.ts +37 -0
- package/treb-grid/src/layout/base_layout.ts +2618 -0
- package/treb-grid/src/layout/grid_layout.ts +299 -0
- package/treb-grid/src/layout/rectangle_cache.ts +86 -0
- package/treb-grid/src/render/selection-renderer.ts +414 -0
- package/treb-grid/src/render/svg_header_overlay.ts +93 -0
- package/treb-grid/src/render/svg_selection_block.ts +187 -0
- package/treb-grid/src/render/tile_renderer.ts +2122 -0
- package/treb-grid/src/types/annotation.ts +216 -0
- package/treb-grid/src/types/border_constants.ts +34 -0
- package/treb-grid/src/types/clipboard_data.ts +31 -0
- package/treb-grid/src/types/data_model.ts +334 -0
- package/treb-grid/src/types/drag_mask.ts +81 -0
- package/treb-grid/src/types/grid.ts +7743 -0
- package/treb-grid/src/types/grid_base.ts +3644 -0
- package/treb-grid/src/types/grid_command.ts +470 -0
- package/treb-grid/src/types/grid_events.ts +124 -0
- package/treb-grid/src/types/grid_options.ts +97 -0
- package/treb-grid/src/types/grid_selection.ts +60 -0
- package/treb-grid/src/types/named_range.ts +369 -0
- package/treb-grid/src/types/scale-control.ts +202 -0
- package/treb-grid/src/types/serialize_options.ts +72 -0
- package/treb-grid/src/types/set_range_options.ts +52 -0
- package/treb-grid/src/types/sheet.ts +3099 -0
- package/treb-grid/src/types/sheet_types.ts +95 -0
- package/treb-grid/src/types/tab_bar.ts +464 -0
- package/treb-grid/src/types/tile.ts +59 -0
- package/treb-grid/src/types/update_flags.ts +75 -0
- package/treb-grid/src/util/dom_utilities.ts +44 -0
- package/treb-grid/src/util/fontmetrics2.ts +179 -0
- package/treb-grid/src/util/ua.ts +104 -0
- package/treb-logo.svg +18 -0
- package/treb-parser/package.json +5 -0
- package/treb-parser/src/csv-parser.ts +122 -0
- package/treb-parser/src/index.ts +25 -0
- package/treb-parser/src/md-parser.ts +526 -0
- package/treb-parser/src/parser-types.ts +397 -0
- package/treb-parser/src/parser.test.ts +298 -0
- package/treb-parser/src/parser.ts +2673 -0
- package/treb-utils/package.json +5 -0
- package/treb-utils/src/dispatch.ts +57 -0
- package/treb-utils/src/event_source.ts +147 -0
- package/treb-utils/src/ievent_source.ts +33 -0
- package/treb-utils/src/index.ts +31 -0
- package/treb-utils/src/measurement.ts +174 -0
- package/treb-utils/src/resizable.ts +160 -0
- package/treb-utils/src/scale.ts +137 -0
- package/treb-utils/src/serialize_html.ts +124 -0
- package/treb-utils/src/template.ts +70 -0
- package/treb-utils/src/validate_uri.ts +61 -0
- package/tsconfig.json +10 -0
- package/tsproject.json +30 -0
- package/util/license-plugin-esbuild.js +86 -0
- package/util/list-css-vars.sh +46 -0
- package/README-esm.md +0 -37
- package/treb-bundle.css +0 -2
- package/treb-bundle.mjs +0 -15
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export const ref_title = {
|
|
23
|
+
'c:tx': {
|
|
24
|
+
'c:strRef': {
|
|
25
|
+
'c:f': '', // reference: Sheet1!$E$3
|
|
26
|
+
'c:strCache': {
|
|
27
|
+
'c:ptCount': {
|
|
28
|
+
a$: {
|
|
29
|
+
'val': '1'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
'c:pt': {
|
|
33
|
+
a$: {
|
|
34
|
+
'idx': '0'
|
|
35
|
+
},
|
|
36
|
+
'c:v': '', // cached value: Fishton Lanier
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
'c:overlay': {
|
|
42
|
+
a$: {
|
|
43
|
+
'val': '0'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
'c:spPr': {
|
|
47
|
+
'a:noFill': {},
|
|
48
|
+
'a:ln': {
|
|
49
|
+
'a:noFill': {}
|
|
50
|
+
},
|
|
51
|
+
'a:effectLst': {}
|
|
52
|
+
},
|
|
53
|
+
'c:txPr': {
|
|
54
|
+
'a:bodyPr': {
|
|
55
|
+
a$: {
|
|
56
|
+
'rot': '0',
|
|
57
|
+
'spcFirstLastPara': '1',
|
|
58
|
+
'vertOverflow': 'ellipsis',
|
|
59
|
+
'vert': 'horz',
|
|
60
|
+
'wrap': 'square',
|
|
61
|
+
'anchor': 'ctr',
|
|
62
|
+
'anchorCtr': '1'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
'a:lstStyle': {},
|
|
66
|
+
'a:p': {
|
|
67
|
+
'a:pPr': {
|
|
68
|
+
'a:defRPr': {
|
|
69
|
+
a$: {
|
|
70
|
+
'sz': '1400',
|
|
71
|
+
'b': '0',
|
|
72
|
+
'i': '0',
|
|
73
|
+
'u': 'none',
|
|
74
|
+
'strike': 'noStrike',
|
|
75
|
+
'kern': '1200',
|
|
76
|
+
'spc': '0',
|
|
77
|
+
'baseline': '0'
|
|
78
|
+
},
|
|
79
|
+
'a:solidFill': {
|
|
80
|
+
'a:schemeClr': {
|
|
81
|
+
a$: {
|
|
82
|
+
'val': 'tx1'
|
|
83
|
+
},
|
|
84
|
+
'a:lumMod': {
|
|
85
|
+
a$: {
|
|
86
|
+
'val': '65000'
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
'a:lumOff': {
|
|
90
|
+
a$: {
|
|
91
|
+
'val': '35000'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
'a:latin': {
|
|
97
|
+
a$: {
|
|
98
|
+
'typeface': '+mn-lt'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
'a:ea': {
|
|
102
|
+
a$: {
|
|
103
|
+
'typeface': '+mn-ea'
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
'a:cs': {
|
|
107
|
+
a$: {
|
|
108
|
+
'typeface': '+mn-cs'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
'a:endParaRPr': {
|
|
114
|
+
a$: {
|
|
115
|
+
'lang': 'en-US'
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const static_title = {
|
|
123
|
+
'c:tx': {
|
|
124
|
+
'c:rich': {
|
|
125
|
+
'a:bodyPr': {
|
|
126
|
+
a$: {
|
|
127
|
+
'rot': '0',
|
|
128
|
+
'spcFirstLastPara': '1',
|
|
129
|
+
'vertOverflow': 'ellipsis',
|
|
130
|
+
'vert': 'horz',
|
|
131
|
+
'wrap': 'square',
|
|
132
|
+
'anchor': 'ctr',
|
|
133
|
+
'anchorCtr': '1'
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
'a:lstStyle': {},
|
|
137
|
+
'a:p': {
|
|
138
|
+
'a:pPr': {
|
|
139
|
+
'a:defRPr': {
|
|
140
|
+
a$: {
|
|
141
|
+
'sz': '1400',
|
|
142
|
+
'b': '0',
|
|
143
|
+
'i': '0',
|
|
144
|
+
'u': 'none',
|
|
145
|
+
'strike': 'noStrike',
|
|
146
|
+
'kern': '1200',
|
|
147
|
+
'spc': '0',
|
|
148
|
+
'baseline': '0'
|
|
149
|
+
},
|
|
150
|
+
'a:solidFill': {
|
|
151
|
+
'a:schemeClr': {
|
|
152
|
+
a$: {
|
|
153
|
+
'val': 'tx1'
|
|
154
|
+
},
|
|
155
|
+
'a:lumMod': {
|
|
156
|
+
a$: {
|
|
157
|
+
'val': '65000'
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
'a:lumOff': {
|
|
161
|
+
a$: {
|
|
162
|
+
'val': '35000'
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
'a:latin': {
|
|
168
|
+
a$: {
|
|
169
|
+
'typeface': '+mn-lt'
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
'a:ea': {
|
|
173
|
+
a$: {
|
|
174
|
+
'typeface': '+mn-ea'
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
'a:cs': {
|
|
178
|
+
a$: {
|
|
179
|
+
'typeface': '+mn-cs'
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
'a:r': {
|
|
185
|
+
'a:rPr': {
|
|
186
|
+
a$: {
|
|
187
|
+
'lang': '' // locale: en-US
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
'a:t': '', // text: Herbal Metrix
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
'c:overlay': {
|
|
196
|
+
a$: {
|
|
197
|
+
'val': '0'
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
'c:spPr': {
|
|
201
|
+
'a:noFill': {},
|
|
202
|
+
'a:ln': {
|
|
203
|
+
'a:noFill': {}
|
|
204
|
+
},
|
|
205
|
+
'a:effectLst': {}
|
|
206
|
+
},
|
|
207
|
+
'c:txPr': {
|
|
208
|
+
'a:bodyPr': {
|
|
209
|
+
a$: {
|
|
210
|
+
'rot': '0',
|
|
211
|
+
'spcFirstLastPara': '1',
|
|
212
|
+
'vertOverflow': 'ellipsis',
|
|
213
|
+
'vert': 'horz',
|
|
214
|
+
'wrap': 'square',
|
|
215
|
+
'anchor': 'ctr',
|
|
216
|
+
'anchorCtr': '1'
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
'a:lstStyle': {},
|
|
220
|
+
'a:p': {
|
|
221
|
+
'a:pPr': {
|
|
222
|
+
'a:defRPr': {
|
|
223
|
+
a$: {
|
|
224
|
+
'sz': '1400',
|
|
225
|
+
'b': '0',
|
|
226
|
+
'i': '0',
|
|
227
|
+
'u': 'none',
|
|
228
|
+
'strike': 'noStrike',
|
|
229
|
+
'kern': '1200',
|
|
230
|
+
'spc': '0',
|
|
231
|
+
'baseline': '0'
|
|
232
|
+
},
|
|
233
|
+
'a:solidFill': {
|
|
234
|
+
'a:schemeClr': {
|
|
235
|
+
a$: {
|
|
236
|
+
'val': 'tx1'
|
|
237
|
+
},
|
|
238
|
+
'a:lumMod': {
|
|
239
|
+
a$: {
|
|
240
|
+
'val': '65000'
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
'a:lumOff': {
|
|
244
|
+
a$: {
|
|
245
|
+
'val': '35000'
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
'a:latin': {
|
|
251
|
+
a$: {
|
|
252
|
+
'typeface': '+mn-lt'
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
'a:ea': {
|
|
256
|
+
a$: {
|
|
257
|
+
'typeface': '+mn-ea'
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
'a:cs': {
|
|
261
|
+
a$: {
|
|
262
|
+
'typeface': '+mn-cs'
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
'a:endParaRPr': {
|
|
268
|
+
a$: {
|
|
269
|
+
'lang': 'en-US'
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export const chart_template =
|
|
277
|
+
{
|
|
278
|
+
'c:chartSpace': {
|
|
279
|
+
a$: {
|
|
280
|
+
'xmlns:c': 'http://schemas.openxmlformats.org/drawingml/2006/chart',
|
|
281
|
+
'xmlns:a': 'http://schemas.openxmlformats.org/drawingml/2006/main',
|
|
282
|
+
'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
|
283
|
+
'xmlns:c16r2': 'http://schemas.microsoft.com/office/drawing/2015/06/chart'
|
|
284
|
+
},
|
|
285
|
+
'c:date1904': {
|
|
286
|
+
a$: {
|
|
287
|
+
'val': '0'
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
'c:lang': {
|
|
291
|
+
a$: {
|
|
292
|
+
'val': 'en-US'
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
'c:roundedCorners': {
|
|
296
|
+
a$: {
|
|
297
|
+
'val': '0'
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
'mc:AlternateContent': {
|
|
301
|
+
a$: {
|
|
302
|
+
'xmlns:mc': 'http://schemas.openxmlformats.org/markup-compatibility/2006'
|
|
303
|
+
},
|
|
304
|
+
'mc:Choice': {
|
|
305
|
+
a$: {
|
|
306
|
+
'Requires': 'c14',
|
|
307
|
+
'xmlns:c14': 'http://schemas.microsoft.com/office/drawing/2007/8/2/chart'
|
|
308
|
+
},
|
|
309
|
+
'c14:style': {
|
|
310
|
+
a$: {
|
|
311
|
+
'val': '102'
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
'mc:Fallback': {
|
|
316
|
+
'c:style': {
|
|
317
|
+
a$: {
|
|
318
|
+
'val': '2'
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
'c:chart': {},
|
|
324
|
+
'c:spPr': {
|
|
325
|
+
'a:solidFill': {
|
|
326
|
+
'a:schemeClr': {
|
|
327
|
+
a$: {
|
|
328
|
+
'val': 'bg1'
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
'a:ln': {
|
|
333
|
+
a$: {
|
|
334
|
+
'w': '9525',
|
|
335
|
+
'cap': 'flat',
|
|
336
|
+
'cmpd': 'sng',
|
|
337
|
+
'algn': 'ctr'
|
|
338
|
+
},
|
|
339
|
+
'a:solidFill': {
|
|
340
|
+
'a:schemeClr': {
|
|
341
|
+
a$: {
|
|
342
|
+
'val': 'tx1'
|
|
343
|
+
},
|
|
344
|
+
'a:lumMod': {
|
|
345
|
+
a$: {
|
|
346
|
+
'val': '15000'
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
'a:lumOff': {
|
|
350
|
+
a$: {
|
|
351
|
+
'val': '85000'
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
'a:round': {}
|
|
357
|
+
},
|
|
358
|
+
'a:effectLst': {}
|
|
359
|
+
},
|
|
360
|
+
'c:txPr': {
|
|
361
|
+
'a:bodyPr': {},
|
|
362
|
+
'a:lstStyle': {},
|
|
363
|
+
'a:p': {
|
|
364
|
+
'a:pPr': {
|
|
365
|
+
'a:defRPr': {}
|
|
366
|
+
},
|
|
367
|
+
'a:endParaRPr': {
|
|
368
|
+
a$: {
|
|
369
|
+
'lang': 'en-US'
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
'c:printSettings': {
|
|
375
|
+
'c:headerFooter': {},
|
|
376
|
+
'c:pageMargins': {
|
|
377
|
+
a$: {
|
|
378
|
+
'b': '0.75',
|
|
379
|
+
'l': '0.7',
|
|
380
|
+
'r': '0.7',
|
|
381
|
+
't': '0.75',
|
|
382
|
+
'header': '0.3',
|
|
383
|
+
'footer': '0.3'
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
'c:pageSetup': {}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// import * as ElementTree from 'elementtree';
|
|
23
|
+
// import { Element, ElementTree as Tree } from 'elementtree';
|
|
24
|
+
import { UnitAddress, UnitRange, UnitLiteral, ExpressionUnit } from 'treb-parser';
|
|
25
|
+
|
|
26
|
+
import { static_title, ref_title, chart_template } from './chart-template-components2';
|
|
27
|
+
import { column_json, column_series } from './column-chart-template2';
|
|
28
|
+
import { donut_json } from './donut-chart-template2';
|
|
29
|
+
import { scatter_json, scatter_series } from './scatter-chart-template2';
|
|
30
|
+
|
|
31
|
+
import { XMLUtils } from '../xml-utils';
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
import { donut_json } from './donut-chart-template';
|
|
35
|
+
import { static_title, ref_title, chart_template } from './chart-template-components';
|
|
36
|
+
import { column_json, column_series } from './column-chart-template';
|
|
37
|
+
import { scatter_json, scatter_series } from './scatter-chart-template';
|
|
38
|
+
import { scatter_series as scatter2_series } from './scatter2-chart-template';
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
// import { v4 as uuidv4 } from 'uuid';
|
|
42
|
+
|
|
43
|
+
import { Localization } from 'treb-base-types';
|
|
44
|
+
import { RelationshipMap } from '../relationship';
|
|
45
|
+
|
|
46
|
+
export interface ChartOptions {
|
|
47
|
+
type: 'donut'|'column'|'bar'|'scatter'|'scatter2';
|
|
48
|
+
title?: UnitLiteral | UnitAddress;
|
|
49
|
+
data: UnitRange[];
|
|
50
|
+
labels?: UnitRange;
|
|
51
|
+
labels2?: UnitRange[];
|
|
52
|
+
names?: ExpressionUnit[];
|
|
53
|
+
smooth?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class Chart {
|
|
57
|
+
|
|
58
|
+
public static next_chart_index = 1;
|
|
59
|
+
|
|
60
|
+
public relationships: RelationshipMap = {};
|
|
61
|
+
|
|
62
|
+
constructor (public options: ChartOptions, public index = Chart.next_chart_index++) {
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
/** set chart title, either static or reference to cell */
|
|
68
|
+
public UpdateChartTitle(chartnode: any) {
|
|
69
|
+
|
|
70
|
+
const unit = this.options.title || {
|
|
71
|
+
type: 'literal', value: '',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// const CC = this.FindNode('c:chart', obj);
|
|
75
|
+
// if (CC) {
|
|
76
|
+
if (unit && unit.type === 'literal') {
|
|
77
|
+
const title = JSON.parse(JSON.stringify(static_title));
|
|
78
|
+
//const AP = this.FindNode('a:p', title);
|
|
79
|
+
const AP = title['c:tx']['c:rich']['a:p'];
|
|
80
|
+
|
|
81
|
+
AP['a:r'] = {
|
|
82
|
+
'a:rPr': {
|
|
83
|
+
a$: {
|
|
84
|
+
lang: Localization.locale,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
'a:t': unit.value,
|
|
88
|
+
};
|
|
89
|
+
chartnode['c:title'] = title;
|
|
90
|
+
}
|
|
91
|
+
else if (unit) {
|
|
92
|
+
const title = JSON.parse(JSON.stringify(ref_title));
|
|
93
|
+
//const CF = title['c:tx']['c:strRef']['c:f'];
|
|
94
|
+
//CF.t$ = unit.label;
|
|
95
|
+
title['c:tx']['c:strRef']['c:f'] = unit.label;
|
|
96
|
+
chartnode['c:title'] = title;
|
|
97
|
+
}
|
|
98
|
+
//}
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public toJSON() {
|
|
103
|
+
|
|
104
|
+
switch (this.options.type) {
|
|
105
|
+
case 'column':
|
|
106
|
+
case 'bar':
|
|
107
|
+
return this.CreateBarChart();
|
|
108
|
+
|
|
109
|
+
case 'scatter':
|
|
110
|
+
case 'scatter2':
|
|
111
|
+
return this.CreateScatterChart();
|
|
112
|
+
|
|
113
|
+
case 'donut':
|
|
114
|
+
return this.CreateDonutChart();
|
|
115
|
+
|
|
116
|
+
default:
|
|
117
|
+
console.info('unhandled chart type', this.options.type);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return this.CreateBarChart();
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public CreateScatterChart() {
|
|
125
|
+
|
|
126
|
+
const template = JSON.parse(JSON.stringify(chart_template));
|
|
127
|
+
const chartspace = template['c:chartSpace'];
|
|
128
|
+
const scatter = JSON.parse(JSON.stringify(scatter_json));
|
|
129
|
+
|
|
130
|
+
if (this.options.smooth) {
|
|
131
|
+
scatter['c:plotArea']['c:scatterChart']['c:scatterStyle'].a$.val = 'smoothMarker';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
chartspace['c:chart'] = scatter;
|
|
135
|
+
|
|
136
|
+
this.UpdateChartTitle(chartspace['c:chart']);
|
|
137
|
+
|
|
138
|
+
const cser = chartspace['c:chart']['c:plotArea']['c:scatterChart']['c:ser']; // this.FindNode('c:ser', template);
|
|
139
|
+
|
|
140
|
+
let legend = false;
|
|
141
|
+
|
|
142
|
+
for (let i = 0; i < this.options.data.length; i++) {
|
|
143
|
+
|
|
144
|
+
const series = JSON.parse(JSON.stringify(scatter_series));
|
|
145
|
+
|
|
146
|
+
series['c:idx'] = { a$: { val: i.toString() }};
|
|
147
|
+
series['c:order'] = { a$: { val: i.toString() }};
|
|
148
|
+
|
|
149
|
+
if (this.options.names && this.options.names[i]) {
|
|
150
|
+
|
|
151
|
+
const name = this.options.names[i];
|
|
152
|
+
switch (name.type) {
|
|
153
|
+
case 'literal':
|
|
154
|
+
series['c:tx'] = {
|
|
155
|
+
'c:v': name.value.toString(),
|
|
156
|
+
};
|
|
157
|
+
legend = true;
|
|
158
|
+
break;
|
|
159
|
+
|
|
160
|
+
case 'range':
|
|
161
|
+
case 'address':
|
|
162
|
+
series['c:tx'] = {
|
|
163
|
+
'c:strRef': {
|
|
164
|
+
'c:f': name.label,
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
legend = true;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
series['c:spPr']['a:ln']['a:solidFill']['a:schemeClr'].a$['val'] = `accent${i+1}`;
|
|
173
|
+
|
|
174
|
+
series['c:yVal']['c:numRef']['c:f'] = this.options.data[i]?.label;
|
|
175
|
+
|
|
176
|
+
if (this.options.labels2 && this.options.labels2[i]) {
|
|
177
|
+
series['c:xVal']['c:numRef']['c:f'] = this.options.labels2[i]?.label;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (this.options.smooth) {
|
|
181
|
+
series['c:smooth'] = { a$: { val: 1 }};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// console.info("SER", JSON.stringify(series, undefined, 2));
|
|
185
|
+
|
|
186
|
+
cser.push(series);
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (legend) {
|
|
191
|
+
chartspace['c:chart']['c:legend'] = {
|
|
192
|
+
'c:legendPos': { a$: {val: 'b'}, },
|
|
193
|
+
'c:overlay': { a$: {val: '0'}, },
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return template;
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public CreateDonutChart() {
|
|
202
|
+
|
|
203
|
+
const template = JSON.parse(JSON.stringify(chart_template));
|
|
204
|
+
const chartspace = template['c:chartSpace'];
|
|
205
|
+
const chart = JSON.parse(JSON.stringify(donut_json));
|
|
206
|
+
chartspace['c:chart'] = chart;
|
|
207
|
+
|
|
208
|
+
this.UpdateChartTitle(chartspace['c:chart']);
|
|
209
|
+
|
|
210
|
+
const donut = chart['c:plotArea']['c:doughnutChart'];
|
|
211
|
+
if (donut) {
|
|
212
|
+
|
|
213
|
+
// const cat = this.FindNode('c:cat/c:strRef/c:f', donut);
|
|
214
|
+
// if (cat) {
|
|
215
|
+
// cat._t = this.options.labels?.label;
|
|
216
|
+
//}
|
|
217
|
+
donut['c:ser']['c:cat']['c:strRef']['c:f'] = this.options.labels?.label || '';
|
|
218
|
+
|
|
219
|
+
//const val = this.FindNode('c:val/c:numRef/c:f', donut);
|
|
220
|
+
//if (val) {
|
|
221
|
+
// val._t = this.options.data[0]?.label;
|
|
222
|
+
//}
|
|
223
|
+
donut['c:ser']['c:val']['c:numRef']['c:f'] = this.options.data[0]?.label || '';
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return template;
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public CreateBarChart() {
|
|
232
|
+
|
|
233
|
+
const template = JSON.parse(JSON.stringify(chart_template));
|
|
234
|
+
const chartspace = template['c:chartSpace'];
|
|
235
|
+
const bar = JSON.parse(JSON.stringify(column_json));
|
|
236
|
+
|
|
237
|
+
chartspace['c:chart'] = bar;
|
|
238
|
+
this.UpdateChartTitle(chartspace['c:chart']);
|
|
239
|
+
|
|
240
|
+
const column = bar['c:plotArea']['c:barChart'];
|
|
241
|
+
|
|
242
|
+
if (column) {
|
|
243
|
+
|
|
244
|
+
const bardir = column['c:barDir'];
|
|
245
|
+
|
|
246
|
+
if (bardir) {
|
|
247
|
+
bardir.a$.val = (this.options.type === 'bar') ? 'bar' : 'col';
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const cser = column['c:ser'];
|
|
251
|
+
|
|
252
|
+
for (let i = 0; i < this.options.data.length; i++) {
|
|
253
|
+
|
|
254
|
+
const series = JSON.parse(JSON.stringify(column_series));
|
|
255
|
+
|
|
256
|
+
series['c:idx'] = { a$: { val: i.toString() }};
|
|
257
|
+
series['c:order'] = { a$: { val: i.toString() }};
|
|
258
|
+
series['c:spPr']['a:solidFill']['a:schemeClr'].a$['val'] = `accent${i+1}`;
|
|
259
|
+
|
|
260
|
+
if (!i && this.options.labels) {
|
|
261
|
+
series['c:cat'] = {
|
|
262
|
+
'c:strRef': {
|
|
263
|
+
'c:f': this.options.labels.label,
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
series['c:val']['c:numRef']['c:f'] = this.options.data[i]?.label;
|
|
269
|
+
|
|
270
|
+
cser.push(series);
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// console.info("T", JSON.stringify(template, undefined, 2));
|
|
277
|
+
return template;
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
}
|