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

Click on chart bar returns last item but not clicked one. #73

Closed
ihar-paliashchuk opened this issue Aug 25, 2021 · 1 comment
Closed

Comments

@ihar-paliashchuk
Copy link

ihar-paliashchuk commented Aug 25, 2021

Hi everyone, I have an issue - when clicking on histogram serries I receive the last HistogramData and current point on the screen. Is this an issue or intended behavior? I expect to return a HistogramData which I click.
If I long click on HistogramData and after a simple click then HistogramData is right, which I clicked.

My setup:

lateinit var histogramSeries: SeriesApi


chart.api.applyOptions {
                layout = layoutOptions {
                    crosshair = CrosshairOptions(
                        vertLine = CrosshairLineOptions(visible = false, labelVisible = false),
                        horzLine = CrosshairLineOptions(visible = false, labelVisible = false)
                    )
                    leftPriceScale = PriceScaleOptions(visible = false)
                    rightPriceScale = PriceScaleOptions(visible = false)
                    handleScale = HandleScaleOptions(
                        mouseWheel = false,
                        pinch = false,
                        axisPressedMouseMove = AxisPressedMouseMoveOptions(time = false, price = false),
                        axisFloatClickReset = false)
                    timeScale = TimeScaleOptions(
                        borderVisible = false,
                        fixLeftEdge = true,
                        fixRightEdge = true,
                        visible = false
                    )
                    handleScroll = HandleScrollOptions(
                        mouseWheel = false,
                        pressedMouseMove = false,
                        horzTouchDrag = false,
                        vertTouchDrag = false
                    )
                    grid = gridOptions {
                        vertLines = GridLineOptions(visible = false)
                        horzLines = GridLineOptions(visible = false)
                    }
                }
            }

            chart.api.addHistogramSeries(
                options = HistogramSeriesOptions(priceLineVisible = false),
                onSeriesCreated = { series ->
                    histogramSeries = series
                }
            )

            val data = listOf(
                HistogramData(Time.BusinessDay(2019, 6, 11), 40.01f),
                HistogramData(Time.BusinessDay(2019, 6, 12), 52.38f),
                HistogramData(Time.BusinessDay(2019, 6, 13), 36.30f),
                HistogramData(Time.BusinessDay(2019, 6, 14), 34.48f),
                WhitespaceData(Time.BusinessDay(2019, 6, 15)),
                WhitespaceData(Time.BusinessDay(2019, 6, 16)),
                HistogramData(Time.BusinessDay(2019, 6, 17), 41.50f),
                HistogramData(Time.BusinessDay(2019, 6, 18), 34.82f)
            )

            histogramSeries.setData(data)
            chart.api.timeScale.fitContent()

            chart.api.subscribeClick {
                 Log.w("", it.toString())
            }
}
@ihar-paliashchuk ihar-paliashchuk changed the title Click on chart bar returns last item but not current. Click on chart bar returns last item but not clicked one. Aug 25, 2021
@timocov
Copy link
Contributor

timocov commented Aug 25, 2021

I think this is actually duplicate of tradingview/lightweight-charts#657. Correct me if I'm wrong.

@timocov timocov closed this as completed Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants