Skip to content

Commit dda8e02

Browse files
committed
refactor: update files for cleaner structure
1 parent a0f164c commit dda8e02

10 files changed

Lines changed: 15 additions & 17 deletions

File tree

api/languages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { parseQueryParams } from '../../src/utils/params.js';
22
import { fetchLanguageData, processLanguageData } from '../../src/api/github.js';
3-
import { generateChartData } from '../../src/charts/chart.js';
3+
import { generateChartData } from '../../src/render/chart.js';
44
import { renderSvg } from '../../src/render/svg.js';
55
import { renderError } from '../../src/render/error.js';
66

src/charts/donut.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { createDonutSegments } from './geometry/donut.js';
2-
import {
3-
DONUT_GEOMETRY
4-
} from '../constants/donut.js';
1+
import { createDonutSegments } from './geometry.js';
2+
import { DONUT_GEOMETRY } from '../constants/geometry.js';
53
import { createLegend } from './legend.js';
64
import {
75
LEGEND_SHIFT_THRESHOLD,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FULL_CIRCLE_ANGLE } from './constants.js';
1+
import { FULL_CIRCLE_ANGLE } from '../constants/geometry.js';
22

33
export const polarToCartesian = (cx, cy, r, angleDeg) => {
44
const angleRad = (angleDeg - 90) * Math.PI / 180;
@@ -45,4 +45,4 @@ export const createDonutSegments = (languages, cx, geometry, colours) => {
4545
currentAngle += angle;
4646
return `<path d="${path}" fill="${colours[i]}"/>`;
4747
}).join('');
48-
}
48+
}

src/charts/geometry/constants.js

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ export const DONUT_GEOMETRY = {
33
OUTER_RADIUS: 80,
44
INNER_RADIUS: 50,
55
MARGIN_RIGHT: 20
6-
}
6+
}
7+
8+
export const FULL_CIRCLE_ANGLE = 359.9999;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { generateDonutChart } from './donut.js';
1+
import { generateDonutChart } from '../charts/donut.js';
22

33
const CHART_GENERATORS = {
44
donut: generateDonutChart,

tests/api/languages/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
22
import handler from "../../../api/languages/index.js";
33
import { parseQueryParams } from "../../../src/utils/params.js";
44
import { fetchLanguageData, processLanguageData } from "../../../src/api/github.js";
5-
import { generateChartData } from "../../../src/charts/chart.js";
5+
import { generateChartData } from "../../../src/render/chart.js";
66
import { renderSvg } from "../../../src/render/svg.js";
77
import { renderError } from "../../../src/render/error.js";
88

99
vi.mock("../../../src/utils/params.js");
1010
vi.mock("../../../src/api/github.js");
11-
vi.mock("../../../src/charts/chart.js");
11+
vi.mock("../../../src/render/chart.js");
1212
vi.mock("../../../src/render/svg.js");
1313
vi.mock("../../../src/render/error.js");
1414

tests/charts/donut.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { describe, it, expect, vi } from "vitest";
22
import { generateDonutChart } from "../../src/charts/donut.js";
3-
import { createDonutSegments } from "../../src/charts/geometry/donut.js";
3+
import { createDonutSegments } from "../../src/charts/geometry.js";
44
import { createLegend } from "../../src/charts/legend.js";
55
import { LEGEND_SHIFT_THRESHOLD } from "../../src/constants/styles.js";
66

7-
vi.mock("../../src/charts/geometry/donut.js", () => ({
7+
vi.mock("../../src/charts/geometry.js", () => ({
88
createDonutSegments: vi.fn(() => '<path d="mockSegment"/>')
99
}));
1010

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import {
33
polarToCartesian,
44
describeSegment,
55
createDonutSegments
6-
} from "../../../src/charts/geometry/donut.js";
7-
import { FULL_CIRCLE_ANGLE } from "../../../src/charts/geometry/constants.js";
6+
} from "../../src/charts/geometry.js";
87

98
const mockGeometry = { CENTER_Y: 100, INNER_RADIUS: 30, OUTER_RADIUS: 50 };
109

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, vi } from "vitest";
2-
import { generateChartData } from "../../src/charts/chart.js";
2+
import { generateChartData } from "../../src/render/chart.js";
33
import { generateDonutChart } from "../../src/charts/donut.js";
44

55
vi.mock("../../src/charts/donut.js", () => ({

0 commit comments

Comments
 (0)