Skip to content

Commit e89f202

Browse files
committed
Fixed locale dependent decimal separator in SVG generation
1 parent 4655ea2 commit e89f202

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sjk-stacktrace/src/main/java/org/gridkit/jvmtool/stacktrace/analytics/flame/GenericFlameGraphGenerator.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.Writer;
2020
import java.util.Arrays;
2121
import java.util.Comparator;
22+
import java.util.Locale;
2223
import java.util.SortedMap;
2324
import java.util.TreeMap;
2425

@@ -29,7 +30,11 @@
2930
public abstract class GenericFlameGraphGenerator {
3031

3132
private static final GenericStackElement[] ROOT = new GenericStackElement[0];
32-
33+
private static final Locale SVG_LOCALE;
34+
static {
35+
SVG_LOCALE = Locale.ROOT;
36+
}
37+
3338
private Node root;
3439

3540
private FlameColorPicker colorPicker = new DefaultColorPicker();
@@ -122,7 +127,7 @@ private void renderNode(Writer writer, Node node, int x, int height, int width,
122127
escape(describe(node)), node.totalCount, 100d * node.totalCount / root.totalCount);
123128
format(writer, "<rect x=\"%.1f\" y=\"%.1f\" width=\"%.1f\" height=\"%.1f\" fill=\"rgb(%d,%d,%d)\" rx=\"2\" ry=\"2\"/>\n",
124129
rx, ry, rw, rh, cr, cg, cb);
125-
format(writer, "<text text-anchor=\"\" x=\"%.1f\" y=\"%.1f\" fill=\"rgb(0,0,0)\">%s</text>\n",
130+
format(writer, "<text x=\"%.1f\" y=\"%.1f\" fill=\"rgb(0,0,0)\">%s</text>\n",
126131
rx + 10, ry + frameheight - 3, escape(trimStr(describe(node), (int)(rw - 10) / 7)));
127132
format(writer, "</g>\n");
128133

@@ -171,7 +176,7 @@ protected String escape(String text) {
171176
protected abstract String describe(Node node);
172177

173178
private void format(Writer writer, String format, Object... args) throws IOException {
174-
writer.append(String.format(format, args));
179+
writer.append(String.format(SVG_LOCALE, format, args));
175180
}
176181

177182
protected void appendHeader(int width, int height, Writer writer) throws IOException {

0 commit comments

Comments
 (0)