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

feat(ssr): add useViewBox opts in renderToSVGString #16272

Merged
merged 1 commit into from
Dec 23, 2021
Merged

Conversation

pissang
Copy link
Contributor

@pissang pissang commented Dec 23, 2021

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Add useViewBox opt in renderToSVGString method to make the generated SVG responsive.

Related PR: #15880 (comment)

Fixed issues

#16127 (comment)

Details

Before: What was the problem?

The generated SVG has no viewBox attribute and is not responsive.

After: How is it fixed in this PR?

Use a useViewBox opt (default to be true) to add viewBox attribute. It's responsive now when width and height are changed.

This allows use to configure width and height in the CSS.

.chart svg {
  width: 100%;
  height: 100%;
}

Misc

@echarts-bot
Copy link

echarts-bot bot commented Dec 23, 2021

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

The pull request is marked to be PR: author is committer because you are a committer of this project.

Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the PR: awaiting doc label.

This PR depends on ZRender changes. Please update the ZRender dependency to the latest nightly version including this change, which takes place everyday at 8:00 UTC (16:00 Beijing Time).
You can use npm i zrender@npm:zrender-nightly@dev to update package.json.
If you have any question about this, please leave a comment and we will give you extra help on this.

@pissang pissang merged commit e084934 into next Dec 23, 2021
@pissang pissang deleted the svg-ssr-viewbox branch December 23, 2021 09:25
@echarts-bot
Copy link

echarts-bot bot commented Dec 23, 2021

Congratulations! Your PR has been merged. Thanks for your contribution! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: author is committer PR: awaiting doc Document changes is required for this PR. size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants