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

[Bug] overlay with point in the future does not saving right #459

Open
oneart-dev opened this issue Jun 26, 2023 · 7 comments
Open

[Bug] overlay with point in the future does not saving right #459

oneart-dev opened this issue Jun 26, 2023 · 7 comments

Comments

@oneart-dev
Copy link
Contributor

Version

9.5.9

Steps to Reproduce

  1. Draw segment or any 2 point overlays with second point beyond last candle (future)
  2. Check overlay points data

Current Behavior

If check points data it will looks li that:

{
"points":[{"timestamp":1687420800000,"value":0.09349152777777778},{"value":0.1189336111111111}]}
}

It will lead to bugs if saving it and restore later

Expected Behavior

Chart should calculate timestamp based on interval and point location or do not let user to make point in the future

Environment

- OS: Macos
- Browser: any
- Framework: not related

Any additional comments?

No response

@oneart-dev
Copy link
Contributor Author

Screen.Recording.2023-06-26.at.11.54.11.mov

@oneart-dev
Copy link
Contributor Author

oneart-dev commented Jun 26, 2023

Best possible fix probably will be draw invisible candles all the way to the right.
Sadly "performEventMoveForDrawing" do not provide kline data at all, so it really hard to implement dirty fix to stop users from drawing beyond last candle

@oneart-dev
Copy link
Contributor Author

I fixed it in my repo by updating it in OverlayView.ts function _coordinateToPoint:

   if (this.coordinateToPointTimestampDataIndexFlag()) {
      const xAxis = chart.getPaneById(PaneIdConstants.XAXIS)?.getAxisComponent() as Axis
      const dataIndex = xAxis.convertFromPixel(coordinate.x)
      const timestamp = timeScaleStore.dataIndexToTimestamp(dataIndex) ?? undefined
      const klines = chart.getChartStore().getDataList()
      if (timestamp === undefined) {
        const index = dataIndex < 0 ? 0 : dataIndex > klines.length - 1 ? klines.length - 1 : dataIndex
        point.timestamp = klines[index].timestamp
        point.dataIndex = index
      } else {
        point.dataIndex = dataIndex
        point.timestamp = timestamp
      }
    }

@liihuu
Copy link
Member

liihuu commented Aug 15, 2023

It may not be necessary to change the source code, listen to the onDrawing of overlay, and then determine if it exceeds the boundary, forcing a reassignment of points.

@Basttyy
Copy link

Basttyy commented Aug 15, 2023

It may not be necessary to change the source code, listen to the onDrawing of overlay, and then determine if it exceeds the boundary, forcing a reassignment of points.

I noticed this too

@oneart-dev
Copy link
Contributor Author

oneart-dev commented Aug 15, 2023

But its not a solution for the problem. If library can't handle it should force it by default.

@xtrmus
Copy link

xtrmus commented Sep 22, 2023

KLineChart._.Features.preview.-.Google.Chrome.22.09.2023.09_49_57.online-video-cutter.com.mp4

Likewise, if the starting and ending points are too far apart, the overlay remains hidden when LoadMore is not performed.

(Even if it is within Timestamp borders)

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

4 participants