ngx-deebodata 0.1.2 → 0.1.4

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 (77) hide show
  1. package/README.md +37 -2
  2. package/fesm2022/ngx-deebodata.mjs +6969 -0
  3. package/fesm2022/ngx-deebodata.mjs.map +1 -0
  4. package/package.json +41 -18
  5. package/types/ngx-deebodata.d.ts +460 -0
  6. package/ng-package.json +0 -7
  7. package/src/lib/data-table/charts/bar-graph-component/bar-graph-component.css +0 -148
  8. package/src/lib/data-table/charts/bar-graph-component/bar-graph-component.html +0 -29
  9. package/src/lib/data-table/charts/bar-graph-component/bar-graph-component.spec.ts +0 -23
  10. package/src/lib/data-table/charts/bar-graph-component/bar-graph-component.ts +0 -282
  11. package/src/lib/data-table/charts/charts-and-graphs/charts-and-graphs.css +0 -27
  12. package/src/lib/data-table/charts/charts-and-graphs/charts-and-graphs.html +0 -53
  13. package/src/lib/data-table/charts/charts-and-graphs/charts-and-graphs.spec.ts +0 -23
  14. package/src/lib/data-table/charts/charts-and-graphs/charts-and-graphs.ts +0 -214
  15. package/src/lib/data-table/charts/column-chart/column-chart.css +0 -19
  16. package/src/lib/data-table/charts/column-chart/column-chart.html +0 -47
  17. package/src/lib/data-table/charts/column-chart/column-chart.spec.ts +0 -23
  18. package/src/lib/data-table/charts/column-chart/column-chart.ts +0 -178
  19. package/src/lib/data-table/charts/line-graph-component/line-graph-component.css +0 -25
  20. package/src/lib/data-table/charts/line-graph-component/line-graph-component.html +0 -59
  21. package/src/lib/data-table/charts/line-graph-component/line-graph-component.spec.ts +0 -23
  22. package/src/lib/data-table/charts/line-graph-component/line-graph-component.ts +0 -661
  23. package/src/lib/data-table/charts/num-value-distro-component/num-value-distro-component.css +0 -53
  24. package/src/lib/data-table/charts/num-value-distro-component/num-value-distro-component.html +0 -27
  25. package/src/lib/data-table/charts/num-value-distro-component/num-value-distro-component.spec.ts +0 -23
  26. package/src/lib/data-table/charts/num-value-distro-component/num-value-distro-component.ts +0 -210
  27. package/src/lib/data-table/charts/pie-graph-component/pie-graph-component.css +0 -0
  28. package/src/lib/data-table/charts/pie-graph-component/pie-graph-component.html +0 -15
  29. package/src/lib/data-table/charts/pie-graph-component/pie-graph-component.spec.ts +0 -23
  30. package/src/lib/data-table/charts/pie-graph-component/pie-graph-component.ts +0 -197
  31. package/src/lib/data-table/data-table-module/data-cell/data-cell.css +0 -0
  32. package/src/lib/data-table/data-table-module/data-cell/data-cell.html +0 -6
  33. package/src/lib/data-table/data-table-module/data-cell/data-cell.spec.ts +0 -23
  34. package/src/lib/data-table/data-table-module/data-cell/data-cell.ts +0 -298
  35. package/src/lib/data-table/data-table-module/data-table-header/data-table-header.css +0 -25
  36. package/src/lib/data-table/data-table-module/data-table-header/data-table-header.html +0 -55
  37. package/src/lib/data-table/data-table-module/data-table-header/data-table-header.spec.ts +0 -23
  38. package/src/lib/data-table/data-table-module/data-table-header/data-table-header.ts +0 -261
  39. package/src/lib/data-table/data-table-module/data-table-paginator/data-table-paginator.css +0 -61
  40. package/src/lib/data-table/data-table-module/data-table-paginator/data-table-paginator.html +0 -24
  41. package/src/lib/data-table/data-table-module/data-table-paginator/data-table-paginator.spec.ts +0 -23
  42. package/src/lib/data-table/data-table-module/data-table-paginator/data-table-paginator.ts +0 -125
  43. package/src/lib/data-table/data-table-module/export-component/export-component.css +0 -83
  44. package/src/lib/data-table/data-table-module/export-component/export-component.html +0 -16
  45. package/src/lib/data-table/data-table-module/export-component/export-component.spec.ts +0 -23
  46. package/src/lib/data-table/data-table-module/export-component/export-component.ts +0 -206
  47. package/src/lib/data-table/data-table-module/ngx-deebodata/ngx-deebodata.css +0 -92
  48. package/src/lib/data-table/data-table-module/ngx-deebodata/ngx-deebodata.html +0 -194
  49. package/src/lib/data-table/data-table-module/ngx-deebodata/ngx-deebodata.spec.ts +0 -23
  50. package/src/lib/data-table/data-table-module/ngx-deebodata/ngx-deebodata.ts +0 -2255
  51. package/src/lib/data-table/data-table-module/row-group-menu/row-group-menu.css +0 -14
  52. package/src/lib/data-table/data-table-module/row-group-menu/row-group-menu.html +0 -27
  53. package/src/lib/data-table/data-table-module/row-group-menu/row-group-menu.spec.ts +0 -23
  54. package/src/lib/data-table/data-table-module/row-group-menu/row-group-menu.ts +0 -58
  55. package/src/lib/data-table/data-table-module/row-group-panel/row-group-panel.css +0 -15
  56. package/src/lib/data-table/data-table-module/row-group-panel/row-group-panel.html +0 -48
  57. package/src/lib/data-table/data-table-module/row-group-panel/row-group-panel.spec.ts +0 -23
  58. package/src/lib/data-table/data-table-module/row-group-panel/row-group-panel.ts +0 -599
  59. package/src/lib/data-table/data-table-module/worker.worker.ts +0 -44
  60. package/src/lib/interfaces/cell-edit.ts +0 -7
  61. package/src/lib/interfaces/column-header.ts +0 -10
  62. package/src/lib/interfaces/column-styles.ts +0 -14
  63. package/src/lib/interfaces/column-symbol.ts +0 -4
  64. package/src/lib/interfaces/data-cell.ts +0 -14
  65. package/src/lib/interfaces/data-row.ts +0 -11
  66. package/src/lib/interfaces/row-number.ts +0 -4
  67. package/src/lib/services/common-service.spec.ts +0 -16
  68. package/src/lib/services/common-service.ts +0 -336
  69. package/src/lib/services/data-table-service.spec.ts +0 -16
  70. package/src/lib/services/data-table-service.ts +0 -605
  71. package/src/lib/services/table-drag-service.spec.ts +0 -16
  72. package/src/lib/services/table-drag-service.ts +0 -347
  73. package/src/lib/styles.css +0 -1068
  74. package/src/public-api.ts +0 -8
  75. package/tsconfig.lib.json +0 -17
  76. package/tsconfig.lib.prod.json +0 -11
  77. package/tsconfig.spec.json +0 -15
@@ -1,29 +0,0 @@
1
- <div #statOptsCont class="center stat-opt-contain">
2
- @for(stat of statOpts; track stat){
3
- <div [style.width]="statBtnWid" class="inline-b center">
4
- <button class="no-btn stat-opt-btn" (click)="handleStatChange(stat)"
5
- [class.stat-opt-btn-active]="selStat() === stat">{{common.titleCase(stat)}}</button>
6
- </div>
7
- }
8
- </div>
9
- <div #innerGB class="inner-bg-contain">
10
- <div #yAxis class="bar-graph-y-cols" [style.height]="((bgDepVarHgt*(numYPlots-1))+17) + 'px'">
11
- @for(num of numTicks(); track $index){
12
- <div class="bg-dep-var" [class.invisible]="num && num === maxYVal" [attr.data-number]="num">{{(num === '0') ? '' : num}}</div>
13
- }
14
- </div><div #barContainer class="bar-graph-real-vals">
15
- @for(bar of barVals; track bar){
16
- <div [ngStyle]="{'width': xLblWidth, 'left': bar.left}"
17
- class="graph-actual-bar" [attr.data-value]="bar.fullValue">
18
- <div [ngStyle]="{'height': bar.height, 'background': bar.background}"></div>
19
- </div>
20
- }
21
- </div>
22
- <div #xValues class="bar-graph-x-cols">
23
- @for(lbl of xLabels; track lbl){
24
- <div class="bg-ind-var center" [style.width]="xLblWidth" (mouseenter)="lblMouseIn($event.target)" (mouseleave)="lblMouseOut($event.target)">
25
- {{lbl}}</div>
26
- }
27
- </div>
28
- </div>
29
- <div #xLabel class="bar-graph-x-label"></div>
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { BarGraphComponent } from './bar-graph-component';
4
-
5
- describe('BarGraphComponent', () => {
6
- let component: BarGraphComponent;
7
- let fixture: ComponentFixture<BarGraphComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [BarGraphComponent]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(BarGraphComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,282 +0,0 @@
1
- import { Component, ElementRef, EventEmitter, Input, ViewChild, Output, HostListener, signal } from '@angular/core';
2
- import { CommonService } from '../../../services/common-service';
3
- import { DataTableService } from '../../../services/data-table-service';
4
- import { CommonModule } from '@angular/common';
5
-
6
- @Component({
7
- selector: 'app-bar-graph-component',
8
- imports: [CommonModule],
9
- templateUrl: './bar-graph-component.html',
10
- styleUrls: ['./bar-graph-component.css', '../../../styles.css']
11
- })
12
- export class BarGraphComponent {
13
-
14
- @HostListener('window:resize', ['$event'])
15
- onWindowResize(e: Event) {
16
- this.handleStatChange(this.selStat(), true)
17
- }
18
-
19
- numTicks = signal<string[]>([])
20
- barVals: any[] = []
21
- xLblWidth: string= ""
22
- xLabels: string[] = []
23
- maxBarWid: number = 90
24
- buildingStat: boolean = false
25
- maxYVal: string = "0";
26
- statData: any[] = []
27
- selStat = signal<string>("avg")
28
- numYPlots: number = 5
29
- bgDepVarHgt: number = 70//height of y ticks
30
- statOpts: string[] = ["avg", "min", "max", "mode", "median", "sum"]
31
- statBtnWid: string = "30px"
32
- titleTrail: string = ""
33
- @Input() column: string = ""
34
- @Input() data: any[] = []
35
- @Output("title") title: EventEmitter<string> = new EventEmitter();
36
- @ViewChild("innerGB", { static: true }) innerGB!: ElementRef;
37
- @ViewChild("xLabel", { static: true }) xLabel!: ElementRef;
38
- @ViewChild("xValues", { static: true }) xValues!: ElementRef;
39
- @ViewChild("yAxis", { static: true }) yAxis!: ElementRef;
40
- @ViewChild("statOptsCont", { static: true }) statOptsCont!: ElementRef;
41
- @ViewChild("barContainer", { static: true }) barContainer!: ElementRef;
42
-
43
- constructor(public common: CommonService,
44
- private dataTableService: DataTableService,
45
- ){ }
46
-
47
- ngOnInit() {
48
- this.buildBarGraphWithTwoCols(this.selStat())
49
- }
50
-
51
- ngAfterContentInit() {
52
- setTimeout( () => { this.sizeUpBgDims() })
53
- }
54
-
55
- sizeUpBgDims() {
56
- const bgWid = this.innerGB.nativeElement.getBoundingClientRect().width
57
- const yWid = this.yAxis.nativeElement.getBoundingClientRect().width
58
- const offY = Math.ceil(yWid+5)
59
- this.statBtnWid = Math.floor((bgWid-offY)/this.statOpts.length) + "px";
60
- this.statOptsCont.nativeElement.style.marginLeft = offY + "px";
61
- this.xValues.nativeElement.style.marginLeft = offY + "px";
62
- this.barContainer.nativeElement.style.marginLeft = offY + "px";
63
- this.xLblWidth = Math.min(this.maxBarWid, (Math.floor((bgWid-offY)/this.xLabels.length))) + "px";
64
- }
65
-
66
- buildBarGraphWithTwoCols(stat: string) {
67
- const bgCols = this.column.split(this.dataTableService.bgSep)
68
- const strCol = bgCols[0]
69
- const numCol = bgCols[1]
70
- if(!this.titleTrail)
71
- this.titleTrail = this.common.titleCase(numCol) + " by " + this.common.titleCase(strCol);
72
- const vals = this.dataTableService.dataFilSrtTracker[strCol].selDDVals.filter( (g: any) => g.value !== "(Select All)")
73
- const vlen = vals.length
74
- let o = 0
75
- for(o; o < vlen; o++){
76
- const val = vals[o].value
77
- const justVal = this.data.filter( d => d["strColumn"] === val).map( d => d["numColumn"] )
78
- const jvlen = justVal.length
79
- if(jvlen){//["avg", "min", "max", "mode", "median", "sum"]
80
- let statobj = {x: val, y: 0}
81
- if(stat === "avg")
82
- statobj.y = (justVal.reduce( (acc, curr) => (acc += curr) , 0)/jvlen)
83
- if(stat === "min")
84
- statobj.y = Math.min(...justVal)
85
- if(stat === "max")
86
- statobj.y = Math.max(...justVal)
87
- if(stat === "sum")
88
- statobj.y = (justVal.reduce( (acc, curr) => (acc += curr) , 0))
89
- if(stat === "median")
90
- statobj.y = this.findDataMedian(justVal, jvlen)
91
- if(stat === "mode")
92
- statobj.y = this.findDataMode(justVal)
93
- this.statData.push(statobj)
94
- this.xLabels.push(val)
95
- }
96
- }
97
- const justNull = this.data.filter( d => d["strColumn"] === "N/A").map( d => d["numColumn"] )
98
- const jlen = justNull.length
99
- if(jlen){
100
- let statobj = {x: "N/A", y: 0}
101
- if(stat === "avg")
102
- statobj.y = (justNull.reduce( (acc, curr) => (acc += curr) , 0)/jlen)
103
- if(stat === "min")
104
- statobj.y = Math.min(...justNull)
105
- if(stat === "max")
106
- statobj.y = Math.max(...justNull)
107
- if(stat === "sum")
108
- statobj.y = (justNull.reduce( (acc, curr) => (acc += curr) , 0))
109
- if(stat === "median")
110
- statobj.y = this.findDataMedian(justNull, jlen)
111
- if(stat === "mode")
112
- statobj.y = this.findDataMode(justNull)
113
- this.statData.push(statobj)
114
- this.xLabels.push("N/A")
115
- }
116
- const par = this.innerGB.nativeElement
117
- const nums = this.statData.map( d => d["y"] );
118
- let srtNums = nums.sort( (a, b) => a - b > 0 ? 1 : -1 )
119
- const max = srtNums[(nums.length-1)]
120
- let lbly = this.common.sanitizeUi(numCol)
121
- const sym = this.dataTableService.dataFilSrtTracker[numCol].colCellSymbol
122
- if(sym)
123
- lbly += " ("+sym+")";
124
- par.setAttribute("data-yaxis", lbly)
125
- this.xLabel.nativeElement.textContent = this.common.sanitizeUi(this.common.titleCase(strCol))
126
- this.buildYAxisBGVals(max)
127
- setTimeout( () => { this.buildBGBars(this.statData, max, sym) })
128
- setTimeout( () => { this.buildingStat = false }, 500)
129
- }
130
-
131
- buildBGBars(data: any[], max: number, sym: any) {
132
- let i = 0
133
- const len = data.length
134
- let background: string = "initial"
135
- const yAx = this.yAxis.nativeElement
136
- const ybds = yAx.getBoundingClientRect()
137
- const yWid = ybds.width
138
- const offY = Math.ceil(yWid+5)
139
- const whiteTxt = ["white", "#FFFFFF", "#ffffff", "rgb(255, 255, 255)", "rgb(255,255,255)"];
140
- if(this.dataTableService.themeColor1 && whiteTxt.indexOf(this.dataTableService.themeColor1) < 0)
141
- background = this.dataTableService.themeColor1;
142
- const useIncr = Math.min(this.maxBarWid, (Math.floor((this.innerGB.nativeElement.getBoundingClientRect().width-offY)/this.xLabels.length)))
143
- for(i; i < len; i++){
144
- const item = data[i]
145
- const bhgt = item["y"]/max;
146
- const strVal = item["y"].toLocaleString(undefined, {maximumFractionDigits: 2})
147
- let symb4 = ""
148
- let symaf = ""
149
- if(sym){
150
- let isCurr = ["$","€","£","¥","₣","₹"].indexOf(sym) > -1
151
- if(isCurr)
152
- symb4 = sym
153
- else
154
- symaf = sym
155
- }
156
- const fVal = item["x"] + ': ' + symb4 + strVal + symaf;
157
- const bv = { id: item["x"], left: ((i*useIncr) + "px"), heightVal: bhgt, height: "0px", fullValue: fVal, numValue: strVal, background: background}
158
- this.barVals.push(bv);
159
- }
160
- this.handleBGBarHgts(data)
161
- }
162
-
163
- handleBGBarHgts(data: any[]) {
164
- let i = 0
165
- let show = false
166
- const len = data.length
167
- const ybds = this.yAxis.nativeElement.getBoundingClientRect()
168
- const maxHgt = ybds.height
169
- const cont = document.getElementById("insField" + this.common.elifyCol(this.column))
170
- const cBds = cont?.getBoundingClientRect()
171
- const insTop = document.getElementsByClassName("chart-contain-show")[0]?.scrollTop || 0;
172
- if(cBds && (cBds.bottom-(cBds.height/2)) < (this.dataTableService.tblTop+insTop+this.dataTableService.dTblHeight))
173
- show = true;
174
- if(show){
175
- for(i; i < len; i++){
176
- const item = data[i]
177
- const xvalue = item["x"]
178
- const bv = this.barVals.find( b => b.id === xvalue)
179
- if(bv){
180
- setTimeout( () => {
181
- bv.height = (Math.ceil(bv.heightVal*maxHgt) + "px")
182
- }, 250)
183
- }
184
- }
185
- }
186
- }
187
-
188
- buildYAxisBGVals(max: number) {
189
- let nts: string[] = []
190
- // let diff = max - min
191
- const incr = max/(this.numYPlots-1)
192
- const strNum = (val: number) => {
193
- return val < 1000 ? val.toLocaleString(undefined, {maximumFractionDigits: 0}) : this.common.doBigData(val);
194
- }
195
- for(let i = (this.numYPlots-1); i >= 0; i--){
196
- try{
197
- const inc = i*incr
198
- let useVal = inc//(min + inc)
199
- if(i === 0)
200
- useVal = 0//min
201
- if(i === (this.numYPlots-1))
202
- useVal = max
203
- const strVal = strNum(useVal);
204
- if(i === (this.numYPlots-1))
205
- this.maxYVal = strVal
206
- nts.push(strVal)
207
- }catch(e){}
208
- }
209
- this.numTicks.set([...nts])
210
- }
211
-
212
- handleStatChange(stat: string, resize?: boolean) {
213
- if(this.selStat() === stat && !resize)
214
- return;
215
- this.buildingStat = true
216
- this.maxYVal = "0"
217
- this.selStat.set(stat)
218
- this.numTicks.set([])
219
- this.barVals = []
220
- this.xLabels = []
221
- this.statData = []
222
- if(!resize)
223
- this.title.emit(this.common.titleCase(stat) + " " + this.titleTrail);
224
- setTimeout( () => {
225
- this.buildBarGraphWithTwoCols(stat);
226
- setTimeout( () => { this.sizeUpBgDims() })
227
- })
228
- }
229
-
230
- findDataMedian(data: number[], len: number): number {
231
- if(len === 1)
232
- return data[0]
233
- if(len === 2)
234
- return (data[0]+data[1])/2
235
- const isOdd = len%2 !== 0
236
- if(isOdd){
237
- return data[Math.ceil(len/2)]
238
- } else {
239
- const loMed = data[len/2]
240
- const hiMed = data[len/2] + 1
241
- return (loMed+hiMed)/2
242
- }
243
- }
244
-
245
- getColumnValueCounts(data: any[]) {
246
- let i = 0
247
- let count: any = {}
248
- const len = data.length
249
- for(i; i < len; i++){
250
- const d = data[i]
251
- const val = "v" + d
252
- if(!count[val] || typeof count[val] === "undefined")
253
- count[val] = 1
254
- else
255
- count[val] += 1
256
- }
257
- return count;
258
- }
259
-
260
- findDataMode(data: any[]): number {
261
- const count = this.getColumnValueCounts(data)
262
- let most = null
263
- for(const prop in count){
264
- if(!most)
265
- most = {text: prop, amount: count[prop]}
266
- if(count[prop] > most.amount)
267
- most = {text: prop, amount: count[prop]}
268
- }
269
- if(most)
270
- return parseInt(most?.text.replace("v", ""))
271
- return 0;
272
- }
273
-
274
- lblMouseIn(el: any) {
275
- el.classList.add("lbl-show")
276
- }
277
-
278
- lblMouseOut(el: any) {
279
- el.classList.remove("lbl-show")
280
- }
281
-
282
- }
@@ -1,27 +0,0 @@
1
- .h3-bg{
2
- text-align: center;
3
- margin-bottom: 7px;
4
- }
5
-
6
- .chart-rel-contain{
7
- z-index: 25;
8
- }
9
-
10
- .chart-contain{
11
- left: 0;
12
- right: 0;
13
- top: 11px;
14
- opacity: 0;
15
- overflow: auto;
16
- position: absolute;
17
- background: white;
18
- }
19
-
20
- .chart-contain .relly button i{
21
- font-size: 30px;
22
- }
23
-
24
- .chart-contain-show{
25
- opacity: 1 !important;
26
- transition: all 0.5s ease-in;
27
- }
@@ -1,53 +0,0 @@
1
- <div class="relly chart-rel-contain">
2
- <div #chartContain class="chart-contain" (scroll)="handleChartScroll($event)" [class.chart-contain-show]="chartsReady()" [style.height]="height">
3
- <div class="relly" style="z-index: 10;">
4
- <button type="button" #xChartsBtn class="abs-right no-btn" (click)="closeCharts()" style="background: white;">
5
- <i class="material-icons error-message heavy" aria-hidden="false">close</i>
6
- </button>
7
- </div>
8
- <div class="insights">
9
- <h2 class="no-weight center" [innerHTML]="h2Text"></h2>
10
- @for(row of iRows; track row; let r = $index){
11
- <div class="insight-field-row">
12
- @for(col of row; track col; let i = $index){
13
- <div [id]="'insField' + common.elifyCol(col.column)" class="insight-field">
14
- @if(rowIsAboveFold().indexOf(r) > -1){
15
- <div style="width: 85%;">
16
- <h3 class="semi-heavy" [class.h3-bg]="col.title.indexOf( ' by ') > -1">{{col.title}}</h3>
17
- @if(dtCols.indexOf(col.column) > -1 && common.goodLs()){
18
- <div class="lg-title-cont">
19
- @if(numCols.length > 1){
20
- @for(opt of numCols; track opt){
21
- <button type="button" class="btn-line-graph-opts" [class.btn-lg-sel]="opt === currNumColNm[col.column]"
22
- (click)="setLineGraphNumCol(r, col.column, opt)">
23
- {{opt + " by " + col.column}}
24
- </button>
25
- }
26
- } @else {
27
- <span class="sp-line-graph-title">{{common.titleCase(currNumColNm[col.column]) + " by " + common.titleCase(col.column)}}</span>
28
- }
29
- </div>
30
- @if(currNumColData[col.column]?.length){
31
- <app-line-graph-component
32
- [column]="col.column"
33
- [data]="col.data"
34
- [numCol]="currNumColNm[col.column]"
35
- (title)="col.title = $event"
36
- ></app-line-graph-component>
37
- }
38
- } @else {
39
- <app-column-chart
40
- [column]="col.column"
41
- [colData]="col.data"
42
- (bgTitle)="col.title = $event"
43
- ></app-column-chart>
44
- }
45
- </div>
46
- }
47
- </div>
48
- }
49
- </div>
50
- }
51
- </div>
52
- </div>
53
- </div>
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ChartsAndGraphs } from './charts-and-graphs';
4
-
5
- describe('ChartsAndGraphs', () => {
6
- let component: ChartsAndGraphs;
7
- let fixture: ComponentFixture<ChartsAndGraphs>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ChartsAndGraphs]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(ChartsAndGraphs);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,214 +0,0 @@
1
- import { Component, ElementRef, EventEmitter, Input, Output, signal, ViewChild } from '@angular/core';
2
- import { CommonService } from '../../../services/common-service';
3
- import { DataTableService } from '../../../services/data-table-service';
4
- import { ColumnChart } from '../column-chart/column-chart';
5
- import { LineGraphComponent } from '../line-graph-component/line-graph-component';
6
- import { CommonModule } from '@angular/common';
7
-
8
- @Component({
9
- selector: 'app-charts-and-graphs',
10
- imports: [ CommonModule, ColumnChart, LineGraphComponent, ],
11
- templateUrl: './charts-and-graphs.html',
12
- styleUrls: ['./charts-and-graphs.css', '../../../styles.css']
13
- })
14
- export class ChartsAndGraphs {
15
-
16
- chartsReady = signal<boolean>(false);
17
- rowIsAboveFold = signal<number[]>([0]);
18
- useData: any[] = []
19
- iRows: any[][] = []
20
- dtCols: string[] = [];
21
- numCols: string[] = [];
22
- filterInfo: string = ""
23
- currNumColData: any = {}//[] = []
24
- currNumColNm: any = {}//string = ""
25
- okBarGraphs: string[] = []
26
- okLineGraphs: string[] = []
27
- hasNoData: string[] = []
28
- @Input() height: string = "";
29
- @Input() state: string = "all";
30
- @Input() chartColumns: string[] = [];
31
- @Output("close") close: EventEmitter<boolean> = new EventEmitter();
32
- @ViewChild("xChartsBtn", { static: true }) xChartsBtn!: ElementRef<HTMLButtonElement>;
33
- @ViewChild("chartsTitle", { static: true }) chartsTitle!: ElementRef<HTMLHeadElement>;
34
- @ViewChild("chartContain", { static: true }) chartContain!: ElementRef<HTMLElement>;
35
- h2Text: string = ""
36
-
37
- constructor(public common: CommonService,
38
- public dataTableService: DataTableService,){ }
39
-
40
- ngOnInit() {
41
- if(this.state === "selected")
42
- this.useData = this.dataTableService.mainData.filter( (d, ind) => this.dataTableService.currSelRows.indexOf(ind) > -1 )
43
- else
44
- this.useData = this.dataTableService.currFilData//.filter( d => true )
45
- this.gatherRelationalPairs()
46
- const dLen = this.useData.length
47
- let filinfo = this.dataTableService.getAllFilSrtInfo()?.replace(/Filtered By:/g, "filtered by").
48
- replace(/ \&bull; Sorted By/g, ", Sorted By").replace(/ \&bull; /g, " ")
49
- this.h2Text = "Data Insights for <b>"+ dLen.toLocaleString(undefined, {maximumFractionDigits: 0}) + "</b>" +
50
- (this.state !== 'all' ? (' ' + this.common.titleCase(this.state)) : '') +" Rows ";
51
- if(filinfo){
52
- this.h2Text = ("Data Insights " + ("for <b>" + (dLen).toLocaleString(undefined, {maximumFractionDigits:0}) +
53
- "</b> row" + (dLen === 1 ? " " : "s ")) + filinfo?.split(", Sorted By")[0].trim())
54
- }
55
- }
56
-
57
- ngAfterViewInit() {
58
- setTimeout( () => {
59
- let r = 0; let c = 0; let u = 0; let o = 0
60
- let useChartCols: string[] = [];
61
- const usableCharts = this.chartColumns.filter( c => !this.hasNoData.includes(c))
62
- const uclen = usableCharts.length
63
- const nlen = this.numCols.length
64
- for(u; u < uclen; u++){
65
- const ucol = usableCharts[u]
66
- useChartCols.push(ucol)
67
- if(this.okBarGraphs.indexOf(ucol) > -1){
68
- for(o; o < nlen; o++)
69
- useChartCols.push(ucol + this.dataTableService.bgSep + this.numCols[o])
70
- o = 0;
71
- }
72
- if(this.okLineGraphs.indexOf(ucol) > -1){
73
- o = 0; let d = 0;
74
- const dtlen = this.dtCols.length
75
- for(o; o < nlen; o++){
76
- for(d; d < dtlen; d++)
77
- useChartCols.push(ucol + this.dataTableService.bgSep + this.numCols[o] + this.dataTableService.bgSep + this.dtCols[d])
78
- d = 0;
79
- }
80
- o = 0;
81
- }
82
- }
83
- const clen = useChartCols.length
84
- const cWid = this.chartContain.nativeElement.getBoundingClientRect().width
85
- const insightColsPerRow = cWid < 640 ? 1 : (cWid < 960 ? 2 : 3);
86
- const rlen = Math.ceil(clen/insightColsPerRow)
87
- for(r; r < rlen; r++){
88
- let i = 0
89
- this.iRows[r] = []
90
- for(i; i < insightColsPerRow; i++){
91
- const col = useChartCols[c]
92
- if(col){
93
- let title = this.common.titleCase(col)
94
- let mappedData: any[] = []
95
- const reg = new RegExp(this.dataTableService.bgSep, "g")
96
- if(reg.test(col)){
97
- const bgCols = col.split(this.dataTableService.bgSep)
98
- const strCol = bgCols[0]
99
- const numCol = bgCols[1]
100
- let dtCol
101
- if(bgCols.length === 3)//line graph
102
- dtCol = bgCols[2]
103
- if(!dtCol){//bar graph
104
- const valsLen = this.dataTableService.dataFilSrtTracker[strCol]?.selDDVals?.filter( (g: any) => g.value !== "(Select All)").length || 0;
105
- const doAvg = this.useData.length <= valsLen ? "" : "Avg ";
106
- title = doAvg + this.common.titleCase(numCol) + " by " + this.common.titleCase(strCol);
107
- mappedData = this.useData.filter( d => d[numCol] === 0 || !!d[numCol]).map( d => ({strColumn: (d[strCol] || "N/A"), numColumn: d[numCol]}))
108
- } else {//line graph
109
- title = "Avg " + this.common.titleCase(numCol) + " by " + this.common.titleCase(dtCol);
110
- mappedData = this.useData.filter( d => d[numCol] === 0 || !!d[numCol]).map( d => ({strColumn: (d[strCol] || "N/A"), numColumn: d[numCol], dtColumn: d[dtCol]}))
111
- }
112
- } else {
113
- if(this.dtCols.indexOf(col) > -1){
114
- const n0 = this.numCols[0]
115
- title = "Avg " + this.common.titleCase(n0) + " by " + this.common.titleCase(col);
116
- mappedData = this.useData.filter( d => d[n0] === 0 || !!d[n0]).map( d => ({numColumn: d[n0], dtColumn: d[col]}))
117
- } else {
118
- mappedData = this.useData.map( d => d[col] )
119
- }
120
- }
121
- this.iRows[r].push({ column: col, data: mappedData, title: title })
122
- c += 1
123
- }
124
- }
125
- }
126
- setTimeout( () => { this.chartsReady.set(true) })
127
- })
128
- }
129
-
130
- handleChartScroll(event: any) {
131
- let abv: number[] = []
132
- const xBtn= this.xChartsBtn.nativeElement
133
- const top = event.target.scrollTop
134
- const rows = document.getElementsByClassName("insight-field-row")
135
- const rlen = rows.length
136
- if(xBtn)
137
- xBtn.style.top = (7 + top) + "px"
138
- for(var i = (rlen-1); i >= 0; i--){
139
- const row: HTMLElement = <HTMLElement>rows[i]
140
- if(this.dataTableService.elIsAboveFold(row, this.dataTableService.tblBot) && !abv.includes(i) && !this.rowIsAboveFold().includes(i))
141
- abv.push(i)
142
- }
143
- this.rowIsAboveFold.set([...this.rowIsAboveFold(), ...abv])
144
- }
145
-
146
-
147
-
148
- gatherRelationalPairs() {//dot plots and bar graphs
149
- let i = 0;
150
- const len = this.chartColumns.length
151
- for(i; i < len; i++){
152
- const col = this.chartColumns[i]
153
- const colData = this.useData.map( (d) => d[col] )
154
- if(colData.every( (d: any) => !d )){
155
- this.hasNoData.push(col)
156
- continue;
157
- }
158
- const yearCol = /(year|yr|fy)/g.test(col?.toLocaleLowerCase())
159
- const allNumData = colData.every( (d: any) => !d || (d && typeof d === "number") )
160
- let bitData;
161
- if(allNumData)
162
- bitData = colData.every( (d: any) => !d || d === 1 || d === 0 )
163
- if(allNumData && !yearCol && !bitData){//num data
164
- this.numCols.push(col);
165
- } else {
166
- const dSet =new Set(colData)
167
- let arrFrmSet: any = []
168
- dSet.forEach( (v) => arrFrmSet.push(v) )
169
- const dateData = (colData.every( (d: any) => !d || this.common.isADateObject(d)) && !colData.every( (d: any) => !d ))
170
- if(dateData || yearCol)
171
- this.dtCols.push(col)
172
- }
173
- }
174
-
175
- if(this.numCols.length){
176
- for(const prop in this.dataTableService.dataFilSrtTracker){
177
- const trkr = this.dataTableService.dataFilSrtTracker[prop]
178
- if(trkr && trkr.selDDVals){
179
- this.okBarGraphs.push(prop)
180
- if(this.dtCols.length)
181
- this.okLineGraphs.push(prop)
182
- }
183
- }
184
- }
185
-
186
- const dtlen = this.dtCols.length
187
- if(dtlen && this.numCols.length && typeof document.querySelectorAll === "function"){
188
- let c = 0
189
- for(c; c < dtlen; c++){
190
- const dcol = this.dtCols[c]
191
- this.currNumColNm[dcol] = this.numCols[0]
192
- this.currNumColData[dcol] = [1]//this.useData.filter( d => !!d).map( (d) => d[this.numCols[0]] )* this was for dot plot, but now we use line graph
193
- }
194
- }
195
- }
196
-
197
- setLineGraphNumCol(rowI: number, dtCol: string, col: string) {
198
- this.currNumColData[dtCol] = []
199
- setTimeout( () => {
200
- this.currNumColNm[dtCol] = col
201
- const irow = this.iRows[rowI].find( i => i.column === dtCol)
202
- if(irow){
203
- this.iRows[rowI].find( i => i.column === dtCol).data = this.useData.filter( d => d[col] === 0 || !!d[col]).map( d => ({numColumn: d[col], dtColumn: d[dtCol]}))
204
- this.iRows[rowI].find( i => i.column === dtCol).title = "Avg " + this.common.titleCase(col) + " by " + this.common.titleCase(dtCol);
205
- }
206
- this.currNumColData[dtCol] = [1]//this.useData.filter( d => !!d).map( (d) => d[col] )* this was for dot plot, but now we use line graph
207
- })
208
- }
209
-
210
- closeCharts() {
211
- this.close.emit(false)
212
- }
213
-
214
- }
@@ -1,19 +0,0 @@
1
- div{
2
- box-sizing: border-box;
3
- padding:7px 7px 0 2px
4
- }
5
-
6
- .half-wid{
7
- padding: 0 !important;
8
- margin: 11px 0 7px 0;
9
- }
10
-
11
- .half-wid span{
12
- vertical-align: middle;
13
- }
14
-
15
- .vdh-loading{
16
- text-align: center;
17
- text-decoration: underline;
18
- padding: 33px 0px 17px 0px;
19
- }