Chart.toImage - Bubble chart with negative bubbles are when bubble size represent WIDTH are not reflected

Hi,

Please run the following sample code and see the below issues, in the generated image.

1. Negative bubles are not present.
2. Bubble Size in image represent AREA instead of WIDTH

Thanks
Muhammed

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import com.aspose.cells.ASeries;
import com.aspose.cells.BubbleSizeRepresents;
import com.aspose.cells.CellsHelper;
import com.aspose.cells.Chart;
import com.aspose.cells.ChartType;
import com.aspose.cells.Color;
import com.aspose.cells.FileFormatType;
import com.aspose.cells.ImageFormat;
import com.aspose.cells.ImageOptions;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.aspose.slides.OleObjectFrame;
import com.aspose.slides.Presentation;
import com.aspose.slides.Slide;

public class BubbleSize {

public static void main(String args[]) {

try {
String[] colTitle = new String[] { "BrandA",
"BrandB",
"BrandC",
"BrandD",
"BrandE",
"BrandF",
"BrandG",
"BrandH",
"BrandJ"
};

//Array of cell data
double[][] data = new double[][] { {1.689, 1.808, 0, 1.027, 1.896, 1.95, .225, .458, 1.07},
{62925500, 1851840, 0, 699800.8, 56409260, 2, 665954.2, 305, 49353140},
{1062954, 3347520, 0, -7185125.3, 1069557, 3234567.9, 8160187.1, -4124534.2, 5280330}
};

Workbook wb = new Workbook();
Worksheet dataSheet = wb.getWorksheets().addSheet();
wb.getPalette().setColor(0, new Color(0xFF, 0x00, 0x00));
wb.getPalette().setColor(1, new Color(0x42, 0xDF, 0xF4));
wb.getPalette().setColor(2, new Color(0x00, 0xF4, 0x65));
wb.getPalette().setColor(3, new Color(0xF9, 0x04, 0x21));

String dataSheetName = "DataSheet";
dataSheet.setName(dataSheetName);

int rowIndex = 0;
for (int i = 0; i < colTitle.length; i++) {
dataSheet.getCells().getCell(rowIndex, i).setValue(colTitle[i]);
}

for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[i].length; j++) {
dataSheet.getCells().getCell(i + 1, j).setValue(data[i][j]);
}
}

//Add a chart sheet
Worksheet chartSheet = wb.getWorksheets().addSheet();
chartSheet.setName("ChartSheet");
int chartSheetIdx = chartSheet.getIndex();

//Add a chart in ChartSheet with data series from DataSheet
int chartRows = 25, chartCols = 15;

Chart chart = chartSheet.getCharts().addChart(ChartType.BUBBLE, 0, 0, 1, 1, 500, 400);
for (int i = 0; i < colTitle.length; i++) {
String dataRef = "=" + dataSheet.getName() + "!$" + CellsHelper.convertColumnIndexToName(i) + "$" + (rowIndex + 3);
int index = chart.getNSeries().add(dataRef, true);
ASeries series = chart.getNSeries().get(index);
//String nameRef = dataSheet.getName() + "!$" + CellsHelper.convertColumnIndexToName(lid) + "$" + (rowIndex + 1);
series.setName(dataSheet.getCells().getCell(rowIndex, i).getStringValue());

String xRef = "=" + dataSheet.getName() + "!$" + CellsHelper.convertColumnIndexToName(i) + "$" + (rowIndex + 2);
series.setXValues(xRef);

String bRef = "=" + dataSheet.getName() + "!$" + CellsHelper.convertColumnIndexToName(i) + "$" + (rowIndex + 4);
series.setBubbleSizes(bRef);

series.getDataLabels().setValueShown(true);

series.setBubbleSizeRepresents(BubbleSizeRepresents.WIDTH);
series.setShowNegativeBubbles(true);

}

chart.getPlotArea().getArea().setVisible(false);

//Get Chart as image.
ImageOptions imgOpts = new ImageOptions();
imgOpts.setImageFormat(ImageFormat.PNG);
imgOpts.setFashion(FileFormatType.EXCEL2003);

chart.toImage(new FileOutputStream("D:\\Temp\\chart.png"), imgOpts);

wb.getWorksheets().setActiveSheet(chartSheetIdx);
wb.setOleSize(0, chartRows, 0, chartCols);

//Save the workbook to stream
ByteArrayOutputStream bout = new ByteArrayOutputStream();
wb.save(bout);
wb.save(new FileOutputStream("D:\\Temp\\output.xls"));

//Write the presentation on disk
pres.write(new FileOutputStream("D:\\Temp\\output.ppt"));
System.out.println("BubbleChart successfully completed!!!" + CellsHelper.getReleaseVersion());

}
catch (Exception e) {
e.printStackTrace();
}
}

}

Hi,

After an initial test, I found the issue you have mentioned. We will figure it out soon.

Your issue has been logged into issue tracking system with an issue id: CELLSJAVA-15916.


Thank you.

The issues you have found earlier (filed as 15916) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Working fine.
Thanks
Muhammed