Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong plot of data in Line Chart #155

Open
Randomboiii03 opened this issue Jan 21, 2024 · 4 comments
Open

Wrong plot of data in Line Chart #155

Randomboiii03 opened this issue Jan 21, 2024 · 4 comments

Comments

@Randomboiii03
Copy link

Randomboiii03 commented Jan 21, 2024

Did I do wrong when setting the chart? All I did is put my data in the chart component, as you can see the data in y value is 1 and the highest is 2 which my data has no 0 value, its 1 and 2s only. Why does it do this, is it my setup fault or is it a bug? Anyone can help me? Thanks

@Composable
private fun getLineChartData(pointData: List<Point>, yScale: Int): LineChartData {
    return LineChartData(
        linePlotData = LinePlotData(
            lines = listOf(
                Line(
                    dataPoints = pointData,
                    LineStyle(
                        color = MaterialTheme.colorScheme.onTertiaryContainer,
                        width = 6f,
                        lineType = LineType.SmoothCurve(isDotted = false)
                    ),
                    IntersectionPoint(
                        color = MaterialTheme.colorScheme.onTertiaryContainer,
                        radius = 4.dp
                    ),
                    SelectionHighlightPoint(color = MaterialTheme.colorScheme.onTertiaryContainer),
                    ShadowUnderLine(
                        alpha = 0.5f,
                        brush = Brush.verticalGradient(
                            colors = listOf(
                                MaterialTheme.colorScheme.onTertiaryContainer,
                                Color.Transparent
                            )
                        )
                    ),
                    SelectionHighlightPopUp()
                )
            )
        ),
        backgroundColor = MaterialTheme.colorScheme.tertiaryContainer,
        xAxisData = getXAxisData(pointData = pointData),
        yAxisData = getYAxisData(yScale = yScale),
        gridLines = GridLines(
            color = MaterialTheme.colorScheme.onTertiaryContainer,
            enableVerticalLines = false
        ),
        paddingRight = 0.dp
    )
}

419999724_401804508903006_5330249170642921648_n

@YSNBx
Copy link

YSNBx commented Jan 21, 2024

Same issue here. When you start the y-axis with 0 but there's no 0 correlated value in your data points, the axis ie either pushed further down to compensate for that "missing" point in your data points and assigns the lowest value to the 0 value on the y-axis.

This needs fixing. I haven't found a way to circumvent it.

@Randomboiii03
Copy link
Author

Same issue here. When you start the y-axis with 0 but there's no 0 correlated value in your data points, the axis ie either pushed further down to compensate for that "missing" point in your data points and assigns the lowest value to the 0 value on the y-axis.

This needs fixing. I haven't found a way to circumvent it.

Did you find any work around for this problem?

@YSNBx
Copy link

YSNBx commented Jan 27, 2024

I haven't, unfortunately. Let me know if you find any workaround.

@saiteja962
Copy link

On looking at the source code.. found out the cause of this issue.. They are setting the min and max values for x and y axis based on the data that we set to plot the charts.

For example, in your case, the data set consists of only 1 and 2.. so here the min and max value for your y axis will be taken as 1 and 2 respectively. Instead the min and max value for the y axis should be from the label that you set to the axis which is 0 and 2.

Either the the sdk has to give the user to set the min and max values explicitly or the min and max values should be calculated from the axis data that the user provides instead of the points data that is used to plot the points in the chart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants