31 lines
950 B
TypeScript
31 lines
950 B
TypeScript
const COLORS = [
|
|
"#FF5733",
|
|
"#33FF57",
|
|
"#3357FF",
|
|
"#F1C40F",
|
|
"#8E44AD",
|
|
"#E67E22",
|
|
"#3498DB",
|
|
"#2ECC71",
|
|
"#E74C3C",
|
|
"#1ABC9C"
|
|
]
|
|
|
|
|
|
strokeWidth = 0.5;
|
|
lineGap = 1;
|
|
points = [{ start: 0, end: 20, count: 2 }, { start: 0, end: 36.5, count: 1 }, { start: 36.5, end: 10, count: 3 }, { start: 10, end: 87, count: 1 }, { start: 87, end: 4.5, count: 1 }, { start: 4.5, end: 90, count: 1 }, { start: 90, end: 2, count: 1 }]
|
|
|
|
get viewBox(): string {
|
|
return `0 0 ${Math.max(...this.points.map(item => item.end))} ${this.getLineNumber(this.points.length - 1, this.points[this.points.length - 1].count) + 1}`
|
|
}
|
|
|
|
lineCountNumber(n: number): number[] {
|
|
return Array(n).fill(null).map((_, i) => i + 1);
|
|
}
|
|
getLineNumber(index: number, lineCount: number): number {
|
|
return this.points.slice(0, index).map(item => item.count).reduce((total, num) => total += num, 0) + lineCount;
|
|
}
|
|
getRandomColor(n: number): string {
|
|
return COLORS[n % COLORS.length];
|
|
} |