Plotting Gantt Chart in aspose Slides

Hi Team,
I have a license for Aspose Total. I have to Plot some Gantt Chart in pptx(Aspose Slides). Data is coming from the data base in the for of Data table or collection .Every where I have got the sample for creating Gantt chart from mpp file and Creating Mpp file as XML.

Plesae provide some sample or steps where I can create Gantt Chart from the dynamic data from database.

Thanks
Sushanta

Hi Sushanta,


Thanks for your interest in Aspose.Slides.

I have observed the requirements shared by you and like to share that Aspose.Slides is able to generate MSO Charts supported in PowerPoint. Unfortunately, the Gantt charts are not directly supported in PowerPoint. However, you can achieve them by using different Bar chart series. Please observe the sample example over this thread link where by I provided the sample code to generate waterfall chart using Aspose.Slides. The chart generated is conjunction of ClusteredColumn and Smooth Line Without Markers charts. You can develop similar example for Gantt chart by taking Bar chart as chart type. The example shared will give you an idea for how to achieve the goal.

Many Thanks,

Hi Mudassir,

Thanks for ur reply . Could you please attach a sample code for this request,which will be helpful to find out some soln for my requirements.

And one more query, Is there any options in Aspose where we can create a MPP file dynamically and can plot the gantt chart using that MPP file.

Thanks

Sushanta

Hi Sushanta,


I regret to share that at the moment i dont have the sample to generate the Gantt Chart. I may need some time to develop sample application for you. I will get back to you with sample code as soon as I will generate sample application for this.

Secondly, I may suggest you to create a Gantt Chart in Microsoft Project and the file as Ole frame inside PowerPoint presentation. You need to use class name “MSProject.Project.9” instead of “Excel.Sheet.8” in sample code shared over following link. This is one other option that you can use as Gantt Charts are not supported in PowerPoint. Please remember that the above class name works if your mpp file is of MS Project 2010 format.

http://www.aspose.com/docs/display/slidesnet/Working+with+OLE+Object+Frames+in+SlideEx#WorkingwithOLEObjectFramesinSlideEx-AddOle

Many Thanks,

Hi Mudassir,

Thanks for the reply. I can not add MS Project 2010 format so I have to do some custom coding to hide first series from ChartTypeEx.StackedBar. But as my date range is on monthly basis I need to make the value axis interval = 1 and needs to cahnge the axis label as jun-13,jul-13 etc. If u could put any light on the same will be helpful.

FYI..

In my .net side I am able t0 achive the same as follows :

Dim lineAxis As New LinearAxis
lineAxis.Orientation = AxisOrientation.X
lineAxis.Interval = 1
lineAxis.Foreground = New SolidColorBrush(Colors.White)
lineAxis.Minimum = Month(minDat)
lineAxis.Maximum = Month(minDat) + 13

chart1.Axes.Add(lineAxis)
Dim dateAxis As New DateTimeAxis
dateAxis.Orientation = AxisOrientation.X
dateAxis.IntervalType = DateTimeIntervalType.Months
dateAxis.VerticalAlignment = Windows.VerticalAlignment.Top
dateAxis.VerticalContentAlignment = Windows.VerticalAlignment.Top
dateAxis.Interval = 1
dateAxis.ShowGridLines = True


Dim dtExactDate, dtExactDate1 As Integer
Dim dtExact As Date
dtExact = maxDat.AddMonths(1)
dtExactDate = -(minDat.Day)
dtExactDate1 = -(dtExact.Day)
dateAxis.Minimum = minDat.AddDays(dtExactDate + 1)
dateAxis.Maximum = dtExact.AddDays(dtExactDate1 + 1)
Dim axisLabelStyle = New Style(GetType(DateTimeAxisLabel))
axisLabelStyle.Setters.Add(New Setter(DateTimeAxisLabel.StringFormatProperty, "{0:MMM-yy}"))

chart1.Axes.Add(dateAxis)

Hope above part will help u understand my requirements.

As I am new to aspose,Any sample codes from you will be helpful.

Thanks

Sushanta

Hi Sushanta,


I have observed the code snippet shared and unfortunately cannot use that as it does not belong to Aspose.Slides. However, I have extracted the idea that you are probably trying to set the value axis format to date and its intervals to monthly basis. The following sample will give you an idea for how to set the value or category axis data format.

PresentationEx pres = new PresentationEx();
SlideEx sld = pres.Slides[0];
Aspose.Slides.Pptx.ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.StackedBar, 10, 60, 700, 300);

chart.ValueAxis.SourceLinked = false;
chart.ValueAxis.BaseUnitScale = TimeUnitType.Months;
chart.ValueAxis.NumberFormat = “[$-409]mmm-yy;@”;
chart.ValueAxis.IsAutomaticMajorUnit = false;
chart.ValueAxis.IsAutomaticMinorUnit = false;
chart.ValueAxis.IsAutomaticMaxValue = false;
chart.ValueAxis.IsAutomaticMinValue = false;
//Starting day number
chart.ValueAxis.MinValue = 1;
//Ending day number
chart.ValueAxis.MaxValue = 365;

//Setting month wise interval
chart.ValueAxis.MajorUnit = 30;

//setting minor unit to 10 days
chart.ValueAxis.MinorUnit = 10;

chart.ValueAxis.MinorUnitScale = TimeUnitType.Days;
chart.ValueAxis.MajorUnitScale = TimeUnitType.Months;

chart.HasLegend = false;
pres.Write(“D:\Aspose Data\Bar.pptx”);

Many Thanks,

Hi Mudassir,

Thanks a lot for your respone. With your help, I am near to my goal . Only One Issue ,Hope you will be able to help me.

chart.ValueAxis.NumberFormat = "[$-409]mmm-yy;@"; This formatting is giving the values lile Jun-00,jul-00......Jan-01,Feb-01 like that..Please give some idea How can I reformat this to jun-13,jul-13...Jan-14,Feb-14 .i.e. needs the current yr and next yr as per the values.
I have one Idea. if current yr is 2013 I can get the value as 365*13+what my value is ....so will this be the right solution or is there any tricks to get the year values instead of 00 and 01.
Thanks & Regards
Sushanta

Hi Sushanta,


That is really appreciable that you are near achieving the goal. I have modified the sample code for your convenience to serve the purpose. Please try using the sample code and shared with us if there is any issue incurring. One thing that I like to add that in some months you will get date 13 and for some you will have 14. As we have set major unit to 30.5 now and some months have 30 days and some with 31 days. I hope you will understand the concept.

PresentationEx pres = new PresentationEx();
SlideEx sld = pres.Slides[0];
Aspose.Slides.Pptx.ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.StackedBar, 10, 60, 700, 300);

chart.ValueAxis.SourceLinked = false;
chart.ValueAxis.BaseUnitScale = TimeUnitType.Months;
//
//[$-409]mmm-yy;@
chart.ValueAxis.NumberFormat = “[$-409]mmm-dd;@”;
chart.ValueAxis.IsAutomaticMajorUnit = false;
chart.ValueAxis.IsAutomaticMinorUnit = false;
chart.ValueAxis.IsAutomaticMaxValue = false;
chart.ValueAxis.IsAutomaticMinValue = false;
//Starting day number
chart.ValueAxis.MinValue = 13;
//Ending day number
chart.ValueAxis.MaxValue = 365;

//Setting month wise interval
chart.ValueAxis.MajorUnit = 30.5f;

//setting minor unit to 10 days
chart.ValueAxis.MinorUnit = 10;

chart.ValueAxis.MinorUnitScale = TimeUnitType.Days;
chart.ValueAxis.MajorUnitScale = TimeUnitType.Months;

chart.HasLegend = false;
pres.Write(“D:\Aspose Data\Bar.pptx”);

Many Thanks,

Hi Mudassir,

Thanks a lot for your helping hand to achive the requirement related to Gantt chart.

I am facing another issue related to export to excel. I am using ImportDataTable like.... sheet.Cells.ImportDataTable(dataTable, true, "A1");

1. Date fields in Datatable are coming with whole things i.e. including time part.I need just MM/dd/YYYY value on My excel.

2. For null date type value its comming as default date value like 1999.......need to get blank in place of the default db values.

3. Some colums in my result set are description fields containg more than 500 characters. I want to implement Wrap text property with fixed width of column.

Please put your suggetion or if any samples are there for the same. If I will loop through all my rows in my result set it will create performance issue as I am exporting large # of records.

Thank You.

Sushanta

Hi Sushanta,


I have observed the inquiry shared by you. It seems that you are having issue related to MS Excel. Please share the issue in Aspose.Cells forum so that our respective support team may help you better in this regard. As far as Aspose.Slides related queries are concerned, you are always welcome and we will be obliged to help you out.

Many Thanks,

Thanks Mudassir.will do the same…