Package-level declarations
Types
Link copied to clipboard
data class GridLines(val color: Color = Color.LightGray, val lineWidth: Dp = 1.dp, val pathEffect: PathEffect? = null, val alpha: Float = 1.0f, val colorFilter: ColorFilter? = null, val blendMode: BlendMode = DrawScope.DefaultBlendMode, val enableHorizontalLines: Boolean = true, val enableVerticalLines: Boolean = true, val drawHorizontalLines: DrawScope.(Float, Float, Float) -> Unit = { xStart, y, xEnd ->
drawLine(
color = color,
start = Offset(xStart, y),
end = Offset(xEnd, y),
strokeWidth = lineWidth.toPx(),
pathEffect = pathEffect,
colorFilter = colorFilter,
blendMode = blendMode
)
}, val drawVerticalLines: DrawScope.(Float, Float, Float) -> Unit = { x, yStart, yEnd ->
drawLine(
color = color,
start = Offset(x, yStart),
end = Offset(x, yEnd),
strokeWidth = lineWidth.toPx(),
pathEffect = pathEffect,
colorFilter = colorFilter,
blendMode = blendMode
)
})
Represents the grid lines for any graph
Link copied to clipboard
data class IntersectionPoint(val color: Color = Color.Black, val radius: Dp = 6.dp, val alpha: Float = 1.0f, val style: DrawStyle = Fill, val colorFilter: ColorFilter? = null, val blendMode: BlendMode = DrawScope.DefaultBlendMode, val draw: DrawScope.(Offset) -> Unit = { center ->
drawCircle(
color,
radius.toPx(),
center,
alpha,
style,
colorFilter,
blendMode
)
})
Represents a point on the line graph
Link copied to clipboard
data class Line(val dataPoints: List<Point>, val lineStyle: LineStyle = LineStyle(), val intersectionPoint: IntersectionPoint? = null, val selectionHighlightPoint: SelectionHighlightPoint? = null, val shadowUnderLine: ShadowUnderLine? = null, val selectionHighlightPopUp: SelectionHighlightPopUp? = null)
Represent a Line in the co.yml.charts.ui.linechart
Link copied to clipboard
data class LineChartData(val linePlotData: LinePlotData, val xAxisData: AxisData = AxisData.Builder().build(), val yAxisData: AxisData = AxisData.Builder().build(), val isZoomAllowed: Boolean = true, val paddingTop: Dp = 30.dp, val bottomPadding: Dp = 10.dp, val paddingRight: Dp = 10.dp, val containerPaddingEnd: Dp = 15.dp, val backgroundColor: Color = Color.White, val gridLines: GridLines? = null, val accessibilityConfig: AccessibilityConfig = AccessibilityConfig())
LineGraphData data class that contains all params user need to define to draw a line graph.
Link copied to clipboard
LinePlotData is a data class that holds line graph related data and styling components
Link copied to clipboard
data class LineStyle(val lineType: LineType = LineType.SmoothCurve(isDotted = false), val color: Color = Color.Black, val width: Float = 8.0f, val alpha: Float = 1.0f, val style: DrawStyle = Stroke(width = width), val colorFilter: ColorFilter? = null, val blendMode: BlendMode = DefaultBlendMode)
Handles styling for the path drawn in the line graph
Link copied to clipboard
data class SelectionHighlightPoint(val color: Color = Color.Red, val radius: Dp = 6.dp, val alpha: Float = 1.0f, val style: DrawStyle = Fill, val colorFilter: ColorFilter? = null, val blendMode: BlendMode = DrawScope.DefaultBlendMode, val draw: DrawScope.(Offset) -> Unit = { point ->
drawCircle(
color,
radius.toPx(),
point,
alpha,
style,
colorFilter,
blendMode
)
}, val isHighlightLineRequired: Boolean = true, val drawHighlightLine: DrawScope.(Offset, Offset) -> Unit = { start, end ->
drawLine(
color,
start,
end,
(radius / 2).toPx(),
Stroke.DefaultCap,
PathEffect.dashPathEffect(floatArrayOf(40f, 20f)),
alpha,
colorFilter,
blendMode
)
})
Represents the point when it is selected on the line graph
Link copied to clipboard
data class SelectionHighlightPopUp(val backgroundColor: Color = Color.White, val backgroundAlpha: Float = 0.7f, val backgroundCornerRadius: CornerRadius = CornerRadius(5f), val backgroundColorFilter: ColorFilter? = null, val backgroundBlendMode: BlendMode = DrawScope.DefaultBlendMode, val backgroundStyle: DrawStyle = Fill, val paddingBetweenPopUpAndPoint: Dp = 20.dp, val labelSize: TextUnit = 14.sp, val labelColor: Color = Color.Black, val labelAlignment: Paint.Align = Paint.Align.CENTER, val labelTypeface: Typeface = Typeface.DEFAULT, val popUpLabel: (Float, Float) -> String = { x, y ->
val xLabel = "x : ${x.toInt()} "
val yLabel = "y : ${String.format("%.2f", y)}"
"$xLabel $yLabel"
}, val draw: DrawScope.(Offset, Point) -> Unit = { selectedOffset, identifiedPoint ->
val highlightTextPaint = TextPaint().apply {
textSize = labelSize.toPx()
color = labelColor.toArgb()
textAlign = labelAlignment
typeface = labelTypeface
}
val label = popUpLabel(identifiedPoint.x, identifiedPoint.y)
drawContext.canvas.nativeCanvas.apply {
val background = getTextBackgroundRect(
selectedOffset.x,
selectedOffset.y,
label,
highlightTextPaint
)
drawRoundRect(
color = backgroundColor,
topLeft = Offset(
background.left.toFloat(),
background.top.toFloat() - paddingBetweenPopUpAndPoint.toPx()
),
size = Size(background.width().toFloat(), background.height().toFloat()),
alpha = backgroundAlpha,
cornerRadius = backgroundCornerRadius,
colorFilter = backgroundColorFilter,
blendMode = backgroundBlendMode,
style = backgroundStyle
)
drawText(
label,
selectedOffset.x,
selectedOffset.y - paddingBetweenPopUpAndPoint.toPx(),
highlightTextPaint
)
}
})
SelectionHighlightPopUp is a data class used to draw the pop on the given selected point on a line to identify the dimensions of the selected point.All the styling related params are included here
Link copied to clipboard
data class ShadowUnderLine(val color: Color = Color.Black, val brush: Brush? = null, val alpha: Float = 0.1f, val style: DrawStyle = Fill, val colorFilter: ColorFilter? = null, val blendMode: BlendMode = DrawScope.DefaultBlendMode, val draw: DrawScope.(Path) -> Unit = { path ->
if (brush != null) {
drawPath(path, brush, alpha, style, colorFilter, blendMode)
} else {
drawPath(path, color, alpha, style, colorFilter, blendMode)
}
}, val drawMultiColor: DrawScope.(Path, Color, Brush?) -> Unit = { path, multiColor, multiColorBrush ->
if (multiColorBrush != null) {
drawPath(path, multiColorBrush, alpha, style, colorFilter, blendMode)
} else {
drawPath(path, multiColor, alpha, style, colorFilter, blendMode)
}
})
Controls the drawing behaviour of the area/section under the line.