Skip to content

Question: How can I reduce the "size" of the generated SVG? #26

@davidvarga

Description

@davidvarga

Hi,

I am using JFreeSVG in combination with JFreeChart to produce SVG images to be embedded later on in HTML.

My problem is that the generated SVG file is huge (as example: plotting a single measurement where the sampling rate is 1ms, the time (X) is 270 seconds long (270k data points) produces an SVG file of 180MB. The picture is perfect but it simpy kills any browser I try to open with.

Question: How can I reduce (drastically) the generated SVG size?

The code generating the SVG (Kotlin):

val chart = createChart(sigData) ?: return@action
val g2 = SVGGraphics2D(600, 400).apply {
    shapeRendering = "optimizeSpeed"
}
chart.draw(g2,  Rectangle(0, 0, 600, 400))
SVGUtils.writeToSVG(calculateExportFile(), g2.svgElement)

I also tried using SVGHints with no luck.

Thanks a lot,
David

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions