We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Scatter Plot - DisplayBlanksAs

I’m creating some Scatter Plot charts using the setting DisplayBlanksAsType.Gap but the empty datapoints appear as if they had a zero value.

I can go open it in PowerPoint and go to Chart Tools > Select Data then exit (clicking either OK or Cancel) then the mark vanish (as they should). It’s a workaround for now, please advise.

Hi Patrick,


Thank you for your interest in Aspose.Slides.

I have observed your comments and I would like to request you to please share with us a sample application to reproduce the issue and the generated presentation as well so that we may investigate it further to help you out.

Best Regards,
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Baseline", typeof(int));
dt.Columns.Add("Survey 1", typeof(int));
dt.Columns.Add("Survey 2", typeof(int));
            
Random rand = new Random();
 
for (int i = 0; i < 365; i++ )
    dt.Rows.Add(DateTime.Parse("1/1/2015").AddDays(i), rand.Next(95, 105), null, null);
 
for (int i = 0; i < 200; i++ )
    dt.Rows.Add(DateTime.Parse("1/1/2015").AddDays(rand.Next(0, 364)), null, rand.Next(75, 125), null);
 
for (int i = 0; i < 100; i++)
    dt.Rows.Add(DateTime.Parse("1/1/2015").AddDays(rand.Next(0, 364)), null, null, rand.Next(50, 150));
 
Presentation p = new Presentation();
 
IChart chart = p.Slides.Last().Shapes.AddChart(ChartType.ScatterWithMarkers, 36, 36, 648, 468);
chart.HasTitle = false;
 
chart.ChartData.ChartDataWorkbook.Clear(0);
chart.ChartData.Categories.Clear();
chart.ChartData.Series.Clear();
 
chart.ChartData.Series.Add(chart.ChartData.ChartDataWorkbook.GetCell(0, 0, 1, "Baseline"), ChartType.ScatterWithMarkers);
chart.ChartData.Series.Last().Marker.Symbol = MarkerStyleType.Circle;
chart.ChartData.Series.Last().Marker.Size = 3;
chart.ChartData.Series.Last().Marker.Format.Line.FillFormat.FillType = FillType.NoFill;
 
chart.ChartData.Series.Add(chart.ChartData.ChartDataWorkbook.GetCell(0, 0, 2, "Survey 1"), ChartType.ScatterWithMarkers);
chart.ChartData.Series.Last().Marker.Symbol = MarkerStyleType.Circle;
chart.ChartData.Series.Last().Marker.Size = 5;
chart.ChartData.Series.Last().Marker.Format.Line.FillFormat.FillType = FillType.NoFill;
            
chart.ChartData.Series.Add(chart.ChartData.ChartDataWorkbook.GetCell(0, 0, 3, "Survey 2"), ChartType.ScatterWithMarkers);
chart.ChartData.Series.Last().Marker.Symbol = MarkerStyleType.Circle;
chart.ChartData.Series.Last().Marker.Size = 5;
chart.ChartData.Series.Last().Marker.Format.Line.FillFormat.FillType = FillType.NoFill;
 
 
foreach (ChartSeries s in chart.ChartData.Series)
    foreach (DataRow r in dt.Rows)
        s.DataPoints.AddDataPointForScatterSeries(chart.ChartData.ChartDataWorkbook.GetCell(0, dt.Rows.IndexOf(r) + 1, 0, Convert.ToDateTime(r[0]).ToOADate()), chart.ChartData.ChartDataWorkbook.GetCell(0, dt.Rows.IndexOf(r) + 1, chart.ChartData.Series.IndexOf(s) + 1, r[chart.ChartData.Series.IndexOf(s) + 1]));
 
chart.DisplayBlanksAs = DisplayBlanksAsType.Gap;
 
chart.Axes.HorizontalAxis.IsNumberFormatLinkedToSource = false;
chart.Axes.HorizontalAxis.NumberFormat = @"MMM";
 
chart.Axes.HorizontalAxis.IsAutomaticMinValue = false;
chart.Axes.HorizontalAxis.MinValue = Convert.ToDateTime(dt.Compute("MIN(Date)", "")).ToOADate();
 
chart.Axes.HorizontalAxis.IsAutomaticMaxValue = false;
chart.Axes.HorizontalAxis.MaxValue = Convert.ToDateTime(dt.Compute("MAX(Date)", "")).ToOADate();
 
 
p.Save("test.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

Hi Patrick,


I have observed your requirements and worked with the code shared by you. I have been able to reproduce the issue. A ticket with ID SLIDESNET-36995 has been logged in our issue tracking system to further investigate and resolve the issue.This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi


Using the same code above with Slides 16.1. The issue still remains with blanks not showing as a gap unless you click to edit data.

I don’t believe this is fixed ,unless I need to add any-more code?

Thanks

Hi Patrick,


I have observed your comments and like to request you to please try using following sample code on your end to serve the purpose.

System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add(“Date”, typeof(DateTime));
table.Columns.Add(“Column1”, typeof(int));
table.Rows.Add(DateTime.Now,null);// put null value
object val = table.Rows[0][1]; //extract null value back
Assert.IsNull(val); //check that value is null => false

Please let us know if the issue persists. We will be glad to help you further.

Best Regards,

Hi


I’ve tried using null and DBNull.Value.

The outcome is the same. The chart displays nulls as 0 until you edit the chart in powerpoint and then they hide.

I’ve attached the example you’ll see the green line across the bottom until you edit the data.

Thanks

Hi Patrick,


I have observed your comments and the file shared by you. I like to share with you that we were unable to reproduce the problem while using Aspose.Slides for .NET 16.1.0 and the updated code as shared by me in last post. Please share with us the updated code which is still reproducing the issue on your end, so that we may proceed further to help you out.

Best Regards,

Hi


Attached is a simple webproject where the error still appears for me using 16.1.
Your additional code was the same for inserting the null value into the row.

Thanks

Hi Patrick,


I am discussing this with our product team and we will get back to you, with our findings, soon.

Best Regards,

Hi Patrick,


I would like to share with you that the issue will not occur if you do not use the DataTable. DataTable is the source of problem now, because the code is putting null value in DataTable but it is extracting empty string instead of null. However, if you want to use the DataTable anyway then you may add a condition in your code like, if value extracted from DataTable cell equals “” (empty string), then replace it with null.

I hope this will clarify the concept. Please share if I may help you further in this regard.

Best Regards,

Thank you. That worked.

Hi Patrick,


Thank you for your valuable feedback.

We are glad to know that your issue is resolved and things have started working on your end.

Please feel free to contact us if we could be of any help to you.

Best Regards,