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

Free Support Forum - aspose.com

How to add a null or blank value to chart

how to add a null or blank value to chart with aspose word.net like below

图片.png (22.3 KB)

@qingyuan.ni,

Thanks for your inquiry. You can use double.NaN value for null or blank value. Please check following sample code snippet. Hopefully it will help you to accomplish the task.

seriesColl.Add("AW Series 1", categories, new double[] { 4.3,2.5,double.NaN,4.5,4.4,6});
seriesColl.Add("AW Series 2", categories, new double[] { 2.4,4.4,1.8,2.8,2.6,3 });
seriesColl.Add("AW Series 3", categories, new double[] { 2,2,3,5,4,2});

it works, but I get an exception when I using the following document as an template to insert a chart with all NaN values. the exception occur at UpdateFields. It’s normal when I using other document as template. Can help me to figure out the reason?

the template:template.zip (14.4 KB)

the code sample:

var doc = new Document(template);
var builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
var shape = builder.InsertChart(ChartType.Line, 400, 300);
var chart = shape.Chart;
chart.Series.Clear();
var count = 10;
var times = new DateTime[count];
var values = new double[count];

for (var i = 0; i < count; i++)
{
    times[i] = DateTime.Now.AddMinutes(i);
    values[i] = double.NaN;
}
chart.Series.Add("Values", times.Select(x => x.ToString("G")).ToArray(), values);
doc.UpdateFields();
doc.Save(fileName);

@qingyuan.ni

Thanks for your feedback. We have managed to replicate the issue with your shared code and document. We have logged a ticket WORDSNET-15799 in our issue tracking system for further investigation and rectification. We will notify you as soon as soon as it is resolved.

We are sorry for the inconvenience.

@qingyuan.ni,

The issues you have found earlier (filed as WORDSNET-15799) have been fixed in this Aspose.Words for .NET 17.9 update and this Aspose.Words for Java 17.9 update.