I’m using .NET slides to create a line chart where the horizontal axis is a date range. When the powerpoint file is created the format of the axis labels is always plain text so I cannot apply min/max limitations or spacing.
In my example below the chart output may look correct at first as there are only 3 days which will each display as a category, but when I expand this to show a whole years worth of data on 1 chart and I want to group the category labels by month, it does nothing due to the fact this axis is a text type not a date type.
If I manually edit the created powerpoint file after creation, I can right click the chart, select edit data, highlight the column with my dates in and format the cells as Dates. This then gives me the axis format options I need, but is there a way to program this step using aspose?
I making an assumption here but maybe I need to do something with the workbook.GetCell function to not only write the data to the cell but also format it as a date? As the data parameter is of type object, I have also tried inserting DateTime’s instead of date strings but I couldn’t get this to work either.
Many thanks
Sample code:
</font></div><div><font face="Courier New" size="2">var chart = slide.Shapes.AddChart(ChartType.Line, x, y, width, height, false);</font></div><div><font face="Courier New" size="2">var workbook = chart.ChartData.ChartDataWorkbook;</font></div></div><div><font face="Courier New" size="2"><br></font></div><div><font face="Courier New" size="2">chart.ChartData.Categories.Add(workbook.GetCell(0, 1, 0, "01/01/2000"));</font></div><div><font face="Courier New" size="2">chart.ChartData.Categories.Add(workbook.GetCell(0, 2, 0, "02/01/2000"));</font></div><div><font face="Courier New" size="2">chart.ChartData.Categories.Add(workbook.GetCell(0, 3, 0, "03/01/2000"));</font></div><div><font face="Courier New" size="2">// TODO: Add more dates</font></div><div><font face="Courier New" size="2"><br></font></div><div><font face="Courier New" size="2">var series = chart.ChartData.Series.Add(workbook.GetCell(0, 0, 1, "SeriesA"), ChartType.Line);</font></div><div><font face="Courier New" size="2">series.DataPoints.AddDataPointForLineSeries(workbook.GetCell(0, 1, 1, 10));</font></div><div><font face="Courier New" size="2">series.DataPoints.AddDataPointForLineSeries(workbook.GetCell(0, 2, 1, 11));</font></div><div><font face="Courier New" size="2">series.DataPoints.AddDataPointForLineSeries(workbook.GetCell(0, 3, 1, 9));</font></div><div><font face="Courier New" size="2">// TODO: Add more data points</font></div><div><font face="Courier New" size="2"><br></font></div><div><div><font face="Courier New" size="2">// Format axis</font></div><div><font face="Courier New" size="2">chart.Axes.HorizontalAxis.MajorUnitScale = TimeUnitType.Months;</font></div><div><font face="Courier New" size="2">chart.Axes.HorizontalAxis.MajorUnit = 1;</font></div><div><font face="Courier New" size="2">chart.Axes.HorizontalAxis.BaseUnitScale = TimeUnitType.Days;</font></div></div><div><font face="Courier New" size="2">