@trebco/treb 28.10.5 → 28.11.1

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/dist/treb.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /*! API v28.10. Copyright 2018-2024 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
1
+ /*! API v28.11. Copyright 2018-2024 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
2
2
 
3
3
  /**
4
4
  * add our tag to the map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "28.10.5",
3
+ "version": "28.11.1",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -310,7 +310,7 @@ export const TransformSeriesData = (raw_data?: UnionValue, default_x?: UnionValu
310
310
  };
311
311
 
312
312
  /** get a unified scale, and formats */
313
- export const CommonData = (series: SeriesType[], y_floor?: number, y_ceiling?: number) => {
313
+ export const CommonData = (series: SeriesType[], y_floor?: number, y_ceiling?: number, x_floor?: number, x_ceiling?: number) => {
314
314
 
315
315
  let x_format = '';
316
316
  let y_format = '';
@@ -362,7 +362,14 @@ export const CommonData = (series: SeriesType[], y_floor?: number, y_ceiling?: n
362
362
  }
363
363
  }
364
364
  }
365
-
365
+
366
+ if (typeof x_floor !== 'undefined') {
367
+ x_min = Math.min(x_min, x_floor);
368
+ }
369
+ if (typeof x_ceiling !== 'undefined') {
370
+ x_min = Math.max(x_min, x_ceiling);
371
+ }
372
+
366
373
  if (typeof y_floor !== 'undefined') {
367
374
  y_min = Math.min(y_min, y_floor);
368
375
  }
@@ -438,7 +445,21 @@ const ApplyLabels = (series_list: SeriesType[], pattern: string, category_labels
438
445
  export const CreateBubbleChart = (args: UnionValue[]): ChartData => {
439
446
 
440
447
  const series: SeriesType[] = TransformSeriesData(args[0]);
441
- const common = CommonData(series);
448
+
449
+ let y_floor: number|undefined = undefined;
450
+ let x_floor: number|undefined = undefined;
451
+
452
+ for (const entry of series) {
453
+
454
+ if (typeof entry.x.range?.min === 'number' && entry.x.range.min > 0 && entry.x.range.min < 50) {
455
+ x_floor = 0;
456
+ }
457
+ if (typeof entry.y.range?.min === 'number' && entry.y.range.min > 0 && entry.y.range.min < 50) {
458
+ y_floor = 0;
459
+ }
460
+ }
461
+
462
+ const common = CommonData(series, y_floor, undefined, x_floor);
442
463
  const title = args[1]?.toString() || undefined;
443
464
  const options = args[2]?.toString() || undefined;
444
465
 
@@ -196,6 +196,8 @@ export class DefaultChartRenderer implements ChartRendererType {
196
196
 
197
197
  // now do type-specific rendering
198
198
 
199
+ let zeros: number[]|undefined = [];
200
+
199
201
  switch (chart_data.type) {
200
202
  case 'scatter':
201
203
  this.renderer.RenderPoints(area, chart_data.x, chart_data.y, 'mc mc-correlation series-1');
@@ -203,10 +205,17 @@ export class DefaultChartRenderer implements ChartRendererType {
203
205
 
204
206
  case 'bubble':
205
207
 
208
+ if (chart_data.x_scale.min <= 0 && chart_data.x_scale.max >= 0) {
209
+ zeros[0] = Math.round(Math.abs(chart_data.x_scale.min / chart_data.x_scale.step));
210
+ }
211
+ if (chart_data.y_scale.min <= 0 && chart_data.y_scale.max >= 0) {
212
+ zeros[1] = Math.round(Math.abs(chart_data.y_scale.max / chart_data.y_scale.step));
213
+ }
214
+
206
215
  this.renderer.RenderGrid(area,
207
216
  chart_data.y_scale.count,
208
217
  chart_data.x_scale.count + 1, // (sigh)
209
- 'chart-grid');
218
+ 'chart-grid', zeros);
210
219
 
211
220
  for (const [index, series] of chart_data.series.entries()) {
212
221
  const series_index = (typeof series.index === 'number') ? series.index : index + 1;
@@ -968,23 +968,54 @@ export class ChartRenderer {
968
968
 
969
969
  }
970
970
 
971
- public RenderGrid(area: Area, y_count: number, x_count = 0, classes?: string | string[]): void {
971
+ public RenderGrid(area: Area, y_count: number, x_count = 0, classes?: string | string[], zeros?: number[]): void {
972
972
 
973
973
  const d: string[] = [];
974
+ const d2: string[] = [];
974
975
 
975
976
  let step = area.height / y_count;
976
977
  for (let i = 0; i <= y_count; i++) {
978
+
977
979
  const y = Math.round(area.top + step * i) - 0.5;
978
- d.push(`M${area.left} ${y} L${area.right} ${y}`);
980
+
981
+ if (zeros && zeros[1] === i) {
982
+ d2.push(`M${area.left} ${y} L${area.right} ${y}`);
983
+ }
984
+ else {
985
+ d.push(`M${area.left} ${y} L${area.right} ${y}`);
986
+ }
979
987
  }
980
988
 
981
989
  step = area.width / (x_count - 1);
982
990
  for (let i = 0; i < x_count; i++) {
991
+
983
992
  const x = Math.round(area.left + step * i) - 0.5;
984
- d.push(`M${x} ${area.top} L${x} ${area.bottom}`);
993
+
994
+ if (zeros && zeros[0] === i) {
995
+ d2.push(`M${x} ${area.top} L${x} ${area.bottom}`);
996
+ }
997
+ else {
998
+ d.push(`M${x} ${area.top} L${x} ${area.bottom}`);
999
+ }
985
1000
  }
986
1001
 
987
1002
  this.group.appendChild(SVGNode('path', {d, class: classes}));
1003
+ if (d2.length) {
1004
+
1005
+ if (classes) {
1006
+ if (!Array.isArray(classes)) {
1007
+ classes = classes + ' zero';
1008
+ }
1009
+ else {
1010
+ classes.push('zero');
1011
+ }
1012
+ }
1013
+ else {
1014
+ classes = 'zero';
1015
+ }
1016
+
1017
+ this.group.appendChild(SVGNode('path', {d: d2, class: classes}));
1018
+ }
988
1019
 
989
1020
  }
990
1021
 
@@ -104,6 +104,11 @@
104
104
  /* grid */
105
105
  .chart-grid, .chart-ticks {
106
106
  stroke: var(--treb-chart-grid-color, #ddd);
107
+
108
+ &.zero {
109
+ stroke: var(--treb-chart-grid-zero-color, var(--treb-chart-grid-color, #999));
110
+ }
111
+
107
112
  }
108
113
 
109
114
  /* mouse elements */
@@ -0,0 +1,553 @@
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-2024 trebco, llc.
18
+ * info@treb.app
19
+ *
20
+ */
21
+
22
+ export const bubble_json =
23
+ {
24
+ 'c:title': {},
25
+ 'c:autoTitleDeleted': {
26
+ a$: {
27
+ 'val': '0'
28
+ }
29
+ },
30
+ 'c:plotArea': {
31
+ 'c:layout': {},
32
+ 'c:bubbleChart': {
33
+ 'c:varyColors': {
34
+ a$: {
35
+ 'val': '0'
36
+ }
37
+ },
38
+ 'c:ser': [],
39
+ 'c:dLbls': {
40
+ 'c:showLegendKey': {
41
+ a$: {
42
+ 'val': '0'
43
+ }
44
+ },
45
+ 'c:showVal': {
46
+ a$: {
47
+ 'val': '0'
48
+ }
49
+ },
50
+ 'c:showCatName': {
51
+ a$: {
52
+ 'val': '0'
53
+ }
54
+ },
55
+ 'c:showSerName': {
56
+ a$: {
57
+ 'val': '0'
58
+ }
59
+ },
60
+ 'c:showPercent': {
61
+ a$: {
62
+ 'val': '0'
63
+ }
64
+ },
65
+ 'c:showBubbleSize': {
66
+ a$: {
67
+ 'val': '0'
68
+ }
69
+ }
70
+ },
71
+ 'c:axId': [
72
+ {
73
+ a$: {
74
+ 'val': '2028657983'
75
+ }
76
+ },
77
+ {
78
+ a$: {
79
+ 'val': '2023395087'
80
+ }
81
+ }
82
+ ]
83
+ },
84
+ 'c:valAx': [
85
+ {
86
+ 'c:axId': {
87
+ a$: {
88
+ 'val': '2028657983'
89
+ }
90
+ },
91
+ 'c:scaling': {
92
+ 'c:orientation': {
93
+ a$: {
94
+ 'val': 'minMax'
95
+ }
96
+ }
97
+ },
98
+ 'c:delete': {
99
+ a$: {
100
+ 'val': '0'
101
+ }
102
+ },
103
+ 'c:axPos': {
104
+ a$: {
105
+ 'val': 'b'
106
+ }
107
+ },
108
+ 'c:majorGridlines': {
109
+ 'c:spPr': {
110
+ 'a:ln': {
111
+ a$: {
112
+ 'w': '9525',
113
+ 'cap': 'flat',
114
+ 'cmpd': 'sng',
115
+ 'algn': 'ctr'
116
+ },
117
+ 'a:solidFill': {
118
+ 'a:schemeClr': {
119
+ a$: {
120
+ 'val': 'tx1'
121
+ },
122
+ 'a:lumMod': {
123
+ a$: {
124
+ 'val': '15000'
125
+ }
126
+ },
127
+ 'a:lumOff': {
128
+ a$: {
129
+ 'val': '85000'
130
+ }
131
+ }
132
+ }
133
+ },
134
+ 'a:round': {}
135
+ },
136
+ 'a:effectLst': {}
137
+ }
138
+ },
139
+ 'c:majorTickMark': {
140
+ a$: {
141
+ 'val': 'none'
142
+ }
143
+ },
144
+ 'c:minorTickMark': {
145
+ a$: {
146
+ 'val': 'none'
147
+ }
148
+ },
149
+ 'c:tickLblPos': {
150
+ a$: {
151
+ 'val': 'nextTo'
152
+ }
153
+ },
154
+ 'c:spPr': {
155
+ 'a:noFill': {},
156
+ 'a:ln': {
157
+ a$: {
158
+ 'w': '9525',
159
+ 'cap': 'flat',
160
+ 'cmpd': 'sng',
161
+ 'algn': 'ctr'
162
+ },
163
+ 'a:solidFill': {
164
+ 'a:schemeClr': {
165
+ a$: {
166
+ 'val': 'tx1'
167
+ },
168
+ 'a:lumMod': {
169
+ a$: {
170
+ 'val': '25000'
171
+ }
172
+ },
173
+ 'a:lumOff': {
174
+ a$: {
175
+ 'val': '75000'
176
+ }
177
+ }
178
+ }
179
+ },
180
+ 'a:round': {}
181
+ },
182
+ 'a:effectLst': {}
183
+ },
184
+ 'c:txPr': {
185
+ 'a:bodyPr': {
186
+ a$: {
187
+ 'rot': '-60000000',
188
+ 'spcFirstLastPara': '1',
189
+ 'vertOverflow': 'ellipsis',
190
+ 'vert': 'horz',
191
+ 'wrap': 'square',
192
+ 'anchor': 'ctr',
193
+ 'anchorCtr': '1'
194
+ }
195
+ },
196
+ 'a:lstStyle': {},
197
+ 'a:p': {
198
+ 'a:pPr': {
199
+ 'a:defRPr': {
200
+ a$: {
201
+ 'sz': '900',
202
+ 'b': '0',
203
+ 'i': '0',
204
+ 'u': 'none',
205
+ 'strike': 'noStrike',
206
+ 'kern': '1200',
207
+ 'baseline': '0'
208
+ },
209
+ 'a:solidFill': {
210
+ 'a:schemeClr': {
211
+ a$: {
212
+ 'val': 'tx1'
213
+ },
214
+ 'a:lumMod': {
215
+ a$: {
216
+ 'val': '65000'
217
+ }
218
+ },
219
+ 'a:lumOff': {
220
+ a$: {
221
+ 'val': '35000'
222
+ }
223
+ }
224
+ }
225
+ },
226
+ 'a:latin': {
227
+ a$: {
228
+ 'typeface': '+mn-lt'
229
+ }
230
+ },
231
+ 'a:ea': {
232
+ a$: {
233
+ 'typeface': '+mn-ea'
234
+ }
235
+ },
236
+ 'a:cs': {
237
+ a$: {
238
+ 'typeface': '+mn-cs'
239
+ }
240
+ }
241
+ }
242
+ },
243
+ 'a:endParaRPr': {
244
+ a$: {
245
+ 'lang': 'en-US'
246
+ }
247
+ }
248
+ }
249
+ },
250
+ 'c:crossAx': {
251
+ a$: {
252
+ 'val': '2023395087'
253
+ }
254
+ },
255
+ 'c:crosses': {
256
+ a$: {
257
+ 'val': 'autoZero'
258
+ }
259
+ },
260
+ 'c:crossBetween': {
261
+ a$: {
262
+ 'val': 'midCat'
263
+ }
264
+ }
265
+ },
266
+ {
267
+ 'c:axId': {
268
+ a$: {
269
+ 'val': '2023395087'
270
+ }
271
+ },
272
+ 'c:scaling': {
273
+ 'c:orientation': {
274
+ a$: {
275
+ 'val': 'minMax'
276
+ }
277
+ }
278
+ },
279
+ 'c:delete': {
280
+ a$: {
281
+ 'val': '0'
282
+ }
283
+ },
284
+ 'c:axPos': {
285
+ a$: {
286
+ 'val': 'l'
287
+ }
288
+ },
289
+ 'c:majorGridlines': {
290
+ 'c:spPr': {
291
+ 'a:ln': {
292
+ a$: {
293
+ 'w': '9525',
294
+ 'cap': 'flat',
295
+ 'cmpd': 'sng',
296
+ 'algn': 'ctr'
297
+ },
298
+ 'a:solidFill': {
299
+ 'a:schemeClr': {
300
+ a$: {
301
+ 'val': 'tx1'
302
+ },
303
+ 'a:lumMod': {
304
+ a$: {
305
+ 'val': '15000'
306
+ }
307
+ },
308
+ 'a:lumOff': {
309
+ a$: {
310
+ 'val': '85000'
311
+ }
312
+ }
313
+ }
314
+ },
315
+ 'a:round': {}
316
+ },
317
+ 'a:effectLst': {}
318
+ }
319
+ },
320
+ 'c:numFmt': {
321
+ a$: {
322
+ 'formatCode': '0.00',
323
+ 'sourceLinked': '1'
324
+ }
325
+ },
326
+ 'c:majorTickMark': {
327
+ a$: {
328
+ 'val': 'none'
329
+ }
330
+ },
331
+ 'c:minorTickMark': {
332
+ a$: {
333
+ 'val': 'none'
334
+ }
335
+ },
336
+ 'c:tickLblPos': {
337
+ a$: {
338
+ 'val': 'nextTo'
339
+ }
340
+ },
341
+ 'c:spPr': {
342
+ 'a:noFill': {},
343
+ 'a:ln': {
344
+ a$: {
345
+ 'w': '9525',
346
+ 'cap': 'flat',
347
+ 'cmpd': 'sng',
348
+ 'algn': 'ctr'
349
+ },
350
+ 'a:solidFill': {
351
+ 'a:schemeClr': {
352
+ a$: {
353
+ 'val': 'tx1'
354
+ },
355
+ 'a:lumMod': {
356
+ a$: {
357
+ 'val': '25000'
358
+ }
359
+ },
360
+ 'a:lumOff': {
361
+ a$: {
362
+ 'val': '75000'
363
+ }
364
+ }
365
+ }
366
+ },
367
+ 'a:round': {}
368
+ },
369
+ 'a:effectLst': {}
370
+ },
371
+ 'c:txPr': {
372
+ 'a:bodyPr': {
373
+ a$: {
374
+ 'rot': '-60000000',
375
+ 'spcFirstLastPara': '1',
376
+ 'vertOverflow': 'ellipsis',
377
+ 'vert': 'horz',
378
+ 'wrap': 'square',
379
+ 'anchor': 'ctr',
380
+ 'anchorCtr': '1'
381
+ }
382
+ },
383
+ 'a:lstStyle': {},
384
+ 'a:p': {
385
+ 'a:pPr': {
386
+ 'a:defRPr': {
387
+ a$: {
388
+ 'sz': '900',
389
+ 'b': '0',
390
+ 'i': '0',
391
+ 'u': 'none',
392
+ 'strike': 'noStrike',
393
+ 'kern': '1200',
394
+ 'baseline': '0'
395
+ },
396
+ 'a:solidFill': {
397
+ 'a:schemeClr': {
398
+ a$: {
399
+ 'val': 'tx1'
400
+ },
401
+ 'a:lumMod': {
402
+ a$: {
403
+ 'val': '65000'
404
+ }
405
+ },
406
+ 'a:lumOff': {
407
+ a$: {
408
+ 'val': '35000'
409
+ }
410
+ }
411
+ }
412
+ },
413
+ 'a:latin': {
414
+ a$: {
415
+ 'typeface': '+mn-lt'
416
+ }
417
+ },
418
+ 'a:ea': {
419
+ a$: {
420
+ 'typeface': '+mn-ea'
421
+ }
422
+ },
423
+ 'a:cs': {
424
+ a$: {
425
+ 'typeface': '+mn-cs'
426
+ }
427
+ }
428
+ }
429
+ },
430
+ 'a:endParaRPr': {
431
+ a$: {
432
+ 'lang': 'en-US'
433
+ }
434
+ }
435
+ }
436
+ },
437
+ 'c:crossAx': {
438
+ a$: {
439
+ 'val': '2028657983'
440
+ }
441
+ },
442
+ 'c:crosses': {
443
+ a$: {
444
+ 'val': 'autoZero'
445
+ }
446
+ },
447
+ 'c:crossBetween': {
448
+ a$: {
449
+ 'val': 'midCat'
450
+ }
451
+ }
452
+ }
453
+ ],
454
+ 'c:spPr': {
455
+ 'a:noFill': {},
456
+ 'a:ln': {
457
+ 'a:noFill': {}
458
+ },
459
+ 'a:effectLst': {}
460
+ }
461
+ },
462
+ 'c:plotVisOnly': {
463
+ a$: {
464
+ 'val': '1'
465
+ }
466
+ },
467
+ 'c:dispBlanksAs': {
468
+ a$: {
469
+ 'val': 'gap'
470
+ }
471
+ },
472
+ 'c:extLst': {
473
+ 'c:ext': {
474
+ a$: {
475
+ 'uri': '{56B9EC1D-385E-4148-901F-78D8002777C0}',
476
+ 'xmlns:c16r3': 'http://schemas.microsoft.com/office/drawing/2017/03/chart'
477
+ },
478
+ 'c16r3:dataDisplayOptions16': {
479
+ 'c16r3:dispNaAsBlank': {
480
+ a$: {
481
+ 'val': '1'
482
+ }
483
+ }
484
+ }
485
+ }
486
+ },
487
+ 'c:showDLblsOverMax': {
488
+ a$: {
489
+ 'val': '0'
490
+ }
491
+ }
492
+ };
493
+
494
+ export const bubble_series = {
495
+
496
+ 'c:spPr': {
497
+ 'a:solidFill': {
498
+ 'a:schemeClr': {
499
+ a$: {
500
+ val: 'accent1',
501
+ },
502
+ 'a:alpha': {
503
+ a$: {
504
+ val: '75000',
505
+ },
506
+ },
507
+ },
508
+ },
509
+ 'a:ln': {
510
+ 'a:noFill': {},
511
+ },
512
+ 'a:effectLst': {},
513
+ },
514
+
515
+ 'c:xVal': {
516
+ 'c:numRef': {
517
+ 'c:f': '',
518
+ }
519
+ },
520
+
521
+ 'c:yVal': {
522
+ 'c:numRef': {
523
+ 'c:f': '',
524
+ }
525
+ },
526
+
527
+ 'c:bubbleSize': {
528
+ 'c:numRef': {
529
+ 'c:f': '',
530
+ }
531
+ },
532
+
533
+ 'c:bubble3D': {
534
+ a$: {
535
+ val: '0',
536
+ }
537
+ },
538
+
539
+ 'c:extLst': {
540
+ 'c:ext': {
541
+ a$: {
542
+ 'uri': '{C3380CC4-5D6E-409C-BE32-E72D297353CC}',
543
+ 'xmlns:c16': 'http://schemas.microsoft.com/office/drawing/2014/chart'
544
+ },
545
+ 'c16:uniqueId': {
546
+ a$: {
547
+ 'val': '{00000000-03D7-43A5-9DAB-5775FFEF9C03}'
548
+ }
549
+ }
550
+ }
551
+ }
552
+
553
+ }