I'm using Interop excel 12.0 to create a chart.
My assigned datarange to yaxis starts from 7/5/2010 till 8/29/2011. but Y axis on chart starts from 7/12/2010 and ends at 8/22/2011 however the chart line growth shows the datas from start to end
myChart.Chart.ChartWizard(xlWorkSheet.get_Range("A1", "B62"),misValue, misValue, misValue,misValue, Excel.XlRowCol.xlColumns, false,
"Spac开发者_C百科e Used Trend Report for databases DLP01P, DLP07P, DPN01P and DUV01P", "Date", "GB", misValue);
Font f = new System.Drawing.Font(FontFamily.GenericSansSerif, 10.0f);
myChart.Chart.ChartTitle.Characters.Font.Size = f.Size;
chartPage.HasTitle = true;
//Trend Line setting
//Creating a series
Excel.Series series = (Excel.Series)chartPage.SeriesCollection(1);
//Setting the series to Secondary (y) axis so as to format the same
series.AxisGroup = Excel.XlAxisGroup.xlSecondary;
//Setting the trendline type
Excel.Trendlines trendlines = (Excel.Trendlines)series.Trendlines(System.Type.Missing);
Excel.Trendline trendline = trendlines.Add(Microsoft.Office.Interop.Excel.XlTrendlineType.xlLinear, 2,
0, misValue, misValue, misValue, false, false, misValue);
//Creating a variable for yaxis and assigning the chart's y axis to the same
Excel.Axis yaxis = (Excel.Axis)chartPage.Axes(Excel.XlAxisType.xlCategory, series.AxisGroup);
yaxis.MajorUnit = 14;
yaxis.MinorUnit = 7;
yaxis.Format.Line.BackColor.RGB = Color.Red.ToArgb();
yaxis.Format.Line.ForeColor.RGB = Color.Red.ToArgb();
yaxis.MajorUnitScale = Excel.XlTimeUnit.xlDays;
yaxis.MinorUnitScale = Excel.XlTimeUnit.xlDays;
yaxis.MinimumScaleIsAuto = false;
yaxis.MinimumScale = ?????
the minimum scale is taking only double values.
If I understand you well, this is what you're looking for: in Excel a date is the day number since 1-1-1900. If you want to calculate that in C# code, keep in mind that in Excel 1900 is a leap year (which it is not, of course, but this originates from compatibility with Lotus 123!), so 7/12/2010
would be 40519.00
.
Try something like this, just change the values
{
chartPrincipal.YAxis.ScaleRange.ValueHigh = 100;
chartPrincipal.YAxis.ScaleRange.ValueLow = 0;
}
精彩评论