ngx-deebodata 0.0.2 → 0.0.3
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/fesm2022/ngx-deebodata.mjs +6863 -0
- package/fesm2022/ngx-deebodata.mjs.map +1 -0
- package/package.json +35 -16
- package/types/ngx-deebodata.d.ts +439 -0
- package/ng-package.json +0 -7
- package/src/lib/data-table/charts/bar-graph-component/bar-graph-component.css +0 -156
- package/src/lib/data-table/charts/bar-graph-component/bar-graph-component.html +0 -29
- package/src/lib/data-table/charts/bar-graph-component/bar-graph-component.spec.ts +0 -23
- package/src/lib/data-table/charts/bar-graph-component/bar-graph-component.ts +0 -286
- package/src/lib/data-table/charts/charts-and-graphs/charts-and-graphs.css +0 -27
- package/src/lib/data-table/charts/charts-and-graphs/charts-and-graphs.html +0 -53
- package/src/lib/data-table/charts/charts-and-graphs/charts-and-graphs.spec.ts +0 -23
- package/src/lib/data-table/charts/charts-and-graphs/charts-and-graphs.ts +0 -214
- package/src/lib/data-table/charts/column-chart/column-chart.css +0 -19
- package/src/lib/data-table/charts/column-chart/column-chart.html +0 -47
- package/src/lib/data-table/charts/column-chart/column-chart.spec.ts +0 -23
- package/src/lib/data-table/charts/column-chart/column-chart.ts +0 -178
- package/src/lib/data-table/charts/line-graph-component/line-graph-component.css +0 -33
- package/src/lib/data-table/charts/line-graph-component/line-graph-component.html +0 -59
- package/src/lib/data-table/charts/line-graph-component/line-graph-component.spec.ts +0 -23
- package/src/lib/data-table/charts/line-graph-component/line-graph-component.ts +0 -661
- package/src/lib/data-table/charts/num-value-distro-component/num-value-distro-component.css +0 -61
- package/src/lib/data-table/charts/num-value-distro-component/num-value-distro-component.html +0 -27
- package/src/lib/data-table/charts/num-value-distro-component/num-value-distro-component.spec.ts +0 -23
- package/src/lib/data-table/charts/num-value-distro-component/num-value-distro-component.ts +0 -210
- package/src/lib/data-table/charts/pie-graph-component/pie-graph-component.css +0 -0
- package/src/lib/data-table/charts/pie-graph-component/pie-graph-component.html +0 -15
- package/src/lib/data-table/charts/pie-graph-component/pie-graph-component.spec.ts +0 -23
- package/src/lib/data-table/charts/pie-graph-component/pie-graph-component.ts +0 -197
- package/src/lib/data-table/data-table-module/data-cell/data-cell.css +0 -0
- package/src/lib/data-table/data-table-module/data-cell/data-cell.html +0 -6
- package/src/lib/data-table/data-table-module/data-cell/data-cell.spec.ts +0 -23
- package/src/lib/data-table/data-table-module/data-cell/data-cell.ts +0 -271
- package/src/lib/data-table/data-table-module/data-table-header/data-table-header.css +0 -25
- package/src/lib/data-table/data-table-module/data-table-header/data-table-header.html +0 -55
- package/src/lib/data-table/data-table-module/data-table-header/data-table-header.spec.ts +0 -23
- package/src/lib/data-table/data-table-module/data-table-header/data-table-header.ts +0 -261
- package/src/lib/data-table/data-table-module/data-table-paginator/data-table-paginator.css +0 -69
- package/src/lib/data-table/data-table-module/data-table-paginator/data-table-paginator.html +0 -24
- package/src/lib/data-table/data-table-module/data-table-paginator/data-table-paginator.spec.ts +0 -23
- package/src/lib/data-table/data-table-module/data-table-paginator/data-table-paginator.ts +0 -125
- package/src/lib/data-table/data-table-module/export-component/export-component.css +0 -91
- package/src/lib/data-table/data-table-module/export-component/export-component.html +0 -16
- package/src/lib/data-table/data-table-module/export-component/export-component.spec.ts +0 -23
- package/src/lib/data-table/data-table-module/export-component/export-component.ts +0 -206
- package/src/lib/data-table/data-table-module/ngx-deebodata/ngx-deebodata.css +0 -91
- package/src/lib/data-table/data-table-module/ngx-deebodata/ngx-deebodata.html +0 -193
- package/src/lib/data-table/data-table-module/ngx-deebodata/ngx-deebodata.spec.ts +0 -23
- package/src/lib/data-table/data-table-module/ngx-deebodata/ngx-deebodata.ts +0 -2226
- package/src/lib/data-table/data-table-module/row-group-menu/row-group-menu.css +0 -14
- package/src/lib/data-table/data-table-module/row-group-menu/row-group-menu.html +0 -27
- package/src/lib/data-table/data-table-module/row-group-menu/row-group-menu.spec.ts +0 -23
- package/src/lib/data-table/data-table-module/row-group-menu/row-group-menu.ts +0 -58
- package/src/lib/data-table/data-table-module/row-group-panel/row-group-panel.css +0 -23
- package/src/lib/data-table/data-table-module/row-group-panel/row-group-panel.html +0 -48
- package/src/lib/data-table/data-table-module/row-group-panel/row-group-panel.spec.ts +0 -23
- package/src/lib/data-table/data-table-module/row-group-panel/row-group-panel.ts +0 -599
- package/src/lib/data-table/data-table-module/worker.worker.ts +0 -44
- package/src/lib/interfaces/cell-edit.ts +0 -5
- package/src/lib/interfaces/column-header.ts +0 -10
- package/src/lib/interfaces/column-styles.ts +0 -14
- package/src/lib/interfaces/column-symbol.ts +0 -4
- package/src/lib/interfaces/data-cell.ts +0 -14
- package/src/lib/interfaces/data-row.ts +0 -11
- package/src/lib/interfaces/row-number.ts +0 -4
- package/src/lib/services/common-service.spec.ts +0 -16
- package/src/lib/services/common-service.ts +0 -336
- package/src/lib/services/data-table-service.spec.ts +0 -16
- package/src/lib/services/data-table-service.ts +0 -597
- package/src/lib/services/table-drag-service.spec.ts +0 -16
- package/src/lib/services/table-drag-service.ts +0 -347
- package/src/lib/styles.css +0 -1065
- package/src/public-api.ts +0 -8
- package/tsconfig.lib.json +0 -17
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
|
@@ -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,286 +0,0 @@
|
|
|
1
|
-
import { Component, ElementRef, EventEmitter, Input, ViewChild, Output, HostListener, signal, NgZone } 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
|
-
showing: boolean = false
|
|
25
|
-
buildingStat: boolean = false
|
|
26
|
-
maxYVal: string = "0";
|
|
27
|
-
statData: any[] = []
|
|
28
|
-
selStat = signal<string>("avg")
|
|
29
|
-
numYPlots: number = 5
|
|
30
|
-
bgDepVarHgt: number = 70//height of y ticks
|
|
31
|
-
statOpts: string[] = ["avg", "min", "max", "mode", "median", "sum"]
|
|
32
|
-
statBtnWid: string = "30px"
|
|
33
|
-
titleTrail: string = ""
|
|
34
|
-
@Input() column: string = ""
|
|
35
|
-
@Input() data: any[] = []
|
|
36
|
-
@Output("title") title: EventEmitter<string> = new EventEmitter();
|
|
37
|
-
@ViewChild("innerGB", { static: true }) innerGB!: ElementRef;
|
|
38
|
-
@ViewChild("xLabel", { static: true }) xLabel!: ElementRef;
|
|
39
|
-
@ViewChild("xValues", { static: true }) xValues!: ElementRef;
|
|
40
|
-
@ViewChild("yAxis", { static: true }) yAxis!: ElementRef;
|
|
41
|
-
@ViewChild("statOptsCont", { static: true }) statOptsCont!: ElementRef;
|
|
42
|
-
@ViewChild("barContainer", { static: true }) barContainer!: ElementRef;
|
|
43
|
-
|
|
44
|
-
constructor(public common: CommonService,
|
|
45
|
-
private dataTableService: DataTableService,
|
|
46
|
-
private _zone: NgZone,
|
|
47
|
-
){ }
|
|
48
|
-
|
|
49
|
-
ngOnInit() {
|
|
50
|
-
this.buildBarGraphWithTwoCols(this.selStat())
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
ngAfterContentInit() {
|
|
54
|
-
this.handleBGBarHgts(this.statData)
|
|
55
|
-
setTimeout( () => { this.sizeUpBgDims() })
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
sizeUpBgDims() {
|
|
59
|
-
const bgWid = this.innerGB.nativeElement.getBoundingClientRect().width
|
|
60
|
-
const yWid = this.yAxis.nativeElement.getBoundingClientRect().width
|
|
61
|
-
const offY = Math.ceil(yWid+5)
|
|
62
|
-
this.statBtnWid = Math.floor((bgWid-offY)/this.statOpts.length) + "px";
|
|
63
|
-
this.statOptsCont.nativeElement.style.marginLeft = offY + "px";
|
|
64
|
-
this.xValues.nativeElement.style.marginLeft = offY + "px";
|
|
65
|
-
this.barContainer.nativeElement.style.marginLeft = offY + "px";
|
|
66
|
-
this.xLblWidth = Math.min(this.maxBarWid, (Math.floor((bgWid-offY)/this.xLabels.length))) + "px";
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
buildBarGraphWithTwoCols(stat: string) {
|
|
70
|
-
const bgCols = this.column.split(this.dataTableService.bgSep)
|
|
71
|
-
const strCol = bgCols[0]
|
|
72
|
-
const numCol = bgCols[1]
|
|
73
|
-
if(!this.titleTrail)
|
|
74
|
-
this.titleTrail = this.common.titleCase(numCol) + " by " + this.common.titleCase(strCol);
|
|
75
|
-
const vals = this.dataTableService.dataFilSrtTracker[strCol].selDDVals.filter( (g: any) => g.value !== "(Select All)")
|
|
76
|
-
const vlen = vals.length
|
|
77
|
-
let o = 0
|
|
78
|
-
for(o; o < vlen; o++){
|
|
79
|
-
const val = vals[o].value
|
|
80
|
-
const justVal = this.data.filter( d => d["strColumn"] === val).map( d => d["numColumn"] )
|
|
81
|
-
const jvlen = justVal.length
|
|
82
|
-
if(jvlen){//["avg", "min", "max", "mode", "median", "sum"]
|
|
83
|
-
let statobj = {x: val, y: 0}
|
|
84
|
-
if(stat === "avg")
|
|
85
|
-
statobj.y = (justVal.reduce( (acc, curr) => (acc += curr) , 0)/jvlen)
|
|
86
|
-
if(stat === "min")
|
|
87
|
-
statobj.y = Math.min(...justVal)
|
|
88
|
-
if(stat === "max")
|
|
89
|
-
statobj.y = Math.max(...justVal)
|
|
90
|
-
if(stat === "sum")
|
|
91
|
-
statobj.y = (justVal.reduce( (acc, curr) => (acc += curr) , 0))
|
|
92
|
-
if(stat === "median")
|
|
93
|
-
statobj.y = this.findDataMedian(justVal, jvlen)
|
|
94
|
-
if(stat === "mode")
|
|
95
|
-
statobj.y = this.findDataMode(justVal)
|
|
96
|
-
this.statData.push(statobj)
|
|
97
|
-
this.xLabels.push(val)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const justNull = this.data.filter( d => d["strColumn"] === "N/A").map( d => d["numColumn"] )
|
|
101
|
-
const jlen = justNull.length
|
|
102
|
-
if(jlen){
|
|
103
|
-
let statobj = {x: "N/A", y: 0}
|
|
104
|
-
if(stat === "avg")
|
|
105
|
-
statobj.y = (justNull.reduce( (acc, curr) => (acc += curr) , 0)/jlen)
|
|
106
|
-
if(stat === "min")
|
|
107
|
-
statobj.y = Math.min(...justNull)
|
|
108
|
-
if(stat === "max")
|
|
109
|
-
statobj.y = Math.max(...justNull)
|
|
110
|
-
if(stat === "sum")
|
|
111
|
-
statobj.y = (justNull.reduce( (acc, curr) => (acc += curr) , 0))
|
|
112
|
-
if(stat === "median")
|
|
113
|
-
statobj.y = this.findDataMedian(justNull, jlen)
|
|
114
|
-
if(stat === "mode")
|
|
115
|
-
statobj.y = this.findDataMode(justNull)
|
|
116
|
-
this.statData.push(statobj)
|
|
117
|
-
this.xLabels.push("N/A")
|
|
118
|
-
}
|
|
119
|
-
const par = this.innerGB.nativeElement
|
|
120
|
-
const nums = this.statData.map( d => d["y"] );
|
|
121
|
-
let srtNums = nums.sort( (a, b) => a - b > 0 ? 1 : -1 )
|
|
122
|
-
const max = srtNums[(nums.length-1)]
|
|
123
|
-
let lbly = this.common.sanitizeUi(numCol)
|
|
124
|
-
const sym = this.dataTableService.dataFilSrtTracker[numCol].colCellSymbol
|
|
125
|
-
if(sym)
|
|
126
|
-
lbly += " ("+sym+")";
|
|
127
|
-
par.setAttribute("data-yaxis", lbly)
|
|
128
|
-
this.xLabel.nativeElement.textContent = this.common.sanitizeUi(this.common.titleCase(strCol))
|
|
129
|
-
this.buildYAxisBGVals(max)
|
|
130
|
-
setTimeout( () => { this.buildBGBars(this.statData, max, sym) })
|
|
131
|
-
setTimeout( () => { this.buildingStat = false }, 500)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
buildBGBars(data: any[], max: number, sym: any) {
|
|
135
|
-
let i = 0
|
|
136
|
-
const len = data.length
|
|
137
|
-
let background: string = "initial"
|
|
138
|
-
const yAx = this.yAxis.nativeElement
|
|
139
|
-
const ybds = yAx.getBoundingClientRect()
|
|
140
|
-
const yWid = ybds.width
|
|
141
|
-
const offY = Math.ceil(yWid+5)
|
|
142
|
-
const whiteTxt = ["white", "#FFFFFF", "#ffffff", "rgb(255, 255, 255)", "rgb(255,255,255)"];
|
|
143
|
-
if(this.dataTableService.themeColor1 && whiteTxt.indexOf(this.dataTableService.themeColor1) < 0)
|
|
144
|
-
background = this.dataTableService.themeColor1;
|
|
145
|
-
const useIncr = Math.min(this.maxBarWid, (Math.floor((this.innerGB.nativeElement.getBoundingClientRect().width-offY)/this.xLabels.length)))
|
|
146
|
-
for(i; i < len; i++){
|
|
147
|
-
const item = data[i]
|
|
148
|
-
const bhgt = item["y"]/max;
|
|
149
|
-
const strVal = item["y"].toLocaleString(undefined, {maximumFractionDigits: 2})
|
|
150
|
-
let symb4 = ""
|
|
151
|
-
let symaf = ""
|
|
152
|
-
if(sym){
|
|
153
|
-
let isCurr = ["$","€","£","¥","₣","₹"].indexOf(sym) > -1
|
|
154
|
-
if(isCurr)
|
|
155
|
-
symb4 = sym
|
|
156
|
-
else
|
|
157
|
-
symaf = sym
|
|
158
|
-
}
|
|
159
|
-
const fVal = item["x"] + ': ' + symb4 + strVal + symaf;
|
|
160
|
-
const bv = { id: item["x"], left: ((i*useIncr) + "px"), heightVal: bhgt, height: "0px", fullValue: fVal, numValue: strVal, background: background}
|
|
161
|
-
this.barVals.push(bv);
|
|
162
|
-
}
|
|
163
|
-
this.handleBGBarHgts(data)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
handleBGBarHgts(data: any[]) {
|
|
167
|
-
let i = 0
|
|
168
|
-
let show = false
|
|
169
|
-
const len = data.length
|
|
170
|
-
const ybds = this.yAxis.nativeElement.getBoundingClientRect()
|
|
171
|
-
const maxHgt = ybds.height
|
|
172
|
-
const cont = document.getElementById("insField" + this.common.elifyCol(this.column))
|
|
173
|
-
const cBds = cont?.getBoundingClientRect()
|
|
174
|
-
const insTop = document.getElementsByClassName("chart-contain-show")[0]?.scrollTop || 0;
|
|
175
|
-
if(cBds && (cBds.bottom-(cBds.height/2)) < (this.dataTableService.tblTop+insTop+this.dataTableService.dTblHeight))
|
|
176
|
-
show = true;
|
|
177
|
-
if(show){
|
|
178
|
-
for(i; i < len; i++){
|
|
179
|
-
const item = data[i]
|
|
180
|
-
const xvalue = item["x"]
|
|
181
|
-
const bv = this.barVals.find( b => b.id === xvalue)
|
|
182
|
-
if(bv){
|
|
183
|
-
this.showing = true
|
|
184
|
-
setTimeout( () => {
|
|
185
|
-
this._zone.run( () => { bv.height = (Math.ceil(bv.heightVal*maxHgt) + "px"); this.barVals = [...this.barVals] });
|
|
186
|
-
}, 250 )
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
buildYAxisBGVals(max: number) {
|
|
193
|
-
let nts: string[] = []
|
|
194
|
-
// let diff = max - min
|
|
195
|
-
const incr = max/(this.numYPlots-1)
|
|
196
|
-
const strNum = (val: number) => {
|
|
197
|
-
return val < 1000 ? val.toLocaleString(undefined, {maximumFractionDigits: 0}) : this.common.doBigData(val);
|
|
198
|
-
}
|
|
199
|
-
for(let i = (this.numYPlots-1); i >= 0; i--){
|
|
200
|
-
try{
|
|
201
|
-
const inc = i*incr
|
|
202
|
-
let useVal = inc//(min + inc)
|
|
203
|
-
if(i === 0)
|
|
204
|
-
useVal = 0//min
|
|
205
|
-
if(i === (this.numYPlots-1))
|
|
206
|
-
useVal = max
|
|
207
|
-
const strVal = strNum(useVal);
|
|
208
|
-
if(i === (this.numYPlots-1))
|
|
209
|
-
this.maxYVal = strVal
|
|
210
|
-
nts.push(strVal)
|
|
211
|
-
}catch(e){}
|
|
212
|
-
}
|
|
213
|
-
this.numTicks.set([...nts])
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
handleStatChange(stat: string, resize?: boolean) {
|
|
217
|
-
if(this.selStat() === stat && !resize)
|
|
218
|
-
return;
|
|
219
|
-
this.buildingStat = true
|
|
220
|
-
this.maxYVal = "0"
|
|
221
|
-
this.selStat.set(stat)
|
|
222
|
-
this.numTicks.set([])
|
|
223
|
-
this.barVals = []
|
|
224
|
-
this.xLabels = []
|
|
225
|
-
this.statData = []
|
|
226
|
-
if(!resize)
|
|
227
|
-
this.title.emit(this.common.titleCase(stat) + " " + this.titleTrail);
|
|
228
|
-
setTimeout( () => {
|
|
229
|
-
this.buildBarGraphWithTwoCols(stat);
|
|
230
|
-
setTimeout( () => { this.sizeUpBgDims() })
|
|
231
|
-
})
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
findDataMedian(data: number[], len: number): number {
|
|
235
|
-
if(len === 1)
|
|
236
|
-
return data[0]
|
|
237
|
-
if(len === 2)
|
|
238
|
-
return (data[0]+data[1])/2
|
|
239
|
-
const isOdd = len%2 !== 0
|
|
240
|
-
if(isOdd){
|
|
241
|
-
return data[Math.ceil(len/2)]
|
|
242
|
-
} else {
|
|
243
|
-
const loMed = data[len/2]
|
|
244
|
-
const hiMed = data[len/2] + 1
|
|
245
|
-
return (loMed+hiMed)/2
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
getColumnValueCounts(data: any[]) {
|
|
250
|
-
let i = 0
|
|
251
|
-
let count: any = {}
|
|
252
|
-
const len = data.length
|
|
253
|
-
for(i; i < len; i++){
|
|
254
|
-
const d = data[i]
|
|
255
|
-
const val = "v" + d
|
|
256
|
-
if(!count[val] || typeof count[val] === "undefined")
|
|
257
|
-
count[val] = 1
|
|
258
|
-
else
|
|
259
|
-
count[val] += 1
|
|
260
|
-
}
|
|
261
|
-
return count;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
findDataMode(data: any[]): number {
|
|
265
|
-
const count = this.getColumnValueCounts(data)
|
|
266
|
-
let most = null
|
|
267
|
-
for(const prop in count){
|
|
268
|
-
if(!most)
|
|
269
|
-
most = {text: prop, amount: count[prop]}
|
|
270
|
-
if(count[prop] > most.amount)
|
|
271
|
-
most = {text: prop, amount: count[prop]}
|
|
272
|
-
}
|
|
273
|
-
if(most)
|
|
274
|
-
return parseInt(most?.text.replace("v", ""))
|
|
275
|
-
return 0;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
lblMouseIn(el: any) {
|
|
279
|
-
el.classList.add("lbl-show")
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
lblMouseOut(el: any) {
|
|
283
|
-
el.classList.remove("lbl-show")
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
}
|
|
@@ -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(/ \• Sorted By/g, ", Sorted By").replace(/ \• /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
|
-
}
|