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 issue 4216: grid padding calc to support array of stroke widths #4410

Merged
merged 3 commits into from
Apr 21, 2024

Conversation

veryinsanee
Copy link
Contributor

New Pull Request

This commit adjusts the plotCoords method to correctly handle cases where the stroke width (stroke.width) is provided as an array of values, which corresponds to different series in the visualization. Previously, the code assumed a single numeric value, leading to incorrect grid padding calculations when multiple series with different stroke widths were present.

Now, the method checks if stroke.width is an array and uses the maximum value from this array for setting grid padding, ensuring that the largest stroke width is properly accommodated.

Changes include:

  • Adding a condition to determine whether stroke.width is an array.
  • Using Math.max(...) to find the maximum stroke width when necessary.
  • Applying this maximum value to adjust gridPad.top and gridPad.bottom.

Fixes #4216

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

…idths

This commit adjusts the `plotCoords` method to correctly handle cases where the stroke width (`stroke.width`) is provided as an array of values, which corresponds to different series in the visualization. Previously, the code assumed a single numeric value, leading to incorrect grid padding calculations when multiple series with different stroke widths were present. 

Now, the method checks if `stroke.width` is an array and uses the maximum value from this array for setting grid padding, ensuring that the largest stroke width is properly accommodated. This fix improves the rendering of visual elements in the chart by preventing clipping and ensuring consistent padding.

Changes include:
- Adding a condition to determine whether `stroke.width` is an array.
- Using `Math.max(...)` to find the maximum stroke width when necessary.
- Applying this maximum value to adjust `gridPad.top` and `gridPad.bottom`.
@junedchhipa junedchhipa merged commit 44d61f6 into apexcharts:main Apr 21, 2024
@lmansur
Copy link

lmansur commented Apr 22, 2024

Thanks @veryinsanee!

@Seros
Copy link

Seros commented Jun 17, 2024

I'm just facing the same issue when I want to change the width of the stroke for multiple series from an numer to an array at
/~https://github.com/VueTorrent/VueTorrent/blob/master/src/components/Navbar/SideWidgets/SpeedGraph.vue#L31
The packages are all up2date but still the graph does not show up. Do you have any idea?

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

Successfully merging this pull request may close these issues.

Can't modify stroke width of multi-series sparkline chart
4 participants