How set chart series name dynamically in chart dynamically using C#

Hi,

We are currently working with .NET Core and Aspose.Words (20.2), using the LINQ Reporting Engine approach.
We are creating a DOCX template, including the following chart :
Aspose_Example.JPG (40.5 KB)
The chart is properly generated, but we cannot set the SerieName using directly the template.
“ChartData” is a .NET List, and referencing [SerieName] in serie description raise an error, indicating that the field cannot be found in “ChartData” object.

In documentation (link), an example is given to define DOCX template and be able to set dynamically the serie name.
A note indicate “You can normally apply this approach to a chart dynamically populated with data.”

Can you help me to find the good way to set dynamically the chart serie name and to dynamically populate the chart ?
Thank you a lot.

@cyrilconter

Following code example shows how to set the chart series name using LINQ Reporting engine. Hope this helps you.

Please get the input template document from here:
ChartTemplate.zip (20.1 KB)

List<PointData> data = new List<PointData>()
{
    new PointData { Time = "12:00:00 AM", Flow = 10, Rainfall = 2 },
    new PointData { Time = "01:00:00 AM", Flow = 15, Rainfall = 4 },
    new PointData { Time = "02:00:00 AM", Flow = 23, Rainfall = 7 }
};

List<string> seriesNames = new List<string>
{
    "Flow",
    "Rainfall"
};

Document doc = new Document(MyDir + "ChartTemplate.docx");

ReportingEngine engine = new ReportingEngine();
engine.BuildReport(doc, new object[] { data, seriesNames }, new string[] { "data", "seriesNames" });

doc.Save(MyDir + "Out.docx");

public class PointData
{
    public string Time { get; set; }
    public int Flow { get; set; }
    public int Rainfall { get; set; }
}