interop - C# Excel Chart can't set serie scale -
I'm trying to attract a threshold (1 row from left to right) To do this, let me give the threshold value Adding the bar and for xValues, the scale of 0 from 0 and 1 is set to 0 to 1.
Public static Zero AddThreshold (chart xlChart, double value, string name, int color, bull secondary) {Series Series = XL Chart Series Collection (). Newshares (); Chain. Name = name; Series.XValues = New list & lt; Int & gt; () {0, 1}. ToArray (); Chain. Value = new list & lt; Double & gt; () {Value, value} .oir (); Axis XXis, Yaxis; If (secondary) {series.AxisGroup = XlAxisGroup.xlSecondary; Xxis = (axis) xlChart.Axes (XlAxisType.xlCategory, XlAxisGroup.xlSecondary); YAxis = (axis) xlChart.Axes (XlAxisType.xlValue, XlAxisGroup.xlSecondary); } Other {xAxis = (axis) xlChart.Axes (XLXType.xlcategory, XlAxisGroup.xlPrimary); YAxis = (axis) xlChart.Axes (XlAxisType.xlValue, XlAxisGroup.xlPrimary); } XAxis.MinimumScale = 0; // COM error is getting here xAxis.MaximumScale = 1; YAxis.Delete (); Chain. Chatt Type = XlChartType.xlXYScatterLinesNoMarkers; Chain. Marker size = 3; Chain. Board. Linesstyle = XLM marker style. XMM MarkerStyleDash; Chain. Board. Color = color; } But I am always getting a COM error and can not understand the problem. The exact method was working in a separate project to make things even more upset (do not ask about this because the code was partially removed by mistake and I do not have to write it again).
If you do not have a value type of axis, you can not set the minimum and maximum axis , And only XY in the XY Scatter Chart, which is a value axis before you set the axis level, you must specify the chart type of the series that was added as a XY Scatter.
Then move it:
chain. ChartType = XlChartType.xlXYScatterLinesNoMarkers; Above it:
xAxis.MinimumScale = 0;
Comments
Post a Comment