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

Free Support Forum - aspose.com

Aspose.Words generates incorrect column stacked chart using C#

Hello,

We are basically thinking of using Aspose.net word product for some of our existing SSRS reports where we can give users flexibility of updating doc templates with static text.

While exploring i got stuck with charts which is mandatory as it needs to be as it is shown in SSRS report, its a stacked col chart.

I have used some sample code and created a stacked chart but the output it creates is not proper like a sum of stack to be shown at top of the col etc.

DocumentBuilder builder = new DocumentBuilder(doc);
        builder.MoveToMergeField("ColChart");
        // Add chart with default data. You can specify different chart types and sizes.
        Shape shape = builder.InsertChart(ChartType.ColumnStacked, 432, 252);
         
        // Chart property of Shape contains all chart related options.
        Chart chart = shape.Chart; 



        // Get chart series collection.
        ChartSeriesCollection seriesColl = chart.Series;
        // Check series count.
        Console.WriteLine(seriesColl.Count);

        // Delete default generated series.
        seriesColl.Clear();

        // Create category names array, in this example we have two categories.
        string[] categories = new string[] { "AW Category 1", "AW Category 2" , "AW Category 3" };

        // Adding new series. Please note, data arrays must not be empty and arrays must be the same size.
        seriesColl.Add("AW Series 1", categories, new double[] { 4,0,0 });
         seriesColl.Add("AW Series 2", categories, new double[] { 7,0,0 });
        seriesColl.Add("AW Series 4", categories, new double[] { 0,40,0 });
        seriesColl.Add("AW Series 5", categories, new double[] { 0, 0, 50 });
         
     //   chart.AxisY.Hidden = true;
        
        foreach (var col in seriesColl)
        { 
             col.DataLabels.ShowValue = true;
            col.DataLabels.ShowSeriesName = false;
            col.DataLabels.ShowCategoryName = false;

        }

I have attached both code, current output and expected output.

Please let us know if its feasible in Aspose.net word.

Stackec col chart.zip (14.6 KB)

@jnkompelli

Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

Hi Tahir,

Sorry for late reply as we thought its not possible in word even manually but now we were able to do it, I now want to populate this chart using Linq reporting engine, i am facing issues in that.

Update:
I asked few questions before which are now sorted ,so deleted that question and asking updated on:

  1. It says value on y should be numeric, but i want to display it like 12.5% , 20 % etc, how can i do that ? If chart is created manually it is possible in that. I have attached both template and manually created chart

  2. The col names are coming from c#, which are string so i cant use superscript in it, is there any way i can do it ? like CatName 1.2 , Here 1.2 will be displayed in small and a bit above usual text like in maths we right power x2 etc.

Manually created & ChartTemplate.zip (46.4 KB)

Edit: Added C# code:

var capdata = new List<CapData>();

        capdata.Add(new CapData() { Name = "Lien", NavValue = 10.00 });
        capdata.Add(new CapData() { Name = "Equity", NavValue = 12.00, PrivateValue = 5.00, PublicValue = 7.00});
        capdata.Add(new CapData() { Name = "Other", NavValue = 5.5 });

engine.BuildReport(doc, capdata, "capData");

Regards,
Jatin

@jnkompelli

We are working over your query and will get back to you soon.

@jnkompelli

In this case, we suggest you please format the template document as shown in attached image for LINQ Reporting. FormatAxis.png (39.2 KB)

If you want to format the chart axis after inserting it into document, please use ChartNumberFormat.FormatCode property. You can use number format as “0.00%”. You can also modify the chart axis after creating it using LINQ Reporting.

Number formatting is used to change the way a value appears in data label and can be used in some very creative ways. The examples of number formats:

  • Number - “#,##0.00”

  • Currency - “”$"#,##0.00"

  • Time - “[$-x-systime]h:mm:ss AM/PM”

  • Date - “d/mm/yyyy”

  • Percentage - “0.00%”

  • Fraction - “# ?/?”

  • Scientific - “0.00E+00”

  • Text - “@”

  • Accounting - “-"$"* #,##0.00-;-”$"* #,##0.00_-;-"$"* “-”??-;-@-"

  • Custom with color - “[Red]-#,##0.0”

We suggest you please read the members of ChartAxis class.

We logged this feature request in your other thread here:

Yes i was also exploring the format stuffs and thanks for providing those examples it will help a lot.

So right now only issue left in chart for us is providing ability to users to update data labels and add superscript.
I know you have created a new feature request so does it covers ability to update it in out file as well right ?

Regards,
Jatin

@jnkompelli

We logged following two features in our issue tracking system for your case.

WORDSNET-20354 : Add feature to update Chart X-Axis with superscript value.
WORDSNET-20362 : Add feature to update Chart X-Axis data.

You will be notified via this forum thread once these features are available. We apologize for your inconvenience.

@jnkompelli

Regarding WORDSNET-20354, please check my reply in your other thread.

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

@tahir.manzoor : I can see you replied earlier that it wont be fixed and to use some special char for superscript. Ofc that solution is not perfect as not every char are present to be used for ex 1,2,3 .

Anyway now i can see yesterday aspose.notifier has posted that its fixed in new version.
So can you please give an example of the usage and how to pass it from c# etc. Also i guess the ability to update the x axis value is not present yet , right ?

@jnkompelli

We did not fix any thing related to this issue. You received notification about this issue because this issue was closed with resolution as 'Cannot Reproduce'. Please check the code example in my following post.