@a.nemreen/dga-ui 0.3.13 → 0.3.14
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/README.md +4 -0
- package/fesm2022/a.nemreen-dga-ui-chart.mjs +445 -0
- package/fesm2022/a.nemreen-dga-ui-chatbot.mjs +295 -0
- package/fesm2022/a.nemreen-dga-ui-dga-icon-registry-sBZfCS6q.mjs +1 -0
- package/fesm2022/a.nemreen-dga-ui-page-transition.mjs +1 -0
- package/fesm2022/a.nemreen-dga-ui-saudi-cities.mjs +1 -0
- package/fesm2022/a.nemreen-dga-ui.mjs +303 -949
- package/package.json +17 -1
- package/types/a.nemreen-dga-ui-chart.d.ts +157 -0
- package/types/a.nemreen-dga-ui-chatbot.d.ts +102 -0
- package/types/a.nemreen-dga-ui-cookies.d.ts +1 -2
- package/types/a.nemreen-dga-ui-page-transition.d.ts +51 -0
- package/types/a.nemreen-dga-ui-saudi-cities.d.ts +19 -0
- package/types/a.nemreen-dga-ui.d.ts +32 -336
package/README.md
CHANGED
|
@@ -64,6 +64,10 @@ Heavier shell pieces ship as separate FESMs so the primary bundle stays lean:
|
|
|
64
64
|
import { DgaHeader } from '@a.nemreen/dga-ui/header';
|
|
65
65
|
import { DgaCookies } from '@a.nemreen/dga-ui/cookies';
|
|
66
66
|
import { DgaDatePicker } from '@a.nemreen/dga-ui/date-picker';
|
|
67
|
+
import { DgaChart } from '@a.nemreen/dga-ui/chart';
|
|
68
|
+
import { DgaChatbot } from '@a.nemreen/dga-ui/chatbot';
|
|
69
|
+
import { DgaPageTransition } from '@a.nemreen/dga-ui/page-transition';
|
|
70
|
+
import { DGA_SAUDI_CITIES } from '@a.nemreen/dga-ui/saudi-cities';
|
|
67
71
|
```
|
|
68
72
|
|
|
69
73
|
Accessibility tools live in a separate package — [`@a.nemreen/a11y`](https://www.npmjs.com/package/@a.nemreen/a11y) — mount with `Accessibility.mount()`.
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import*as r from"@angular/core";import{input as c,booleanAttribute as y,signal as w,computed as o,ChangeDetectionStrategy as P,Component as D}from"@angular/core";import{dgaSafeCssColor as $}from"@a.nemreen/dga-ui";const N=["#1b8354","#3b82f6","#f59e0b","#ef4444","#64748b","#0d9488"];class S{type=c("bar",...ngDevMode?[{debugName:"type"}]:[]);series=c([],...ngDevMode?[{debugName:"series"}]:[]);labels=c([],...ngDevMode?[{debugName:"labels"}]:[]);datasets=c([],...ngDevMode?[{debugName:"datasets"}]:[]);legend=c(!0,{...ngDevMode?{debugName:"legend"}:{},transform:y});tooltip=c(!0,{...ngDevMode?{debugName:"tooltip"}:{},transform:y});grid=c(!0,{...ngDevMode?{debugName:"grid"}:{},transform:y});stacked=c(!1,{...ngDevMode?{debugName:"stacked"}:{},transform:y});smooth=c(!0,{...ngDevMode?{debugName:"smooth"}:{},transform:y});area=c(!1,{...ngDevMode?{debugName:"area"}:{},transform:y});dots=c(!0,{...ngDevMode?{debugName:"dots"}:{},transform:y});colors=c([],...ngDevMode?[{debugName:"colors"}]:[]);tooltipValueLabel=c("القيمة",...ngDevMode?[{debugName:"tooltipValueLabel"}]:[]);height=c(220,...ngDevMode?[{debugName:"height"}]:[]);label=c("رسم بياني",...ngDevMode?[{debugName:"label"}]:[]);width=400;pieSize=180;pad={t:16,r:12,b:28,l:36};hiddenNames=w(new Set,...ngDevMode?[{debugName:"hiddenNames"}]:[]);hiddenSeries=this.hiddenNames.asReadonly();hoveredCategoryIndex=w(null,...ngDevMode?[{debugName:"hoveredCategoryIndex"}]:[]);hoveredSlice=w(null,...ngDevMode?[{debugName:"hoveredSlice"}]:[]);isPieType=o(()=>this.type()==="pie"||this.type()==="donut",...ngDevMode?[{debugName:"isPieType"}]:[]);categories=o(()=>{if(this.labels().length)return this.labels();const e=this.datasets();if(e.length){const t=e.reduce((a,i)=>Math.max(a,i.data.length),0);return Array.from({length:t},(a,i)=>String(i+1))}return this.series().map(t=>t.label)},...ngDevMode?[{debugName:"categories"}]:[]);seriesList=o(()=>{const e=this.datasets();if(e.length)return e;const t=this.series();return t.length?[{name:this.label()||"",data:t.map(a=>a.value)}]:[]},...ngDevMode?[{debugName:"seriesList"}]:[]);visibleSeriesList=o(()=>this.seriesList().filter(e=>!this.hiddenNames().has(e.name)),...ngDevMode?[{debugName:"visibleSeriesList"}]:[]);piePoints=o(()=>{if(this.series().length)return this.series();const e=this.datasets();if(e.length){const t=this.labels();return e[0].data.map((a,i)=>({label:t[i]??String(i+1),value:a}))}return[]},...ngDevMode?[{debugName:"piePoints"}]:[]);visiblePiePoints=o(()=>this.piePoints().filter(e=>!this.hiddenNames().has(e.label)),...ngDevMode?[{debugName:"visiblePiePoints"}]:[]);showLegend=o(()=>this.legend()&&(this.isPieType()||this.seriesList().length>1),...ngDevMode?[{debugName:"showLegend"}]:[]);legendItems=o(()=>this.isPieType()?this.piePoints().map((e,t)=>({name:e.label,color:this.colorFor(t),value:e.value})):this.seriesList().map((e,t)=>({name:e.name,color:this.colorFor(t),value:null})),...ngDevMode?[{debugName:"legendItems"}]:[]);colorFor(e){const t=`var(--dga-chart-color-${e%6+1}, ${N[e%N.length]})`,a=this.colors()[e];return a?$(a,t):t}toggleSeries(e){this.hiddenNames.update(t=>{const a=this.isPieType()?this.piePoints().length:this.seriesList().length,i=new Set(t);return i.has(e)?i.delete(e):i.add(e),i.size>=a?t:i})}ariaLabel=o(()=>{const e=this.type()==="bar"?"أعمدة":this.type()==="line"?"خطي":this.type()==="donut"?"حلقي":"دائري",t=this.isPieType()?this.piePoints().map(a=>`${a.label}: ${a.value}`):this.seriesList().flatMap(a=>a.data.map((i,l)=>`${a.name?a.name+" ":""}${this.categories()[l]??l+1}: ${i}`));return`${this.label()} (${e}). ${t.join("، ")}`},...ngDevMode?[{debugName:"ariaLabel"}]:[]);plot=o(()=>{const e=this.height(),{t,r:a,b:i,l}=this.pad;return{x:l,y:t,w:this.width-l-a,h:e-t-i}},...ngDevMode?[{debugName:"plot"}]:[]);gridYs=o(()=>{const{y:e,h:t}=this.plot();return[e,e+t/2,e+t]},...ngDevMode?[{debugName:"gridYs"}]:[]);maxValue=o(()=>{const e=this.visibleSeriesList();if(!e.length)return 1;if(this.type()==="bar"&&this.stacked()){const a=this.categories().length;let i=0;for(let l=0;l<a;l++){let s=0;for(const d of e)s+=Math.max(0,d.data[l]??0);i=Math.max(i,s)}return i<=0?1:i}let t=0;for(const a of e)for(const i of a.data)t=Math.max(t,i);return t<=0?1:t},...ngDevMode?[{debugName:"maxValue"}]:[]);groupLayout=o(()=>{const{x:e,w:t}=this.plot(),a=Math.max(this.categories().length,1),i=12,l=Math.max(4,(t-i*(a-1))/a);return{x:e,groupW:l,groupGap:i,n:a}},...ngDevMode?[{debugName:"groupLayout"}]:[]);categoryTicks=o(()=>{const e=this.categories(),{x:t,groupW:a,groupGap:i}=this.groupLayout();return e.map((l,s)=>({index:s,category:l,x:t+s*(a+i)+a/2,hitX:t+s*(a+i),hitW:a}))},...ngDevMode?[{debugName:"categoryTicks"}]:[]);bars=o(()=>{const e=this.visibleSeriesList(),t=this.categories(),{y:a,h:i}=this.plot(),{x:l,groupW:s,groupGap:d}=this.groupLayout(),u=this.maxValue(),h=this.stacked(),b=e.length>1&&!h?4:0,m=h?s:Math.max(2,(s-b*Math.max(e.length-1,0))/Math.max(e.length,1)),v=[];for(let n=0;n<t.length;n++){const x=l+n*(s+d);if(h){let g=a+i;for(let p=0;p<e.length;p++){const f=e[p].data[n]??0,k=Math.max(0,f)/u*i;g-=k,v.push({seriesIndex:p,categoryIndex:n,x,y:g,w:m,h:k,value:f,color:this.colorFor(p),name:e[p].name,category:t[n]})}}else for(let g=0;g<e.length;g++){const p=e[g].data[n]??0,f=Math.max(0,p)/u*i;v.push({seriesIndex:g,categoryIndex:n,x:x+g*(m+b),y:a+i-f,w:m,h:f,value:p,color:this.colorFor(g),name:e[g].name,category:t[n]})}}return v},...ngDevMode?[{debugName:"bars"}]:[]);visibleLines=o(()=>{const e=this.visibleSeriesList(),t=this.categories(),{x:a,y:i,w:l,h:s}=this.plot(),d=this.maxValue(),u=t.length;if(!u)return[];const h=this.smooth(),b=i+s;return e.map((m,v)=>{const n=m.data.slice(0,u).map((f,k)=>{const M=u===1?a+l/2:a+k/(u-1)*l,L=i+s-Math.max(0,f)/d*s;return{x:M,y:L,value:f,category:t[k]}}),x=this.colorFor(v),g=h?this.smoothPathD(n):this.straightPathD(n),p=n.length>1?this.areaPathD(n,b,h):"";return{name:m.name,color:x,points:n,linePath:g,areaPath:p}})},...ngDevMode?[{debugName:"visibleLines"}]:[]);straightPathD(e){return e.length?e.map((t,a)=>`${a===0?"M":"L"} ${t.x} ${t.y}`).join(" "):""}smoothPathD(e){if(e.length<2)return e.length===1?`M ${e[0].x} ${e[0].y}`:"";const t=[`M ${e[0].x} ${e[0].y}`];for(let a=0;a<e.length-1;a++){const i=e[a===0?0:a-1],l=e[a],s=e[a+1],d=e[a+2<e.length?a+2:e.length-1],u=l.x+(s.x-i.x)/6,h=l.y+(s.y-i.y)/6,b=s.x-(d.x-l.x)/6,m=s.y-(d.y-l.y)/6;t.push(`C ${u} ${h}, ${b} ${m}, ${s.x} ${s.y}`)}return t.join(" ")}areaPathD(e,t,a){const i=a?this.smoothPathD(e):this.straightPathD(e),l=e[0],s=e[e.length-1];return`${i} L ${s.x} ${t} L ${l.x} ${t} Z`}pieSlices=o(()=>{const e=this.visiblePiePoints(),t=e.reduce((d,u)=>d+Math.max(0,u.value),0)||1,a=this.pieSize/2,i=this.pieSize/2,l=this.pieSize*.42;let s=-Math.PI/2;return e.map((d,u)=>{const h=Math.max(0,d.value)/t*Math.PI*2,b=s,m=s+h;s=m;const v=h>Math.PI?1:0,n=a+l*Math.cos(b),x=i+l*Math.sin(b),g=a+l*Math.cos(m),p=i+l*Math.sin(m),f=b+h/2;return{index:u,label:d.label,value:d.value,color:this.colorFor(u),d:`M ${a} ${i} L ${n} ${x} A ${l} ${l} 0 ${v} 1 ${g} ${p} Z`,midX:a+l*.65*Math.cos(f),midY:i+l*.65*Math.sin(f)}})},...ngDevMode?[{debugName:"pieSlices"}]:[]);onCategoryEnter(e){this.tooltip()&&this.hoveredCategoryIndex.set(e)}onCategoryLeave(){this.hoveredCategoryIndex.set(null)}onSliceEnter(e,t){this.tooltip()&&this.hoveredSlice.set({index:e,label:t.label,value:t.value})}onSliceLeave(){this.hoveredSlice.set(null)}categoryAriaLabel(e){const t=this.categories()[e]??"",a=this.visibleSeriesList().map(i=>`${i.name?i.name+" ":""}${i.data[e]??0}`);return`${t}: ${a.join("، ")}`}categoryTooltip=o(()=>{const e=this.hoveredCategoryIndex();if(e===null||!this.tooltip())return null;const t=this.categoryTicks()[e];if(!t)return null;const i=this.visibleSeriesList().map((l,s)=>({name:l.name||t.category,color:this.colorFor(s),value:l.data[e]??0}));return{x:t.x,y:this.plot().y,title:t.category,items:i}},...ngDevMode?[{debugName:"categoryTooltip"}]:[]);sliceTooltip=o(()=>{const e=this.hoveredSlice();if(!e||!this.tooltip())return null;const t=this.pieSlices()[e.index];return t?{x:t.midX,y:t.midY,title:t.label,items:[{name:this.tooltipValueLabel(),color:t.color,value:t.value}]}:null},...ngDevMode?[{debugName:"sliceTooltip"}]:[]);formatValue(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:2}).format(e)}pieTooltipStyle(e){const a=Math.min(Math.max(e.x,8),this.pieSize-8);return e.y<this.pieSize*.28?{left:`${a}px`,top:`${Math.min(e.y+12,this.pieSize-8)}px`,transform:"translate(-50%, 0)"}:{left:`${a}px`,top:`${Math.max(e.y-8,8)}px`,transform:"translate(-50%, -100%)"}}plotTooltipStyle(e){const t=this.height(),a=e.x/this.width*100,i=e.y/t*100;return{left:`${a}%`,top:`${i}%`,transform:"translate(-50%, calc(-100% - 8px))"}}static ɵfac=r.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"22.1.5",ngImport:r,type:S,deps:[],target:r.ɵɵFactoryTarget.Component});static ɵcmp=r.ɵɵngDeclareComponent({minVersion:"17.0.0",version:"22.1.5",type:S,isStandalone:!0,selector:"dga-chart",inputs:{type:{classPropertyName:"type",publicName:"type",isSignal:!0,isRequired:!1,transformFunction:null},series:{classPropertyName:"series",publicName:"series",isSignal:!0,isRequired:!1,transformFunction:null},labels:{classPropertyName:"labels",publicName:"labels",isSignal:!0,isRequired:!1,transformFunction:null},datasets:{classPropertyName:"datasets",publicName:"datasets",isSignal:!0,isRequired:!1,transformFunction:null},legend:{classPropertyName:"legend",publicName:"legend",isSignal:!0,isRequired:!1,transformFunction:null},tooltip:{classPropertyName:"tooltip",publicName:"tooltip",isSignal:!0,isRequired:!1,transformFunction:null},grid:{classPropertyName:"grid",publicName:"grid",isSignal:!0,isRequired:!1,transformFunction:null},stacked:{classPropertyName:"stacked",publicName:"stacked",isSignal:!0,isRequired:!1,transformFunction:null},smooth:{classPropertyName:"smooth",publicName:"smooth",isSignal:!0,isRequired:!1,transformFunction:null},area:{classPropertyName:"area",publicName:"area",isSignal:!0,isRequired:!1,transformFunction:null},dots:{classPropertyName:"dots",publicName:"dots",isSignal:!0,isRequired:!1,transformFunction:null},colors:{classPropertyName:"colors",publicName:"colors",isSignal:!0,isRequired:!1,transformFunction:null},tooltipValueLabel:{classPropertyName:"tooltipValueLabel",publicName:"tooltipValueLabel",isSignal:!0,isRequired:!1,transformFunction:null},height:{classPropertyName:"height",publicName:"height",isSignal:!0,isRequired:!1,transformFunction:null},label:{classPropertyName:"label",publicName:"label",isSignal:!0,isRequired:!1,transformFunction:null}},host:{properties:{"attr.data-type":"type()"},classAttribute:"block w-full"},ngImport:r,template:`
|
|
2
|
+
<div class="flex w-full flex-col gap-md">
|
|
3
|
+
@if (isPieType()) {
|
|
4
|
+
<div class="flex flex-col items-center gap-lg sm:flex-row sm:items-start">
|
|
5
|
+
<div
|
|
6
|
+
class="relative shrink-0"
|
|
7
|
+
[style.width.px]="pieSize"
|
|
8
|
+
[style.height.px]="pieSize"
|
|
9
|
+
>
|
|
10
|
+
<svg
|
|
11
|
+
class="block h-full w-full"
|
|
12
|
+
[attr.viewBox]="'0 0 ' + pieSize + ' ' + pieSize"
|
|
13
|
+
role="img"
|
|
14
|
+
[attr.aria-label]="ariaLabel()"
|
|
15
|
+
>
|
|
16
|
+
@for (slice of pieSlices(); track slice.label + slice.index) {
|
|
17
|
+
<path
|
|
18
|
+
[attr.d]="slice.d"
|
|
19
|
+
[attr.fill]="slice.color"
|
|
20
|
+
stroke="var(--dga-chart-dot-fill, #fff)"
|
|
21
|
+
stroke-width="2"
|
|
22
|
+
tabindex="0"
|
|
23
|
+
[attr.aria-label]="slice.label + ': ' + formatValue(slice.value)"
|
|
24
|
+
(pointerenter)="onSliceEnter(slice.index, slice)"
|
|
25
|
+
(pointerleave)="onSliceLeave()"
|
|
26
|
+
(focus)="onSliceEnter(slice.index, slice)"
|
|
27
|
+
(blur)="onSliceLeave()"
|
|
28
|
+
/>
|
|
29
|
+
}
|
|
30
|
+
@if (type() === 'donut') {
|
|
31
|
+
<circle
|
|
32
|
+
[attr.cx]="pieSize / 2"
|
|
33
|
+
[attr.cy]="pieSize / 2"
|
|
34
|
+
[attr.r]="pieSize * 0.28"
|
|
35
|
+
class="fill-surface"
|
|
36
|
+
/>
|
|
37
|
+
}
|
|
38
|
+
</svg>
|
|
39
|
+
@if (sliceTooltip(); as tip) {
|
|
40
|
+
<div
|
|
41
|
+
class="dga-chart-tooltip"
|
|
42
|
+
role="tooltip"
|
|
43
|
+
[style]="pieTooltipStyle(tip)"
|
|
44
|
+
>
|
|
45
|
+
<div class="dga-chart-tooltip__title">{{ tip.title }}</div>
|
|
46
|
+
@for (line of tip.items; track line.name) {
|
|
47
|
+
<div class="dga-chart-tooltip__row">
|
|
48
|
+
<span [style.color]="line.color">{{ line.name }}:</span>
|
|
49
|
+
<span class="dga-chart-tooltip__value">{{ formatValue(line.value) }}</span>
|
|
50
|
+
</div>
|
|
51
|
+
}
|
|
52
|
+
</div>
|
|
53
|
+
}
|
|
54
|
+
</div>
|
|
55
|
+
@if (showLegend()) {
|
|
56
|
+
<ul class="m-0 flex list-none flex-col gap-sm p-0" role="list">
|
|
57
|
+
@for (item of legendItems(); track item.name) {
|
|
58
|
+
<li>
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
61
|
+
class="flex items-center gap-sm rounded-sm text-body-sm text-paragraph
|
|
62
|
+
focus-visible:outline focus-visible:outline-2
|
|
63
|
+
focus-visible:outline-offset-2 focus-visible:outline-focus"
|
|
64
|
+
[class.opacity-40]="hiddenSeries().has(item.name)"
|
|
65
|
+
(click)="toggleSeries(item.name)"
|
|
66
|
+
>
|
|
67
|
+
<span
|
|
68
|
+
class="inline-block size-md shrink-0 rounded-full"
|
|
69
|
+
[style.background]="item.color"
|
|
70
|
+
aria-hidden="true"
|
|
71
|
+
></span>
|
|
72
|
+
<span class="font-medium text-fg">{{ item.name }}</span>
|
|
73
|
+
@if (item.value !== null) {
|
|
74
|
+
<span class="text-muted">{{ formatValue(item.value) }}</span>
|
|
75
|
+
}
|
|
76
|
+
</button>
|
|
77
|
+
</li>
|
|
78
|
+
}
|
|
79
|
+
</ul>
|
|
80
|
+
}
|
|
81
|
+
</div>
|
|
82
|
+
} @else {
|
|
83
|
+
<div class="relative w-full">
|
|
84
|
+
<svg
|
|
85
|
+
class="block w-full"
|
|
86
|
+
[attr.viewBox]="'0 0 ' + width + ' ' + height()"
|
|
87
|
+
[attr.height]="height()"
|
|
88
|
+
role="img"
|
|
89
|
+
[attr.aria-label]="ariaLabel()"
|
|
90
|
+
>
|
|
91
|
+
@if (grid()) {
|
|
92
|
+
@for (y of gridYs(); track y) {
|
|
93
|
+
<line
|
|
94
|
+
[attr.x1]="pad.l"
|
|
95
|
+
[attr.x2]="width - pad.r"
|
|
96
|
+
[attr.y1]="y"
|
|
97
|
+
[attr.y2]="y"
|
|
98
|
+
stroke="var(--dga-chart-grid)"
|
|
99
|
+
stroke-width="1"
|
|
100
|
+
/>
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@if (type() === 'bar') {
|
|
105
|
+
@for (bar of bars(); track bar.categoryIndex + '-' + bar.seriesIndex) {
|
|
106
|
+
<rect
|
|
107
|
+
[attr.x]="bar.x"
|
|
108
|
+
[attr.y]="bar.y"
|
|
109
|
+
[attr.width]="bar.w"
|
|
110
|
+
[attr.height]="bar.h"
|
|
111
|
+
[attr.fill]="bar.color"
|
|
112
|
+
rx="2"
|
|
113
|
+
/>
|
|
114
|
+
}
|
|
115
|
+
} @else {
|
|
116
|
+
@for (line of visibleLines(); track line.name) {
|
|
117
|
+
@if (area() && line.areaPath) {
|
|
118
|
+
<path
|
|
119
|
+
[attr.d]="line.areaPath"
|
|
120
|
+
[attr.fill]="line.color"
|
|
121
|
+
fill-opacity="var(--dga-chart-area-opacity, 0.18)"
|
|
122
|
+
stroke="none"
|
|
123
|
+
/>
|
|
124
|
+
}
|
|
125
|
+
<path
|
|
126
|
+
[attr.d]="line.linePath"
|
|
127
|
+
fill="none"
|
|
128
|
+
[attr.stroke]="line.color"
|
|
129
|
+
stroke-width="2"
|
|
130
|
+
stroke-linejoin="round"
|
|
131
|
+
stroke-linecap="round"
|
|
132
|
+
/>
|
|
133
|
+
@if (dots()) {
|
|
134
|
+
@for (pt of line.points; track pt.x) {
|
|
135
|
+
<circle
|
|
136
|
+
[attr.cx]="pt.x"
|
|
137
|
+
[attr.cy]="pt.y"
|
|
138
|
+
r="4"
|
|
139
|
+
[attr.fill]="'var(--dga-chart-dot-fill, #fff)'"
|
|
140
|
+
[attr.stroke]="line.color"
|
|
141
|
+
stroke-width="2"
|
|
142
|
+
/>
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@for (tick of categoryTicks(); track tick.category + tick.index) {
|
|
149
|
+
<rect
|
|
150
|
+
[attr.x]="tick.hitX"
|
|
151
|
+
[attr.y]="plot().y"
|
|
152
|
+
[attr.width]="tick.hitW"
|
|
153
|
+
[attr.height]="plot().h"
|
|
154
|
+
fill="transparent"
|
|
155
|
+
tabindex="0"
|
|
156
|
+
[attr.aria-label]="categoryAriaLabel(tick.index)"
|
|
157
|
+
(pointerenter)="onCategoryEnter(tick.index)"
|
|
158
|
+
(pointerleave)="onCategoryLeave()"
|
|
159
|
+
(focus)="onCategoryEnter(tick.index)"
|
|
160
|
+
(blur)="onCategoryLeave()"
|
|
161
|
+
/>
|
|
162
|
+
<text
|
|
163
|
+
[attr.x]="tick.x"
|
|
164
|
+
[attr.y]="height() - 8"
|
|
165
|
+
text-anchor="middle"
|
|
166
|
+
font-size="11"
|
|
167
|
+
fill="var(--dga-chart-label)"
|
|
168
|
+
>
|
|
169
|
+
{{ tick.category }}
|
|
170
|
+
</text>
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
<text x="4" [attr.y]="pad.t + 4" font-size="10" fill="var(--dga-chart-text)">
|
|
174
|
+
{{ maxValue() }}
|
|
175
|
+
</text>
|
|
176
|
+
<text x="4" [attr.y]="height() - pad.b" font-size="10" fill="var(--dga-chart-text)">
|
|
177
|
+
0
|
|
178
|
+
</text>
|
|
179
|
+
</svg>
|
|
180
|
+
|
|
181
|
+
@if (categoryTooltip(); as tip) {
|
|
182
|
+
<div
|
|
183
|
+
class="dga-chart-tooltip"
|
|
184
|
+
role="tooltip"
|
|
185
|
+
[style]="plotTooltipStyle(tip)"
|
|
186
|
+
>
|
|
187
|
+
<div class="dga-chart-tooltip__title">{{ tip.title }}</div>
|
|
188
|
+
@for (line of tip.items; track line.name) {
|
|
189
|
+
<div class="dga-chart-tooltip__row">
|
|
190
|
+
<span [style.color]="line.color">{{ line.name }}:</span>
|
|
191
|
+
<span class="dga-chart-tooltip__value">{{ formatValue(line.value) }}</span>
|
|
192
|
+
</div>
|
|
193
|
+
}
|
|
194
|
+
</div>
|
|
195
|
+
}
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
@if (showLegend()) {
|
|
199
|
+
<ul class="m-0 flex list-none flex-wrap items-center gap-lg p-0" role="list">
|
|
200
|
+
@for (item of legendItems(); track item.name) {
|
|
201
|
+
<li>
|
|
202
|
+
<button
|
|
203
|
+
type="button"
|
|
204
|
+
class="flex items-center gap-sm rounded-sm text-body-sm text-paragraph
|
|
205
|
+
focus-visible:outline focus-visible:outline-2
|
|
206
|
+
focus-visible:outline-offset-2 focus-visible:outline-focus"
|
|
207
|
+
[class.opacity-40]="hiddenSeries().has(item.name)"
|
|
208
|
+
(click)="toggleSeries(item.name)"
|
|
209
|
+
>
|
|
210
|
+
<span
|
|
211
|
+
class="inline-block size-md shrink-0 rounded-full"
|
|
212
|
+
[style.background]="item.color"
|
|
213
|
+
aria-hidden="true"
|
|
214
|
+
></span>
|
|
215
|
+
<span class="font-medium text-fg">{{ item.name }}</span>
|
|
216
|
+
</button>
|
|
217
|
+
</li>
|
|
218
|
+
}
|
|
219
|
+
</ul>
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
</div>
|
|
223
|
+
`,isInline:!0,styles:[".dga-chart-tooltip{pointer-events:none;z-index:1;min-width:max-content;max-width:min(16rem,calc(100vw - 2rem));border-radius:var(--radius-md, .375rem);border:1px solid var(--dga-chart-tooltip-border, var(--color-border, #e2e8f0));background:var(--dga-chart-tooltip-bg, var(--color-card, #fff));padding:.375rem .625rem;box-shadow:0 4px 12px #0000001f;font-size:.6875rem;line-height:1.35;white-space:nowrap}.dga-chart-tooltip__title{font-weight:600;color:var(--dga-chart-label, var(--color-fg, #0f172a));margin-bottom:.125rem}.dga-chart-tooltip__row{display:flex;align-items:baseline;gap:.375rem}.dga-chart-tooltip__value{font-variant-numeric:tabular-nums;font-weight:500}\n"],changeDetection:r.ChangeDetectionStrategy.OnPush})}r.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"22.1.5",ngImport:r,type:S,decorators:[{type:D,args:[{selector:"dga-chart",standalone:!0,template:`
|
|
224
|
+
<div class="flex w-full flex-col gap-md">
|
|
225
|
+
@if (isPieType()) {
|
|
226
|
+
<div class="flex flex-col items-center gap-lg sm:flex-row sm:items-start">
|
|
227
|
+
<div
|
|
228
|
+
class="relative shrink-0"
|
|
229
|
+
[style.width.px]="pieSize"
|
|
230
|
+
[style.height.px]="pieSize"
|
|
231
|
+
>
|
|
232
|
+
<svg
|
|
233
|
+
class="block h-full w-full"
|
|
234
|
+
[attr.viewBox]="'0 0 ' + pieSize + ' ' + pieSize"
|
|
235
|
+
role="img"
|
|
236
|
+
[attr.aria-label]="ariaLabel()"
|
|
237
|
+
>
|
|
238
|
+
@for (slice of pieSlices(); track slice.label + slice.index) {
|
|
239
|
+
<path
|
|
240
|
+
[attr.d]="slice.d"
|
|
241
|
+
[attr.fill]="slice.color"
|
|
242
|
+
stroke="var(--dga-chart-dot-fill, #fff)"
|
|
243
|
+
stroke-width="2"
|
|
244
|
+
tabindex="0"
|
|
245
|
+
[attr.aria-label]="slice.label + ': ' + formatValue(slice.value)"
|
|
246
|
+
(pointerenter)="onSliceEnter(slice.index, slice)"
|
|
247
|
+
(pointerleave)="onSliceLeave()"
|
|
248
|
+
(focus)="onSliceEnter(slice.index, slice)"
|
|
249
|
+
(blur)="onSliceLeave()"
|
|
250
|
+
/>
|
|
251
|
+
}
|
|
252
|
+
@if (type() === 'donut') {
|
|
253
|
+
<circle
|
|
254
|
+
[attr.cx]="pieSize / 2"
|
|
255
|
+
[attr.cy]="pieSize / 2"
|
|
256
|
+
[attr.r]="pieSize * 0.28"
|
|
257
|
+
class="fill-surface"
|
|
258
|
+
/>
|
|
259
|
+
}
|
|
260
|
+
</svg>
|
|
261
|
+
@if (sliceTooltip(); as tip) {
|
|
262
|
+
<div
|
|
263
|
+
class="dga-chart-tooltip"
|
|
264
|
+
role="tooltip"
|
|
265
|
+
[style]="pieTooltipStyle(tip)"
|
|
266
|
+
>
|
|
267
|
+
<div class="dga-chart-tooltip__title">{{ tip.title }}</div>
|
|
268
|
+
@for (line of tip.items; track line.name) {
|
|
269
|
+
<div class="dga-chart-tooltip__row">
|
|
270
|
+
<span [style.color]="line.color">{{ line.name }}:</span>
|
|
271
|
+
<span class="dga-chart-tooltip__value">{{ formatValue(line.value) }}</span>
|
|
272
|
+
</div>
|
|
273
|
+
}
|
|
274
|
+
</div>
|
|
275
|
+
}
|
|
276
|
+
</div>
|
|
277
|
+
@if (showLegend()) {
|
|
278
|
+
<ul class="m-0 flex list-none flex-col gap-sm p-0" role="list">
|
|
279
|
+
@for (item of legendItems(); track item.name) {
|
|
280
|
+
<li>
|
|
281
|
+
<button
|
|
282
|
+
type="button"
|
|
283
|
+
class="flex items-center gap-sm rounded-sm text-body-sm text-paragraph
|
|
284
|
+
focus-visible:outline focus-visible:outline-2
|
|
285
|
+
focus-visible:outline-offset-2 focus-visible:outline-focus"
|
|
286
|
+
[class.opacity-40]="hiddenSeries().has(item.name)"
|
|
287
|
+
(click)="toggleSeries(item.name)"
|
|
288
|
+
>
|
|
289
|
+
<span
|
|
290
|
+
class="inline-block size-md shrink-0 rounded-full"
|
|
291
|
+
[style.background]="item.color"
|
|
292
|
+
aria-hidden="true"
|
|
293
|
+
></span>
|
|
294
|
+
<span class="font-medium text-fg">{{ item.name }}</span>
|
|
295
|
+
@if (item.value !== null) {
|
|
296
|
+
<span class="text-muted">{{ formatValue(item.value) }}</span>
|
|
297
|
+
}
|
|
298
|
+
</button>
|
|
299
|
+
</li>
|
|
300
|
+
}
|
|
301
|
+
</ul>
|
|
302
|
+
}
|
|
303
|
+
</div>
|
|
304
|
+
} @else {
|
|
305
|
+
<div class="relative w-full">
|
|
306
|
+
<svg
|
|
307
|
+
class="block w-full"
|
|
308
|
+
[attr.viewBox]="'0 0 ' + width + ' ' + height()"
|
|
309
|
+
[attr.height]="height()"
|
|
310
|
+
role="img"
|
|
311
|
+
[attr.aria-label]="ariaLabel()"
|
|
312
|
+
>
|
|
313
|
+
@if (grid()) {
|
|
314
|
+
@for (y of gridYs(); track y) {
|
|
315
|
+
<line
|
|
316
|
+
[attr.x1]="pad.l"
|
|
317
|
+
[attr.x2]="width - pad.r"
|
|
318
|
+
[attr.y1]="y"
|
|
319
|
+
[attr.y2]="y"
|
|
320
|
+
stroke="var(--dga-chart-grid)"
|
|
321
|
+
stroke-width="1"
|
|
322
|
+
/>
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
@if (type() === 'bar') {
|
|
327
|
+
@for (bar of bars(); track bar.categoryIndex + '-' + bar.seriesIndex) {
|
|
328
|
+
<rect
|
|
329
|
+
[attr.x]="bar.x"
|
|
330
|
+
[attr.y]="bar.y"
|
|
331
|
+
[attr.width]="bar.w"
|
|
332
|
+
[attr.height]="bar.h"
|
|
333
|
+
[attr.fill]="bar.color"
|
|
334
|
+
rx="2"
|
|
335
|
+
/>
|
|
336
|
+
}
|
|
337
|
+
} @else {
|
|
338
|
+
@for (line of visibleLines(); track line.name) {
|
|
339
|
+
@if (area() && line.areaPath) {
|
|
340
|
+
<path
|
|
341
|
+
[attr.d]="line.areaPath"
|
|
342
|
+
[attr.fill]="line.color"
|
|
343
|
+
fill-opacity="var(--dga-chart-area-opacity, 0.18)"
|
|
344
|
+
stroke="none"
|
|
345
|
+
/>
|
|
346
|
+
}
|
|
347
|
+
<path
|
|
348
|
+
[attr.d]="line.linePath"
|
|
349
|
+
fill="none"
|
|
350
|
+
[attr.stroke]="line.color"
|
|
351
|
+
stroke-width="2"
|
|
352
|
+
stroke-linejoin="round"
|
|
353
|
+
stroke-linecap="round"
|
|
354
|
+
/>
|
|
355
|
+
@if (dots()) {
|
|
356
|
+
@for (pt of line.points; track pt.x) {
|
|
357
|
+
<circle
|
|
358
|
+
[attr.cx]="pt.x"
|
|
359
|
+
[attr.cy]="pt.y"
|
|
360
|
+
r="4"
|
|
361
|
+
[attr.fill]="'var(--dga-chart-dot-fill, #fff)'"
|
|
362
|
+
[attr.stroke]="line.color"
|
|
363
|
+
stroke-width="2"
|
|
364
|
+
/>
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
@for (tick of categoryTicks(); track tick.category + tick.index) {
|
|
371
|
+
<rect
|
|
372
|
+
[attr.x]="tick.hitX"
|
|
373
|
+
[attr.y]="plot().y"
|
|
374
|
+
[attr.width]="tick.hitW"
|
|
375
|
+
[attr.height]="plot().h"
|
|
376
|
+
fill="transparent"
|
|
377
|
+
tabindex="0"
|
|
378
|
+
[attr.aria-label]="categoryAriaLabel(tick.index)"
|
|
379
|
+
(pointerenter)="onCategoryEnter(tick.index)"
|
|
380
|
+
(pointerleave)="onCategoryLeave()"
|
|
381
|
+
(focus)="onCategoryEnter(tick.index)"
|
|
382
|
+
(blur)="onCategoryLeave()"
|
|
383
|
+
/>
|
|
384
|
+
<text
|
|
385
|
+
[attr.x]="tick.x"
|
|
386
|
+
[attr.y]="height() - 8"
|
|
387
|
+
text-anchor="middle"
|
|
388
|
+
font-size="11"
|
|
389
|
+
fill="var(--dga-chart-label)"
|
|
390
|
+
>
|
|
391
|
+
{{ tick.category }}
|
|
392
|
+
</text>
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
<text x="4" [attr.y]="pad.t + 4" font-size="10" fill="var(--dga-chart-text)">
|
|
396
|
+
{{ maxValue() }}
|
|
397
|
+
</text>
|
|
398
|
+
<text x="4" [attr.y]="height() - pad.b" font-size="10" fill="var(--dga-chart-text)">
|
|
399
|
+
0
|
|
400
|
+
</text>
|
|
401
|
+
</svg>
|
|
402
|
+
|
|
403
|
+
@if (categoryTooltip(); as tip) {
|
|
404
|
+
<div
|
|
405
|
+
class="dga-chart-tooltip"
|
|
406
|
+
role="tooltip"
|
|
407
|
+
[style]="plotTooltipStyle(tip)"
|
|
408
|
+
>
|
|
409
|
+
<div class="dga-chart-tooltip__title">{{ tip.title }}</div>
|
|
410
|
+
@for (line of tip.items; track line.name) {
|
|
411
|
+
<div class="dga-chart-tooltip__row">
|
|
412
|
+
<span [style.color]="line.color">{{ line.name }}:</span>
|
|
413
|
+
<span class="dga-chart-tooltip__value">{{ formatValue(line.value) }}</span>
|
|
414
|
+
</div>
|
|
415
|
+
}
|
|
416
|
+
</div>
|
|
417
|
+
}
|
|
418
|
+
</div>
|
|
419
|
+
|
|
420
|
+
@if (showLegend()) {
|
|
421
|
+
<ul class="m-0 flex list-none flex-wrap items-center gap-lg p-0" role="list">
|
|
422
|
+
@for (item of legendItems(); track item.name) {
|
|
423
|
+
<li>
|
|
424
|
+
<button
|
|
425
|
+
type="button"
|
|
426
|
+
class="flex items-center gap-sm rounded-sm text-body-sm text-paragraph
|
|
427
|
+
focus-visible:outline focus-visible:outline-2
|
|
428
|
+
focus-visible:outline-offset-2 focus-visible:outline-focus"
|
|
429
|
+
[class.opacity-40]="hiddenSeries().has(item.name)"
|
|
430
|
+
(click)="toggleSeries(item.name)"
|
|
431
|
+
>
|
|
432
|
+
<span
|
|
433
|
+
class="inline-block size-md shrink-0 rounded-full"
|
|
434
|
+
[style.background]="item.color"
|
|
435
|
+
aria-hidden="true"
|
|
436
|
+
></span>
|
|
437
|
+
<span class="font-medium text-fg">{{ item.name }}</span>
|
|
438
|
+
</button>
|
|
439
|
+
</li>
|
|
440
|
+
}
|
|
441
|
+
</ul>
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
</div>
|
|
445
|
+
`,changeDetection:P.OnPush,host:{class:"block w-full","[attr.data-type]":"type()"},styles:[".dga-chart-tooltip{pointer-events:none;z-index:1;min-width:max-content;max-width:min(16rem,calc(100vw - 2rem));border-radius:var(--radius-md, .375rem);border:1px solid var(--dga-chart-tooltip-border, var(--color-border, #e2e8f0));background:var(--dga-chart-tooltip-bg, var(--color-card, #fff));padding:.375rem .625rem;box-shadow:0 4px 12px #0000001f;font-size:.6875rem;line-height:1.35;white-space:nowrap}.dga-chart-tooltip__title{font-weight:600;color:var(--dga-chart-label, var(--color-fg, #0f172a));margin-bottom:.125rem}.dga-chart-tooltip__row{display:flex;align-items:baseline;gap:.375rem}.dga-chart-tooltip__value{font-variant-numeric:tabular-nums;font-weight:500}\n"]}]}],propDecorators:{type:[{type:r.Input,args:[{isSignal:!0,alias:"type",required:!1}]}],series:[{type:r.Input,args:[{isSignal:!0,alias:"series",required:!1}]}],labels:[{type:r.Input,args:[{isSignal:!0,alias:"labels",required:!1}]}],datasets:[{type:r.Input,args:[{isSignal:!0,alias:"datasets",required:!1}]}],legend:[{type:r.Input,args:[{isSignal:!0,alias:"legend",required:!1}]}],tooltip:[{type:r.Input,args:[{isSignal:!0,alias:"tooltip",required:!1}]}],grid:[{type:r.Input,args:[{isSignal:!0,alias:"grid",required:!1}]}],stacked:[{type:r.Input,args:[{isSignal:!0,alias:"stacked",required:!1}]}],smooth:[{type:r.Input,args:[{isSignal:!0,alias:"smooth",required:!1}]}],area:[{type:r.Input,args:[{isSignal:!0,alias:"area",required:!1}]}],dots:[{type:r.Input,args:[{isSignal:!0,alias:"dots",required:!1}]}],colors:[{type:r.Input,args:[{isSignal:!0,alias:"colors",required:!1}]}],tooltipValueLabel:[{type:r.Input,args:[{isSignal:!0,alias:"tooltipValueLabel",required:!1}]}],height:[{type:r.Input,args:[{isSignal:!0,alias:"height",required:!1}]}],label:[{type:r.Input,args:[{isSignal:!0,alias:"label",required:!1}]}]}});export{S as DgaChart};
|