project type ready & tooltip changes
This commit is contained in:
parent
02c9c58091
commit
0f4c25b45f
@ -31,6 +31,10 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
|
|||||||
barProgressSelectedColor = "#8282f5",
|
barProgressSelectedColor = "#8282f5",
|
||||||
barBackgroundColor = "#b8c2cc",
|
barBackgroundColor = "#b8c2cc",
|
||||||
barBackgroundSelectedColor = "#aeb8c2",
|
barBackgroundSelectedColor = "#aeb8c2",
|
||||||
|
projectProgressColor = "#f1c453",
|
||||||
|
projectProgressSelectedColor = "#f29e4c",
|
||||||
|
projectBackgroundColor = "#65c16f",
|
||||||
|
projectBackgroundSelectedColor = "#46ad51",
|
||||||
milestoneBackgroundColor = "#f1c453",
|
milestoneBackgroundColor = "#f1c453",
|
||||||
milestoneBackgroundSelectedColor = "#f29e4c",
|
milestoneBackgroundSelectedColor = "#f29e4c",
|
||||||
handleWidth = 8,
|
handleWidth = 8,
|
||||||
@ -90,6 +94,10 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
|
|||||||
barProgressSelectedColor,
|
barProgressSelectedColor,
|
||||||
barBackgroundColor,
|
barBackgroundColor,
|
||||||
barBackgroundSelectedColor,
|
barBackgroundSelectedColor,
|
||||||
|
projectProgressColor,
|
||||||
|
projectProgressSelectedColor,
|
||||||
|
projectBackgroundColor,
|
||||||
|
projectBackgroundSelectedColor,
|
||||||
milestoneBackgroundColor,
|
milestoneBackgroundColor,
|
||||||
milestoneBackgroundSelectedColor
|
milestoneBackgroundSelectedColor
|
||||||
)
|
)
|
||||||
@ -106,6 +114,12 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
|
|||||||
barProgressSelectedColor,
|
barProgressSelectedColor,
|
||||||
barBackgroundColor,
|
barBackgroundColor,
|
||||||
barBackgroundSelectedColor,
|
barBackgroundSelectedColor,
|
||||||
|
projectProgressColor,
|
||||||
|
projectProgressSelectedColor,
|
||||||
|
projectBackgroundColor,
|
||||||
|
projectBackgroundSelectedColor,
|
||||||
|
milestoneBackgroundColor,
|
||||||
|
milestoneBackgroundSelectedColor,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -23,7 +23,10 @@ export type TaskGanttContentProps = {
|
|||||||
svg?: React.RefObject<SVGSVGElement>;
|
svg?: React.RefObject<SVGSVGElement>;
|
||||||
svgHeight: number;
|
svgHeight: number;
|
||||||
svgWidth: number;
|
svgWidth: number;
|
||||||
displayXEndpoint?: number;
|
displayXStartEndpoint?: {
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
};
|
||||||
taskHeight: number;
|
taskHeight: number;
|
||||||
arrowColor: string;
|
arrowColor: string;
|
||||||
arrowIndent: number;
|
arrowIndent: number;
|
||||||
@ -49,7 +52,7 @@ export const TaskGanttContent: React.FC<TaskGanttContentProps> = ({
|
|||||||
timeStep,
|
timeStep,
|
||||||
svg,
|
svg,
|
||||||
svgHeight,
|
svgHeight,
|
||||||
displayXEndpoint,
|
displayXStartEndpoint,
|
||||||
taskHeight,
|
taskHeight,
|
||||||
arrowColor,
|
arrowColor,
|
||||||
arrowIndent,
|
arrowIndent,
|
||||||
@ -290,12 +293,12 @@ export const TaskGanttContent: React.FC<TaskGanttContentProps> = ({
|
|||||||
})}
|
})}
|
||||||
</g>
|
</g>
|
||||||
<g className="toolTip">
|
<g className="toolTip">
|
||||||
{ganttEvent.changedTask && displayXEndpoint && (
|
{ganttEvent.changedTask && displayXStartEndpoint && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
arrowIndent={arrowIndent}
|
arrowIndent={arrowIndent}
|
||||||
rowHeight={rowHeight}
|
rowHeight={rowHeight}
|
||||||
svgHeight={svgHeight}
|
svgHeight={svgHeight}
|
||||||
displayXEndpoint={displayXEndpoint}
|
displayXStartEndpoint={displayXStartEndpoint}
|
||||||
task={ganttEvent.changedTask}
|
task={ganttEvent.changedTask}
|
||||||
fontFamily={fontFamily}
|
fontFamily={fontFamily}
|
||||||
fontSize={fontSize}
|
fontSize={fontSize}
|
||||||
|
|||||||
@ -25,8 +25,11 @@ export const TaskGantt: React.FC<TaskGanttProps> = ({
|
|||||||
const ganttSVGRef = useRef<SVGSVGElement>(null);
|
const ganttSVGRef = useRef<SVGSVGElement>(null);
|
||||||
const horizontalContainerRef = useRef<HTMLDivElement>(null);
|
const horizontalContainerRef = useRef<HTMLDivElement>(null);
|
||||||
const verticalContainerRef = useRef<HTMLDivElement>(null);
|
const verticalContainerRef = useRef<HTMLDivElement>(null);
|
||||||
const [displayXEndpoint, setDisplayXEndpoint] = useState(0);
|
const [displayXStartEndpoint, setDisplayXStartEndpoint] = useState({
|
||||||
const newBarProps = { ...barProps, svg: ganttSVGRef, displayXEndpoint };
|
start: 0,
|
||||||
|
end: 0,
|
||||||
|
});
|
||||||
|
const newBarProps = { ...barProps, svg: ganttSVGRef, displayXStartEndpoint };
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (horizontalContainerRef.current) {
|
if (horizontalContainerRef.current) {
|
||||||
@ -37,7 +40,10 @@ export const TaskGantt: React.FC<TaskGanttProps> = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (verticalContainerRef.current) {
|
if (verticalContainerRef.current) {
|
||||||
verticalContainerRef.current.scrollLeft = scrollX;
|
verticalContainerRef.current.scrollLeft = scrollX;
|
||||||
setDisplayXEndpoint(verticalContainerRef.current.clientWidth + scrollX);
|
setDisplayXStartEndpoint({
|
||||||
|
start: scrollX,
|
||||||
|
end: verticalContainerRef.current.clientWidth + scrollX,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// verticalContainerRef.current?.clientWidth need for resize window tracking
|
// verticalContainerRef.current?.clientWidth need for resize window tracking
|
||||||
}, [scrollX, verticalContainerRef.current?.clientWidth]);
|
}, [scrollX, verticalContainerRef.current?.clientWidth]);
|
||||||
|
|||||||
@ -7,7 +7,10 @@ export type TooltipProps = {
|
|||||||
task: BarTask;
|
task: BarTask;
|
||||||
arrowIndent: number;
|
arrowIndent: number;
|
||||||
svgHeight: number;
|
svgHeight: number;
|
||||||
displayXEndpoint: number;
|
displayXStartEndpoint: {
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
};
|
||||||
rowHeight: number;
|
rowHeight: number;
|
||||||
fontSize: string;
|
fontSize: string;
|
||||||
fontFamily: string;
|
fontFamily: string;
|
||||||
@ -21,7 +24,7 @@ export const Tooltip: React.FC<TooltipProps> = ({
|
|||||||
task,
|
task,
|
||||||
rowHeight,
|
rowHeight,
|
||||||
svgHeight,
|
svgHeight,
|
||||||
displayXEndpoint,
|
displayXStartEndpoint,
|
||||||
arrowIndent,
|
arrowIndent,
|
||||||
fontSize,
|
fontSize,
|
||||||
fontFamily,
|
fontFamily,
|
||||||
@ -29,26 +32,66 @@ export const Tooltip: React.FC<TooltipProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const tooltipRef = useRef<HTMLDivElement | null>(null);
|
const tooltipRef = useRef<HTMLDivElement | null>(null);
|
||||||
const [toolWidth, setToolWidth] = useState(1000);
|
const [toolWidth, setToolWidth] = useState(1000);
|
||||||
|
const [toolHeight, setToolHeight] = useState(1000);
|
||||||
const [relatedY, setRelatedY] = useState(task.index * rowHeight);
|
const [relatedY, setRelatedY] = useState(task.index * rowHeight);
|
||||||
const [relatedX, setRelatedX] = useState(displayXEndpoint);
|
const [relatedX, setRelatedX] = useState(displayXStartEndpoint.end);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (tooltipRef.current) {
|
if (tooltipRef.current) {
|
||||||
const tooltipHeight = tooltipRef.current.offsetHeight;
|
const tooltipHeight = tooltipRef.current.offsetHeight * 1.1;
|
||||||
const tooltipY = task.index * rowHeight;
|
let tooltipY = task.index * rowHeight;
|
||||||
if (tooltipY + tooltipHeight > svgHeight) {
|
|
||||||
setRelatedY(svgHeight - tooltipHeight * 1.05);
|
|
||||||
}
|
|
||||||
const newWidth = tooltipRef.current.scrollWidth * 1.1;
|
const newWidth = tooltipRef.current.scrollWidth * 1.1;
|
||||||
let newRelatedX = task.x2 + arrowIndent + arrowIndent * 0.5;
|
let newRelatedX = task.x2 + arrowIndent + arrowIndent * 0.5;
|
||||||
if (newWidth + newRelatedX > displayXEndpoint) {
|
if (newWidth + newRelatedX > displayXStartEndpoint.end) {
|
||||||
newRelatedX = task.x1 - arrowIndent - arrowIndent * 0.5 - newWidth;
|
newRelatedX = task.x1 - arrowIndent - arrowIndent * 0.5 - newWidth;
|
||||||
}
|
}
|
||||||
|
const tooltipLowerPoint = tooltipHeight + tooltipY;
|
||||||
|
|
||||||
|
if (
|
||||||
|
newRelatedX < displayXStartEndpoint.start &&
|
||||||
|
tooltipLowerPoint > svgHeight
|
||||||
|
) {
|
||||||
|
tooltipY -= tooltipHeight;
|
||||||
|
newRelatedX = (task.x1 + task.x2 - newWidth) * 0.5;
|
||||||
|
if (newRelatedX + newWidth > displayXStartEndpoint.end) {
|
||||||
|
newRelatedX = displayXStartEndpoint.end - newWidth;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
newRelatedX + newWidth > displayXStartEndpoint.end ||
|
||||||
|
newRelatedX - newWidth < displayXStartEndpoint.start
|
||||||
|
) {
|
||||||
|
newRelatedX = displayXStartEndpoint.end - newWidth;
|
||||||
|
}
|
||||||
|
} else if (
|
||||||
|
newRelatedX < displayXStartEndpoint.start &&
|
||||||
|
tooltipLowerPoint < svgHeight
|
||||||
|
) {
|
||||||
|
tooltipY += rowHeight;
|
||||||
|
newRelatedX = (task.x1 + task.x2 - newWidth) * 0.5;
|
||||||
|
if (
|
||||||
|
newRelatedX + newWidth > displayXStartEndpoint.end ||
|
||||||
|
newRelatedX - newWidth < displayXStartEndpoint.start
|
||||||
|
) {
|
||||||
|
newRelatedX = displayXStartEndpoint.end - newWidth;
|
||||||
|
}
|
||||||
|
} else if (tooltipLowerPoint > svgHeight) {
|
||||||
|
tooltipY = svgHeight - tooltipHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
setRelatedY(tooltipY);
|
||||||
setToolWidth(newWidth);
|
setToolWidth(newWidth);
|
||||||
setRelatedX(newRelatedX);
|
setRelatedX(newRelatedX);
|
||||||
|
if (tooltipHeight !== 1000) {
|
||||||
|
setToolHeight(tooltipHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [tooltipRef, task, arrowIndent, displayXEndpoint]);
|
}, [tooltipRef, task, arrowIndent, displayXStartEndpoint]);
|
||||||
return (
|
return (
|
||||||
<foreignObject x={relatedX} y={relatedY} width={toolWidth} height={1000}>
|
<foreignObject
|
||||||
|
x={relatedX}
|
||||||
|
y={relatedY}
|
||||||
|
width={toolWidth}
|
||||||
|
height={toolHeight}
|
||||||
|
>
|
||||||
<div ref={tooltipRef} className={styles.tooltipDetailsContainer}>
|
<div ref={tooltipRef} className={styles.tooltipDetailsContainer}>
|
||||||
<TooltipContent
|
<TooltipContent
|
||||||
task={task}
|
task={task}
|
||||||
|
|||||||
@ -14,6 +14,10 @@ export const convertToBarTasks = (
|
|||||||
barProgressSelectedColor: string,
|
barProgressSelectedColor: string,
|
||||||
barBackgroundColor: string,
|
barBackgroundColor: string,
|
||||||
barBackgroundSelectedColor: string,
|
barBackgroundSelectedColor: string,
|
||||||
|
projectProgressColor: string,
|
||||||
|
projectProgressSelectedColor: string,
|
||||||
|
projectBackgroundColor: string,
|
||||||
|
projectBackgroundSelectedColor: string,
|
||||||
milestoneBackgroundColor: string,
|
milestoneBackgroundColor: string,
|
||||||
milestoneBackgroundSelectedColor: string
|
milestoneBackgroundSelectedColor: string
|
||||||
) => {
|
) => {
|
||||||
@ -37,6 +41,10 @@ export const convertToBarTasks = (
|
|||||||
barProgressSelectedColor,
|
barProgressSelectedColor,
|
||||||
barBackgroundColor,
|
barBackgroundColor,
|
||||||
barBackgroundSelectedColor,
|
barBackgroundSelectedColor,
|
||||||
|
projectProgressColor,
|
||||||
|
projectProgressSelectedColor,
|
||||||
|
projectBackgroundColor,
|
||||||
|
projectBackgroundSelectedColor,
|
||||||
milestoneBackgroundColor,
|
milestoneBackgroundColor,
|
||||||
milestoneBackgroundSelectedColor
|
milestoneBackgroundSelectedColor
|
||||||
);
|
);
|
||||||
@ -71,6 +79,10 @@ const convertToBarTask = (
|
|||||||
barProgressSelectedColor: string,
|
barProgressSelectedColor: string,
|
||||||
barBackgroundColor: string,
|
barBackgroundColor: string,
|
||||||
barBackgroundSelectedColor: string,
|
barBackgroundSelectedColor: string,
|
||||||
|
projectProgressColor: string,
|
||||||
|
projectProgressSelectedColor: string,
|
||||||
|
projectBackgroundColor: string,
|
||||||
|
projectBackgroundSelectedColor: string,
|
||||||
milestoneBackgroundColor: string,
|
milestoneBackgroundColor: string,
|
||||||
milestoneBackgroundSelectedColor: string
|
milestoneBackgroundSelectedColor: string
|
||||||
): BarTask => {
|
): BarTask => {
|
||||||
@ -91,6 +103,23 @@ const convertToBarTask = (
|
|||||||
milestoneBackgroundSelectedColor
|
milestoneBackgroundSelectedColor
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case "project":
|
||||||
|
barTask = convertToBar(
|
||||||
|
task,
|
||||||
|
index,
|
||||||
|
dates,
|
||||||
|
dateDelta,
|
||||||
|
columnWidth,
|
||||||
|
rowHeight,
|
||||||
|
taskHeight,
|
||||||
|
barCornerRadius,
|
||||||
|
handleWidth,
|
||||||
|
projectProgressColor,
|
||||||
|
projectProgressSelectedColor,
|
||||||
|
projectBackgroundColor,
|
||||||
|
projectBackgroundSelectedColor
|
||||||
|
);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
barTask = convertToBar(
|
barTask = convertToBar(
|
||||||
task,
|
task,
|
||||||
@ -127,6 +156,7 @@ const convertToBar = (
|
|||||||
barBackgroundColor: string,
|
barBackgroundColor: string,
|
||||||
barBackgroundSelectedColor: string
|
barBackgroundSelectedColor: string
|
||||||
): BarTask => {
|
): BarTask => {
|
||||||
|
debugger;
|
||||||
const x1 = taskXCoordinate(task.start, dates, dateDelta, columnWidth);
|
const x1 = taskXCoordinate(task.start, dates, dateDelta, columnWidth);
|
||||||
const x2 = taskXCoordinate(task.end, dates, dateDelta, columnWidth);
|
const x2 = taskXCoordinate(task.end, dates, dateDelta, columnWidth);
|
||||||
const y = taskYCoordinate(index, rowHeight, taskHeight);
|
const y = taskYCoordinate(index, rowHeight, taskHeight);
|
||||||
|
|||||||
@ -86,6 +86,10 @@ export interface StylingOption {
|
|||||||
barProgressSelectedColor?: string;
|
barProgressSelectedColor?: string;
|
||||||
barBackgroundColor?: string;
|
barBackgroundColor?: string;
|
||||||
barBackgroundSelectedColor?: string;
|
barBackgroundSelectedColor?: string;
|
||||||
|
projectProgressColor?: string;
|
||||||
|
projectProgressSelectedColor?: string;
|
||||||
|
projectBackgroundColor?: string;
|
||||||
|
projectBackgroundSelectedColor?: string;
|
||||||
milestoneBackgroundColor?: string;
|
milestoneBackgroundColor?: string;
|
||||||
milestoneBackgroundSelectedColor?: string;
|
milestoneBackgroundSelectedColor?: string;
|
||||||
arrowColor?: string;
|
arrowColor?: string;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user