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

Free Support Forum - aspose.com

Dates for chart categories don't work nice

Hello.


I need to have dates in the category axis of an area chart.
After many hacks I have managed to put dates as categories, but I can’t make Aspose to tell Office that those are in fact dates. So, I get categries formatted as dates but the category axis is not linear and the dates are placed like discrete points.

I attach a demo the demonstrates the problem.
The first button executes code that does not work at all (although it should as far as I can tell).
The second button executes code that puts the correct dates (thanks to a few hacks), but Office does not understand that the axis is a date axis and the axis values are not placed linearly according to their value (if you set the axis type to date axis from Office you will get the desired chart).

Is there a way to achive this with Aspose?
Am I missing sth?

(I have also found this: https://forum.aspose.com/t/77005. I have hacked my way to get it working so far. If you could provide me another hack that will make it work a little better, it would be nice.)

Thanks,
Kostas

Hi Kostas,

I have worked over the scenario shared by you in detail and have also observed the other thread mentioned by you. Actually, what you are looking for is setting the date axis for category axis. Unfortunately, the desired support is presently not available in Aspose.Slides. Since there is no support for Date Axis so even if you add the date type by following custom data format in respective excel sheet, it will not work. I have created an issue with ID SLIDESNET-34668 in our issue tracking system as new feature support to provide support for Date axis as attached in the image shared. This will serve the purpose for you. For your kind reference, I have also devised some workaround approach for setting the date format for value axis of chart. This may help you as well in some other scenario as work around.

public static void testChart()
{

PresentationEx pres = new PresentationEx();

SlideEx sld = pres.Slides[0];

ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 10, 60, 700, 300);

ChartSeriesEx series = chart.ChartData.Series[0];
String Sername = series.NameCells.GetConcateNameFromCells;
ChartDataCell cell = series.NameCells[0];//0 is series index
chart.ValueAxis.SourceLinked=false;
chart.ValueAxis.BaseUnitScale=TimeUnitType.Months;
//
//[$-409]mmm-yy;@
// chart.getValueAxis().setNumberFormat("[$-409]mmm-dd;@");
chart.ValueAxis.NumberFormat=“mmm-yyyy”;
chart.ValueAxis.IsAutomaticMajorUnit=false;
chart.ValueAxis.IsAutomaticMinorUnit=false;
chart.ValueAxis.IsAutomaticMaxValue=false;
chart.ValueAxis.IsAutomaticMinValue=false;

//Starting day number
// chart.getValueAxis().setMinValue(13);
chart.ValueAxis.MinValue=(365.25f * 109) + 163;
//Ending day number
// chart.getValueAxis().setMaxValue(365);
chart.ValueAxis.MaxValue=(365.25f * 110) + 15;

//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(path+“Bar2.pptx”);


}


We are sorry for your inconvenience,

The issues you have found earlier (filed as SLIDESNET-34668) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.