Dear,
I am using the bellow code to generate a bubble chart:
private void CreateSlide()
{
SlideEx sld = pres.Slides[0];
Aspose.Slides.Pptx.ChartEx lChart = sld.Shapes.AddChart(ChartTypeEx.Bubble, 10, 60, 500, 300);
lChart.HasLegend = false;
TextFrameEx tf = lChart.ValueAxis.TextProperties;
PortionFormatEx port = tf.Paragraphs[0].ParagraphFormat.DefaultPortionFormat;
port.LatinFont = new FontDataEx(“Arial”); //Set the Font for the Portion
port.FontBold = NullableBool.True; //Set Bold property of the Font
port.FontItalic = NullableBool.False; //Set Italic property of the Font
port.FontHeight = 10; //Set the Height of the Font
port.FillFormat.FillType = FillTypeEx.Solid;
port.FillFormat.SolidFillColor.Color = Color.Black;
//tf = lChart.CategoryAxis.TextProperties; <-- this line causes error
lChart.HasTitle = true;
lChart.ChartTitle.Text.Text = “test”;
// lChart.ChartData.Series.Clear(); <-- this code causes error
ChartDataCellFactory fact = lChart.ChartData.ChartDataCellFactory;
lChart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), lChart.Type);
ChartSeriesEx series = lChart.ChartData.Series[0];
series.Format.Fill.FillType = FillTypeEx.Solid;
series.Format.Fill.SolidFillColor.Color = Color.Green;
series.Values.Add(fact.GetCell(0, 1, 0, 10));
series.Values.Add(fact.GetCell(0, 1, 1, -20));
series.Values.Add(fact.GetCell(0, 1, 2, 30));
AddLegendToBubbleChart(series, “1”, 0, 10, “”, System.Drawing.Color.Red);
series.Values.Add(fact.GetCell(0, 2, 0, 15));
series.Values.Add(fact.GetCell(0, 2, 1, -25));
series.Values.Add(fact.GetCell(0, 2, 2, 35));
AddLegendToBubbleChart(series, “2”, 1, 10, “”, System.Drawing.Color.Red);
series.Values.Add(fact.GetCell(0, 3, 0, 20));
series.Values.Add(fact.GetCell(0, 3, 1, 30));
series.Values.Add(fact.GetCell(0, 3, 2, 40));
AddLegendToBubbleChart(series, “3”, 2, 10, “”, System.Drawing.Color.Red);
series.Values.Add(fact.GetCell(0, 4, 0, 25));
series.Values.Add(fact.GetCell(0, 4, 1, 35));
series.Values.Add(fact.GetCell(0, 4, 2, 45));
AddLegendToBubbleChart(series, “4”, 3, 10, “”, System.Drawing.Color.Red);
}
public void AddLegendToBubbleChart(ChartSeriesEx series, string text, int id, int height, string fontName, System.Drawing.Color fontColor)
{
DataLabelEx lbl = new DataLabelEx(series);
lbl.TextFrame.Text = text;
lbl.ShowValue = true;
lbl.Position = LegendDataLabelPositionEx.Center;
for (int i = 0; i < lbl.TextFrame.Paragraphs.Count; i++)
{
PortionFormatEx pt = lbl.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat;
pt.FontHeight = 8;
pt.LatinFont = new FontDataEx(fontName);
pt.FillFormat.FillType = FillTypeEx.Solid;
pt.FillFormat.SolidFillColor.Color = fontColor;
}
lbl.Id = id;
series.Labels.Add(lbl);
}
I faced a number of issues, kindly find them bellow:
1- Only 3 bubbles are shown in the presentation and not 4. This is due to the fact that only 3 values are selected in the excel when clicking "Editing Data"
2- i was able to format the Horizontal Axis but not the Vertical Axis since “lChart.CategoryAxis” is always null.
3- i was unable to delete the Major Axis Gridlines
4- Formatting the bubbles labels is not working (this might be due to an error in my code “AddLegendToBubbleChart”, if so please provide me with a code snippet that allows me to format the bubbles labels)
5- is it possible to use percentage instead of values in the vertical and horizontal axis as shown in the attached screenshot? (the percentage in the screenshot has been edited manually)
6- Clearing the default values “lChart.ChartData.Series.Clear();” does not cause a runtime error, but when i open the presentation generated by this caude it shows the following message: “Powerpoint was not able to display some of the text, images, or objects on slide …”.
7- using this line: lChart.HasTitle = false; (which is not mentioned in the above code) does not hide the chart title, but the name of the series is added as title. (the same issue has been observed in multiple chart types including Column charts and Bar charts)
Could you please check the above issues and provide me with an estimation on when these issues could be fixed.
Thank you in advance,
Sami Simon