HRS
July 3, 2013, 2:45am
1
I am new to Aspose Slifdes and would lie to create a stacked bar chart with Dateaxis and would also like to change the orientation of the plotting.
Also i would like to
* set the range for the valueaxis with min and Max dates
* set the tickUnit
* Format as MM.yy
Can anyone help please
Hi,
Thanks for your interest in Aspose.Slides.
I have observed the requirements shared by you. Please try using the following sample code on your end.
PresentationEx pres = new PresentationEx();
SlideEx sld = pres.getSlides().get_Item(0);
ChartEx chart = sld.getShapes().addChart(ChartTypeEx.ClusteredColumn, 10, 60, 700, 300);
ChartSeriesEx series = chart.getChartData().getSeries().get_Item(0);
String Sername=series.getNameCells().getGetConcateNameFromCells();
ChartDataCell cell = series.getNameCells().get_Item(0);//0 is series index
chart.getValueAxis().setSourceLinked(false);
chart.getValueAxis().setBaseUnitScale(TimeUnitType.Months);
chart.getValueAxis().setNumberFormat(“[$-409]mmm-dd;@”);
chart.getValueAxis().isAutomaticMajorUnit(false);
chart.getValueAxis().isAutomaticMinorUnit(false);
chart.getValueAxis().isAutomaticMaxValue(false);
chart.getValueAxis().isAutomaticMinValue(false);
chart.getValueAxis().setMinValue(13);
chart.getValueAxis().setMaxValue(365);
//Setting month wise interval
chart.getValueAxis().setMajorUnit(30.5f);
//setting minor unit to 10 days
chart.getValueAxis().setMinorUnit(10);
chart.getValueAxis().setMinorUnitScale(TimeUnitType.Days);
chart.getValueAxis().setMajorUnitScale(TimeUnitType.Months);
pres.write(“D:\Aspose Data\Bar2.pptx”);
For setting the number format, please follow this
document link for your kind reference as well.
Many Thanks,
HRS
July 4, 2013, 1:55am
3
Thanks for the sample .It did help me a bit .
Also i would like to
set the range for the axis .currently Iam getting from Jan14 --Dec 14.also in a erratic manner ie…Jan-14,Feb-13,Mar-15,Apr-14,May-15…
For example i would to have minValue as June 12 and maxValue as Jun 14
Thanks in advance
Regards
Hi, I have observed your requirements and like to share that if you want to set the minimum value to June 12, then you need to set the axis minimum value to day number of June 12 and max value of axis to desired date day number.
chart.getValueAxis().setMinValue(163);//June 12 day number
chart.getValueAxis().setMaxValue(379);//Jan 14 day number in next year 365+14 I hope this will clear the concept to you. Secondly, for you inquiry related dates coming in value axis in erratic manner, I like to share that you need to set the Major unit that set as interval for the value axis values. This is constant for all values and one cannot set major unit between two successive intervals. Since some months have 30 and some have 31 days so you get different dates on value axis as it is mapped on number of days and not defined dates. Please share, if I may help you further in this regard, Many Thanks,
HRS
July 4, 2013, 6:50am
5
Thanks for your Input
erratic value axis is because i have written
chart.getValueAxis().setNumberFormat("[$-409]mmm-dd;@"); instead of mmm-yy
I want to set MinValue as June 2012.When i set
chart.getValueAxis().setMinValue(-365) the axis gets shifted
chart.getValueAxis().setMaxValue(365*11); //sets MaxValue as Dec 2014
Hi,
Please try using the following sample code to serve the purpose. Please share, if I may help you further in this regard.
public static void testChart()
PresentationEx pres = new PresentationEx();
SlideEx sld = pres.getSlides().get_Item(0);
ChartEx chart = sld.getShapes().addChart(ChartTypeEx.ClusteredColumn, 10, 60, 700, 300);
ChartSeriesEx series = chart.getChartData().getSeries().get_Item(0);
String Sername=series.getNameCells().getGetConcateNameFromCells();
ChartDataCell cell = series.getNameCells().get_Item(0);//0 is series index
chart.getValueAxis().setSourceLinked(false);
chart.getValueAxis().setBaseUnitScale(TimeUnitType.Months);
// chart.getValueAxis().setNumberFormat("[$-409]mmm-dd;@");
chart.getValueAxis().setNumberFormat(“mmm-yyyy”);
chart.getValueAxis().isAutomaticMajorUnit(false);
chart.getValueAxis().isAutomaticMinorUnit(false);
chart.getValueAxis().isAutomaticMaxValue(false);
chart.getValueAxis().isAutomaticMinValue(false);
// chart.getValueAxis().setMinValue(13);
chart.getValueAxis().setMinValue((365.25f109)+163);
// chart.getValueAxis().setMaxValue(365);
chart.getValueAxis().setMaxValue((365.25f 110)+15);
//Setting month wise interval
chart.getValueAxis().setMajorUnit(30.5f);
//setting minor unit to 10 days
chart.getValueAxis().setMinorUnit(10);
chart.getValueAxis().setMinorUnitScale(TimeUnitType.Days);
chart.getValueAxis().setMajorUnitScale(TimeUnitType.Months);
pres.write(“D:\Aspose Data\Bar2.pptx”);
Many Thanks,
HRS
July 9, 2013, 1:48am
7
Thanks for the reply it did help a lot …
Any significance for the factor 110 for year 2013
Regards
Hi, I added the factor 110 as on my PC the chart was picking starting date as 1904. So, I had to shift it to 2013 and used this factor. You can use the value shared or tailor it as per your requirements. Many Thanks,
HRS
July 9, 2013, 6:50am
9
Many Thanks …I did that only …