yogthos/json-to-pdf

Scaling doesn't work for charts

delebota opened this issue · 6 comments

I was trying to generate a smaller chart to display some test data, but the chart still just takes up a full page.

["chart",
{"type":"pie-chart", "title":"System Types", "xscale":0.3, "yscale":0.4, "align":"center"},
["AIX", 21], ["Windows", 23], ["Linux", 345]
]

Also is there a way to disable the grey background for pie-charts? I understand its purpose for line and bar charts, but it is pointless for a pie chart and makes it take up 2-3 times as much space as it needs to.

Also just a heads up, but the entire Image section in the README is in a code block.

Looks like the xscale and yscale don't actually work for charts, but you can use the "scale" key instead to uniformly scale it:

[{"title":"My document"},
  ["chart", 
   {"type":"pie-chart", "title":"System Types",
    "scale":     20,
    "align":"center"}, 
   ["AIX", 21], ["Windows", 23], ["Linux", 345]]

Alternatively, you can also set "width" and "height" explicitly.

It's not currently possible to change the background color, but that's something that could be added.

Thanks for the heads up on the image section. :)

I was actually playing around with JFreeChart and it looks like you can call setOutlinePaint(null) and setBackgroundPaint(Color.white) on the PiePlot (which you can get from chart.getPlot()). Makes it look a bit cleaner!

pie

Could be a nice feature to add in the future.

I'm just adding the ability to set the background color using a [r b g] vector. I'll push out an updated in a bit. So you'd be able to do something like this:

[{"title":"My document"},
  ["chart", 
   {"type":"pie-chart",
    "title":"System Types",
    "scale":     20,
    "align":"center",
    "background":[255,255,255]}, 
   ["AIX", 21], ["Windows", 23], ["Linux", 345]]

just pushed out a new version that supports the background

Wow, thanks a lot! I'll close this ticket since you fixed the original issue already.