Chart problem

Hi,

I have following problem.

I would like to create a chart in Aspose.Slides with dates on category axis. Could you tell me how format the source cells as a date? I would like to achieve effect similar to code in Aspose.Cells:

Style style = new Style();
style.Number = 15;
cells[0, columnNumber].SetStyle(style);

Is it possible to set two styles for the title in Aspose.Slides the same way as in Aspose.Cells? I would like change font color and size only for 2 characters. I have found this solution for Aspose.Cells:

chart.Title.Characters(0, 2).Font.Color = titleColor;

Best regards,
Piotr

Hi Piotr,


Thanks for inquiring Aspose.Slides and please accept my apologies for the delayed response.

I have observed the requirements shared by you but unfortunately have not been able to completely understand them. Can you please elaborate your requirements in the form of PowerPoint presentation by highlighting the requirements in the form of snap shot. I will try to help you out further on the basis of that.

Many Thanks,

Hi,

I would like to build chart which is similar to chart in attached file. Category axis includes dates. I use code from this site: Create or Update PowerPoint Presentation Charts in C# or .NET|Aspose.Slides Documentation in categories I am using DateTime objects:

//Instantiate PresentationEx class that represents PPTX file
PresentationEx pres = new PresentationEx();

//Access first slide
SlideEx sld = pres.Slides[0];

// Add chart with default data
ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 0, 0, 500, 500);

//Setting chart Title
chart.ChartTitle.Text.Text = "Sample Title";
chart.ChartTitle.Text.CenterText = true;
chart.ChartTitle.Height = 20;
chart.HasTitle = true;

//Set first series to Show Values
chart.ChartData.Series[0].Labels.ShowValue = true;

//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;

//Getting the chart data worksheet
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;

//Delete default generated series and categories
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();
int s = chart.ChartData.Series.Count;
s = chart.ChartData.Categories.Count;

//Adding new series
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.Type);
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.Type);

//Adding new categories
DateTime dateTime1 = new DateTime(1990, 1, 1);
DateTime dateTime2 = new DateTime(1992, 1, 1);
DateTime dateTime3 = new DateTime(1993, 1, 1);
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, dateTime1));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, dateTime2));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, dateTime3));

//Take first chart series
ChartSeriesEx series = chart.ChartData.Series[0];

//Now populating series data
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, 20));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 1, 50));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 1, 30));

//Take second chart series
series = chart.ChartData.Series[1];

//Now populating series data
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 2, 30));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 2, 10));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 2, 60));

//create custom lables for each of categories for new series
//first label will be show Category name
DataLabelEx lbl = new DataLabelEx(series);
lbl.ShowCategoryName = true;
lbl.Id = 0;
series.Labels.Add(lbl);

//Show series name for second label
lbl = new DataLabelEx(series);
lbl.ShowSeriesName = true;
lbl.Id = 1;
series.Labels.Add(lbl);

//show value for third label
lbl = new DataLabelEx(series);
lbl.ShowValue = true;
lbl.ShowSeriesName = true;
lbl.Separator = "/";
lbl.Id = 2;
series.Labels.Add(lbl);

// show value and custom text
lbl = new DataLabelEx(series);
lbl.TextFrame.Text = "My text";
lbl.Id = 3;
series.Labels.Add(lbl);

// Save presentation with chart
pres.Write(@"C:\AsposeChart.pptx");

When I try to edit generated chart data, the dates are numbers. I also would like to format dates to remove hours, minutes and seconds.

How to style chart title (change font color and font size) the same as in attached file?

Best regards,
Piotr

Hi Piotr,


Thanks for sharing the information. I have observed the issue shared by you and it seems to a missing feature in Aspose.Slides. An issue with ID SLIDESNET-33784 has been created in our issue tracking system to further investigate and resolve the issue. For the time being I may suggest you to please try using following options in your sample code.

chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, 1990));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, 1992));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, 1993));


We are sorry for your inconvenience,

Hi,

I wanted to inquire about when we could expect this issue to be resolved as it has significant impact on planning of our project and we wanted to be able to make decision if we should wait for some patch for Aspose.Slides or should we work on some workaround.

Best regards,

Piotr

Hi Piotr,


I have verified from our issue tracking system and like to share that the issue has been scheduled for investigation during current week. Hopefully, by the end of this week we will be able to share the ETA with you once the investigation will be completed by our development team. I will be able to share the further information with you once it will be shared by our development team.

Many Thanks,

Hi Piotr,


I have received response from our development team and like to share that the issue will be resolved in upcoming release of Aspose.Slides for .NET 6.9.0. We will share the notification with you as soon as the issue will be resolved.

Many Thanks,

Hi piosid90.


A hack to make it work a little bit is the following:
		public static double DateTimeToOfficeDate(DateTime pDate)
{
return pDate.Subtract(new DateTime(1904, 1, 1)).TotalDays;
}
		lChart.ChartData.Categories.Add(lFact.GetCell(cDefaultWorksheetIndex, 4, 0, DateTimeToOfficeDate(DateTime.Now.AddDays(31))));
	        lChart.CategoryAxis.NumberFormat = “yyyy.mm.d”;
lChart.CategoryAxis.SourceLinked = false;
This will add the dates that you want, but it won’t make Office see the axis as a date axis (meaning that it won’t distribute the categories linearly according to their value along the axis).
Until we get a fix from Aspose, it seems that we will both be waiting with our hands crossed on this one…

Cheers,
Kostas

Hi Piotr and Kostas,

I am sorry for your inconvenience.

I like to share that the issue is blocked due to limitation in current Aspose.Slides API. The mentioned feature support for setting the date time format for for category axis will be availble in upcoming merged API of Aspose.Slides for .NET. The said API will be available during early Q1 of 2014.

Once again, we are sorry for your inconvenience,

The issues you have found earlier (filed as SLIDESNET-33801) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.fayyaz