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

fix(chart) fixed cursor positioning with large Y rescaling without LV_USE_LARGE_COORD #2399

merged 1 commit into from Jul 23, 2021


Copy link

Description of the feature or fix

Example of the issue (notice the chart.set_range(lv.chart.AXIS.PRIMARY_Y, -1000, 1000), and that when clicking the chart the cursor gets wrongly positioned):

This is due to the overflow of
p_out->y = (int32_t)((int32_t)ser->y_points[id] - chart->ymin[ser->y_axis_sec]) * h;
when p_out->y is an int16_t (when LV_USE_LARGE_COORD is not set).
This is just a temporary calculation, so there is no need to use LV_USE_LARGE_COORD just for this. In most cases, after the division:
p_out->y = p_out->y / (chart->ymax[ser->y_axis_sec] - chart->ymin[ser->y_axis_sec])
p_out->y will again be in the [-32k,+32k] range.
Using a temporary int32_t solves this.

Copy link

Looks good, thank you!

@kisvegabor kisvegabor merged commit 1b7e2b5 into lvgl:master Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants