Translate all Chinese comments and strings to English

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 20:03:19 +08:00
parent 7d5918837b
commit 1d621bf304
57 changed files with 499 additions and 499 deletions

View File

@@ -24,22 +24,22 @@ import getMoment from 'moment';
* with boundary points.
*/
export function setLineChartData(baseData, xMax, xMin, isPercent, yMax, yMin) {
// baseData 轉換為包含 x 和 y 屬性的物件陣列
// Convert baseData to an array of objects with x and y properties
let data = baseData.map(i => ({ x: i.x, y: i.y }));
// 計算 y 軸最小值
// Calculate the Y-axis minimum value
let b = calculateYMin(baseData, isPercent, yMin, yMax);
// 計算 y 軸最大值
// Calculate the Y-axis maximum value
let mf = calculateYMax(baseData, isPercent, yMin, yMax);
// 添加最小值
// Prepend the minimum value
data.unshift({
x: xMin,
y: b,
});
// 添加最大值
// Append the maximum value
data.push({
x: xMax,
y: mf,
@@ -140,11 +140,11 @@ export function setBarChartData(baseData) {
* values in seconds.
*/
export function timeRange(minTime, maxTime, amount) {
// x 軸(時間軸)的範圍是最大-最小,從最小值按照 index 累加間距到最大值
// The X-axis (time axis) range is max - min; accumulate intervals from min to max by index
const startTime = minTime;
const endTime = maxTime;
let timeRange = []; // return數據初始化
const timeGap = (endTime - startTime) / (amount - 1); // 切分成多少段
let timeRange = []; // Initialize the return data array
const timeGap = (endTime - startTime) / (amount - 1); // Divide into segments
for (let i = 0; i < amount; i++) {
timeRange.push(startTime + timeGap * i);
@@ -165,7 +165,7 @@ export function yTimeRange(data, yAmount, yMax) {
const yRange = [];
const yGap = (1/ (yAmount-1));
// 貝茲曲線公式
// Cubic Bezier curve formula
const threebsr = function (t, a1, a2, a3, a4) {
return (
(1 - t) * (1 - t) * (1 - t) * a1 +
@@ -204,8 +204,8 @@ export function yTimeRange(data, yAmount, yMax) {
* @returns {number} The index of the closest value in the array.
*/
export function getXIndex(data, xValue) {
let closestIndex = xValue; // 假定第一个元素的索引是 0
let smallestDifference = Math.abs(xValue - data[0]); // 初始差值设为第一个元素与目标数的差值
let closestIndex = xValue; // Assume the first element index is 0
let smallestDifference = Math.abs(xValue - data[0]); // Initialize difference to the gap between the first element and target
for (let i = 0; i < data.length; i++) {
let difference = Math.abs(xValue - data[i]);
@@ -244,7 +244,7 @@ export function formatTime(seconds) {
}
result += `${remainingSeconds}s`;
return result.trim(); // 去除最后一个空格
return result.trim(); // Remove trailing whitespace
} else {
return null;
}
@@ -258,12 +258,12 @@ export function formatTime(seconds) {
export function formatMaxTwo(times) {
const formattedTimes = [];
for (let time of times) {
// 匹配數字和單位(天、小時、分鐘、秒), 假設數字不可能大於10位數
// Match numbers and units (days, hours, minutes, seconds); assume numbers have at most 10 digits
let units = time.match(/\d{1,10}[dhms]/g);
let formattedTime = '';
let count = 0;
// 只保留最大的兩個單位
// Keep only the two largest units
for (let unit of units) {
if (count >= 2) {
break;
@@ -271,7 +271,7 @@ export function formatMaxTwo(times) {
formattedTime += unit + ' ';
count++;
}
formattedTimes.push(formattedTime.trim()); // 去除末尾的空格
formattedTimes.push(formattedTime.trim()); // Remove trailing whitespace
}
return formattedTimes;
}