@gh-top-languages/lib 1.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/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/charts/donut.d.ts +3 -0
- package/dist/charts/donut.d.ts.map +1 -0
- package/dist/charts/donut.js +13 -0
- package/dist/charts/donut.js.map +1 -0
- package/dist/charts/geometry.d.ts +5 -0
- package/dist/charts/geometry.d.ts.map +1 -0
- package/dist/charts/geometry.js +52 -0
- package/dist/charts/geometry.js.map +1 -0
- package/dist/charts/layout.d.ts +7 -0
- package/dist/charts/layout.d.ts.map +1 -0
- package/dist/charts/layout.js +17 -0
- package/dist/charts/layout.js.map +1 -0
- package/dist/charts/legend.d.ts +3 -0
- package/dist/charts/legend.d.ts.map +1 -0
- package/dist/charts/legend.js +42 -0
- package/dist/charts/legend.js.map +1 -0
- package/dist/charts/pie.d.ts +3 -0
- package/dist/charts/pie.d.ts.map +1 -0
- package/dist/charts/pie.js +13 -0
- package/dist/charts/pie.js.map +1 -0
- package/dist/constants/config.d.ts +11 -0
- package/dist/constants/config.d.ts.map +1 -0
- package/dist/constants/config.js +11 -0
- package/dist/constants/config.js.map +1 -0
- package/dist/constants/geometry.d.ts +12 -0
- package/dist/constants/geometry.d.ts.map +1 -0
- package/dist/constants/geometry.js +8 -0
- package/dist/constants/geometry.js.map +1 -0
- package/dist/constants/styles.d.ts +21 -0
- package/dist/constants/styles.d.ts.map +1 -0
- package/dist/constants/styles.js +21 -0
- package/dist/constants/styles.js.map +1 -0
- package/dist/constants/themes.d.ts +18 -0
- package/dist/constants/themes.d.ts.map +1 -0
- package/dist/constants/themes.js +69 -0
- package/dist/constants/themes.js.map +1 -0
- package/dist/constants/types.d.ts +2 -0
- package/dist/constants/types.d.ts.map +1 -0
- package/dist/constants/types.js +5 -0
- package/dist/constants/types.js.map +1 -0
- package/dist/render/chart.d.ts +3 -0
- package/dist/render/chart.d.ts.map +1 -0
- package/dist/render/chart.js +11 -0
- package/dist/render/chart.js.map +1 -0
- package/dist/render/error.d.ts +3 -0
- package/dist/render/error.d.ts.map +1 -0
- package/dist/render/error.js +19 -0
- package/dist/render/error.js.map +1 -0
- package/dist/render/svg.d.ts +2 -0
- package/dist/render/svg.d.ts.map +1 -0
- package/dist/render/svg.js +22 -0
- package/dist/render/svg.js.map +1 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/params.d.ts +18 -0
- package/dist/utils/params.d.ts.map +1 -0
- package/dist/utils/params.js +37 -0
- package/dist/utils/params.js.map +1 -0
- package/dist/utils/sanitize.d.ts +2 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +13 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/package.json +48 -0
- package/src/charts/donut.ts +22 -0
- package/src/charts/geometry.ts +88 -0
- package/src/charts/layout.ts +19 -0
- package/src/charts/legend.ts +53 -0
- package/src/charts/pie.ts +22 -0
- package/src/constants/config.ts +11 -0
- package/src/constants/geometry.ts +9 -0
- package/src/constants/styles.ts +23 -0
- package/src/constants/themes.ts +68 -0
- package/src/constants/types.ts +4 -0
- package/src/render/chart.ts +24 -0
- package/src/render/error.ts +25 -0
- package/src/render/svg.ts +31 -0
- package/src/types.ts +28 -0
- package/src/utils/params.ts +47 -0
- package/src/utils/sanitize.ts +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mason L'Etoile
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# GitHub Top Languages Library
|
|
2
|
+
|
|
3
|
+
Core library for github-top-languages projects — chart generation, SVG output, and parameter parsing
|
|
4
|
+
|
|
5
|
+
## Modules
|
|
6
|
+
|
|
7
|
+
| Module | Description |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `charts/donut.js` | Donut chart segment and legend generation |
|
|
10
|
+
| `charts/pie.js` | Pie chart segment and legend generation |
|
|
11
|
+
| `charts/geometry.js` | SVG arc path math and segment helpers |
|
|
12
|
+
| `charts/legend.js` | Legend element generation |
|
|
13
|
+
| `charts/layout.js` | Shared layout calculations |
|
|
14
|
+
| `render/chart.js` | Chart type dispatcher |
|
|
15
|
+
| `render/svg.js` | SVG document rendering |
|
|
16
|
+
| `render/error.js` | Error SVG rendering |
|
|
17
|
+
| `utils/params.js` | Query parameter parsing and normalization |
|
|
18
|
+
| `utils/sanitize.js` | HTML entity sanitization |
|
|
19
|
+
| `constants/config.js` | Default configuration values |
|
|
20
|
+
| `constants/geometry.js` | Geometry constants |
|
|
21
|
+
| `constants/styles.js` | Style and layout constants |
|
|
22
|
+
| `constants/themes.js` | Built-in colour themes |
|
|
23
|
+
| `constants/types.js` | Valid chart type values |
|
|
24
|
+
| `types.js` | Shared TypeScript types |
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install github-top-languages-lib
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
MIT License - see [LICENSE](./LICENSE) for details.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"donut.d.ts","sourceRoot":"","sources":["../../src/charts/donut.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAA2B,MAAM,aAAa,CAAC;AAMzF,wBAAgB,kBAAkB,CAChC,mBAAmB,EAAE,QAAQ,EAAE,EAC/B,aAAa,EAAQ,KAAK,EAC1B,KAAK,EAAgB,MAAM,EAC3B,MAAM,EAAe,OAAO,GAC3B,WAAW,CAUb"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { resolveLayout, calculateChartCenter, calculateLegendStartX } from "./layout.js";
|
|
2
|
+
import { DONUT_GEOMETRY } from "../constants/geometry.js";
|
|
3
|
+
import { createDonutSegments } from "./geometry.js";
|
|
4
|
+
import { createLegend } from "./legend.js";
|
|
5
|
+
export function generateDonutChart(normalizedLanguages, selectedTheme, width, stroke) {
|
|
6
|
+
const { isShifted, useStroke } = resolveLayout(normalizedLanguages.length, stroke);
|
|
7
|
+
const chartX = calculateChartCenter(width, isShifted);
|
|
8
|
+
const legendStartX = calculateLegendStartX(chartX, DONUT_GEOMETRY.OUTER_RADIUS);
|
|
9
|
+
const segments = createDonutSegments(normalizedLanguages, chartX, DONUT_GEOMETRY, [...selectedTheme.colours], useStroke);
|
|
10
|
+
const legend = createLegend(normalizedLanguages, isShifted, selectedTheme, legendStartX, useStroke);
|
|
11
|
+
return { segments, legend };
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=donut.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"donut.js","sourceRoot":"","sources":["../../src/charts/donut.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,cAAc,EAA8C,MAAM,0BAA0B,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAyC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAgD,MAAM,aAAa,CAAC;AAEzF,MAAM,UAAU,kBAAkB,CAChC,mBAA+B,EAC/B,aAA0B,EAC1B,KAA2B,EAC3B,MAA4B;IAE5B,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEnF,MAAM,MAAM,GAAqB,oBAAoB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACxE,MAAM,YAAY,GAAe,qBAAqB,CAAC,MAAM,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAE5F,MAAM,QAAQ,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;IACzH,MAAM,MAAM,GAAK,YAAY,CAAC,mBAAmB,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IAEtG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Point, Language, Geometry } from "../types.js";
|
|
2
|
+
export declare const polarToCartesian: (cx: number, cy: number, r: number, angleDeg: number) => Point;
|
|
3
|
+
export declare const describeSegment: (cx: number, cy: number, innerR: number, outerR: number, startAngle: number, endAngle: number) => string;
|
|
4
|
+
export declare const createDonutSegments: (languages: Language[], cx: number, geometry: Geometry, colours: string[], stroke: boolean) => string;
|
|
5
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/charts/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAG5D,eAAO,MAAM,gBAAgB,GAC3B,IAAU,MAAM,EAChB,IAAU,MAAM,EAChB,GAAU,MAAM,EAChB,UAAU,MAAM,KACf,KAMF,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,IAAY,MAAM,EAClB,IAAY,MAAM,EAClB,QAAY,MAAM,EAClB,QAAY,MAAM,EAClB,YAAY,MAAM,EAClB,UAAY,MAAM,KACjB,MAiCF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,WAAW,QAAQ,EAAE,EACrB,IAAW,MAAM,EACjB,UAAW,QAAQ,EACnB,SAAW,MAAM,EAAE,EACnB,QAAW,OAAO,KACjB,MAuBF,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FULL_CIRCLE_ANGLE } from "../constants/geometry.js";
|
|
2
|
+
export const polarToCartesian = (cx, cy, r, angleDeg) => {
|
|
3
|
+
const angleRad = (angleDeg - 90) * Math.PI / 180;
|
|
4
|
+
return {
|
|
5
|
+
x: cx + (r * Math.cos(angleRad)),
|
|
6
|
+
y: cy + (r * Math.sin(angleRad))
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export const describeSegment = (cx, cy, innerR, outerR, startAngle, endAngle) => {
|
|
10
|
+
const angleDiff = endAngle - startAngle;
|
|
11
|
+
if (angleDiff >= 360 || angleDiff <= -360) {
|
|
12
|
+
const midAngle = startAngle + 180;
|
|
13
|
+
const firstHalf = describeSegment(cx, cy, innerR, outerR, startAngle, midAngle);
|
|
14
|
+
const secondHalf = describeSegment(cx, cy, innerR, outerR, midAngle, endAngle);
|
|
15
|
+
return firstHalf + ' ' + secondHalf;
|
|
16
|
+
}
|
|
17
|
+
const startOuter = polarToCartesian(cx, cy, outerR, endAngle);
|
|
18
|
+
const endOuter = polarToCartesian(cx, cy, outerR, startAngle);
|
|
19
|
+
const largeArcFlag = endAngle - startAngle <= 180 ? '0' : '1';
|
|
20
|
+
if (innerR === 0) {
|
|
21
|
+
return `
|
|
22
|
+
M ${cx} ${cy}
|
|
23
|
+
L ${startOuter.x} ${startOuter.y}
|
|
24
|
+
A ${outerR} ${outerR} 0 ${largeArcFlag} 0 ${endOuter.x} ${endOuter.y}
|
|
25
|
+
Z
|
|
26
|
+
`.trim();
|
|
27
|
+
}
|
|
28
|
+
const startInner = polarToCartesian(cx, cy, innerR, startAngle);
|
|
29
|
+
const endInner = polarToCartesian(cx, cy, innerR, endAngle);
|
|
30
|
+
return `
|
|
31
|
+
M ${startOuter.x} ${startOuter.y}
|
|
32
|
+
A ${outerR} ${outerR} 0 ${largeArcFlag} 0 ${endOuter.x} ${endOuter.y}
|
|
33
|
+
L ${startInner.x} ${startInner.y}
|
|
34
|
+
A ${innerR} ${innerR} 0 ${largeArcFlag} 1 ${endInner.x} ${endInner.y}
|
|
35
|
+
Z
|
|
36
|
+
`.trim();
|
|
37
|
+
};
|
|
38
|
+
export const createDonutSegments = (languages, cx, geometry, colours, stroke) => {
|
|
39
|
+
let currentAngle = -0.1;
|
|
40
|
+
return languages.map((lang, i) => {
|
|
41
|
+
let angle = (lang.pct / 100) * 360;
|
|
42
|
+
const segmentAngle = Math.min(currentAngle + angle + 0.1, FULL_CIRCLE_ANGLE);
|
|
43
|
+
const path = describeSegment(cx, geometry.CENTER_Y, geometry.INNER_RADIUS, geometry.OUTER_RADIUS, currentAngle, segmentAngle);
|
|
44
|
+
currentAngle += angle;
|
|
45
|
+
const fillColour = colours[i % colours.length];
|
|
46
|
+
const strokeAttr = stroke
|
|
47
|
+
? ` stroke="#000" stroke-width="0.5" stroke-linejoin="round"`
|
|
48
|
+
: ` stroke="${fillColour}" stroke-width="0.2"`;
|
|
49
|
+
return `<path d="${path}" fill="${fillColour}"${strokeAttr} shape-rendering="geometricPrecision"/>`;
|
|
50
|
+
}).join('');
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/charts/geometry.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function resolveLayout(count: number, stroke: boolean): {
|
|
2
|
+
isShifted: boolean;
|
|
3
|
+
useStroke: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function calculateChartCenter(width: number, isShifted: boolean): number;
|
|
6
|
+
export declare function calculateLegendStartX(chartCenterX: number, radius: number): number;
|
|
7
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/charts/layout.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;;;EAK3D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAK9E;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAElF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LEGEND_SHIFT_THRESHOLD, LEGEND_STYLES, CHART_MARGIN_RIGHT } from "../constants/styles.js";
|
|
2
|
+
export function resolveLayout(count, stroke) {
|
|
3
|
+
return {
|
|
4
|
+
isShifted: count > LEGEND_SHIFT_THRESHOLD,
|
|
5
|
+
useStroke: count > 1 ? stroke : false
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function calculateChartCenter(width, isShifted) {
|
|
9
|
+
const legendWidth = isShifted
|
|
10
|
+
? LEGEND_STYLES.COLUMN_WIDTH * 2
|
|
11
|
+
: LEGEND_STYLES.WIDTH;
|
|
12
|
+
return (width - legendWidth - CHART_MARGIN_RIGHT) / 2;
|
|
13
|
+
}
|
|
14
|
+
export function calculateLegendStartX(chartCenterX, radius) {
|
|
15
|
+
return chartCenterX + radius + CHART_MARGIN_RIGHT;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/charts/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEnG,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAe;IAC1D,OAAO;QACL,SAAS,EAAE,KAAK,GAAG,sBAAsB;QACzC,SAAS,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;KACtC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAAE,SAAkB;IACpE,MAAM,WAAW,GAAG,SAAS;QAC3B,CAAC,CAAC,aAAa,CAAC,YAAY,GAAG,CAAC;QAChC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;IACxB,OAAO,CAAC,KAAK,GAAG,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,YAAoB,EAAE,MAAc;IACxE,OAAO,YAAY,GAAG,MAAM,GAAG,kBAAkB,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/charts/legend.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAgB,YAAY,CAC1B,SAAS,EAAM,QAAQ,EAAE,EACzB,SAAS,EAAM,OAAO,EACtB,aAAa,EAAE,KAAK,EACpB,YAAY,EAAG,MAAM,EACrB,MAAM,EAAS,OAAO,GACrB,MAAM,CA2CR"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LEGEND_STYLES } from "../constants/styles.js";
|
|
2
|
+
export function createLegend(languages, isShifted, selectedTheme, legendStartX, stroke) {
|
|
3
|
+
const numLangs = languages.length;
|
|
4
|
+
return languages.map((lang, i) => {
|
|
5
|
+
let x, y;
|
|
6
|
+
if (!isShifted) {
|
|
7
|
+
x = legendStartX;
|
|
8
|
+
y = LEGEND_STYLES.START_Y + i * LEGEND_STYLES.ROW_HEIGHT;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
const half = Math.ceil(numLangs / 2);
|
|
12
|
+
const col = Math.floor(i / half);
|
|
13
|
+
const row = i % half;
|
|
14
|
+
x = legendStartX + col * LEGEND_STYLES.COLUMN_WIDTH;
|
|
15
|
+
y = LEGEND_STYLES.START_Y + row * LEGEND_STYLES.ROW_HEIGHT;
|
|
16
|
+
}
|
|
17
|
+
const fill = selectedTheme.colours[i];
|
|
18
|
+
const strokeAttr = stroke
|
|
19
|
+
? ` stroke="#000" stroke-width="0.5" stroke-linejoin="round"`
|
|
20
|
+
: ``;
|
|
21
|
+
return `
|
|
22
|
+
<rect
|
|
23
|
+
x="${x}"
|
|
24
|
+
y="${y - LEGEND_STYLES.SQUARE_SIZE + 3}"
|
|
25
|
+
width="${LEGEND_STYLES.SQUARE_SIZE}"
|
|
26
|
+
height="${LEGEND_STYLES.SQUARE_SIZE}"
|
|
27
|
+
fill="${fill}"
|
|
28
|
+
rx="${LEGEND_STYLES.SQUARE_RADIUS}"${strokeAttr}
|
|
29
|
+
/>
|
|
30
|
+
<text
|
|
31
|
+
x="${x + LEGEND_STYLES.SQUARE_SIZE + 5}"
|
|
32
|
+
y="${y}"
|
|
33
|
+
fill="${selectedTheme.text}"
|
|
34
|
+
font-size="${LEGEND_STYLES.FONT_SIZE}"
|
|
35
|
+
font-family="Arial"
|
|
36
|
+
>
|
|
37
|
+
${lang.lang} ${lang.pct.toFixed(1)}%
|
|
38
|
+
</text>
|
|
39
|
+
`;
|
|
40
|
+
}).join('');
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=legend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legend.js","sourceRoot":"","sources":["../../src/charts/legend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,MAAM,wBAAwB,CAAC;AAG9D,MAAM,UAAU,YAAY,CAC1B,SAAyB,EACzB,SAAsB,EACtB,aAAoB,EACpB,YAAqB,EACrB,MAAsB;IAEtB,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC;IAElC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,CAAS,EAAE,CAAS,CAAC;QAEzB,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,CAAC,GAAG,YAAY,CAAC;YACjB,CAAC,GAAG,aAAa,CAAC,OAAO,GAAG,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;YACrC,MAAM,GAAG,GAAI,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;YAClC,MAAM,GAAG,GAAI,CAAC,GAAG,IAAI,CAAC;YAEtB,CAAC,GAAG,YAAY,GAAG,GAAG,GAAG,aAAa,CAAC,YAAY,CAAC;YACpD,CAAC,GAAG,aAAa,CAAC,OAAO,GAAG,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC;QAC7D,CAAC;QAED,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,UAAU,GAAG,MAAM;YACvB,CAAC,CAAC,2DAA2D;YAC7D,CAAC,CAAC,EAAE,CAAC;QAEP,OAAO;;aAEE,CAAC;aACD,CAAC,GAAG,aAAa,CAAC,WAAW,GAAG,CAAC;iBAC7B,aAAa,CAAC,WAAW;kBACxB,aAAa,CAAC,WAAW;gBAC3B,IAAI;cACN,aAAa,CAAC,aAAa,IAAI,UAAU;;;aAG1C,CAAC,GAAG,aAAa,CAAC,WAAW,GAAG,CAAC;aACjC,CAAC;gBACE,aAAa,CAAC,IAAI;qBACb,aAAa,CAAC,SAAS;;;QAGpC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;;KAEnC,CAAC;IACJ,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie.d.ts","sourceRoot":"","sources":["../../src/charts/pie.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAA2B,MAAM,aAAa,CAAC;AAMzF,wBAAgB,gBAAgB,CAC9B,mBAAmB,EAAE,QAAQ,EAAE,EAC/B,aAAa,EAAQ,KAAK,EAC1B,KAAK,EAAgB,MAAM,EAC3B,MAAM,EAAe,OAAO,GAC3B,WAAW,CAUb"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { resolveLayout, calculateChartCenter, calculateLegendStartX } from "./layout.js";
|
|
2
|
+
import { PIE_GEOMETRY } from "../constants/geometry.js";
|
|
3
|
+
import { createDonutSegments } from "./geometry.js";
|
|
4
|
+
import { createLegend } from "./legend.js";
|
|
5
|
+
export function generatePieChart(normalizedLanguages, selectedTheme, width, stroke) {
|
|
6
|
+
const { isShifted, useStroke } = resolveLayout(normalizedLanguages.length, stroke);
|
|
7
|
+
const chartX = calculateChartCenter(width, isShifted);
|
|
8
|
+
const legendStartX = calculateLegendStartX(chartX, PIE_GEOMETRY.OUTER_RADIUS);
|
|
9
|
+
const segments = createDonutSegments(normalizedLanguages, chartX, PIE_GEOMETRY, [...selectedTheme.colours], useStroke);
|
|
10
|
+
const legend = createLegend(normalizedLanguages, isShifted, selectedTheme, legendStartX, useStroke);
|
|
11
|
+
return { segments, legend };
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=pie.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie.js","sourceRoot":"","sources":["../../src/charts/pie.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,YAAY,EAAgD,MAAM,0BAA0B,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAyC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAgD,MAAM,aAAa,CAAC;AAEzF,MAAM,UAAU,gBAAgB,CAC9B,mBAA+B,EAC/B,aAA0B,EAC1B,KAA2B,EAC3B,MAA4B;IAE5B,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEnF,MAAM,MAAM,GAAqB,oBAAoB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACxE,MAAM,YAAY,GAAe,qBAAqB,CAAC,MAAM,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IAE1F,MAAM,QAAQ,GAAG,mBAAmB,CAAC,mBAAmB,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;IACvH,MAAM,MAAM,GAAG,YAAY,CAAC,mBAAmB,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IAEpG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const DEFAULT_CONFIG: {
|
|
2
|
+
readonly TITLE: "Top Languages";
|
|
3
|
+
readonly WIDTH: 400;
|
|
4
|
+
readonly MIN_WIDTH: 400;
|
|
5
|
+
readonly HEIGHT: 300;
|
|
6
|
+
readonly MIN_HEIGHT: 265;
|
|
7
|
+
readonly COUNT: 8;
|
|
8
|
+
readonly MAX_COUNT: 16;
|
|
9
|
+
};
|
|
10
|
+
export declare const REFRESH_INTERVAL: number;
|
|
11
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/constants/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;CAQjB,CAAC;AAEX,eAAO,MAAM,gBAAgB,QAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/constants/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAO,eAAe;IAC3B,KAAK,EAAO,GAAG;IACf,SAAS,EAAG,GAAG;IACf,MAAM,EAAM,GAAG;IACf,UAAU,EAAE,GAAG;IACf,KAAK,EAAO,CAAC;IACb,SAAS,EAAG,EAAE;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const FULL_CIRCLE_ANGLE = 359.9999;
|
|
2
|
+
export declare const DONUT_GEOMETRY: {
|
|
3
|
+
readonly INNER_RADIUS: 50;
|
|
4
|
+
readonly CENTER_Y: 170;
|
|
5
|
+
readonly OUTER_RADIUS: 80;
|
|
6
|
+
};
|
|
7
|
+
export declare const PIE_GEOMETRY: {
|
|
8
|
+
readonly INNER_RADIUS: 0;
|
|
9
|
+
readonly CENTER_Y: 170;
|
|
10
|
+
readonly OUTER_RADIUS: 80;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/constants/geometry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAO1C,eAAO,MAAM,cAAc;;;;CAAkD,CAAC;AAC9E,eAAO,MAAM,YAAY;;;;CAAoD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const FULL_CIRCLE_ANGLE = 359.9999;
|
|
2
|
+
const BASE_GEOMETRY = {
|
|
3
|
+
CENTER_Y: 170,
|
|
4
|
+
OUTER_RADIUS: 80,
|
|
5
|
+
};
|
|
6
|
+
export const DONUT_GEOMETRY = { ...BASE_GEOMETRY, INNER_RADIUS: 50 };
|
|
7
|
+
export const PIE_GEOMETRY = { ...BASE_GEOMETRY, INNER_RADIUS: 0 };
|
|
8
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/constants/geometry.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAE1C,MAAM,aAAa,GAAG;IACpB,QAAQ,EAAM,GAAG;IACjB,YAAY,EAAE,EAAE;CACR,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,aAAa,EAAE,YAAY,EAAE,EAAE,EAAW,CAAC;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAK,EAAE,GAAG,aAAa,EAAE,YAAY,EAAE,CAAC,EAAY,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const TITLE_STYLES: {
|
|
2
|
+
readonly TEXT_Y: 30;
|
|
3
|
+
readonly FONT_SIZE: 24;
|
|
4
|
+
};
|
|
5
|
+
export declare const LEGEND_STYLES: {
|
|
6
|
+
readonly START_Y: 80;
|
|
7
|
+
readonly ROW_HEIGHT: 25;
|
|
8
|
+
readonly SQUARE_SIZE: 12;
|
|
9
|
+
readonly SQUARE_RADIUS: 2;
|
|
10
|
+
readonly FONT_SIZE: 11;
|
|
11
|
+
readonly WIDTH: 130;
|
|
12
|
+
readonly COLUMN_WIDTH: 105;
|
|
13
|
+
};
|
|
14
|
+
export declare const ERROR_STYLES: {
|
|
15
|
+
readonly TEXT_Y: 100;
|
|
16
|
+
readonly FONT_SIZE: 18;
|
|
17
|
+
readonly COLOUR: "#ff6b6b";
|
|
18
|
+
};
|
|
19
|
+
export declare const LEGEND_SHIFT_THRESHOLD = 8;
|
|
20
|
+
export declare const CHART_MARGIN_RIGHT = 20;
|
|
21
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/constants/styles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;CAGf,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;;;CAQhB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;CAIf,CAAC;AAEX,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,kBAAkB,KAAS,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const TITLE_STYLES = {
|
|
2
|
+
TEXT_Y: 30,
|
|
3
|
+
FONT_SIZE: 24
|
|
4
|
+
};
|
|
5
|
+
export const LEGEND_STYLES = {
|
|
6
|
+
START_Y: 80,
|
|
7
|
+
ROW_HEIGHT: 25,
|
|
8
|
+
SQUARE_SIZE: 12,
|
|
9
|
+
SQUARE_RADIUS: 2,
|
|
10
|
+
FONT_SIZE: 11,
|
|
11
|
+
WIDTH: 130,
|
|
12
|
+
COLUMN_WIDTH: 105
|
|
13
|
+
};
|
|
14
|
+
export const ERROR_STYLES = {
|
|
15
|
+
TEXT_Y: 100,
|
|
16
|
+
FONT_SIZE: 18,
|
|
17
|
+
COLOUR: "#ff6b6b"
|
|
18
|
+
};
|
|
19
|
+
export const LEGEND_SHIFT_THRESHOLD = 8;
|
|
20
|
+
export const CHART_MARGIN_RIGHT = 20;
|
|
21
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/constants/styles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAK,EAAE;IACb,SAAS,EAAE,EAAE;CACL,CAAC;AAEX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAQ,EAAE;IACjB,UAAU,EAAK,EAAE;IACjB,WAAW,EAAI,EAAE;IACjB,aAAa,EAAE,CAAC;IAChB,SAAS,EAAM,EAAE;IACjB,KAAK,EAAU,GAAG;IAClB,YAAY,EAAG,GAAG;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAK,GAAG;IACd,SAAS,EAAE,EAAE;IACb,MAAM,EAAK,SAAS;CACZ,CAAC;AAEX,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,kBAAkB,GAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const THEMES: {
|
|
2
|
+
readonly default: {
|
|
3
|
+
readonly bg: "#0d1117";
|
|
4
|
+
readonly text: "#ffffff";
|
|
5
|
+
readonly colours: readonly ["#A8D5Ba", "#FFD6A5", "#FFAAA6", "#D0CFCF", "#CBAACB", "#FFE156", "#96D5E9", "#F3B0C3", "#B4A7D6", "#FFB6B9", "#A3E4D7", "#F8B88B", "#C9E4CA", "#FAD7A0", "#AED6F1", "#D7BDE2"];
|
|
6
|
+
};
|
|
7
|
+
readonly light: {
|
|
8
|
+
readonly bg: "#ffffff";
|
|
9
|
+
readonly text: "#2f2f2f";
|
|
10
|
+
readonly colours: readonly ["#2ecc71", "#3498db", "#e74c3c", "#f39c12", "#9b59b6", "#1abc9c", "#e67e22", "#34495e", "#16a085", "#c0392b", "#8e44ad", "#27ae60", "#d35400", "#2980b9", "#7f8c8d", "#f1c40f"];
|
|
11
|
+
};
|
|
12
|
+
readonly dark: {
|
|
13
|
+
readonly bg: "#1a1a1a";
|
|
14
|
+
readonly text: "#ccd6f6";
|
|
15
|
+
readonly colours: readonly ["#ff6b6b", "#4ecdc3", "#45b7d1", "#ffa07a", "#98d8c8", "#f7dc6f", "#bb8fce", "#64ffda", "#85c1e2", "#ff8a80", "#a7ffeb", "#ffd54f", "#ea80fc", "#80d8ff", "#ffab91", "#b9f6ca"];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=themes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/constants/themes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;CAmET,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const THEMES = {
|
|
2
|
+
default: {
|
|
3
|
+
bg: "#0d1117",
|
|
4
|
+
text: "#ffffff",
|
|
5
|
+
colours: [
|
|
6
|
+
"#A8D5Ba",
|
|
7
|
+
"#FFD6A5",
|
|
8
|
+
"#FFAAA6",
|
|
9
|
+
"#D0CFCF",
|
|
10
|
+
"#CBAACB",
|
|
11
|
+
"#FFE156",
|
|
12
|
+
"#96D5E9",
|
|
13
|
+
"#F3B0C3",
|
|
14
|
+
"#B4A7D6",
|
|
15
|
+
"#FFB6B9",
|
|
16
|
+
"#A3E4D7",
|
|
17
|
+
"#F8B88B",
|
|
18
|
+
"#C9E4CA",
|
|
19
|
+
"#FAD7A0",
|
|
20
|
+
"#AED6F1",
|
|
21
|
+
"#D7BDE2"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
light: {
|
|
25
|
+
bg: "#ffffff",
|
|
26
|
+
text: "#2f2f2f",
|
|
27
|
+
colours: [
|
|
28
|
+
"#2ecc71",
|
|
29
|
+
"#3498db",
|
|
30
|
+
"#e74c3c",
|
|
31
|
+
"#f39c12",
|
|
32
|
+
"#9b59b6",
|
|
33
|
+
"#1abc9c",
|
|
34
|
+
"#e67e22",
|
|
35
|
+
"#34495e",
|
|
36
|
+
"#16a085",
|
|
37
|
+
"#c0392b",
|
|
38
|
+
"#8e44ad",
|
|
39
|
+
"#27ae60",
|
|
40
|
+
"#d35400",
|
|
41
|
+
"#2980b9",
|
|
42
|
+
"#7f8c8d",
|
|
43
|
+
"#f1c40f"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
dark: {
|
|
47
|
+
bg: "#1a1a1a",
|
|
48
|
+
text: "#ccd6f6",
|
|
49
|
+
colours: [
|
|
50
|
+
"#ff6b6b",
|
|
51
|
+
"#4ecdc3",
|
|
52
|
+
"#45b7d1",
|
|
53
|
+
"#ffa07a",
|
|
54
|
+
"#98d8c8",
|
|
55
|
+
"#f7dc6f",
|
|
56
|
+
"#bb8fce",
|
|
57
|
+
"#64ffda",
|
|
58
|
+
"#85c1e2",
|
|
59
|
+
"#ff8a80",
|
|
60
|
+
"#a7ffeb",
|
|
61
|
+
"#ffd54f",
|
|
62
|
+
"#ea80fc",
|
|
63
|
+
"#80d8ff",
|
|
64
|
+
"#ffab91",
|
|
65
|
+
"#b9f6ca"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=themes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.js","sourceRoot":"","sources":["../../src/constants/themes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO,EAAE;QACP,EAAE,EAAI,SAAS;QACf,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YACP,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;SACV;KACF;IACD,KAAK,EAAE;QACL,EAAE,EAAI,SAAS;QACf,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YACP,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;SACV;KACF;IACD,IAAI,EAAE;QACJ,EAAE,EAAI,SAAS;QACf,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YACP,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;SACV;KACF;CACO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/constants/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,2BAGd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/constants/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO;IACP,KAAK;CACG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../src/render/chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAc3E,wBAAgB,iBAAiB,CAC/B,IAAI,EAAO,QAAQ,EAAE,EACrB,KAAK,EAAM,KAAK,EAChB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAM,MAAM,EACjB,MAAM,EAAK,OAAO,GACjB,WAAW,CAGb"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { generateDonutChart } from "../charts/donut.js";
|
|
2
|
+
import { generatePieChart } from "../charts/pie.js";
|
|
3
|
+
const CHART_GENERATORS = {
|
|
4
|
+
donut: generateDonutChart,
|
|
5
|
+
pie: generatePieChart,
|
|
6
|
+
};
|
|
7
|
+
export function generateChartData(data, theme, chartType, width, stroke) {
|
|
8
|
+
const generator = CHART_GENERATORS[chartType] || CHART_GENERATORS.donut;
|
|
9
|
+
return generator(data, theme, width, stroke);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.js","sourceRoot":"","sources":["../../src/render/chart.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAA4B,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAA8B,MAAM,kBAAkB,CAAC;AAEhF,MAAM,gBAAgB,GAKF;IAClB,KAAK,EAAE,kBAAkB;IACzB,GAAG,EAAI,gBAAgB;CACxB,CAAA;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAAqB,EACrB,KAAgB,EAChB,SAAoB,EACpB,KAAiB,EACjB,MAAkB;IAElB,MAAM,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC;IACxE,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/render/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAI,MAAM,aAAa,CAAC;AAK3C,wBAAgB,WAAW,CACzB,OAAO,EAAS,MAAM,EACtB,KAAK,EAAW,MAAM,EACtB,MAAM,EAAU,MAAM,EACtB,aAAa,CAAC,EAAE,KAAK,GACpB,MAAM,CAcR"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { THEMES } from "../constants/themes.js";
|
|
2
|
+
import { ERROR_STYLES } from "../constants/styles.js";
|
|
3
|
+
import { sanitize } from "../utils/sanitize.js";
|
|
4
|
+
export function renderError(message, width, height, selectedTheme) {
|
|
5
|
+
const background = selectedTheme?.bg || THEMES.default.bg;
|
|
6
|
+
const maxLen = 40;
|
|
7
|
+
const truncated = message.length > maxLen
|
|
8
|
+
? sanitize(message.slice(0, maxLen)) + "..."
|
|
9
|
+
: sanitize(message);
|
|
10
|
+
return `
|
|
11
|
+
<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
|
|
12
|
+
<rect width="${width}" height="${height}" fill="${background}" rx="10"/>
|
|
13
|
+
<text x="${width / 2}" y="${ERROR_STYLES.TEXT_Y}" text-anchor="middle" fill="${ERROR_STYLES.COLOUR}" font-family="Arial" font-size="${ERROR_STYLES.FONT_SIZE}">
|
|
14
|
+
Error: ${truncated}
|
|
15
|
+
</text>
|
|
16
|
+
</svg>
|
|
17
|
+
`.trim();
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/render/error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAQ,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAM,MAAM,sBAAsB,CAAC;AAEpD,MAAM,UAAU,WAAW,CACzB,OAAsB,EACtB,KAAsB,EACtB,MAAsB,EACtB,aAAqB;IAErB,MAAM,UAAU,GAAG,aAAa,EAAE,EAAE,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM;QACvC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,KAAK;QAC5C,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO;kBACS,KAAK,aAAa,MAAM;qBACrB,KAAK,aAAa,MAAM,WAAW,UAAU;iBACjD,KAAK,GAAC,CAAC,QAAQ,YAAY,CAAC,MAAM,gCAAgC,YAAY,CAAC,MAAM,oCAAoC,YAAY,CAAC,SAAS;iBAC/I,SAAS;;;GAGvB,CAAC,IAAI,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../src/render/svg.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CACvB,KAAK,EAAO,MAAM,EAClB,MAAM,EAAM,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAI,MAAM,EAClB,MAAM,EAAM,MAAM,EAClB,KAAK,EAAO,MAAM,GAAG,IAAI,EACzB,UAAU,EAAE,MAAM,GACjB,MAAM,CAoBR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TITLE_STYLES } from "../constants/styles.js";
|
|
2
|
+
export function renderSvg(width, height, background, segments, legend, title, textColour) {
|
|
3
|
+
const titleElement = title ? `
|
|
4
|
+
<text
|
|
5
|
+
x="${width / 2}"
|
|
6
|
+
y="${TITLE_STYLES.TEXT_Y}"
|
|
7
|
+
text-anchor="middle" fill="${textColour}"
|
|
8
|
+
font-family="Arial" font-size="${TITLE_STYLES.FONT_SIZE}"
|
|
9
|
+
>
|
|
10
|
+
${title}
|
|
11
|
+
</text>
|
|
12
|
+
` : '';
|
|
13
|
+
return `
|
|
14
|
+
<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
|
|
15
|
+
<rect width="${width}" height="${height}" fill="${background}" rx="10"/>
|
|
16
|
+
${titleElement}
|
|
17
|
+
${segments}
|
|
18
|
+
${legend}
|
|
19
|
+
</svg>
|
|
20
|
+
`.trim();
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=svg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../../src/render/svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAErD,MAAM,UAAU,SAAS,CACvB,KAAkB,EAClB,MAAkB,EAClB,UAAkB,EAClB,QAAkB,EAClB,MAAkB,EAClB,KAAyB,EACzB,UAAkB;IAElB,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC;;WAEpB,KAAK,GAAC,CAAC;WACP,YAAY,CAAC,MAAM;mCACK,UAAU;uCACN,YAAY,CAAC,SAAS;;QAErD,KAAK;;GAEV,CAAC,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;kBACS,KAAK,aAAa,MAAM;qBACrB,KAAK,aAAa,MAAM,WAAW,UAAU;QAC1D,YAAY;QACZ,QAAQ;QACR,MAAM;;GAEX,CAAC,IAAI,EAAE,CAAC;AACX,CAAC"}
|