master: change repo
This commit is contained in:
28
src/services/ChartService.ts
Normal file
28
src/services/ChartService.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import IPoint from '@/models/IPoint'
|
||||
import { money } from '@/utils/filters'
|
||||
import ICurrency from '@/models/ICurrency'
|
||||
|
||||
class ChartService {
|
||||
public valueToPoint(value: number, index: number, total: number): IPoint {
|
||||
const x = 0
|
||||
const y = -value * 1.6
|
||||
const angle = ((Math.PI * 2) / total) * index
|
||||
const cos = Math.cos(angle)
|
||||
const sin = Math.sin(angle)
|
||||
const tx = x * cos - y * sin + 200
|
||||
const ty = x * sin + y * cos + 200
|
||||
return {
|
||||
x: tx,
|
||||
y: ty
|
||||
}
|
||||
}
|
||||
|
||||
public getLabel(user: string, cost: number, currency: ICurrency): string {
|
||||
if (!user) {
|
||||
return ''
|
||||
}
|
||||
return `${user} (${money(cost, currency)})`
|
||||
}
|
||||
}
|
||||
|
||||
export default new ChartService()
|
||||
Reference in New Issue
Block a user