Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
portal-apps-manage
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
angular
portal-apps-manage
Commits
f1458961
Commit
f1458961
authored
Oct 28, 2025
by
sawit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
แก้ไขเพิ่ม
parent
ed89bf27
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
6 deletions
+79
-6
bar-chart-widget.component.ts
...nt/widgets/bar-chart-widget/bar-chart-widget.component.ts
+30
-1
simple-kpi-widget.component.ts
.../widgets/simple-kpi-widget/simple-kpi-widget.component.ts
+6
-3
syncfusion-pivot-widget.component.ts
...cfusion-pivot-widget/syncfusion-pivot-widget.component.ts
+43
-2
No files found.
src/app/portal-manage/dashboard-management/widgets/bar-chart-widget/bar-chart-widget.component.ts
View file @
f1458961
...
@@ -17,6 +17,7 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
...
@@ -17,6 +17,7 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
public
primaryXAxis
:
Object
;
public
primaryXAxis
:
Object
;
public
primaryYAxis
:
Object
;
public
primaryYAxis
:
Object
;
public
dataLabel
:
Object
=
{};
constructor
(
protected
override
dashboardStateService
:
DashboardStateService
)
{
constructor
(
protected
override
dashboardStateService
:
DashboardStateService
)
{
super
(
dashboardStateService
);
super
(
dashboardStateService
);
...
@@ -28,6 +29,19 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
...
@@ -28,6 +29,19 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
this
.
primaryYAxis
=
{
title
:
this
.
configObj
.
yAxisTitle
||
''
};
this
.
primaryYAxis
=
{
title
:
this
.
configObj
.
yAxisTitle
||
''
};
this
.
type
=
this
.
configObj
.
type
||
'Column'
;
this
.
type
=
this
.
configObj
.
type
||
'Column'
;
this
.
chartData
=
[];
this
.
chartData
=
[];
// Configure data labels based on showDataLabels config
const
showDataLabels
=
this
.
configObj
.
showDataLabels
===
true
||
this
.
configObj
.
showDataLabels
===
'true'
;
if
(
showDataLabels
)
{
this
.
dataLabel
=
{
visible
:
true
,
position
:
'Top'
};
}
else
{
this
.
dataLabel
=
{
visible
:
false
};
}
}
}
onDataUpdate
(
data
:
any
[]):
void
{
onDataUpdate
(
data
:
any
[]):
void
{
...
@@ -37,6 +51,13 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
...
@@ -37,6 +51,13 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
return
;
return
;
}
}
// Update data label configuration based on config
const
showDataLabels
=
this
.
configObj
.
showDataLabels
===
true
||
this
.
configObj
.
showDataLabels
===
'true'
;
this
.
dataLabel
=
{
visible
:
showDataLabels
,
position
:
showDataLabels
?
'Top'
:
'Auto'
};
// Support multiple field name formats from config
// Support multiple field name formats from config
const
xField
=
this
.
configObj
.
xField
||
this
.
configObj
.
xAxisField
||
'x'
;
const
xField
=
this
.
configObj
.
xField
||
this
.
configObj
.
xAxisField
||
'x'
;
const
yField
=
this
.
configObj
.
yField
||
this
.
configObj
.
yAxisField
||
'y'
;
const
yField
=
this
.
configObj
.
yField
||
this
.
configObj
.
yAxisField
||
'y'
;
...
@@ -48,7 +69,8 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
...
@@ -48,7 +69,8 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
yField
,
yField
,
valueField
,
valueField
,
aggregation
:
this
.
configObj
.
aggregation
,
aggregation
:
this
.
configObj
.
aggregation
,
config
:
this
.
configObj
config
:
this
.
configObj
,
showDataLabels
});
});
// Handle aggregation if needed
// Handle aggregation if needed
...
@@ -62,6 +84,13 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
...
@@ -62,6 +84,13 @@ export class BarChartWidgetComponent extends BaseWidgetComponent {
}
}
}
}
console
.
log
(
'BarChart aggregation:'
,
{
original
:
this
.
configObj
.
aggregation
,
effective
:
effectiveAggregation
,
xField
,
valueField
});
if
(
effectiveAggregation
===
'sum'
||
effectiveAggregation
===
'count'
)
{
if
(
effectiveAggregation
===
'sum'
||
effectiveAggregation
===
'count'
)
{
const
groupedData
=
data
.
reduce
((
acc
,
item
)
=>
{
const
groupedData
=
data
.
reduce
((
acc
,
item
)
=>
{
const
key
=
item
[
xField
]
||
''
;
const
key
=
item
[
xField
]
||
''
;
...
...
src/app/portal-manage/dashboard-management/widgets/simple-kpi-widget/simple-kpi-widget.component.ts
View file @
f1458961
...
@@ -346,15 +346,18 @@ export class SimpleKpiWidgetComponent extends BaseWidgetComponent {
...
@@ -346,15 +346,18 @@ export class SimpleKpiWidgetComponent extends BaseWidgetComponent {
// Handle count aggregation separately as it doesn't need a valueField
// Handle count aggregation separately as it doesn't need a valueField
if
(
this
.
aggregation
===
'count'
)
{
if
(
this
.
aggregation
===
'count'
)
{
// If valueField is specified and it's a date/unique field, count unique values
// If valueField is specified and it's an ID field or date field, count unique values
if
(
this
.
valueField
&&
[
'dateid'
,
'date'
,
'datetime'
,
'day'
].
some
(
part
=>
this
.
valueField
.
toLowerCase
().
includes
(
part
)))
{
if
(
this
.
valueField
&&
([
'id'
,
'employeeid'
].
some
(
part
=>
this
.
valueField
.
toLowerCase
().
includes
(
part
))
||
[
'dateid'
,
'date'
,
'datetime'
,
'day'
].
some
(
part
=>
this
.
valueField
.
toLowerCase
().
includes
(
part
))))
{
// Count unique values instead of all records
// Count unique values instead of all records
const
uniqueValues
=
new
Set
(
transformedData
.
map
(
item
=>
item
[
this
.
valueField
]));
const
uniqueValues
=
new
Set
(
transformedData
.
map
(
item
=>
item
[
this
.
valueField
]));
this
.
value
=
uniqueValues
.
size
.
toLocaleString
();
this
.
value
=
uniqueValues
.
size
.
toLocaleString
();
console
.
log
(
`SimpleKpiWidget counting unique
${
this
.
valueField
}
:
${
uniqueValues
.
size
}
from
${
transformedData
.
length
}
records`
);
console
.
log
(
`SimpleKpiWidget counting unique
${
this
.
valueField
}
:
${
uniqueValues
.
size
}
unique values
from
${
transformedData
.
length
}
records`
);
}
else
{
}
else
{
// Regular count: count all records
// Regular count: count all records
this
.
value
=
(
transformedData
?.
length
||
0
).
toLocaleString
();
this
.
value
=
(
transformedData
?.
length
||
0
).
toLocaleString
();
console
.
log
(
`SimpleKpiWidget counting all records:
${
this
.
value
}
`
);
}
}
this
.
updateTrendData
(
transformedData
);
this
.
updateTrendData
(
transformedData
);
this
.
updateLabel
(
transformedData
);
this
.
updateLabel
(
transformedData
);
...
...
src/app/portal-manage/dashboard-management/widgets/syncfusion-pivot-widget/syncfusion-pivot-widget.component.ts
View file @
f1458961
...
@@ -386,10 +386,28 @@ export class SyncfusionPivotWidgetComponent extends BaseWidgetComponent implemen
...
@@ -386,10 +386,28 @@ export class SyncfusionPivotWidgetComponent extends BaseWidgetComponent implemen
getWidgetState
():
string
|
null
{
getWidgetState
():
string
|
null
{
if
(
this
.
pivotview
&&
this
.
pivotview
.
dataSourceSettings
)
{
if
(
this
.
pivotview
&&
this
.
pivotview
.
dataSourceSettings
)
{
const
report
=
this
.
pivotview
.
dataSourceSettings
;
const
report
=
this
.
pivotview
.
dataSourceSettings
;
// Convert values: if field name contains 'id' and type is 'Sum', change to 'Count'
const
processedValues
=
report
.
values
?.
map
(
v
=>
{
if
(
!
v
||
!
v
.
name
)
return
v
;
const
fieldLower
=
v
.
name
.
toLowerCase
();
let
type
=
v
.
type
;
// Auto-detect ID fields and change from Sum to Count
if
(
v
.
type
===
'Sum'
&&
(
fieldLower
.
includes
(
'id'
)
||
fieldLower
.
includes
(
'employee'
)
&&
fieldLower
.
includes
(
'id'
)))
{
type
=
'Count'
;
console
.
warn
(
`PivotWidget: Converting
${
v
.
name
}
from Sum to Count (ID field detected)`
);
}
return
{
name
:
v
.
name
,
type
};
})
||
[];
const
perspective
=
{
const
perspective
=
{
rows
:
report
.
rows
?.
map
(
r
=>
({
name
:
r
.
name
}))
||
[],
rows
:
report
.
rows
?.
map
(
r
=>
({
name
:
r
.
name
}))
||
[],
columns
:
report
.
columns
?.
map
(
c
=>
({
name
:
c
.
name
}))
||
[],
columns
:
report
.
columns
?.
map
(
c
=>
({
name
:
c
.
name
}))
||
[],
values
:
report
.
values
?.
map
(
v
=>
({
name
:
v
.
name
,
type
:
v
.
type
}))
||
[]
,
values
:
processedValues
,
filters
:
report
.
filters
?.
map
(
f
=>
({
name
:
f
.
name
}))
||
[],
filters
:
report
.
filters
?.
map
(
f
=>
({
name
:
f
.
name
}))
||
[],
chartSettings
:
{
chartSeries
:
{
type
:
(
this
.
pivotview
.
chartSettings
?.
chartSeries
as
any
)?.
type
||
(
this
.
chartSettings
?.
chartSeries
as
any
)?.
type
}
},
chartSettings
:
{
chartSeries
:
{
type
:
(
this
.
pivotview
.
chartSettings
?.
chartSeries
as
any
)?.
type
||
(
this
.
chartSettings
?.
chartSeries
as
any
)?.
type
}
},
};
};
...
@@ -402,11 +420,28 @@ export class SyncfusionPivotWidgetComponent extends BaseWidgetComponent implemen
...
@@ -402,11 +420,28 @@ export class SyncfusionPivotWidgetComponent extends BaseWidgetComponent implemen
if
(
state
&&
state
!==
'{}'
)
{
if
(
state
&&
state
!==
'{}'
)
{
try
{
try
{
const
perspective
=
JSON
.
parse
(
state
);
const
perspective
=
JSON
.
parse
(
state
);
// Process values: detect ID fields and change type
const
processedValues
=
(
perspective
.
values
||
[]).
map
((
v
:
any
)
=>
{
const
fieldLower
=
v
.
name
.
toLowerCase
();
let
type
=
v
.
type
;
// Auto-detect ID fields and change from Sum to Count
if
(
v
.
type
===
'Sum'
&&
(
fieldLower
.
includes
(
'id'
)
||
fieldLower
.
includes
(
'employee'
)
&&
fieldLower
.
includes
(
'id'
)))
{
type
=
'Count'
;
console
.
warn
(
`PivotWidget setState: Converting
${
v
.
name
}
from Sum to Count (ID field detected)`
);
}
return
{
name
:
v
.
name
,
type
};
});
this
.
dataSourceSettings
=
{
this
.
dataSourceSettings
=
{
...
this
.
dataSourceSettings
,
...
this
.
dataSourceSettings
,
rows
:
perspective
.
rows
||
[],
rows
:
perspective
.
rows
||
[],
columns
:
perspective
.
columns
||
[],
columns
:
perspective
.
columns
||
[],
values
:
p
erspective
.
values
||
[]
,
values
:
p
rocessedValues
,
filters
:
perspective
.
filters
||
[],
filters
:
perspective
.
filters
||
[],
};
};
if
(
perspective
.
chartSettings
)
{
if
(
perspective
.
chartSettings
)
{
...
@@ -454,6 +489,12 @@ export class SyncfusionPivotWidgetComponent extends BaseWidgetComponent implemen
...
@@ -454,6 +489,12 @@ export class SyncfusionPivotWidgetComponent extends BaseWidgetComponent implemen
// The refresh is implicitly handled by the dataBound event now
// The refresh is implicitly handled by the dataBound event now
}
}
// Apply perspective if exists (for auto-converting Sum to Count for ID fields)
if
(
this
.
perspective
&&
this
.
perspective
!==
'{}'
)
{
console
.
log
(
'PivotWidget onDataUpdate: Applying perspective'
,
this
.
perspective
);
this
.
setWidgetState
(
this
.
perspective
as
string
);
}
// Update loading and error states
// Update loading and error states
this
.
isLoading
=
false
;
this
.
isLoading
=
false
;
this
.
hasError
=
false
;
this
.
hasError
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment