Madrapps / plot

An android compose library with different Graphs and Charts
Apache License 2.0
159 stars 20 forks source link

LineWidth is not synchronized to XAxisWidth #8

Open jns-codeworks opened 2 years ago

jns-codeworks commented 2 years ago

It seems like XAxis.stepSize is not synchronized to the xOffset between DataPoints. Changing stepSize only has effect on XAxis, not on Line

    val ethereumOneWeek = listOf(
        DataPoint(1f, 2938.67f),
        DataPoint(2f, 2971.3f),
        DataPoint(3f, 2887.21f),
        DataPoint(4f, 2704.42f),
        DataPoint(5f, 2646.03f),
        DataPoint(6f, 2637.95f),
        DataPoint(7f, 2548.08f),
    )

    LineGraph(
        plot = LinePlot(
            grid = LinePlot.Grid(Color.White.copy(alpha = 0.12f)),
            lines = listOf(
                element = LinePlot.Line(
                    dataPoints = ethereumOneWeek,
                    connection = LinePlot.Connection(color, 2.dp),
                    intersection = null,
                ),
            ),
            xAxis = LinePlot.XAxis(
                steps = 7,
                stepSize = 40.dp,
            ),
        ),
        modifier = Modifier
            .fillMaxWidth()
            .height(200.dp)
    )

chart

GH860 commented 1 year ago

you can change this line val xOffset = 20.dp.toPx() * xZoom.value in draw function to val xOffset = plot.xAxis.stepSize.toPx() * xZoom.value

superdiazzz commented 3 months ago

you can change this line val xOffset = 20.dp.toPx() * xZoom.value in draw function to val xOffset = plot.xAxis.stepSize.toPx() * xZoom.value

Where i can write this code? please more detail