Please please help me create a chart inside my word document

I have a very very simple requirement - and I cannot find documentation that lets me create what I need. Ive spent days now looking into this, and I cant believe that I cant get this working.

ALL I want is a simple bar chart (Bar_Stacked_100) with 4 rows and 3 different coloured bars in each row depending on the data - and to add that to my Word paragraph IWParagraph) - should be very simple

I have a data object type call 'Data' with 3 integer properties and one string property. This represents the chart 'Row'
I want the string property to be the label on the left, and I want each of the integer properties to be the 3 colored bars depending on value - but add up to 100%

I simply cannot get this scenario to work in any way

I have been through EVERY piece of example code on the internet. I cant work out a way for this to work.

Particular questions are:

1) How to a hook up the string property in my data class to the left row label
2) How do I tell the code which integer property represents which block of color in the chart

How can I get any of it to work ?

Can someone point me to an example where I can get something meaningful to appear in my DocIO generated document

Here is the data class for the rows

public class Data
{
    public string Area { get; set; }
    public int RedCount { get; set; }
    public int AmberCount { get; set; }
    public int GreenCount { get; set; }
}

If anyone can show code that puts a few of these rows into a stacked bar_100 chart in a word document I would be massively relived.

Thanks



3 Replies 1 reply marked as answer

SB Suriya Balamurugan Syncfusion Team August 10, 2020 11:23 AM UTC

Hi Dean,

Thank you for contacting Syncfusion support.

From the given details, we have found your end requirement is to create a simple bar chart (Bar_Stacked_100) with 4 rows and 3 different coloured bars in each row depending on the data and add it into the paragraph of the Word document. To meet your requirement, we suggest you create custom chart of type “Bar_Stacked_100” and customize the chart elements as per your wish.

Based on this, We have prepared a sample application to create Bar_Stacked_100 type chart and add it into the Word document as per your requirement and it can be downloaded from the below link:
https://www.syncfusion.com/downloads/support/forum/156749/ze/CreateWordSample1011854692

In the above sample, we have done the following things:
  1. Creates a Word document.
  2. Gets the chart data from the properties of the given Data class.
  3. Creates a chart based on the data and add it into the paragraph of the Word document.
  4. Customize the chart elements like title, Data labels position as per requirement
  5. Saves the Word document.

Please refer our UG documentation to know more about how to create custom charts:
https://help.syncfusion.com/file-formats/docio/working-with-charts#creating-custom-charts

Please refer our UG documentation to know more about how to customize the chart elements:
https://help.syncfusion.com/file-formats/docio/working-with-charts#customizing-the-chart--its-elements

Please let us know if you have any other questions.

Regards,
Suriya Balamurugan.
 


Marked as answer

DE Dean August 12, 2020 07:08 PM UTC

Ahhhhhhhh- Thanks you SOOOO much. This is absolutely perfect. 
My pain is over. 
I really appreciate your efforts to create a sample app for me - very much appreciated


Regards

Dean


PN Preethi Nesakkan Gnanadurai Syncfusion Team August 13, 2020 09:41 AM UTC

Hi Dan, 
  
  
Most welcome. 
  
Regards, 
Preethi 


Loader.
Up arrow icon