I am updating a bubble chart programmatically. When assigning string values to the XValue.Data, YValue.Data, and BubbleSize.Data properties and then using slide.GetThumbnail(), the X axis values for the bubble chart are not being honored. Instead, each item in the series is assigned an incremental value starting at 1. So if you have three items, the bubbles will appear on the X-Axis at 1, 2, & 3. Meanwhile, the Y-axis and BubbleSize of each item is rendered appropriately. Note that if you use Decimal or Integer values to assign to position & size of the bubbles, everything works fine. While I’m happy to have found a workaround, it did cost me a good bit of extra debugging time Also note that if you assign strings to the X-Axis and then save to PPTX, the chart renders fine when opened in PowerPoint, it is only the thumbnail which seems to exhibit the issue.
Charts.zip (66.3 KB)
public class ExistingChart
{
public static void Run()
{
string dataDir = RunExamples.GetDataDir_Charts();
Presentation pres = new Presentation(dataDir + "ExistingBubbleChart.pptx");
ISlide sld = pres.Slides[0];
IChart chart = (IChart)sld.Shapes[1];
int defaultWorksheetIndex = 0;
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;
fact.GetCell(defaultWorksheetIndex, 1, 0, "Modified Category 1");
fact.GetCell(defaultWorksheetIndex, 2, 0, "Modified Category 2");
IChartSeries series = chart.ChartData.Series[0];
fact.GetCell(defaultWorksheetIndex, 0, 1, "New_Series1");// Modifying series name
series.DataPoints[0].XValue.Data = "90";
series.DataPoints[0].YValue.Data = "123";
series.DataPoints[0].BubbleSize.Data = "5";
series.DataPoints[1].XValue.Data = "3";
series.DataPoints[1].YValue.Data = "44";
series.DataPoints[1].BubbleSize.Data = "7";
series.DataPoints[2].XValue.Data = "30";
series.DataPoints[2].YValue.Data = "45";
series.DataPoints[2].BubbleSize.Data = "2";
var bmp = sld.GetThumbnail(1f, 1f);
bmp.Save(dataDir + "AsposeChartModified_out.png", ImageFormat.Png);
pres.Save(dataDir + "AsposeChartModified_out.pptx", SaveFormat.Pptx);
//ExEnd:ExistingChart
}
}