refactor: move endPoint creation to draw-utils
This commit is contained in:
parent
2451e58df9
commit
9053b01462
@ -25,6 +25,33 @@ export function equilizeNoOfElements(array1, array2,
|
||||
return [array1, array2];
|
||||
}
|
||||
|
||||
export function getEndpointsForTrapezoid(startPositions) {
|
||||
const endPosition = []
|
||||
let [point_a, point_b] = startPositions
|
||||
|
||||
// For an equilateral triangle, the angles are always 60 deg.
|
||||
// The end points on the polygons can be created using the following formula
|
||||
//
|
||||
// end_point_x = start_x +/- height * 1/2
|
||||
// end_point_y = start_y + height
|
||||
//
|
||||
// b
|
||||
// _______________________________
|
||||
// \ |_| /
|
||||
// \ | /
|
||||
// \ | h /
|
||||
// \ | /
|
||||
// \|____________________/
|
||||
//
|
||||
// b = h * cos(60 deg)
|
||||
//
|
||||
|
||||
endPosition[0] = [point_a[0] + height * 0.5, point_a[1] + height]
|
||||
endPosition[1] = [point_b[0] - height * 0.5, point_b[1] + height]
|
||||
|
||||
return endPosition
|
||||
}
|
||||
|
||||
export function truncateString(txt, len) {
|
||||
if (!txt) {
|
||||
return;
|
||||
|
||||
@ -190,30 +190,8 @@ export function percentageBar(x, y, width, height,
|
||||
return createSVG("rect", args);
|
||||
}
|
||||
|
||||
export function funnelSlice(className, startPositions, height, fill='none') {
|
||||
const endPosition = []
|
||||
let [point_a, point_b] = startPositions[0]
|
||||
|
||||
// For an equilateral triangle, the angles are always 60 deg.
|
||||
// The end points on the polygons can be created using the following formula
|
||||
//
|
||||
// end_point_x = start_x + height
|
||||
// end_point_y = start_y +/- height * 1/2
|
||||
//
|
||||
// b
|
||||
// _______________________________
|
||||
// \ |_| /
|
||||
// \ | /
|
||||
// \ | h /
|
||||
// \ | /
|
||||
// \|____________________/
|
||||
//
|
||||
// b = h * cos(60 deg)
|
||||
//
|
||||
|
||||
endPosition[0] = [point_a[0] + height, point_a[1] + height * 0.5]
|
||||
endPosition[1] = [point_b[0] + height, point_b[1] - height * 0.5]
|
||||
|
||||
export function funnelSlice(className, startPositions, endPosition, height, fill='none') {
|
||||
return createSVG("polygon")
|
||||
}
|
||||
|
||||
export function heatSquare(className, x, y, size, fill='none', data={}) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user