-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
The code on the Readme:
val pointsData: List<Point> =
listOf(Point(0f, 40f), Point(1f, 90f), Point(2f, 0f), Point(3f, 60f), Point(4f, 10f))
val xAxisData = AxisData.Builder()
.axisStepSize(100.dp)
.backgroundColor(Color.Blue)
.steps(pointsData.size - 1)
.labelData { i -> i.toString() }
.labelAndAxisLinePadding(15.dp)
.build()
val yAxisData = AxisData.Builder()
.steps(steps)
.backgroundColor(Color.Red)
.labelAndAxisLinePadding(20.dp)
.labelData { i ->
val yScale = 100 / steps
(i * yScale).formatToSinglePrecision()
}.build()
val lineChartData = LineChartData(
linePlotData = LinePlotData(
lines = listOf(
Line(
dataPoints = pointsData,
LineStyle(),
IntersectionPoint(),
SelectionHighlightPoint(),
ShadowUnderLine(),
SelectionHighlightPopUp()
)
),
),
xAxisData = xAxisData,
yAxisData = yAxisData,
gridLines = GridLines(),
backgroundColor = Color.White
)
LineChart(
modifier = Modifier
.fillMaxWidth()
.height(300.dp),
lineChartData = lineChartData
)
This has several problems:
Doesn't compile
This doesn't compile:
.labelData { i ->
val yScale = 100 / steps
(i * yScale).formatToSinglePrecision()
}.build()
If you change the 100
into 100f
, it does.
Wrong value in y axis (1)
If I correct this, it looks like this:
Like you can see, the y axis implies that the second dot has the value of 100. It does not: it has the value of 90.
Wrong value in y axis (2)
If you then change the third point from Point(2f, 0f)
to Point(2f, 10f)
, it looks like this:

The third value is then implied to be 0. It is not, it has the value of 10.
First number of the X axis can't be read
The 0 on the X axis can't be read as it is overwritten by the red Y axis legend. The previous issues are all related, but this is a new one.
Metadata
Metadata
Assignees
Labels
No labels