我想添加一個額外的數據系列圖表這顯示了CPU的閾值,我可以得到的範圍和創建的圖形沒有門檻,但我不知道如何將閾值添加到圖表。 我需要創建另一個圖表對象嗎?我可以使用現有的,只需添加新的範圍?如何添加額外的系列到Excel圖表使用C#
你是如何創建的圖表? - 見下面的代碼。 此圖表是否已經在Excel文件中創建,並且您想要在Excel文件中修改圖表?是圖表已經在Excel文件中。
Excel.ChartObjects sCPUChart; Excel.ChartObject sCPUChartObjects;門檻
C55 = 0
C56 = 1
D55 = 75
D56 = 75
我不知道如何刪除出現在圖表 2個附加軸如果我註釋掉 -
sCPUChart = sDBSheet.ChartObjects(Type.Missing);
sCPUChartObjects = sCPUChart.Add(49, 15, 360, 215);
Excel.Chart sChartCPU;
sChartCPU = sCPUChartObjects.Chart;
sChartCPU.SetSourceData(cpuChartRange, Missing.Value);
sChartCPU.ChartWizard(Source: cpuChartRange, Gallery: Excel.XlChartType.xlLine, Format: 2, HasLegend: true);
sChartCPU.Location(Excel.XlChartLocation.xlLocationAsObject, sDBSheet.Name);
//CPU Chart Axis
Excel.Axis xSChartCPUAxis;
xSChartCPUAxis = sChartCPU.Axes(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary);
Excel.Axis ySChartCPUAxis;
ySChartCPUAxis = syChartCPU.Axes(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary);
ySChartCPUAxis.HasMajorGridlines = true;
ySChartCPUAxis.MaximumScaleIsAuto = true;
//Set Summary CPU Series
Excel.Series sCPUSeries = sChartCPU.SeriesCollection(1);
sCPUSeries.Name = "CPU";
//-------
// this is where I am having my issue
//I don't know how to add the threshold line to the graph with the existing graph being displayed
//sChartCPU.set_HasAxis(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlSecondary, true);
//summaryChartCPU.SetSourceData(summaryMemThreshold, Type.Missing); -- things break
//-------
I have now done the following:
Excel.SeriesCollection threshold = sChartCPU.sseriesCollection();
Excel.Series line = threshold.NewSeries();
line.Formula = "=SERIES(Summ!$D$54,Summ!$C$55:$C$56,Summ!$D$55:$D$56)";
line.ChartType = Excel.XlChartType.xLScatterLinesNoMarkers;
when the threshold line is created I have the following
我在細胞D54值line.ChartType,那麼軸是正確的,但我只得到一個閾值數據點??我不明白爲什麼。
您是如何創建圖表的?該圖表是否已經在Excel文件中創建,並且您想要在Excel文件中修改圖表? – Amber