Origin Change for Line chart

Price Chart for Two companies.zip (130.9 KB)

Hi Team,
Could you please help with attached data, As per attached data i have prices on vertical axis and years on horizontal axis.

Request you please provide a solution for how to change the origin of horizontal axis from 1st Jan 2012 to 7/4/2012(Least Date for Red chart), but the rest of plotting(vertical grid lines) for years should start with Jan itself. and not from 4th July 2013, 4th July 2014 and so on.

Request your respond ASAP

@chouhan551547,

Thanks for the template file and details.

See the following sample code for your reference (I have used your template file to update your existing chart as per your desired origin DateTime value):
e.g
Sample code:

 Workbook workbook = new Workbook("e:\\test2\\Price Chart for Two companies.xlsx");
            
            //Get the chart in the first sheet.
            Chart chart = workbook.Worksheets[0].Charts[0];
            //Define the minimum Date (dd/mm/yyyy - you may change it according to your regional settings).
            DateTime minDate = Convert.ToDateTime("4/7/2012");
            chart.CategoryAxis.MinValue = minDate;

            workbook.Save("e:\\test2\\out1.xlsx");

Hope, this helps a bit.

Thank you.

Thanks for the quick response.

This will definitely solve the first problem to start the chart with min date, Now what we need is to start next major vertical grid line from 1st Jan,2013 then next one 1st Jan 2014 and so on. so the last one should be 1st Jan 2017 with data plotted till Apr-2017.

Thanks again for quick response.

@chouhan551547,

I am not entirely certain if this is possible in MS Excel. We need your desired chart (with your demanded major and minor units specified for the category axis). Please modify the chart in the template file as per your requirements in MS Excel manually and re-attach it here again. We will check how to do it via Aspose.Cells APIs. Moreover, if you could accomplish the task in MS Excel manually, surely, Aspose.Cells can do that.

Thank you.