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

Free Support Forum - aspose.com

TimeScale Axis not working as desired

I currently have a work book with two sheets one with graph data and one with a chart. I would like to construct a chart with the data from the other sheet. I am currently sending an attachment of teh excel sheet and the code I have left in teh comments so as to give you a fair idea as to what are the thing I have tried. My issues here is i want the x-axis to disply dates by months appart
I mean if i have 13 enteries of date values spread over 6 months then i want the x-axis to go display only 6 months and the graph to be spread out

//Set properties of nseries

//chart.CategoryAxis.CategoryType = CategoryType.TimeScale;
chart.NSeries.CategoryData = (HIDDEN_DATA + category);

//chart.AutoSacling = false;

chart.PlotArea.Area.ForegroundColor = Color.Transparent;
chart.PlotArea.Border.IsVisible = false;
int pax = chart.PlotArea.X;
int pay = chart.PlotArea.Y;
//Set Properties of categoryaxis title

chart.CategoryAxis.CategoryType = CategoryType.TimeScale;

////chart.CategoryAxis.BaseUnitScale = TimeUnit.Months;

chart.CategoryAxis.MajorUnitScale = TimeUnit.Months;

chart.CategoryAxis.MajorUnit = 1;

////chart.CategoryAxis.MinorUnitScale = TimeUnit.Days;

////chart.CategoryAxis.MinorUnit = 30;

////chart.CategoryAxis.MinValue = Convert.ToDateTime(wb.Worksheets[HIDDEN_DATA].Cells[_dateStartCell].Value);

//////chart.CategoryAxis.MinValue = 40140;

////chart.CategoryAxis.MaxValue = Convert.ToDateTime(wb.Worksheets[HIDDEN_DATA].Cells[_dateEndCell].Value);

////////chart.CategoryAxis.MajorUnit = 30;

////////chart.CategoryAxis.MinorUnit = 7;

Any reply would be kindly appreciated.

Could anyone please acknowledge on having look at this issue, just to be sure that it is bought to notice of the support team.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We have added your request in our internal issue tracking system with issue id: CELLSNET-17744. We will investigate your issue and get back to you soon.

Thank You & Best Regards,

Thank you Guys, much appreciated!!!

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


After further analyzing your issue, we think that the issue is caused by the chart's source data in your template file. For CategoryType.TimeScale the data should be of data type Date but in your template file it is of type string. Please change the data to date type for column A and check if your code works fine.

Thank You & Best Regards,

Tried that and the resulting garph is as shown in the attached sheet. The data I am filling is of type DateTime and I am filling in the cell as below

mapdatacells[mapdataWriteRowStartPosition, DATA_SHEET_DATE_COL_POSITION].PutValue(tr.TrendData[j].measuredOn);

tr.TrendData[j].measuredOn this is of DateTime type. If this is not the right way then can you please mention the rigt way of changing the cell format to date format.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

For putting a string value as a date value, please check the following codes:

Workbook workbook = new Workbook();

Cells cells = workbook.Worksheets[0].Cells;

string date = "11/25/2009";

cells["A1"].PutValue(date, true);

Style style = cells["A1"].GetStyle();

style.Custom = "mm/dd/yyyy";



Also, if the cell value is a date value, the default horizontal alignment is right alignment (which is left aligned in your template file).

Thank You & Best Regards,

Thanks guys, it works great now. I have another question, I am still not sure weather aspose supports this or not. My question, is there way where I can implement stepped graph type ? I am attaching a snap shot of the UI in our application and that is exactley what we need on the excel sheet using the excel data in the attached sheet, I still am not sure which charttype to use if aspose does support it. Any reply would be greatly appreciated guys.


Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

As there are two Y values in one x point and also

1: You have to duplicate some value, please check A1:A12, A18:A9 of the attached file.

2: As there are two and more series in the chart, please use Scatter chart, then each series can use special x values.

Thank You & Best Regards,

Thank you all for the help. Working as desired.