Controlling PivotChart Image Size

by Nov 2, 2017

I’m having some difficulty in an aquascript in controlling the size of output chart. No matter what I set the chart properties to for setImageHeight and setImageWidth, the output chart is ALWAYS 800×600. Here’s the setup of the chart properties and where I write it to file.  The small size of the chart is corrupting the text on the chart.

 

// create pivot chart
pivotChart = aqua.chart.newChart();
pivotChart.setDataSource(pivot);
pivotChart.properties.setThemeDefault();
pivotChart.properties.setBackgroundColorBottom('#d7dcf5');
pivotChart.properties.setBackgroundColorTop('#ebf0f5');
pivotChart.properties.setCategoryAxisDateFormat("");
pivotChart.properties.setCategoryAxisDateTimeFormat("");
pivotChart.properties.setCategoryAxisTimeFormat("");
pivotChart.properties.setCategoryAxisNumberFormat("");
pivotChart.properties.setCategorySpacing(1.0);
pivotChart.properties.setDepth(5.0);
pivotChart.properties.setNumericCategoryAxis(false);
pivotChart.properties.setFixedCategoryCount(0);
pivotChart.properties.setShowFixedCategoryCount(false);
pivotChart.properties.setFont('Arial-PLAIN-17');
pivotChart.properties.setFontTitle('Arial-PLAIN-17');
pivotChart.properties.setLegendFontSize(1.0);
pivotChart.properties.setSeriesFontSize(1.0);
pivotChart.properties.setCategoryFontSize(1.0);
pivotChart.properties.setValueFontSize(0.5);
pivotChart.properties.setTitleFontSize(1.75);
pivotChart.properties.setAxisTitleFontSize(1.25);
pivotChart.properties.setDataLabelFontSize(1.0);
pivotChart.properties.setGroupSmallValuesThreshold(3.0);
pivotChart.properties.setGroupSmallValues(true);
pivotChart.properties.setHeight(30.0);
pivotChart.properties.setImageWidth(2000);
pivotChart.properties.setImageHeight(2000);
pivotChart.properties.setShowLegend(false);
pivotChart.properties.setShowLegendBorder(true);
pivotChart.properties.setLegendHeight(160);
pivotChart.properties.setLegendHeightTypeFit();
pivotChart.properties.setLegendPositionTopRight();
pivotChart.properties.setLegendWidth(100);
pivotChart.properties.setLegendWidthTypeFit();
pivotChart.properties.setUseLegendMargin(false);
pivotChart.properties.setLightingDefault();
pivotChart.properties.setOpacity(1.0);
pivotChart.properties.setLineWidth(1.0);
pivotChart.properties.setShowMarkers(true);
pivotChart.properties.setMapRange('');
pivotChart.properties.setMapRangeColors('');
pivotChart.properties.setMapShowBackground(false);
pivotChart.properties.setMapShowDetails(false);
pivotChart.properties.setMergeAxis(true);
pivotChart.properties.setPanX(0.0);
pivotChart.properties.setPanY(0.0);
pivotChart.properties.setPieShowLines(true);
pivotChart.properties.setPieShowValues(true);
pivotChart.properties.setPieExplode(0.0);
pivotChart.properties.setPieLabelDistance(3.0);
pivotChart.properties.setReverseValueAxis(false);
pivotChart.properties.setRotationX(325);
pivotChart.properties.setRotationY(0);
pivotChart.properties.setRotationZ(0);
pivotChart.properties.setSeriesAxisDateFormat("");
pivotChart.properties.setSeriesAxisDateTimeFormat("");
pivotChart.properties.setSeriesAxisTimeFormat("");
pivotChart.properties.setSeriesAxisNumberFormat("");
pivotChart.properties.setSeriesSpacing(1.0);
pivotChart.properties.setStackedPercent(false);
pivotChart.properties.setTitle('');
pivotChart.properties.setTitlePositionBottomCenter();
pivotChart.properties.setUseTitleMargin(false);
pivotChart.properties.setUseAxisTitleMargin(false);
pivotChart.properties.setAxisTitleOnEdge(false);
pivotChart.properties.setTitleCategory('');
pivotChart.properties.setTitleValue('');
pivotChart.properties.setValueAxisNumberFormat("");
pivotChart.properties.setWidth(30.0);
pivotChart.properties.setView2D(false);
pivotChart.properties.setFitChartToImage(true);
pivotChart.properties.setZoom(1.0);
pivotChart.properties.setShowDataLabels(true);
pivotChart.properties.setShowValueAxis(true);
pivotChart.properties.setShowValueAxisTicks(true);
pivotChart.properties.setShowValueAxisLines(true);
pivotChart.properties.setShowCategoryAxis(true);
pivotChart.properties.setShowCategoryAxisTicks(true);
pivotChart.properties.setShowCategoryAxisLines(true);
pivotChart.properties.setShowSeriesAxis(true);
pivotChart.properties.setShowGrid(true);
pivotChart.properties.setFillGrid(true);
pivotChart.properties.setGridOpacity(0.5);
pivotChart.properties.setGridLineWidth(1.0);
pivotChart.properties.setChartTypePie(0);
pivotChart.properties.setColumnTypeCube(0);
pivotChart.properties.setShowDataLabels(0, false);

var fileWriter = aqua.io.newFileWriter();
fileWriter.setFile("C:/test/chart.png");
fileWriter.write(pivotChart.renderToImage("png"));

I’m also seeing some strange behavior in the autocorrect suggestions. The editor is telling me that fileWriter.write does not accept the output of the renderToImage function of the chart. It still works though.

Thanks for the great product guys. You are the best.

Brian Hatch

Response

Abdullah Asif over 5 years ago

No matter what I set the chart properties to for setImageHeight and setImageWidth, the output chart is ALWAYS 800×600.

In Aqua Data Studio go to File > Options > General > Chart > Buffer Size. By default this value is blank which means we’ll generate an 800×600 buffer size. Please try increasing the buffer size by picking one of the values from the drop down & see if one of the larger buffer sizes gives you an image quality that you are satisfied with.

You will have to restart ADS after you make the buffer size configuration change.

Once you have defined a large enough buffer size, in AquaScript set the chart properties using setImageHeight and setImageWidth to customize the image size. Note that if you set the image height and width more than the buffer size, the image dimensions will be based on buffer size.

The editor is telling me that fileWriter.write does not accept the output of the renderToImage function of the chart. It still works though.

We are looking into this issue.

Sachin Prakash over 5 years ago

The editor is telling me that fileWriter.write does not accept the output of the renderToImage function of the chart. It still works though.

We have logged this as a bug and will investigate fixing it in a future release: https://www.aquaclusters.com/app/home/project/public/aquadatastudio/issue/15405