Skip to content

feat(SVG): support for viewport in SVG only providing width and height#1403

Merged
dangreen merged 3 commits intochartist-js:mainfrom
evangelion1204:support-viewbox
Sep 30, 2025
Merged

feat(SVG): support for viewport in SVG only providing width and height#1403
dangreen merged 3 commits intochartist-js:mainfrom
evangelion1204:support-viewbox

Conversation

@evangelion1204
Copy link
Contributor

@evangelion1204 evangelion1204 commented Mar 2, 2023

For now a draft but this should outline what should be achieved. The charts scale without redrawing and rearranging. The drawback might be that fonts can get too small if no responsive options are used.

I do believe we could also smartly skip redraw in such cases until we hit a breakpoint.

Closes #1402

@gionkunz
Copy link
Collaborator

Hey, thanks for your contribution! I guess this would also be relevant for the other chart types, right? https://github.com/chartist-js/chartist/blob/main/src/charts/BarChart/BarChart.ts#L215-L221

@evangelion1204
Copy link
Contributor Author

evangelion1204 commented Mar 23, 2023

Sure, I just use a fork right now and needed it for Line-Charts although I also have Bar-Chats in use. I am going to add it here too. I will update the PR within the next days.

@evangelion1204
Copy link
Contributor Author

@gionkunz the example I added it to is not too great though. Only thing missing are unit tests around the createSvg function.

@evangelion1204
Copy link
Contributor Author

Ok, updated the tests.

@evangelion1204
Copy link
Contributor Author

@gionkunz In case you got some time please review. I would also like to create more PRs later on.

@evangelion1204
Copy link
Contributor Author

@gionkunz Quick reminder 😄

@dangreen dangreen merged commit 752f0a7 into chartist-js:main Sep 30, 2025
@github-actions github-actions bot mentioned this pull request Sep 30, 2025
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.

Support for viewBox for scalable and responsive charts

3 participants