-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathGanttUtils.kt
More file actions
50 lines (46 loc) · 1.78 KB
/
GanttUtils.kt
File metadata and controls
50 lines (46 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package info.appdev.chartexample
import info.appdev.charting.data.BarEntry
/**
* Utility class for creating time interval entries for Gantt-style charts.
* Provides helper methods to create BarEntry objects with time interval data.
*/
object GanttUtils {
/**
* Create a time interval entry for a single task.
*
* @param taskIndex Y-axis position (task row)
* @param startTime Start time value
* @param duration Duration value
* @return BarEntry configured for time interval rendering
*/
fun createTimeIntervalEntry(taskIndex: Float, startTime: Float, duration: Float): BarEntry {
return BarEntry(taskIndex, floatArrayOf(startTime, duration))
}
/**
* Create a time interval entry with multiple segments.
* Useful for showing multiple time ranges for a single task.
*
* @param taskIndex Y-axis position (task row)
* @param timeIntervals Array of [start1, duration1, start2, duration2, ...]
* @return BarEntry configured for time interval rendering
*/
fun createMultiSegmentEntry(taskIndex: Float, timeIntervals: FloatArray): BarEntry {
require(timeIntervals.size >= 2) { "timeIntervals must have at least 2 elements" }
return BarEntry(taskIndex, timeIntervals)
}
/**
* Create a time interval entry with custom data.
*
* @param taskIndex Y-axis position (task row)
* @param startTime Start time value
* @param duration Duration value
* @param data Custom data object
* @return BarEntry configured for time interval rendering with data
*/
fun createTimeIntervalEntry(
taskIndex: Float, startTime: Float,
duration: Float, data: Any?
): BarEntry {
return BarEntry(taskIndex, floatArrayOf(startTime, duration), data)
}
}