@design.estate/dees-catalog 3.55.3 → 3.55.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_bundle/bundle.js +2415 -1142
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/component.d.ts +26 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/component.js +214 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/demo.d.ts +3 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/demo.js +116 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/index.d.ts +1 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/index.js +2 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/styles.d.ts +1 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/styles.js +7 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/template.d.ts +3 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-bar/template.js +12 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/component.d.ts +25 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/component.js +196 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/demo.d.ts +3 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/demo.js +122 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/index.d.ts +1 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/index.js +2 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/styles.d.ts +1 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/styles.js +14 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/template.d.ts +3 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-donut/template.js +12 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-echarts-base.d.ts +22 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-echarts-base.js +145 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-echarts-styles.d.ts +1 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-echarts-styles.js +36 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-echarts-theme.d.ts +22 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-echarts-theme.js +85 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/component.d.ts +25 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/component.js +224 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/demo.d.ts +3 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/demo.js +124 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/index.d.ts +1 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/index.js +2 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/styles.d.ts +1 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/styles.js +11 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/template.d.ts +3 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-gauge/template.js +12 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/component.d.ts +28 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/component.js +177 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/demo.d.ts +3 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/demo.js +113 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/index.d.ts +1 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/index.js +2 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/styles.d.ts +1 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/styles.js +7 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/template.d.ts +3 -0
- package/dist_ts_web/elements/00group-chart/dees-chart-radar/template.js +12 -0
- package/dist_ts_web/elements/00group-chart/index.d.ts +4 -0
- package/dist_ts_web/elements/00group-chart/index.js +5 -1
- package/dist_ts_web/elements/00group-dataview/dees-statsgrid/dees-statsgrid.js +17 -17
- package/dist_ts_web/services/DeesServiceLibLoader.d.ts +31 -1
- package/dist_ts_web/services/DeesServiceLibLoader.js +31 -1
- package/dist_ts_web/services/index.d.ts +1 -1
- package/dist_ts_web/services/versions.d.ts +1 -0
- package/dist_ts_web/services/versions.js +2 -1
- package/dist_watch/bundle.js +2415 -1142
- package/dist_watch/bundle.js.map +4 -4
- package/package.json +2 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/elements/00group-chart/dees-chart-bar/component.ts +158 -0
- package/ts_web/elements/00group-chart/dees-chart-bar/demo.ts +120 -0
- package/ts_web/elements/00group-chart/dees-chart-bar/index.ts +1 -0
- package/ts_web/elements/00group-chart/dees-chart-bar/styles.ts +7 -0
- package/ts_web/elements/00group-chart/dees-chart-bar/template.ts +13 -0
- package/ts_web/elements/00group-chart/dees-chart-donut/component.ts +142 -0
- package/ts_web/elements/00group-chart/dees-chart-donut/demo.ts +127 -0
- package/ts_web/elements/00group-chart/dees-chart-donut/index.ts +1 -0
- package/ts_web/elements/00group-chart/dees-chart-donut/styles.ts +14 -0
- package/ts_web/elements/00group-chart/dees-chart-donut/template.ts +13 -0
- package/ts_web/elements/00group-chart/dees-chart-echarts-base.ts +112 -0
- package/ts_web/elements/00group-chart/dees-chart-echarts-styles.ts +36 -0
- package/ts_web/elements/00group-chart/dees-chart-echarts-theme.ts +91 -0
- package/ts_web/elements/00group-chart/dees-chart-gauge/component.ts +161 -0
- package/ts_web/elements/00group-chart/dees-chart-gauge/demo.ts +125 -0
- package/ts_web/elements/00group-chart/dees-chart-gauge/index.ts +1 -0
- package/ts_web/elements/00group-chart/dees-chart-gauge/styles.ts +11 -0
- package/ts_web/elements/00group-chart/dees-chart-gauge/template.ts +13 -0
- package/ts_web/elements/00group-chart/dees-chart-radar/component.ts +132 -0
- package/ts_web/elements/00group-chart/dees-chart-radar/demo.ts +119 -0
- package/ts_web/elements/00group-chart/dees-chart-radar/index.ts +1 -0
- package/ts_web/elements/00group-chart/dees-chart-radar/styles.ts +7 -0
- package/ts_web/elements/00group-chart/dees-chart-radar/template.ts +13 -0
- package/ts_web/elements/00group-chart/index.ts +4 -0
- package/ts_web/elements/00group-dataview/dees-statsgrid/dees-statsgrid.ts +16 -16
- package/ts_web/services/DeesServiceLibLoader.ts +58 -1
- package/ts_web/services/index.ts +1 -1
- package/ts_web/services/versions.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design.estate/dees-catalog",
|
|
3
|
-
"version": "3.55.
|
|
3
|
+
"version": "3.55.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.",
|
|
6
6
|
"main": "dist_ts_web/index.js",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@tiptap/extension-underline": "^2.23.0",
|
|
35
35
|
"@tiptap/starter-kit": "^2.23.0",
|
|
36
36
|
"@tsclass/tsclass": "^9.5.0",
|
|
37
|
+
"echarts": "^5.6.0",
|
|
37
38
|
"lightweight-charts": "^5.1.0",
|
|
38
39
|
"highlight.js": "11.11.1",
|
|
39
40
|
"ibantools": "^4.5.1",
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@design.estate/dees-catalog',
|
|
6
|
-
version: '3.55.
|
|
6
|
+
version: '3.55.5',
|
|
7
7
|
description: 'A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript.'
|
|
8
8
|
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {
|
|
2
|
+
customElement,
|
|
3
|
+
property,
|
|
4
|
+
type TemplateResult,
|
|
5
|
+
} from '@design.estate/dees-element';
|
|
6
|
+
|
|
7
|
+
import { DeesChartEchartsBase } from '../dees-chart-echarts-base.js';
|
|
8
|
+
import { demoFunc } from './demo.js';
|
|
9
|
+
import { barStyles } from './styles.js';
|
|
10
|
+
import { renderChartBar } from './template.js';
|
|
11
|
+
import { getEchartsSeriesColors, getThemeColors, hexToRgba } from '../dees-chart-echarts-theme.js';
|
|
12
|
+
|
|
13
|
+
export interface IBarSeriesItem {
|
|
14
|
+
name: string;
|
|
15
|
+
data: number[];
|
|
16
|
+
color?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
'dees-chart-bar': DeesChartBar;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@customElement('dees-chart-bar')
|
|
26
|
+
export class DeesChartBar extends DeesChartEchartsBase {
|
|
27
|
+
public static demo = demoFunc;
|
|
28
|
+
public static demoGroups = ['Chart'];
|
|
29
|
+
|
|
30
|
+
@property({ type: Array })
|
|
31
|
+
accessor categories: string[] = [];
|
|
32
|
+
|
|
33
|
+
@property({ type: Array })
|
|
34
|
+
accessor series: IBarSeriesItem[] = [];
|
|
35
|
+
|
|
36
|
+
@property({ type: Boolean })
|
|
37
|
+
accessor horizontal: boolean = false;
|
|
38
|
+
|
|
39
|
+
@property({ type: Boolean })
|
|
40
|
+
accessor stacked: boolean = false;
|
|
41
|
+
|
|
42
|
+
@property({ type: Boolean })
|
|
43
|
+
accessor showLegend: boolean = true;
|
|
44
|
+
|
|
45
|
+
@property({ attribute: false })
|
|
46
|
+
accessor valueFormatter: (value: number) => string = (val) => `${val}`;
|
|
47
|
+
|
|
48
|
+
public static styles = barStyles;
|
|
49
|
+
|
|
50
|
+
public render(): TemplateResult {
|
|
51
|
+
return renderChartBar(this);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public async updated(changedProperties: Map<string, any>) {
|
|
55
|
+
super.updated(changedProperties);
|
|
56
|
+
if (
|
|
57
|
+
this.chartInstance &&
|
|
58
|
+
(changedProperties.has('categories') ||
|
|
59
|
+
changedProperties.has('series') ||
|
|
60
|
+
changedProperties.has('horizontal') ||
|
|
61
|
+
changedProperties.has('stacked') ||
|
|
62
|
+
changedProperties.has('showLegend'))
|
|
63
|
+
) {
|
|
64
|
+
this.updateChart();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected buildOption(): Record<string, any> {
|
|
69
|
+
const colors = getThemeColors(this.goBright);
|
|
70
|
+
const seriesColors = getEchartsSeriesColors(this.goBright);
|
|
71
|
+
const formatter = this.valueFormatter;
|
|
72
|
+
|
|
73
|
+
const categoryAxis: Record<string, any> = {
|
|
74
|
+
type: 'category',
|
|
75
|
+
data: this.categories,
|
|
76
|
+
axisLine: { lineStyle: { color: colors.borderStrong } },
|
|
77
|
+
axisLabel: { color: colors.textMuted },
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const valueAxis: Record<string, any> = {
|
|
81
|
+
type: 'value',
|
|
82
|
+
axisLine: { show: false },
|
|
83
|
+
axisLabel: {
|
|
84
|
+
color: colors.textMuted,
|
|
85
|
+
formatter: (val: number) => formatter(val),
|
|
86
|
+
},
|
|
87
|
+
splitLine: { lineStyle: { color: colors.borderSubtle } },
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const fillAlpha = this.goBright ? 0.15 : 0.25;
|
|
91
|
+
const borderRadius = this.horizontal ? [0, 4, 4, 0] : [4, 4, 0, 0];
|
|
92
|
+
const noBorderRadius = [0, 0, 0, 0];
|
|
93
|
+
|
|
94
|
+
const legendData: Array<{ name: string; itemStyle: { color: string } }> = [];
|
|
95
|
+
|
|
96
|
+
const seriesData = this.series.map((s, index) => {
|
|
97
|
+
const color = s.color || seriesColors[index % seriesColors.length];
|
|
98
|
+
legendData.push({ name: s.name, itemStyle: { color } });
|
|
99
|
+
return {
|
|
100
|
+
name: s.name,
|
|
101
|
+
type: 'bar' as const,
|
|
102
|
+
data: s.data,
|
|
103
|
+
stack: this.stacked ? 'total' : undefined,
|
|
104
|
+
itemStyle: {
|
|
105
|
+
color: hexToRgba(color, fillAlpha),
|
|
106
|
+
borderColor: color,
|
|
107
|
+
borderWidth: 1,
|
|
108
|
+
borderRadius: this.stacked ? noBorderRadius : borderRadius,
|
|
109
|
+
},
|
|
110
|
+
barMaxWidth: 40,
|
|
111
|
+
barGap: '20%',
|
|
112
|
+
emphasis: {
|
|
113
|
+
itemStyle: {
|
|
114
|
+
color: hexToRgba(color, fillAlpha + 0.15),
|
|
115
|
+
borderColor: color,
|
|
116
|
+
borderWidth: 1.5,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// For stacked bars, round the top corners of the last visible series
|
|
123
|
+
if (this.stacked && seriesData.length > 0) {
|
|
124
|
+
const last = seriesData[seriesData.length - 1];
|
|
125
|
+
last.itemStyle.borderRadius = borderRadius;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
tooltip: {
|
|
130
|
+
trigger: 'axis',
|
|
131
|
+
axisPointer: { type: 'shadow' },
|
|
132
|
+
formatter: (params: any) => {
|
|
133
|
+
const items = Array.isArray(params) ? params : [params];
|
|
134
|
+
let result = `<strong>${items[0].axisValueLabel}</strong><br/>`;
|
|
135
|
+
for (const p of items) {
|
|
136
|
+
const solidColor = p.borderColor || p.color;
|
|
137
|
+
const marker = `<span style="display:inline-block;margin-right:4px;border-radius:10px;width:10px;height:10px;background-color:${solidColor};"></span>`;
|
|
138
|
+
result += `${marker}${p.seriesName}: <strong>${formatter(p.value)}</strong><br/>`;
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
legend: this.showLegend && this.series.length > 1
|
|
144
|
+
? { bottom: 8, itemWidth: 10, itemHeight: 10, data: legendData }
|
|
145
|
+
: { show: false },
|
|
146
|
+
grid: {
|
|
147
|
+
left: 16,
|
|
148
|
+
right: 16,
|
|
149
|
+
top: 16,
|
|
150
|
+
bottom: this.showLegend && this.series.length > 1 ? 40 : 16,
|
|
151
|
+
containLabel: true,
|
|
152
|
+
},
|
|
153
|
+
xAxis: this.horizontal ? valueAxis : categoryAxis,
|
|
154
|
+
yAxis: this.horizontal ? categoryAxis : valueAxis,
|
|
155
|
+
series: seriesData,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { html, css, cssManager } from '@design.estate/dees-element';
|
|
2
|
+
import type { DeesChartBar } from './component.js';
|
|
3
|
+
import '@design.estate/dees-wcctools/demotools';
|
|
4
|
+
import './component.js';
|
|
5
|
+
|
|
6
|
+
export const demoFunc = () => {
|
|
7
|
+
const endpointCategories = ['/api/users', '/api/orders', '/api/products', '/api/auth', '/api/search'];
|
|
8
|
+
const endpointSeries = [
|
|
9
|
+
{ name: 'GET', data: [1240, 890, 720, 2100, 560] },
|
|
10
|
+
{ name: 'POST', data: [320, 450, 180, 890, 40] },
|
|
11
|
+
{ name: 'PUT', data: [90, 210, 150, 30, 10] },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const regionCategories = ['US-East', 'US-West', 'EU', 'Asia', 'Other'];
|
|
15
|
+
const regionSeries = [
|
|
16
|
+
{ name: 'Requests', data: [4500, 3200, 2800, 1900, 600] },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
return html`
|
|
20
|
+
<dees-demowrapper .runAfterRender=${async (elementArg: HTMLElement) => {
|
|
21
|
+
const vertChart = elementArg.querySelector('#vert-chart') as DeesChartBar;
|
|
22
|
+
const horizChart = elementArg.querySelector('#horiz-chart') as DeesChartBar;
|
|
23
|
+
const stackChart = elementArg.querySelector('#stack-chart') as DeesChartBar;
|
|
24
|
+
|
|
25
|
+
const buttons = elementArg.querySelectorAll('dees-button');
|
|
26
|
+
buttons.forEach((button: any) => {
|
|
27
|
+
const text = button.text?.trim();
|
|
28
|
+
if (text === 'Randomize') {
|
|
29
|
+
button.addEventListener('click', () => {
|
|
30
|
+
vertChart.series = endpointSeries.map((s) => ({
|
|
31
|
+
...s,
|
|
32
|
+
data: s.data.map((v) => Math.round(v * (0.5 + Math.random()))),
|
|
33
|
+
}));
|
|
34
|
+
horizChart.series = regionSeries.map((s) => ({
|
|
35
|
+
...s,
|
|
36
|
+
data: s.data.map((v) => Math.round(v * (0.5 + Math.random()))),
|
|
37
|
+
}));
|
|
38
|
+
stackChart.series = endpointSeries.map((s) => ({
|
|
39
|
+
...s,
|
|
40
|
+
data: s.data.map((v) => Math.round(v * (0.5 + Math.random()))),
|
|
41
|
+
}));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}}>
|
|
46
|
+
<style>
|
|
47
|
+
${css`
|
|
48
|
+
.demoBox {
|
|
49
|
+
position: relative;
|
|
50
|
+
background: ${cssManager.bdTheme('hsl(0 0% 95%)', 'hsl(0 0% 9%)')};
|
|
51
|
+
height: 100%;
|
|
52
|
+
width: 100%;
|
|
53
|
+
padding: 40px;
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
gap: 24px;
|
|
58
|
+
}
|
|
59
|
+
.chartRow {
|
|
60
|
+
display: grid;
|
|
61
|
+
grid-template-columns: 1fr 1fr;
|
|
62
|
+
gap: 24px;
|
|
63
|
+
}
|
|
64
|
+
.controls {
|
|
65
|
+
display: flex;
|
|
66
|
+
gap: 12px;
|
|
67
|
+
margin-bottom: 8px;
|
|
68
|
+
}
|
|
69
|
+
.info {
|
|
70
|
+
color: ${cssManager.bdTheme('hsl(215.4 16.3% 56.9%)', 'hsl(215 20.2% 55.1%)')};
|
|
71
|
+
font-size: 12px;
|
|
72
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Geist Sans', sans-serif;
|
|
73
|
+
text-align: center;
|
|
74
|
+
margin-top: 8px;
|
|
75
|
+
}
|
|
76
|
+
`}
|
|
77
|
+
</style>
|
|
78
|
+
<div class="demoBox">
|
|
79
|
+
<div class="controls">
|
|
80
|
+
<dees-button-group label="Actions:">
|
|
81
|
+
<dees-button>Randomize</dees-button>
|
|
82
|
+
</dees-button-group>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<div class="chartRow">
|
|
86
|
+
<dees-chart-bar
|
|
87
|
+
id="vert-chart"
|
|
88
|
+
.label=${'Requests by Endpoint'}
|
|
89
|
+
.categories=${endpointCategories}
|
|
90
|
+
.series=${endpointSeries}
|
|
91
|
+
.valueFormatter=${(val: number) => `${val} req`}
|
|
92
|
+
></dees-chart-bar>
|
|
93
|
+
|
|
94
|
+
<dees-chart-bar
|
|
95
|
+
id="horiz-chart"
|
|
96
|
+
.label=${'Traffic by Region'}
|
|
97
|
+
.categories=${regionCategories}
|
|
98
|
+
.series=${regionSeries}
|
|
99
|
+
.horizontal=${true}
|
|
100
|
+
.valueFormatter=${(val: number) => `${(val / 1000).toFixed(1)}k`}
|
|
101
|
+
></dees-chart-bar>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<dees-chart-bar
|
|
105
|
+
id="stack-chart"
|
|
106
|
+
.label=${'Stacked: Requests by Endpoint'}
|
|
107
|
+
.categories=${endpointCategories}
|
|
108
|
+
.series=${endpointSeries}
|
|
109
|
+
.stacked=${true}
|
|
110
|
+
.valueFormatter=${(val: number) => `${val} req`}
|
|
111
|
+
></dees-chart-bar>
|
|
112
|
+
|
|
113
|
+
<div class="info">
|
|
114
|
+
Bar chart with vertical, horizontal, and stacked modes •
|
|
115
|
+
Click 'Randomize' to update data with animation
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</dees-demowrapper>
|
|
119
|
+
`;
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './component.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { html, type TemplateResult } from '@design.estate/dees-element';
|
|
2
|
+
import type { DeesChartBar } from './component.js';
|
|
3
|
+
|
|
4
|
+
export const renderChartBar = (component: DeesChartBar): TemplateResult => {
|
|
5
|
+
return html`
|
|
6
|
+
<dees-tile>
|
|
7
|
+
<div slot="header" class="chartHeader">
|
|
8
|
+
<span class="chartLabel">${component.label}</span>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="chartContainer"></div>
|
|
11
|
+
</dees-tile>
|
|
12
|
+
`;
|
|
13
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {
|
|
2
|
+
customElement,
|
|
3
|
+
property,
|
|
4
|
+
type TemplateResult,
|
|
5
|
+
} from '@design.estate/dees-element';
|
|
6
|
+
|
|
7
|
+
import { DeesChartEchartsBase } from '../dees-chart-echarts-base.js';
|
|
8
|
+
import { demoFunc } from './demo.js';
|
|
9
|
+
import { donutStyles } from './styles.js';
|
|
10
|
+
import { renderChartDonut } from './template.js';
|
|
11
|
+
import { getEchartsSeriesColors, getThemeColors, hexToRgba } from '../dees-chart-echarts-theme.js';
|
|
12
|
+
|
|
13
|
+
export interface IDonutDataItem {
|
|
14
|
+
name: string;
|
|
15
|
+
value: number;
|
|
16
|
+
color?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
'dees-chart-donut': DeesChartDonut;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@customElement('dees-chart-donut')
|
|
26
|
+
export class DeesChartDonut extends DeesChartEchartsBase {
|
|
27
|
+
public static demo = demoFunc;
|
|
28
|
+
public static demoGroups = ['Chart'];
|
|
29
|
+
|
|
30
|
+
@property({ type: Array })
|
|
31
|
+
accessor data: IDonutDataItem[] = [];
|
|
32
|
+
|
|
33
|
+
@property({ type: Boolean })
|
|
34
|
+
accessor showLegend: boolean = true;
|
|
35
|
+
|
|
36
|
+
@property({ type: Boolean })
|
|
37
|
+
accessor showLabels: boolean = true;
|
|
38
|
+
|
|
39
|
+
@property({ type: String })
|
|
40
|
+
accessor innerRadiusPercent: string = '55%';
|
|
41
|
+
|
|
42
|
+
@property({ attribute: false })
|
|
43
|
+
accessor valueFormatter: (value: number) => string = (val) => `${val}`;
|
|
44
|
+
|
|
45
|
+
public static styles = donutStyles;
|
|
46
|
+
|
|
47
|
+
public render(): TemplateResult {
|
|
48
|
+
return renderChartDonut(this);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public async updated(changedProperties: Map<string, any>) {
|
|
52
|
+
super.updated(changedProperties);
|
|
53
|
+
if (
|
|
54
|
+
this.chartInstance &&
|
|
55
|
+
(changedProperties.has('data') ||
|
|
56
|
+
changedProperties.has('showLegend') ||
|
|
57
|
+
changedProperties.has('showLabels') ||
|
|
58
|
+
changedProperties.has('innerRadiusPercent'))
|
|
59
|
+
) {
|
|
60
|
+
this.updateChart();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected buildOption(): Record<string, any> {
|
|
65
|
+
const themeColors = getThemeColors(this.goBright);
|
|
66
|
+
const seriesColors = getEchartsSeriesColors(this.goBright);
|
|
67
|
+
const fillAlpha = this.goBright ? 0.15 : 0.2;
|
|
68
|
+
|
|
69
|
+
const legendData: Array<{ name: string; itemStyle: { color: string } }> = [];
|
|
70
|
+
|
|
71
|
+
const data = this.data.map((item, index) => {
|
|
72
|
+
const color = item.color || seriesColors[index % seriesColors.length];
|
|
73
|
+
legendData.push({ name: item.name, itemStyle: { color } });
|
|
74
|
+
return {
|
|
75
|
+
name: item.name,
|
|
76
|
+
value: item.value,
|
|
77
|
+
itemStyle: {
|
|
78
|
+
color: hexToRgba(color, fillAlpha),
|
|
79
|
+
borderColor: color,
|
|
80
|
+
borderWidth: 1,
|
|
81
|
+
},
|
|
82
|
+
emphasis: {
|
|
83
|
+
itemStyle: {
|
|
84
|
+
color: hexToRgba(color, fillAlpha + 0.15),
|
|
85
|
+
borderColor: color,
|
|
86
|
+
borderWidth: 1.5,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const formatter = this.valueFormatter;
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
tooltip: {
|
|
96
|
+
trigger: 'item',
|
|
97
|
+
formatter: (params: any) => {
|
|
98
|
+
const solidColor = params.data?.itemStyle?.borderColor || params.color;
|
|
99
|
+
const marker = `<span style="display:inline-block;margin-right:4px;border-radius:10px;width:10px;height:10px;background-color:${solidColor};"></span>`;
|
|
100
|
+
return `${marker}${params.name}: <strong>${formatter(params.value)}</strong> (${params.percent}%)`;
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
legend: this.showLegend
|
|
104
|
+
? {
|
|
105
|
+
orient: 'vertical',
|
|
106
|
+
right: 16,
|
|
107
|
+
top: 'center',
|
|
108
|
+
itemWidth: 10,
|
|
109
|
+
itemHeight: 10,
|
|
110
|
+
itemGap: 12,
|
|
111
|
+
data: legendData,
|
|
112
|
+
formatter: (name: string) => {
|
|
113
|
+
const item = this.data.find((d) => d.name === name);
|
|
114
|
+
return item ? `${name} ${formatter(item.value)}` : name;
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
: { show: false },
|
|
118
|
+
series: [
|
|
119
|
+
{
|
|
120
|
+
type: 'pie',
|
|
121
|
+
radius: [this.innerRadiusPercent, '85%'],
|
|
122
|
+
center: this.showLegend ? ['35%', '50%'] : ['50%', '50%'],
|
|
123
|
+
avoidLabelOverlap: true,
|
|
124
|
+
padAngle: 2,
|
|
125
|
+
itemStyle: {
|
|
126
|
+
borderRadius: 4,
|
|
127
|
+
},
|
|
128
|
+
label: this.showLabels
|
|
129
|
+
? {
|
|
130
|
+
show: true,
|
|
131
|
+
formatter: '{b}: {d}%',
|
|
132
|
+
fontSize: 11,
|
|
133
|
+
color: themeColors.textSecondary,
|
|
134
|
+
textBorderColor: 'transparent',
|
|
135
|
+
}
|
|
136
|
+
: { show: false },
|
|
137
|
+
data,
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { html, css, cssManager } from '@design.estate/dees-element';
|
|
2
|
+
import type { DeesChartDonut } from './component.js';
|
|
3
|
+
import '@design.estate/dees-wcctools/demotools';
|
|
4
|
+
import './component.js';
|
|
5
|
+
|
|
6
|
+
export const demoFunc = () => {
|
|
7
|
+
const diskData = [
|
|
8
|
+
{ name: 'Documents', value: 42 },
|
|
9
|
+
{ name: 'Media', value: 28 },
|
|
10
|
+
{ name: 'Applications', value: 15 },
|
|
11
|
+
{ name: 'System', value: 10 },
|
|
12
|
+
{ name: 'Other', value: 5 },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const statusData = [
|
|
16
|
+
{ name: 'Healthy', value: 156 },
|
|
17
|
+
{ name: 'Warning', value: 23 },
|
|
18
|
+
{ name: 'Critical', value: 8 },
|
|
19
|
+
{ name: 'Unknown', value: 3 },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const trafficData = [
|
|
23
|
+
{ name: 'API', value: 45200 },
|
|
24
|
+
{ name: 'Static Assets', value: 23100 },
|
|
25
|
+
{ name: 'WebSocket', value: 12800 },
|
|
26
|
+
{ name: 'GraphQL', value: 8900 },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
return html`
|
|
30
|
+
<dees-demowrapper .runAfterRender=${async (elementArg: HTMLElement) => {
|
|
31
|
+
const diskChart = elementArg.querySelector('#disk-chart') as DeesChartDonut;
|
|
32
|
+
const statusChart = elementArg.querySelector('#status-chart') as DeesChartDonut;
|
|
33
|
+
const trafficChart = elementArg.querySelector('#traffic-chart') as DeesChartDonut;
|
|
34
|
+
|
|
35
|
+
// Wire up buttons
|
|
36
|
+
const buttons = elementArg.querySelectorAll('dees-button');
|
|
37
|
+
buttons.forEach((button: any) => {
|
|
38
|
+
const text = button.text?.trim();
|
|
39
|
+
if (text === 'Randomize') {
|
|
40
|
+
button.addEventListener('click', () => {
|
|
41
|
+
diskChart.data = diskData.map((d) => ({
|
|
42
|
+
...d,
|
|
43
|
+
value: Math.round(d.value * (0.5 + Math.random())),
|
|
44
|
+
}));
|
|
45
|
+
statusChart.data = statusData.map((d) => ({
|
|
46
|
+
...d,
|
|
47
|
+
value: Math.round(d.value * (0.3 + Math.random() * 1.4)),
|
|
48
|
+
}));
|
|
49
|
+
trafficChart.data = trafficData.map((d) => ({
|
|
50
|
+
...d,
|
|
51
|
+
value: Math.round(d.value * (0.5 + Math.random())),
|
|
52
|
+
}));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}}>
|
|
57
|
+
<style>
|
|
58
|
+
${css`
|
|
59
|
+
.demoBox {
|
|
60
|
+
position: relative;
|
|
61
|
+
background: ${cssManager.bdTheme('hsl(0 0% 95%)', 'hsl(0 0% 9%)')};
|
|
62
|
+
height: 100%;
|
|
63
|
+
width: 100%;
|
|
64
|
+
padding: 40px;
|
|
65
|
+
box-sizing: border-box;
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
gap: 24px;
|
|
69
|
+
}
|
|
70
|
+
.chartRow {
|
|
71
|
+
display: grid;
|
|
72
|
+
grid-template-columns: 1fr 1fr;
|
|
73
|
+
gap: 24px;
|
|
74
|
+
}
|
|
75
|
+
.controls {
|
|
76
|
+
display: flex;
|
|
77
|
+
gap: 12px;
|
|
78
|
+
margin-bottom: 8px;
|
|
79
|
+
}
|
|
80
|
+
.info {
|
|
81
|
+
color: ${cssManager.bdTheme('hsl(215.4 16.3% 56.9%)', 'hsl(215 20.2% 55.1%)')};
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Geist Sans', sans-serif;
|
|
84
|
+
text-align: center;
|
|
85
|
+
margin-top: 8px;
|
|
86
|
+
}
|
|
87
|
+
`}
|
|
88
|
+
</style>
|
|
89
|
+
<div class="demoBox">
|
|
90
|
+
<div class="controls">
|
|
91
|
+
<dees-button-group label="Actions:">
|
|
92
|
+
<dees-button>Randomize</dees-button>
|
|
93
|
+
</dees-button-group>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<div class="chartRow">
|
|
97
|
+
<dees-chart-donut
|
|
98
|
+
id="disk-chart"
|
|
99
|
+
.label=${'Disk Usage (GB)'}
|
|
100
|
+
.data=${diskData}
|
|
101
|
+
.valueFormatter=${(val: number) => `${val} GB`}
|
|
102
|
+
></dees-chart-donut>
|
|
103
|
+
|
|
104
|
+
<dees-chart-donut
|
|
105
|
+
id="status-chart"
|
|
106
|
+
.label=${'Service Status'}
|
|
107
|
+
.data=${statusData}
|
|
108
|
+
.valueFormatter=${(val: number) => `${val} services`}
|
|
109
|
+
.innerRadiusPercent=${'0%'}
|
|
110
|
+
></dees-chart-donut>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<dees-chart-donut
|
|
114
|
+
id="traffic-chart"
|
|
115
|
+
.label=${'Traffic Distribution'}
|
|
116
|
+
.data=${trafficData}
|
|
117
|
+
.valueFormatter=${(val: number) => `${(val / 1000).toFixed(1)}k req`}
|
|
118
|
+
></dees-chart-donut>
|
|
119
|
+
|
|
120
|
+
<div class="info">
|
|
121
|
+
Donut chart with configurable inner radius (set to 0% for full pie) •
|
|
122
|
+
Click 'Randomize' to update data with animation
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</dees-demowrapper>
|
|
126
|
+
`;
|
|
127
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './component.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { css, cssManager } from '@design.estate/dees-element';
|
|
2
|
+
import { echartsBaseStyles } from '../dees-chart-echarts-styles.js';
|
|
3
|
+
|
|
4
|
+
export const donutStyles = [
|
|
5
|
+
...echartsBaseStyles,
|
|
6
|
+
css`
|
|
7
|
+
:host {
|
|
8
|
+
height: 360px;
|
|
9
|
+
}
|
|
10
|
+
.chartContainer {
|
|
11
|
+
inset: 12px 0;
|
|
12
|
+
}
|
|
13
|
+
`,
|
|
14
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { html, type TemplateResult } from '@design.estate/dees-element';
|
|
2
|
+
import type { DeesChartDonut } from './component.js';
|
|
3
|
+
|
|
4
|
+
export const renderChartDonut = (component: DeesChartDonut): TemplateResult => {
|
|
5
|
+
return html`
|
|
6
|
+
<dees-tile>
|
|
7
|
+
<div slot="header" class="chartHeader">
|
|
8
|
+
<span class="chartLabel">${component.label}</span>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="chartContainer"></div>
|
|
11
|
+
</dees-tile>
|
|
12
|
+
`;
|
|
13
|
+
};
|