AnyChart / export-server

Export Server is a Java based server intended for exporting charts in .pdf, .jpg, .png, .svg, .csv, .xslx, .json and .xml formats
http://export.anychart.com/status
Apache License 2.0
20 stars 6 forks source link

problems with default image size #3

Closed elteto closed 6 years ago

elteto commented 6 years ago

Hi! i have a problem with image size, i set the witdth an heigth in the container but allways get an image with 1024x800 size.

chart = anychart.pie3d([['Horas Normales',3468893.744400],['Horas Extras',1220272.28],['Horas Contratadas',254691.069600],['Otros Costos',315363.49],]); chart.background().stroke("1 black"); chart.radius('55%25').innerRadius('10%25'); var legend = chart.legend(); var legendTitle = chart.legend().title(); legendTitle.useHtml(true); legendTitle.enabled(true); legendTitle.text("Costos (Historico)"); legendTitle.fontSize(12); legendTitle.vAlign("top"); legend.itemsLayout("vertical"); legend.position("left"); legend.align("top"); legend.fontSize(12); legend.width(180); legend.positionMode("outside"); chart.labels().fontSize(15); chart.container('container').width(450); chart.container('container').height(290); chart.draw();

costo_historico

Shestac92 commented 6 years ago

@elteto There's no need to set the container bounds in the chart code, export-server provides commands to define bounds and dimensions. Width and height set to the container define the chart bounds in the exported document, but not the dimension of png or jpg. For this purpose, you should set width and height to the export server config. If you use the command line mode you can achieve it like this: java -jar anychart-export.jar cmd --script "var chart = anychart.line([1,2,5]); chart.container('container'); chart.draw();" --output-path YOUR_OUT_PATH --output-file "chart.png" --image-width 450 --image-height 290 --container-width 900 --container-height 580 The image quality will be better if the container is larger than the image proportionally, but it's up to you. If you use the web server mode you can do the same. The short command to launch the export-server on local-host on port 2000: java -jar export-server.jar server -H 0.0.0.0 -P 2000 -a y The CURL command to get a png export: curl -X POST -H "Accept: application/json" --data "responseType=file&file-name=chart.png&width=450&height=290&dataType=script&data=var chart = anychart.line([1,2,5]); chart.container('container'); chart.draw();" localhost:2000/png -o "chart.png"

You may learn about using and configuring export-server in the following articles here and here