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

hotfix/dev-107.30 → develop #2057

Merged
merged 27 commits into from
Dec 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6db80eb
Upgrades sirius-web 🕸️
jakobvogel Nov 18, 2024
9419955
Merge branch 'develop' into feature/jvo/OX-9272-SVG-Charts
jakobvogel Nov 26, 2024
2809faf
Upgrades Sirius ☄️
jakobvogel Nov 26, 2024
0950f8f
Merge branch 'develop' into feature/jvo/OX-9272-SVG-Charts
jakobvogel Nov 27, 2024
b237f2a
Removes dependency on JFreeChart ⚰️
jakobvogel Dec 3, 2024
d9035eb
Adds data container for charts 📊
jakobvogel Dec 5, 2024
57bf5ef
Adds pie and spider charts 📈
jakobvogel Dec 5, 2024
2a5d29f
Adds helper for obtaining a PDF-compatible SCG chart 🖨️
jakobvogel Dec 5, 2024
6971bdc
Bumps Sirius dependencies 🪐
jakobvogel Dec 5, 2024
fbd95d6
Merge pull request #2056 from scireum/ili/HF_107.2.1
jakobvogel Dec 6, 2024
4240299
Merge branch 'hotfix/dev-107.3.0' into feature/jvo/OX-9272-SVG-Charts
jakobvogel Dec 6, 2024
bcf0fbe
Removes blank line 🧹
jakobvogel Dec 11, 2024
9e920ca
Inlines helpers 🥞
jakobvogel Dec 11, 2024
e7aa697
Moves remaining static methods into helper class 🚛
jakobvogel Dec 11, 2024
9b2fad4
Inlines another helper 🫧
jakobvogel Dec 11, 2024
c98cb8f
Renames variables 📛
jakobvogel Dec 11, 2024
49dc88c
Uses `Math.TAU` 🐂
jakobvogel Dec 11, 2024
ffb3112
Renames abstract base class 📇
jakobvogel Dec 11, 2024
abda5ac
Adapts gray colors to design system definitions 🎨
jakobvogel Dec 11, 2024
db3ac87
Renames spider to radar chart 🕷️
jakobvogel Dec 11, 2024
6991f3f
Introduces a doughnut chart 🍩
jakobvogel Dec 11, 2024
5e2cbec
Renamed constants 📛
jakobvogel Dec 11, 2024
5d944a5
Writes numbers differently ✍️
jakobvogel Dec 11, 2024
1cd2fc0
Moves the internal helper back 🎡
jakobvogel Dec 11, 2024
09fccfd
Improves documentation and wording ✍️
jakobvogel Dec 11, 2024
2883f89
Merge pull request #2054 from scireum/feature/jvo/OX-9272-SVG-Charts
jakobvogel Dec 12, 2024
7f36257
Merge branch 'develop' into hotfix/dev-107.3.0
jakobvogel Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moves the internal helper back 🎡
…as I misunderstood @sabieber's review feedback.

OX-9272
  • Loading branch information
jakobvogel committed Dec 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 1cd2fc0bb16101d024113f8683b142e41bf0dbe9
22 changes: 22 additions & 0 deletions src/main/java/sirius/biz/charts/Chart.java
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@

package sirius.biz.charts;

import org.apache.batik.anim.dom.SVGDOMImplementation;
import org.w3c.dom.Element;

import java.awt.Dimension;
@@ -156,4 +157,25 @@ public abstract class Chart {
* @return the SVG representation of the chart
*/
public abstract Element toSvg(Dimension bounds);

/**
* Creates an empty SVG element with the view box centered.
*
* @param bounds the dimensions of the viewport
* @return an empty SVG element with the view box centered
*/
protected Element createSvgElementWithCenteredViewbox(Dimension bounds) {
Element svgElement = SVGDOMImplementation.getDOMImplementation()
.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
Chart.TAG_SVG,
null)
.getDocumentElement();
svgElement.setAttribute(Chart.ATTRIBUTE_VIEW_BOX,
String.format("%f %f %f %f",
-0.5 * bounds.width,
-0.5 * bounds.height,
(double) bounds.width,
(double) bounds.height));
return svgElement;
}
}
22 changes: 0 additions & 22 deletions src/main/java/sirius/biz/charts/Charts.java
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
package sirius.biz.charts;

import com.lowagie.text.xml.XmlDomWriter;
import org.apache.batik.anim.dom.SVGDOMImplementation;
import org.w3c.dom.Element;
import sirius.kernel.di.std.Register;
import sirius.web.templates.pdf.TagliatellePDFContentHandler;
@@ -44,25 +43,4 @@ public String exportChartForPdf(Chart chart, Dimension bounds) {
xmlWriter.write(element);
return writer.toString();
}

/**
* Creates an empty SVG element with the view box centered.
*
* @param bounds the dimensions of the viewport
* @return an empty SVG element with the view box centered
*/
protected static Element createSvgElementWithCenteredViewbox(Dimension bounds) {
Element svgElement = SVGDOMImplementation.getDOMImplementation()
.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
Chart.TAG_SVG,
null)
.getDocumentElement();
svgElement.setAttribute(Chart.ATTRIBUTE_VIEW_BOX,
String.format("%f %f %f %f",
-0.5 * bounds.width,
-0.5 * bounds.height,
(double) bounds.width,
(double) bounds.height));
return svgElement;
}
}
2 changes: 1 addition & 1 deletion src/main/java/sirius/biz/charts/PieChart.java
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ public Dataset<N> getDataset() {

@Override
public Element toSvg(Dimension bounds) {
Element svgElement = Charts.createSvgElementWithCenteredViewbox(bounds);
Element svgElement = createSvgElementWithCenteredViewbox(bounds);

Element pieGroupElement =
svgElement.getOwnerDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, TAG_GROUP);
2 changes: 1 addition & 1 deletion src/main/java/sirius/biz/charts/RadarChart.java
Original file line number Diff line number Diff line change
@@ -162,7 +162,7 @@ public List<Dataset<N>> getDatasets() {

@Override
public Element toSvg(Dimension bounds) {
Element svgElement = Charts.createSvgElementWithCenteredViewbox(bounds);
Element svgElement = createSvgElementWithCenteredViewbox(bounds);

Element backgroundGroupElement =
svgElement.getOwnerDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, TAG_GROUP);
Loading